Пример #1
0
 /// <summary>
 /// ibtnChangePasswordSubmit_Click
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void ibtnChangePasswordSubmit_Click(object sender, EventArgs e)
 {
     try
     {
         Utilities objPwd = new Utilities();
         _usersLogin             = new UsersDL();
         _usersLogin.UserName    = Convert.ToInt32(txtUserName.Text);
         _usersLogin.OldPassword = objPwd.EncryptText(txtOldPwd.Text);
         _usersLogin.Password    = objPwd.EncryptText(txtpwd.Text);
         if (_usersLogin.ChangePassword())
         {
             lblmsg.Text = "Password Successfully Updated.";
             System.Text.StringBuilder sb = new System.Text.StringBuilder();
             sb.Append("<script>alert('Password Successfully Updated.');");
             sb.Append("</script>");
             ScriptManager.RegisterStartupScript(this.Page, typeof(string), "MyScript", sb.ToString(), false);
             mvLogin.ActiveViewIndex = 0;
             Response.Redirect("~/Login.aspx", false);
         }
         else
         {
             System.Text.StringBuilder sb = new System.Text.StringBuilder();
             sb.Append("<script>alert('Incorrect existing password!');");
             sb.Append("</script>");
             ScriptManager.RegisterStartupScript(this.Page, typeof(string), "MyScript", sb.ToString(), false);
         }
     }
     catch (Exception ex)
     {
         ErrorLog.LogErrorMessageToDB("Login.aspx", "", "ibtnChangePasswordSubmit_Click", ex.Message, new ACEConnection());
     }
 }
Пример #2
0
 /// <summary>
 /// btnSubmit_Click
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnSubmit_Click(object sender, ImageClickEventArgs e)
 {
     try
     {
         Utilities objPwd = new Utilities();
         _usersDL             = new UsersDL();
         _usersDL.UserName    = Convert.ToInt32(Session["UserName"].ToString());
         _usersDL.OldPassword = objPwd.EncryptText(txtOldPwd.Text);
         _usersDL.Password    = objPwd.EncryptText(txtpwd.Text);
         if (_usersDL.ChangePassword())
         {
             lblmsg.Text = "Password Successfully Updated.";
             System.Text.StringBuilder sb = new System.Text.StringBuilder();
             sb.Append("<script>alert('Password Successfully Updated.');");
             sb.Append("</script>");
             ScriptManager.RegisterStartupScript(this.Page, typeof(string), "MyScript", sb.ToString(), false);
         }
         else
         {
             System.Text.StringBuilder sb = new System.Text.StringBuilder();
             sb.Append("<script>alert('Incorrect existing password!');");
             sb.Append("</script>");
             ScriptManager.RegisterStartupScript(this.Page, typeof(string), "MyScript", sb.ToString(), false);
         }
     }
     catch (Exception ex)
     {
         ErrorLog.LogErrorMessageToDB("ChangePassword.aspx", "", "btnSubmit_Click", ex.Message.ToString(), new ACEConnection());
     }
 }
Пример #3
0
 /// <summary>
 /// ddlEmployee_SelectedIndexChanged
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void ddlEmployee_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         if (ddlEmployee.SelectedValue != "" && ddlEmployee.SelectedValue != null)
         {
             int CompanyID = Convert.ToInt32(ddlCompany.SelectedValue);
             int UserID    = Convert.ToInt32(ddlEmployee.SelectedValue);
             _users = new UsersDL();
             _users.GetUserRole(UserID, CompanyID);
             lblRoleDescription.Text       = "Role : ";
             lblRoleName.Text              = _users.RoleName;
             _usersXPages.UserID           = Convert.ToInt32(ddlEmployee.SelectedValue);
             gvUserPageSettings.DataSource = _usersXPages.GetUsersPagesList(UserID, CompanyID).Tables[0].DefaultView;
             gvUserPageSettings.DataBind();
             btnSave.Visible   = true;
             btnCancel.Visible = true;
         }
         else
         {
             gvUserPageSettings.DataSource = null;
             gvUserPageSettings.DataBind();
             btnSave.Visible         = false;
             btnCancel.Visible       = false;
             lblRoleDescription.Text = "";
             lblRoleName.Text        = "";
         }
     }
     catch (Exception ex)
     {
         ErrorLog.LogErrorMessageToDB("UserPageSettings.aspx", "", "ddlEmployee_SelectedIndexChanged", ex.Message, new ACEConnection());
     }
 }
Пример #4
0
 /// <summary>
 /// To retrieve the details of a particular user
 /// </summary>
 /// <param name="userID">userID</param>
 /// <param name="isProperties">Whether all properties</param>
 private void GetUserDetails(int userID, bool isProperties)
 {
     try
     {
         _currentUser = new UsersDL(userID, isProperties);
         AssignValues();
     }
     catch (Exception ex)
     {
         ErrorLog.LogErrorMessageToDB("AddEditUser.aspx", "", "GetUserDetails(int userID, bool isProperties)", ex.Message.ToString(), new ACEConnection());
     }
 }
Пример #5
0
 internal int Update()
 {
     try
     {
         using (UsersDL _usersdlDL = new UsersDL())
         {
             return(_usersdlDL.Update(this));
         }
     }
     catch
     {
         throw;
     }
 }
Пример #6
0
 internal int InsertAndGetId()
 {
     try
     {
         using (UsersDL _usersdlDL = new UsersDL())
         {
             return(_usersdlDL.InsertAndGetId(this));
         }
     }
     catch
     {
         throw;
     }
 }
Пример #7
0
 private void RefreshGrd()
 {
     try
     {
         using (UsersDL usrgDL = new UsersDL())
         {
             grdUsers.DataSource = usrgDL.GetTable(users);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #8
0
        /// <summary>
        /// To get the list of available users
        /// </summary>
        /// <param name="userID">It is set as zero to select all users</param>
        /// <param name="searchText">The text to search</param>
        private void GetUserDetails(string searchText, bool activatedDeactivated)
        {
            try
            {
                //Convert.ToInt32(Session["CompanyID"]);
                SessionControl.CompanyID.cxToInt32();
                // Get the list of users
                UsersDL userDetails = new UsersDL();

                DataView dView = userDetails.GetUserListByCompanyID(_companyID, searchText, activatedDeactivated).Tables[0].DefaultView;
                gvUserDetails.DataSource = dView;
                gvUserDetails.DataBind();
            }
            catch (Exception ex)
            {
                ErrorLog.LogErrorMessageToDB("ViewUser.aspx", "", "GetUserDetails(int userID, string searchText)", ex.Message.ToString(), new ACEConnection());
            }
        }
Пример #9
0
        /// <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());
            }
        }
 public FrmPerson()
 {
     try
     {
         InitializeComponent();
         p = new Person();
         using (UsersDL usrsDL = new UsersDL())
         {
             cmbxCreatedBy.DataSource    = usrsDL.GetTableAsList <Users>();
             cmbxCreatedBy.DisplayMember = "UserName";
             cmbxCreatedBy.ValueMember   = "OBJID";
         }
         RefreshGrd();
     }
     catch (Exception ex)
     {
         MessageBox.Show(string.Format("Message : {0}", ex.Message));
     }
 }
Пример #11
0
 //GetUserById
 public static Users1 GetUserById(int userId)
 {
     return(UsersConvertor.ConvertToDto(UsersDL.GetUserById(userId)));
 }
Пример #12
0
 //LogIn2
 public static Users1 Login2(string email, string password)
 {
     return(UsersConvertor.ConvertToDto(
                UsersDL.GetAllUsers().FirstOrDefault(u => u.Email.Equals(email) && u.Password.Equals(password))));
 }
Пример #13
0
 //LogIn1
 public static Users1 Login1(string userName, string password)
 {
     return(UsersConvertor.ConvertToDto(
                UsersDL.GetAllUsers().FirstOrDefault(u => u.UserName.Equals(userName) && u.Password.Equals(password))));
 }
Пример #14
0
        //Delete האם יש למחוק קודם מהטבלאות שהוא נמצא בהן בקשרי גומלין
        public static void DeleteUser(Users1 user)
        {
            Users newUser = UsersConvertor.ConvertToDL(user);

            UsersDL.DeleteUser(newUser);
        }
Пример #15
0
 //Update
 public static void UpdateUser(Users1 user)
 {
     UsersDL.UpdateUser(UsersConvertor.ConvertToDL(user));
 }
Пример #16
0
        //Add
        public static void AddUser(Users1 user)
        {
            Users newUser = UsersConvertor.ConvertToDL(user);

            UsersDL.AddUser(newUser);
        }
Пример #17
0
        /// <summary>
        /// ibtnSubmitForgotPassword_Click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void ibtnSubmitForgotPassword_Click(object sender, EventArgs e)
        {
            try
            {
                StringBuilder sbMail    = new StringBuilder();
                StringBuilder sb        = new StringBuilder();
                DataSet       dsUser    = new DataSet();
                UsersDL       userDLObj = new UsersDL();
                dsUser = userDLObj.GetUserDetails(txtForgotUserName.Text);
                if (dsUser.Tables[0].Rows.Count > 0)
                {
                    DataRow dRow = dsUser.Tables[0].Rows[0];

                    string regeneratePassword = "";
                    string emailID            = "";
                    string employeeName       = "";
                    int    userID             = 0;

                    if (dRow["OfficeEmailID"] != DBNull.Value)
                    {
                        emailID = dRow["OfficeEmailID"].ToString();
                    }
                    else
                    {
                        emailID = "";
                    }

                    if (dRow["FName"] != DBNull.Value)
                    {
                        employeeName = dRow["FName"].ToString();
                    }
                    else
                    {
                        employeeName = "";
                    }

                    userID = Convert.ToInt32(dRow["UserID"].ToString());

                    regeneratePassword = CreateRandomPassword(8);

                    Utilities util = new Utilities();
                    regeneratePassword = util.EncryptText(regeneratePassword);

                    if (txtEmailID.Text.ToUpper().ToString() == emailID.ToUpper().ToString())
                    {
                        TransactionResult result = new UsersDL().UserForgotPassword(userID, regeneratePassword);

                        if (result.Status == TransactionStatus.Success)
                        {
                            UsersDL theUser = new UsersDL(userID, true);

                            // From Address
                            _msg.From = new MailAddress("*****@*****.**");

                            // To Address
                            _msg.To.Add(new MailAddress(txtEmailID.Text));

                            // Subject
                            _msg.Subject = "ACE - Forgot Password Assistance";

                            // Body
                            sbMail.Append("Dear " + employeeName + ",");
                            sbMail.Append(Environment.NewLine);
                            sbMail.Append(Environment.NewLine);

                            sbMail.Append("Your password had been changed.");

                            sbMail.Append(Environment.NewLine);
                            sbMail.Append(Environment.NewLine);

                            sbMail.Append("Kindly login with your Username and the new password. ");
                            sbMail.Append("Please make sure you change your password for information security reasons.");
                            sbMail.Append(Environment.NewLine);
                            sbMail.Append(Environment.NewLine);

                            sbMail.Append("Your new login information is given below to access the intranet site,");
                            sbMail.Append(Environment.NewLine);

                            sbMail.Append("http://192.2.200.2/Order");
                            sbMail.Append(Environment.NewLine);
                            sbMail.Append(Environment.NewLine);

                            sbMail.Append("Username : "******"Password : "******"Thank you,");
                            sbMail.Append(Environment.NewLine);
                            sbMail.Append(Environment.NewLine);

                            sbMail.Append("Daniel Jacob.");
                            sbMail.Append(Environment.NewLine);
                            sbMail.Append(Environment.NewLine);

                            _msg.Body = sbMail.ToString();

                            if (OrderSettings.SendMail)
                            {
                                SmtpClient client = new SmtpClient();
                                client.Send(_msg);
                            }

                            mvLogin.ActiveViewIndex = 0;
                        }
                        sb.Append("<script>alert('" + "Recovery Email Sent - sent to your " + txtEmailID.Text + "  email address" + ".');");
                        sb.Append("</script>");
                        ScriptManager.RegisterStartupScript(this.Page, typeof(string), "MyScript", sb.ToString(), false);
                    }
                    else
                    {
                        sb.Append("<script>alert('" + "Invalid email address" + ".');");
                        sb.Append("</script>");
                        ScriptManager.RegisterStartupScript(this.Page, typeof(string), "MyScript", sb.ToString(), false);
                    }

                    txtForgotUserName.Text = "";
                    txtEmailID.Text        = "";
                }
                else
                {
                    sb.Append("<script>alert('" + "Invalid User. Please Enter valid Username" + ".');");
                    sb.Append("</script>");
                    ScriptManager.RegisterStartupScript(this.Page, typeof(string), "MyScript", sb.ToString(), false);
                }
            }
            catch (Exception ex)
            {
                ErrorLog.LogErrorMessageToDB("Login.aspx", "", "ibtnSubmitForgotPassword_Click", ex.Message, new ACEConnection());
            }
        }
Пример #18
0
        /// <summary>
        /// btnSubmit_Click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                bool isChecked = false;

                if ((txtUserName.Text != "") && (txtPassword.Text != ""))
                {
                    FormsAuthentication.Initialize();
                    Utilities objPwd = new Utilities();

                    _usersLogin = new UsersDL();

                    _usersLogin.UserName = txtUserName.Text.cxToInt32();
                    _usersLogin.Password = objPwd.EncryptText(txtPassword.Text);


                    if (_usersLogin.GetLogin())
                    {
                        isChecked = chkRememberMe.Checked;
                        if (isChecked)
                        {
                            HttpCookie myCookie = new HttpCookie("myCookie");
                            Response.Cookies.Remove("myCookie");
                            Response.Cookies.Add(myCookie);
                            myCookie.Values.Add("username", txtUserName.Text.cxToString());
                            DateTime dtExpiry = DateTime.Now.AddDays(15); //you can add years and months too here
                            Response.Cookies["myCookie"].Expires = dtExpiry;
                        }
                        else
                        {
                            HttpCookie myCookie = new HttpCookie("myCookie");
                            Response.Cookies.Remove("myCookie");
                            Response.Cookies.Add(myCookie);
                            myCookie.Values.Add("username", txtUserName.Text.cxToString());
                            DateTime dtExpiry = DateTime.Now.AddSeconds(1); //you can add years and months too here
                            Response.Cookies["myCookie"].Expires = dtExpiry;
                        }

                        TransactionResult result;
                        result = new UsersDL().UpdateLastLoginDate(_usersLogin.UserID);

                        if (!_usersLogin.IsPasswordChanged)
                        {
                            //commented on 16/04/2014
                            //Session["UserName"] = _usersLogin.UserName;
                            //Session["UserID"] = _usersLogin.UserID;
                            //Session["CompanyID"] = _usersLogin.CompanyID;
                            //Session["CompanyName"] = _usersLogin.CompanyName;
                            //Session["EmployeeName"] = _usersLogin.EmployeeName;
                            //Session["EmployeeID"] = _usersLogin.EmployeeID;
                            //Session["EmployeeDOB"] = _usersLogin.EmployeeDOB;
                            //Session["EmployeeWeddingDate"] = _usersLogin.EmployeeWeddingDate;
                            //Session["SpouseName"] = _usersLogin.SpouseName;
                            //Session["DateFormat"] = _usersLogin.DateFormat;
                            //Session["Role"] = _usersLogin.RoleName;
                            //Session["DepartmentID"] = _usersLogin.DepartmentID;
                            //Session["DepartmentName"] = _usersLogin.DepartmentName;

                            SessionControl.UserName            = _usersLogin.UserName;
                            SessionControl.UserID              = _usersLogin.UserID;
                            SessionControl.CompanyID           = _usersLogin.CompanyID;
                            SessionControl.CompanyName         = _usersLogin.CompanyName;
                            SessionControl.EmployeeName        = _usersLogin.EmployeeName;
                            SessionControl.EmployeeID          = _usersLogin.EmployeeID;
                            SessionControl.EmployeeDOB         = _usersLogin.EmployeeDOB.ToString();
                            SessionControl.EmployeeWeddingDate = _usersLogin.EmployeeWeddingDate.ToString();
                            SessionControl.SpouseName          = _usersLogin.SpouseName;
                            SessionControl.DateFormat          = _usersLogin.DateFormat;
                            SessionControl.Role           = _usersLogin.RoleName;
                            SessionControl.DepartmentID   = _usersLogin.DepartmentID;
                            SessionControl.DepartmentName = _usersLogin.DepartmentName;


                            FormsAuthenticationTicket _faTicket = new FormsAuthenticationTicket(1, txtUserName.Text, DateTime.Now, DateTime.Now.AddMinutes(30), false, _usersLogin.Password, FormsAuthentication.FormsCookieName);
                            string     hash   = FormsAuthentication.Encrypt(_faTicket);
                            HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, hash);
                            if (_faTicket.IsPersistent)
                            {
                                cookie.Expires = _faTicket.Expiration;
                            }

                            Response.Cookies.Add(cookie);

                            if (Request.QueryString["LeaveEmail"] == "Y")
                            {
                                Response.Redirect("~/Leave/LeaveApproval.aspx", false);
                            }
                            if (_usersLogin.DepartmentName == "MT-HBT")
                            {
                                Response.Redirect("../ECTranscription/Login.aspx?UserID=" + _usersLogin.UserID.cxToString(), false);
                            }
                            if (_usersLogin.DepartmentName == "MT-Trainee")
                            {
                                Response.Redirect("../ECTranscription/Login.aspx?UserID=" + _usersLogin.UserID.cxToString(), false);
                            }
                            if (_usersLogin.DepartmentName == "Proofer-HBT")
                            {
                                Response.Redirect("../ECTranscription/Login.aspx?UserID=" + _usersLogin.UserID.cxToString() + "&UserDepartmentName=" + _usersLogin.DepartmentName.cxToString(), false);
                            }
                            if (_usersLogin.DepartmentName == "QC-HBT")
                            {
                                Response.Redirect("../ECTranscription/Login.aspx?UserID=" + _usersLogin.UserID.cxToString() + "&UserDepartmentName=" + _usersLogin.DepartmentName.cxToString(), false);
                            }
                            else
                            {
                                Response.Redirect("~/Default.aspx", false);
                            }
                        }
                        else
                        {
                            mvLogin.ActiveViewIndex = 2;
                        }
                    }
                    else
                    {
                        lblmsg.Text = "Invalid UserName / Password";
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorLog.LogErrorMessageToDB("Login.aspx", "", "btnSubmit_Click", ex.Message, new ACEConnection());
            }
        }
Пример #19
0
 //GeByUserName
 public static Users1 GeByUserName(string userName)
 {
     return(UsersConvertor.ConvertToDto(UsersDL.GetAllUsers().FirstOrDefault(u => u.UserName.Equals(userName))));
 }
Пример #20
0
        /// <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());
            }
        }
Пример #21
0
 //GetAllUsers
 public static List <Users1> GetAllUsers()
 {
     return(UsersConvertor.ConvertToListDto(UsersDL.GetAllUsers()));
 }
Пример #22
0
        /// <summary>
        /// gvUserDetails_RowCommand
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void gvUserDetails_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                if (e.CommandName == "ResetPassword")
                {
                    StringBuilder sbMail = new StringBuilder();

                    Control     source   = e.CommandSource as Control;
                    GridViewRow row      = source.NamingContainer as GridViewRow;
                    int         rowIndex = int.Parse(e.CommandArgument.ToString());
                    // Get the selected row's user id, emp id
                    int userIDToReset = Convert.ToInt32(gvUserDetails.DataKeys[rowIndex].Values["UserID"]);
                    int employeeID    = Convert.ToInt32(gvUserDetails.DataKeys[rowIndex].Values["EmployeeID"]);

                    EmployeeDL employee = new EmployeeDL(employeeID, true);

                    Utilities objPwd = new Utilities();

                    string   password = "";
                    DateTime dob      = (DateTime)employee.Dob;
                    password = objPwd.EncryptText(Convert.ToString(dob.ToString("dd") + employee.EmployeeCode.ToString() + dob.ToString("MM")));

                    TransactionResult result = new UsersDL().UserResetPassword(userIDToReset, password);

                    StringBuilder sb = new StringBuilder();
                    sb.Append("<script>alert('" + result.Message.ToString() + ".');");
                    sb.Append("</script>");
                    ScriptManager.RegisterStartupScript(this.Page, typeof(string), "MyScript", sb.ToString(), false);

                    // If reset password had been successful
                    if (result.Status == TransactionStatus.Success)
                    {
                        UsersDL theUser = new UsersDL(userIDToReset, true);

                        // From Address
                        _msg.From = new MailAddress("*****@*****.**");

                        // To Address
                        _msg.To.Add(new MailAddress(employee.OfficeEmailID));

                        // Subject
                        _msg.Subject = "ACE: Password has been Reset";

                        // Body
                        sbMail.Append("Dear " + employee.EmployeeName + ",");
                        sbMail.Append(Environment.NewLine);
                        sbMail.Append(Environment.NewLine);

                        sbMail.Append("Your password had been reset.");

                        sbMail.Append(Environment.NewLine);
                        sbMail.Append(Environment.NewLine);

                        sbMail.Append("Kindly login with your employee ID and the new password. ");
                        sbMail.Append("Please make sure you change your password for information security reasons.");
                        sbMail.Append(Environment.NewLine);
                        sbMail.Append(Environment.NewLine);

                        sbMail.Append("Your new login information is given below to access the intranet site,");
                        sbMail.Append(Environment.NewLine);

                        sbMail.Append("http://192.2.200.2/Order");

                        sbMail.Append(Environment.NewLine);
                        sbMail.Append(Environment.NewLine);

                        sbMail.Append("User ID : " + theUser.UserName);
                        sbMail.Append(Environment.NewLine);

                        sbMail.Append("Password : "******"Thank you,");
                        sbMail.Append(Environment.NewLine);
                        sbMail.Append(Environment.NewLine);

                        sbMail.Append("Daniel Jacob.");
                        sbMail.Append(Environment.NewLine);
                        sbMail.Append(Environment.NewLine);

                        _msg.Body = sbMail.ToString();

                        if (OrderSettings.SendMail)
                        {
                            SmtpClient client = new SmtpClient();
                            client.Send(_msg);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorLog.LogErrorMessageToDB("ViewUser.aspx", "", "gvUserDetails_RowCommand", ex.Message.ToString(), new ACEConnection());
            }
        }