0

ログインページを作成していますが、すでに Web サービスに接続しています。

「ロール」を配置/挿入するたびにエラーが発生します。Webサービスでは、Webサービスには学生、講師、管理者、および管理者の役割があり、アプリケーションは学生の役割のみを使用します。

私のデザイン

<Image x:Name="imgLinton" HorizontalAlignment="Left" Height="141" Margin="27,24,0,0" VerticalAlignment="Top" Width="398" Source="/Assets/Kolej.png" Grid.ColumnSpan="2"/>

<TextBlock x:Name="loginlbl_UserName" HorizontalAlignment="Left" Margin="10,216,0,0" TextWrapping="Wrap" Text="User Name" VerticalAlignment="Top"/>

 <TextBox x:Name="logintxt_UserName" HorizontalAlignment="Left" Height="65" Margin="125,197,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="265" FontSize="20" RenderTransformOrigin="0.492,-0.623"/>

 <TextBlock x:Name="loginlbl_UserName1" HorizontalAlignment="Left" Height="27" Margin="10,281,0,0" TextWrapping="Wrap" Text="Password" VerticalAlignment="Top" Width="98"/>

  <Button x:Name="login_btnlogin" Content="Login" HorizontalAlignment="Left" Margin="125,399,0,0" VerticalAlignment="Top" Click="login_btnlogin_Click" Height="71" Width="221">

  </Button>
  <Button x:Name="login_btnback" Content="Back" HorizontalAlignment="Left" Height="71" Margin="125,475,0,0" VerticalAlignment="Top" Width="221">
  <i:Interaction.Triggers>
  <i:EventTrigger EventName="Click">
  <ec:NavigateToPageAction TargetPage="/MainPage.xaml"/>
  </i:EventTrigger>
  </i:Interaction.Triggers>
  </Button>

  <TextBlock x:Name="login_lblerror" HorizontalAlignment="Left" Height="35" Margin="27,327,0,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top" Width="398" Foreground="#FFFF0006" FontWeight="Bold"/>
  <PasswordBox x:Name="logintxt_Password" HorizontalAlignment="Left" Height="64" Margin="125,263,0,0" VerticalAlignment="Top" Width="265" RenderTransformOrigin="1.455,-0.432"/>

これは私のコードです

    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Navigation;
    using Microsoft.Phone.Controls;
    using Microsoft.Phone.Shell;
    using System.Threading;

    namespace project2
     {
public partial class login : PhoneApplicationPage
{
    string userID = null;

    public login()
    {            
        InitializeComponent();            

    }

    private void login_btnlogin_Click(object sender, RoutedEventArgs e)
    {
        ServiceReference2.Service1SoapClient myClient = new ServiceReference2.Service1SoapClient();   
        myClient.loginwebCompleted += new EventHandler<ServiceReference2.loginwebCompletedEventArgs>(myClient_loginCompleted);
        myClient.loginwebAsync(logintxt_UserName.Text, logintxt_Password.Password);

        string loginstatus = null;
        string[] words = myClient.Split(".");
        string userrole = words(0);

        if (Information.IsNumeric(words(0)))
        {
            string userID = words(1);

            if (userrole == "1")
            {
                NavigationService.Cookies("logincookie").Value = userID;
                NavigationService.Navigate(new Uri("/myprofile.xaml?ID=" + userID, UriKind.Relative));
            }

            else if ((userrole == "2" | userrole == "3" | userrole == "0"))
            {
                login_lblerror.Text = "Please Login via Website (lecturer, management and Admin)";

            }
            else
            {
                login_lblerror.Text = loginstatus;
            }
        }

        else
        {
            login_lblerror.Text = loginstatus;
        }
    }
}
4

0 に答える 0