private void btnLogin_Click(object sender, EventArgs e) { int user_id = DBLayer.ID; if (txtPassword.Text != "" && cmbUserName.Text != "") { UserID = userID(cmbUserName.Text); string Password = this.txtPassword.Text; bool result = DBLayer.CHKUSER(UserID, Password); DBLayer.SetUserID(UserID); if (result) { if (Chk_Login == 0) { user_ID = UserID; DBLayer.ID = GroupID(UserID); R_ID = Next_R_ID(); txtPassword.Text = ""; //MessageBox.Show("You are now logged in! \nPress OK to Proceed", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); Main frm = new Main(); tblLogingTableAdapter.AddLoginTime(UserID, DateTime.Now, R_ID); frm.Show(); frm.BringToFront(); this.Hide(); Chk_Login = 1; } else { Main frm = new Main(); tblLogingTableAdapter.AddLogoffTime(user_id, DateTime.Now, frm.Loging_ID(user_id, R_ID)); DBLayer.ID = UserID; tblLogingTableAdapter.AddLoginTime(UserID, DateTime.Now, Next_R_ID()); frm.Chk_Rights(); this.Hide(); } } else { lblMessage.Text = "Invalid UserName or Password!!"; lblMessage.ForeColor = Color.OrangeRed; } } else { if (cmbUserName.Text == "" && txtPassword.Text != "") { lblMessage.Text = "Please provide User Name to SignIn!!"; } else if (txtPassword.Text == "" && cmbUserName.Text != "") { lblMessage.Text = "Please provide Password to SignIn!!"; } else { lblMessage.Text = "Please provide User Name or\nPassword to SignIn!!"; } lblMessage.ForeColor = Color.OrangeRed; } }