private void button1_Click(object sender, RoutedEventArgs e) { EQ_DomainContext context = new EQ_DomainContext(); this.busyIndicator1.IsBusy = true; EntityQuery<tblUser> q = (from n in context.GetTblUserQuery() where n.UserID == txtUserID.Text && n.Password == txtPassword.Password select n); LoadOperation<tblUser> lo = context.Load<tblUser>(q); lo.Completed += (s, a) => { if (lo.Error != null) { MessageBox.Show(lo.Error.Message); this.busyIndicator1.IsBusy = false; return; } tblUser user = lo.Entities.FirstOrDefault<tblUser>(); if (user == null) { MessageBox.Show("帳號密碼錯誤 !"); this.busyIndicator1.IsBusy = false; return; }; // slDBManager.WebContext client = new WebContext(); WebService.WebServiceSoapClient client = new WebService.WebServiceSoapClient(); client.RegisterSessionCompleted += (ss, aa) => { if (aa.Error != null) { MessageBox.Show(aa.Error.Message); this.busyIndicator1.IsBusy = false; return; } this.busyIndicator1.IsBusy = true; this.NavigationService.Navigate(new Uri("/EqManager.xaml?userid="+user.UserID+"&username="+user.UserName,UriKind.Relative)); }; client.RegisterSessionAsync(user.UserID); }; }