private void back_Click(object sender, EventArgs e) { AccountantHome acc = new AccountantHome(); this.Hide(); acc.Show(); }
private void log_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection("Data Source=DESKTOP-N0BITSB;Initial Catalog=BMS;Integrated Security=True"); try { con.Open(); string adminquery = "select * from Admin where adminID= '" + id.Text.Trim() + "' and password = '******'"; SqlDataAdapter dAdmin = new SqlDataAdapter(adminquery, con); DataTable dtblad = new DataTable(); dAdmin.Fill(dtblad); string accountantquery = "select * from Accountant where accountantID = '" + id.Text.Trim() + "' and Password = '******'"; SqlDataAdapter dAccountant = new SqlDataAdapter(accountantquery, con); DataTable dtblacc = new DataTable(); dAccountant.Fill(dtblacc); string customerquery = "select * from Customer where Customer_ID = '" + id.Text.Trim() + "' and Password = '******'"; SqlDataAdapter dCustomer = new SqlDataAdapter(customerquery, con); DataTable dtblcus = new DataTable(); dCustomer.Fill(dtblcus); count = count + 1; if (count > 3) { MessageBox.Show("Wrong !! ...System Will be Closed !!"); this.Close(); } if (dtblad.Rows.Count == 1 && select.selectedValue == "Admin") { AdminHome admin = new AdminHome(); this.Hide(); admin.Show(); } else if (dtblad.Rows.Count == 0 && select.selectedValue == "Admin") { MessageBox.Show("Check Your ID or Password"); id.Clear(); pass.Clear(); id.Focus(); } if (dtblacc.Rows.Count == 1 && select.selectedValue == "Accountant") { AccountantHome accountant = new AccountantHome(); this.Hide(); accountant.Show(); } else if (dtblacc.Rows.Count == 0 && select.selectedValue == "Accountant") { MessageBox.Show("Check Your ID or Password"); id.Clear(); pass.Clear(); id.Focus(); } if (dtblcus.Rows.Count == 1 && select.selectedValue == "Customer") { globalvariable.value = id.Text; CustomerHome customer = new CustomerHome(id.Text); this.Hide(); customer.Show(); } else if (dtblcus.Rows.Count == 0 && select.selectedValue == "Customer") { MessageBox.Show("Check Your ID or Password"); id.Clear(); pass.Clear(); id.Focus(); } } catch (Exception) { throw; } finally { con.Close(); } }