private void btnLogin_Click(object sender, EventArgs e) { string username = tbUsername.Text.Trim(); string password = tbPassword.Text.Trim(); //check if fields are empty if (String.IsNullOrEmpty(username) || String.IsNullOrEmpty(password)) { lblOutput.Text = "Please enter username and password"; return; } try { clientAdmin = new EFlatsServiceReference.WcfEFlatsServiceAdminClient("NetTcpBinding_IWcfEFlatsServiceAdmin"); switch (clientAdmin.AdminLogin(username, password)) { //1 - success, 2 - passwords dont match, 3 - emails dont match, else - not connected to wcf or db case 1: { this.Hide(); MainForm mainForm = new MainForm(); mainForm.ShowDialog(); break; } case 2: { lblOutput.Text = "Incorrect Username or Password"; break; } case 3: { lblOutput.Text = "Incorrect Username or Password"; break; } default: { lblOutput.Text = "Unable to connect - Try again"; break; } } } catch { lblOutput.Text = "Unable to connect - Restart application and Try again"; return; } }
private void btnLogin_Click(object sender, EventArgs e) { string username = tbUsername.Text.Trim(); string password = tbPassword.Text.Trim(); //check if fields are empty if(String.IsNullOrEmpty(username) || String.IsNullOrEmpty(password)) { lblOutput.Text = "Please enter username and password"; return; } try { clientAdmin = new EFlatsServiceReference.WcfEFlatsServiceAdminClient("NetTcpBinding_IWcfEFlatsServiceAdmin"); switch (clientAdmin.AdminLogin(username, password)) { //1 - success, 2 - passwords dont match, 3 - emails dont match, else - not connected to wcf or db case 1: { this.Hide(); MainForm mainForm = new MainForm(); mainForm.ShowDialog(); break; } case 2: { lblOutput.Text = "Incorrect Username or Password"; break; } case 3: { lblOutput.Text = "Incorrect Username or Password"; break; } default: { lblOutput.Text = "Unable to connect - Try again"; break; } } } catch { lblOutput.Text = "Unable to connect - Restart application and Try again"; return; } }
//------------------------------------------------------------------------------------ //private methods private void GetDataSetToGrid() { try { clientAdmin = new EFlatsServiceReference.WcfEFlatsServiceAdminClient("NetTcpBinding_IWcfEFlatsServiceAdmin"); //load table ds = new DataSet(); ds = clientAdmin.AdminGetTableData(cbType.SelectedItem.ToString().Trim()); BindingSource bSource = new BindingSource(); bSource.DataSource = ds.Tables[0]; dataGridViewUser.DataSource = bSource; SetColumnsReadOnly(); } catch { lblOutput.Text = "Unable to connect to the Database"; } }
//private methods private void GetDataSetToGrid() { try { //refresh connection to client clientAdmin = new EFlatsServiceReference.WcfEFlatsServiceAdminClient("NetTcpBinding_IWcfEFlatsServiceAdmin"); //load table ds = clientAdmin.AdminGetTableData("Flats"); BindingSource bSource = new BindingSource(); bSource.DataSource = ds.Tables[0]; dataGridView.DataSource = bSource; ds.Tables[0].Columns["Id"].ReadOnly = true; } catch { lblOutput.Text = "Unable to connect to the Database"; } }