private void btn_login_Click(object sender, EventArgs e) { try { using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["cn"].ConnectionString)) { if (string.IsNullOrEmpty(txt_uerName.Text)) { MsgBox.Warning("Enter User Name"); txt_uerName.Focus(); return; } if (string.IsNullOrEmpty(txt_password.Text)) { MsgBox.Warning("password required"); txt_password.Focus(); return; } if (db.State == ConnectionState.Closed) { db.Open(); string _sql = $"Select EM.Designation,EL.userName,EL.userPassword From Employee_Master_Table EM Inner Join Emp_Login EL on EL.employeeID=EM.emp_ID where EL.userName='******' AND EL.userPassword='******'"; BackpanelObj obj = db.Query <BackpanelObj>(_sql, commandType: CommandType.Text).SingleOrDefault(); if (obj.userName == txt_uerName.Text && obj.userPassword == txt_password.Text) { if (obj.Designation == "Admin") { using (PMS.AdminPanel.UI.frmMainForAdmin frmObj = new PMS.AdminPanel.UI.frmMainForAdmin()) { Cursor.Current = Cursors.WaitCursor; try { Thread.Sleep(3100); // wait for a while } finally { Cursor.Current = Cursors.Default; this.Close(); frmObj.ShowDialog(); } } } else { MsgBox.Show(8); } } else { MsgBox.Show(4); } } } } catch { MsgBox.Show(4); } }
private void btn_login_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txt_uerName.Text)) { MsgBox.Warning("Please enter user name"); txt_uerName.Focus(); return; } if (string.IsNullOrEmpty(txt_password.Text)) { MsgBox.Warning("Please enter password"); txt_password.Focus(); return; } try { Cursor.Current = Cursors.WaitCursor; Thread.Sleep(2500); using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["cn"].ConnectionString)) { if (db.State == ConnectionState.Closed) { db.Open(); string _sql = $"Select EM.Designation,EL.userName,EL.userPassword,EM.emp_ID From Employee_Master_Table EM Inner Join Emp_Login EL on EL.employeeID=EM.emp_ID where EL.userName='******' AND EL.userPassword='******'"; MapLoginData obj = db.Query <MapLoginData>(_sql, commandType: CommandType.Text).SingleOrDefault(); if (obj != null) { if (obj.userName == txt_uerName.Text && obj.userPassword == txt_password.Text) { if (obj.Designation == "Admin") { UserName = obj.userName; EmployeeID = obj.emp_ID; //using (PMS.AdminPanel.UI.frmMainForAdmin obj1 = new PMS.AdminPanel.UI.frmMainForAdmin()) //{ // this.Hide(); // obj1.ShowDialog(); //} using (UI.SystemAdminMenu obj1 = new SystemAdminMenu()) { this.Hide(); BackpanelObj obj3 = new BackpanelObj(); obj1.ShowDialog(); } } else if (obj.Designation == "Manager") { using (UI.ManagerMenu obj2 = new UI.ManagerMenu()) { this.Hide(); obj2.ShowDialog(); } } else if (obj.Designation == "Cashier") { using (UI.CashierMenu obj2 = new UI.CashierMenu()) { this.Hide(); obj2.ShowDialog(); } } else if (obj.Designation == "Chef") { using (UI.PreparedFoodOrder obj2 = new UI.PreparedFoodOrder()) { this.Hide(); obj2.ShowDialog(); } } //add some more else { MsgBox.InvalidUser("Invalid Access"); } } else { MsgBox.Show(4); } } else { MsgBox.Show(4); } } else { MsgBox.Show(5); } db.Close(); } } catch { MsgBox.Error("invalid User name/password combination"); } finally { Cursor.Current = Cursors.Default; } }