protected void saveButton_Click(object sender, EventArgs e) { if (userNameDropDownList.SelectedValue == "" || userNameDropDownList.SelectedValue == null) { return; } oUserInfoEntity.UserID = userIdTextBox.Text; oUserInfoEntity.UserType = userTypeDropDownList.SelectedValue; oUserInfoEntity.Password = passwordTextBox.Text; oUserInfoEntity.ConfirmPassword = confirmPasswordTextBox.Text; oUserInfoEntity.Active = activeCheckBox.Checked; oUserInfoEntity.EmployeeID = userNameDropDownList.SelectedValue; oUserInfoEntity.CreateBy = DateTime.Now.ToShortDateString(); oUserInfoEntity.LastModifiedBy = DateTime.Now.ToShortDateString(); string message = ""; if (oUserInfoEntity.Password != oUserInfoEntity.ConfirmPassword) { message = "Password and confirmed password are not same"; ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "MessageBox", "alert('" + message + "')", true); return; } if (saveButton.Text == "Update") { if (Session["ID"] != null) { oUserInfoEntity.ID = Convert.ToInt16(Session["ID"]); int i = oUserInfoDAO.UpdateUserInfo(oUserInfoEntity); if (i == 1) { message = "User Updated Successfully"; Clear(); } else { message = "User Not Updated!"; } } } else { string condition = " where userId='" + oUserInfoEntity.UserID + "'"; DataTable dt = oUserInfoDAO.GetUserInfo(condition); if (dt.Rows.Count > 0) { message = "User Id already in Database"; ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "MessageBox", "alert('" + message + "')", true); return; } int i = oUserInfoDAO.InsertUserInfo(oUserInfoEntity); if (i == 1) { MenuAndSubMenuDAO oMenuAndSubMenuDAO = new MenuAndSubMenuDAO(); dt = oMenuAndSubMenuDAO.GetSubMenu(""); UserAssignRightDAO oUserAssignRightDAO = new UserAssignRightDAO(); for (int k = 0; k < dt.Rows.Count; k++) { UserAssignRightEntity oUserAssignRightEntity = new UserAssignRightEntity(); oUserAssignRightEntity.UserID = oUserInfoEntity.UserID; oUserAssignRightEntity.MenuNo = dt.Rows[k]["MenuNo"].ToString(); oUserAssignRightEntity.SubMenuNo = dt.Rows[k]["SubMenuNo"].ToString(); oUserAssignRightEntity.MenuRights = false; oUserAssignRightEntity.SubMenuRights = false; oUserAssignRightEntity.CreateBy = DateTime.Now.ToShortDateString(); oUserAssignRightEntity.LastModifiedBy = DateTime.Now.ToShortDateString(); int n = oUserAssignRightDAO.InsertUserAssignRight(oUserAssignRightEntity); } message = "User Created Successfully"; Clear(); } else { message = "User Not Created!"; } } gridViewBind(); ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "MessageBox", "alert('" + message + "')", true); }