private void btnsave_Click(object sender, EventArgs e) { try { ConnectionClass l_ConnectionClass = new ConnectionClass(); userId = l_ConnectionClass.generateIDnew("select max(userId) from [tbluserlogin]"); userName = txtusrname.Text.ToString(); string userPwd = txtpwd.Text; string userConPwd = txtconfirmpwd.Text; string logouttime = DateTime.MinValue.ToString(); users = l_ConnectionClass.checkuser(userName); if (users > 0) { MessageBox.Show("username already exists."); } //If the password and confirmed passwrd are not same, a message box pops up and asks the user to reenter them. else if(!userPwd.Equals(userConPwd)) { MessageBox.Show("Passwords given in two places are not matching. Please re enter."); } else { l_ConnectionClass.SaveAddUser(userId, userName, userStatus, userRole, userPwd, userConPwd, logouttime); LoadGrid(); ClearFields(); txtusrname.Focus(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }