private void logOutToolStripMenuItem_Click(object sender, EventArgs e) { if (MessageBox.Show("Are you Sure You Want to Logout?", "Make Sure", MessageBoxButtons.YesNo) == DialogResult.Yes) { MainMDI mainForm = new MainMDI(); Form1 Login = new Form1(); MainMDI.ActiveForm.Dispose(); Program.username = ""; Login.Show(); } }
private void btnLogin_Click(object sender, EventArgs e) { if (txtUsername.Text == null || txtPassword.Text == null || cboUserType.SelectedIndex == 0) { lblMessage.Text = "Please Provide Valid Users Credential"; CleanLoginForm(); } else { DataTable dt = bllg.LoginUser(txtUsername.Text, txtPassword.Text, Convert.ToInt32(cboUserType.SelectedValue.ToString())); if (dt.Rows.Count > 0) { Program.username = txtUsername.Text; Program.userId = Convert.ToInt32(dt.Rows[0][0].ToString()); if (cboUserType.Text == "Admin") { MainMDI mainForm = new MainMDI(); mainForm.Show(); mainForm.userPanelToolStripMenuItem.Visible = false; this.Hide(); } else if (cboUserType.Text == "User") { MainMDI mainForm = new MainMDI(); mainForm.Show(); mainForm.adminPanelToolStripMenuItem.Visible = false; this.Close(); } } else { invalid.Text = "* User Details Dose'nt Matched. Plese Try Again"; } } }