/// <summary> /// btnSave_Click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { try { // Adding RolesXPages TransactionResult result; CheckBox chkIsAddEdit; CheckBox chkIsDelete; _users = new UsersDL(); foreach (GridViewRow outerRow in gvUserPageSettings.Rows) { GridView outerGrid = (GridView)outerRow.FindControl("gvUpdateUserPageSettings"); foreach (GridViewRow innerRow in outerGrid.Rows) { _usersXPages = new UsersXPagesDL(); _usersXPages.CompanyID = Convert.ToInt32(ddlCompany.SelectedValue.ToString()); _usersXPages.UserID = Convert.ToInt32(ddlEmployee.SelectedValue.ToString()); _usersXPages.PageID = Convert.ToInt32(innerRow.Cells[1].Text.ToString()); chkIsAddEdit = (CheckBox)(innerRow.Cells[6].FindControl("cbCheckBoxAdd")); _usersXPages.IsAddorEdit = chkIsAddEdit.Checked; chkIsDelete = (CheckBox)(innerRow.Cells[7].FindControl("cbCheckBoxDelete")); _usersXPages.IsDelete = chkIsDelete.Checked; _usersXPages.ScreenMode = ScreenMode.Add; _users.UserPages.Add(_usersXPages); // Add / Edit the UsersXPages } } //If successful, get the RolesXPages details _users.ScreenMode = ScreenMode.Edit; result = _users.Commit(); // Display the Status - Whether successfully saved or not System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("<script>alert('" + result.Message.ToString() + ".');"); sb.Append("</script>"); ScriptManager.RegisterStartupScript(this.Page, typeof(string), "MyScript", sb.ToString(), false); ddlEmployee_SelectedIndexChanged(sender, e); } catch (Exception ex) { ErrorLog.LogErrorMessageToDB("UserPageSettings.aspx", "", "btnSave_Click", ex.Message.ToString(), new ACEConnection()); } }
/// <summary> /// btnSave_Click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { try { StringBuilder sbMail = new StringBuilder(); // Create a new User Object _currentUser = new UsersDL(); // Set whether Add / Edit _currentUser.AddEditOption = 1; if (chkValid.Checked == true) { Utilities objPwd = new Utilities(); // From Address _msg.From = new MailAddress("*****@*****.**"); // To Address _msg.To.Add(new MailAddress(hdfOfficeEmailID.Value.ToString())); // Subject _msg.Subject = "Welcome to ACE"; // Body sbMail.Append("Dear All,"); sbMail.Append(Environment.NewLine); sbMail.Append(Environment.NewLine); sbMail.Append("We are happy to welcome you to the ACE family and are delighted to give you a login to Order."); sbMail.Append(Environment.NewLine); sbMail.Append(Environment.NewLine); sbMail.Append("Order is our intranet system, where you can update your personal details, check your "); sbMail.Append("attendance, interact with fellow employees, share information, blog etc. To start "); sbMail.Append("with, we would like you to post personal information about yourself and keep "); sbMail.Append("updating information, as and when required."); sbMail.Append(Environment.NewLine); sbMail.Append(Environment.NewLine); sbMail.Append("Kindly login with your employee ID and make sure that you change your password for "); sbMail.Append("information security reasons."); sbMail.Append(Environment.NewLine); sbMail.Append(Environment.NewLine); sbMail.Append("Please get back to us with your suggestions, comments and feedback."); sbMail.Append(Environment.NewLine); sbMail.Append(Environment.NewLine); sbMail.Append("Your login information is given below to access our intranet site,"); sbMail.Append(Environment.NewLine); sbMail.Append("http://ACE.com/Order"); sbMail.Append(Environment.NewLine); sbMail.Append(Environment.NewLine); sbMail.Append("User ID : " + txtUserName.Text); sbMail.Append(Environment.NewLine); sbMail.Append("Password : "******"Thank you,"); sbMail.Append(Environment.NewLine); sbMail.Append(Environment.NewLine); sbMail.Append("HR."); sbMail.Append(Environment.NewLine); sbMail.Append(Environment.NewLine); _msg.Body = sbMail.ToString(); } // Assign Values to the User Object _currentUser.UserID = Convert.ToInt32(txtUserID.Text); _currentUser.UserName = Convert.ToInt32(txtUserName.Text); _currentUser.Password = txtPassword.Text; if (lblEmployeeID.Text != "" && lblEmployeeID.Text.ToString() != null) { _currentUser.EmployeeID = Convert.ToInt32(lblEmployeeID.Text); } if (chkValid.Checked == true) { _currentUser.IsValid = true; } else { _currentUser.IsValid = false; } _currentUser.AuditUserID = Convert.ToInt32(Session["UserID"]); // Add / Edit the User TransactionResult result; _currentUser.ScreenMode = ScreenMode.Add; result = _currentUser.Commit(); // Display the Status - Whether successfully saved or not System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("<script>alert('" + result.Message.ToString() + ".');"); sb.Append("</script>"); ScriptManager.RegisterStartupScript(this.Page, typeof(string), "MyScript", sb.ToString(), false); // If successful get and display the saved User if (result.Status == TransactionStatus.Success) { if (hdfOfficeEmailID.Value.ToString() != "") { //to send mail if (chkValid.Checked == true) { if (OrderSettings.SendMail) { SmtpClient client = new SmtpClient(); client.Send(_msg); } } } lblRole.Visible = false; ddlRole.Visible = false; GetUserDetails(_currentUser.UserID, true); LoadDropDownLists(); } } catch (Exception ex) { ErrorLog.LogErrorMessageToDB("AddEditUser.aspx", "", "btnSave_Click", ex.Message.ToString(), new ACEConnection()); } }