private void Connect_Click(object sender, RoutedEventArgs e) { if (!string.IsNullOrEmpty(tbUsername.Text)) { ClientCallback callback = new ClientCallback(); Four_in_rowServiceClient client = new Four_in_rowServiceClient( new InstanceContext(callback)); string userId = tbUsername.Text.Trim(); string password = tbPassword.Text.Trim(); try { client.Connect(userId, password); MainWindow mainWindow = new MainWindow(); mainWindow.Client = client; mainWindow.Callback = callback; mainWindow.Username = userId; mainWindow.Title = userId; this.Close(); mainWindow.Show(); } catch (FaultException <UserPasswordFault> ex) { MessageBox.Show(ex.Detail.Message); } catch (FaultException <UserIdNotExistFault> ex) { MessageBox.Show(ex.Detail.Message); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void submit_click(object sender, RoutedEventArgs e) { if (allFieldsFilled()) { string userId = tbUserId.Text.Trim(); string userName = tbUsername.Text.Trim(); string password = tbPassword.Text; ClientCallback callback = new ClientCallback(); Four_in_rowServiceClient client = new Four_in_rowServiceClient( new InstanceContext(callback)); try { client.Register(userId, userName, password); this.Close(); /* MainWindow mainWindow = new MainWindow(); * mainWindow.Client = client; * mainWindow.Callback = callback; * mainWindow.Username = userId; * mainWindow.Title = userId; * this.Close(); * mainWindow.Show();*/ } catch (FaultException <UserIdExistsFault> ex) { MessageBox.Show(ex.Detail.Message); } } }