private void btnLogin_Click(object sender, EventArgs e) { if (IsValidated()) { try { clsLogin user = new clsLogin(); user.UserName = txtName.Text; user.Password = txtPassword.Text; clsDBLogin dbLogin = new clsDBLogin(); dbLogin.CheckUser(user); if (dbLogin.Count > 0) { this.Hide(); frmMenu ss = new frmMenu(); ss.Show(); } else { MessageBox.Show("User Name or Password is incorrect. Please try again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtName.Clear(); txtPassword.Clear(); txtName.Focus(); } } catch (ApplicationException ex) { MessageBox.Show("Error:" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void btnAdd_Click(object sender, EventArgs e) { if (IsValidated()) { try { clsLogin user = new clsLogin(); user.UserName = txtUser.Text; user.Password = txtPassword.Text; clsDBLogin dbLogin = new clsDBLogin(); int Useradded = 0; Useradded = dbLogin.AddUser(user); if (Useradded > 0) { lblMessage.Text = "User has been added."; txtUser.Clear(); txtPassword.Clear(); txtUser.Focus(); } else { lblMessage.Text = "Error. Please try again."; txtUser.Clear(); txtPassword.Clear(); txtUser.Focus(); } } catch (ApplicationException ex) { MessageBox.Show("Error:" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private clsLogin GetLoginDetails() { clsLogin lg = new clsLogin(); clsDBLogin dbLogin = new clsDBLogin(); return(lg); }