Example #1
0
        private void loadEntity()
        {
            Employee_BAL objImpl = new Employee_BAL();
            Employee_DTO objInfo = objImpl.GetObject(EmployeeID);

            if (objInfo == null)
            {
                return;
            }
            txtFullName.Text    = objInfo.FullName;
            txtDateOfBirth.Text = objInfo.DateOfBirth.ToString("dd/MM/yyyy");
            if (objInfo.Gender == true)
            {
                rbtFeMale.Checked = true;
            }
            else
            {
                rbtMale.Checked = true;
            }
            ddlSubject.SelectedValue  = objInfo.SubjectID.ToString();
            ddlPosition.SelectedValue = objInfo.PositionID.ToString();
            txtAcademicRank.Text      = objInfo.AcademicRank;
            txtBachelorDegree.Text    = objInfo.BachelorDegree;
            txtEmail.Text             = objInfo.Email;
            txtPhone.Text             = objInfo.Phone;
            txtAddress.Text           = objInfo.Address;
            hddImagePath.Value        = "/assets/global/employee/" + objInfo.ImagePath;
            hddFileImage.Value        = objInfo.ImagePath;
            User_BAL objUser_BAL = new User_BAL();
            User_DTO objUser_DTO = objUser_BAL.GetObject(EmployeeID);

            txtUsername.Text      = objUser_DTO.UserName;
            ddlRole.SelectedValue = objUser_DTO.Role.ToString();
        }
Example #2
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            User_BAL          objUserImpl = new User_BAL();
            UserExtension_DTO objInfo     = objUserImpl.Login(txtUsername.Text, StringHelper.MD5(txtPassword.Text));

            if (objInfo != null)
            {
                if (objInfo.IsLock == true)
                {
                    litError.Text = "<div class='alert alert-danger'><button class='close' data-close='alert'></button><span>Tài khoản đang bị khóa!</span></div>";
                }
                else
                {
                    Session["LockScreen"] = false;
                    Session["UserLogin"]  = objInfo;
                    if (chkRemember.Checked == true)
                    {
                        HttpCookie userCookie = new HttpCookie("userInfo");
                        userCookie.Values["userName"] = txtUsername.Text;
                        userCookie.Values["password"] = txtPassword.Text;
                        userCookie.Expires            = DateTime.Now.AddDays(1);
                        Response.Cookies.Add(userCookie);
                    }
                    objUserImpl.UpdateLastIPAddress(objInfo.UserID, GetIPAddress());
                    Response.Redirect("~/Default");
                }
            }
            else
            {
                litError.Text = "<div class='alert alert-danger'><button class='close' data-close='alert'></button><span>Tài khoản và mật khẩu không đúng!</span></div>";
            }
        }
Example #3
0
        private void LoadData()
        {
            User_BAL objImpl = new User_BAL();

            rptUser.DataSource = objImpl.Search(txtKeyword.Text);
            rptUser.DataBind();
        }
Example #4
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     if (Session["UserLogin"] != null)
     {
         UserExtension_DTO objInfo = (UserExtension_DTO)Session["UserLogin"];
         User_BAL          objImpl = new User_BAL();
         if (objInfo.Password == StringHelper.MD5(txtCurrentPassword.Text))
         {
             objImpl.ChangePassword(objInfo.UserID, StringHelper.MD5(txtNewPassword.Text));
             litError.Text = "<div class='alert alert-danger'><button class='close' data-close='alert'></button><span>Thay đổi mật khẩu thành công!</span></div>";
         }
         else
         {
             litError.Text = "<div class='alert alert-danger'><button class='close' data-close='alert'></button><span>Mật khẩu không đúng!</span></div>";
         }
     }
 }
Example #5
0
 protected void btnLogin_Click(object sender, EventArgs e)
 {
     if (Session["UserLogin"] != null)
     {
         UserExtension_DTO objInfo     = (UserExtension_DTO)Session["UserLogin"];
         User_BAL          objUserImpl = new User_BAL();
         UserExtension_DTO objInfonew  = objUserImpl.Login(objInfo.UserName, StringHelper.MD5(txtPassword.Text));
         if (objInfonew != null)
         {
             Session["UserLogin"]  = objInfonew;
             Session["LockScreen"] = false;
             Response.Redirect("~/Default");
         }
         else
         {
             litError.Text = "<div class='alert alert-danger alert-lock'><button class='close' data-close='alert'></button><span>Mật khẩu không đúng!</span></div>";
         }
     }
     else
     {
         Response.Redirect("~/Account/Login");
     }
 }
Example #6
0
        protected void rptUser_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            int      userID  = int.Parse(e.CommandArgument.ToString());
            string   cmd     = e.CommandName;
            User_BAL objImpl = new User_BAL();

            if (cmd == "ResetPassword")
            {
                objImpl.ChangePassword(userID, StringHelper.MD5("123456"));
                litError.Text = "<div class='alert alert-danger'><button class='close' data-close='alert'></button><span>Reset mật khẩu thành công!</span></div>";
            }
            else if (cmd == "LockUsser")
            {
                objImpl.UpdateLockUsser(userID, true);
                litError.Text = "<div class='alert alert-danger'><button class='close' data-close='alert'></button><span>Khóa tài khoản thành công!</span></div>";
            }
            else if (cmd == "UnLockUsser")
            {
                objImpl.UpdateLockUsser(userID, false);
                litError.Text = "<div class='alert alert-danger'><button class='close' data-close='alert'></button><span>Mở khóa tài khoản thành công!</span></div>";
            }
            LoadData();
        }
Example #7
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Employee_DTO objInfo = new Employee_DTO();

            objInfo.FullName = txtFullName.Text;
            if (String.IsNullOrEmpty(txtDateOfBirth.Text) == false)
            {
                objInfo.DateOfBirth = DateTime.ParseExact(txtDateOfBirth.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            }
            objInfo.Gender         = rbtFeMale.Checked == true ? true : false;
            objInfo.SubjectID      = int.Parse(ddlSubject.SelectedValue.ToString());
            objInfo.PositionID     = int.Parse(ddlPosition.SelectedValue.ToString());
            objInfo.AcademicRank   = txtAcademicRank.Text;
            objInfo.BachelorDegree = txtBachelorDegree.Text;
            objInfo.Email          = txtEmail.Text;
            objInfo.Address        = txtAddress.Text;
            objInfo.Phone          = txtPhone.Text;
            objInfo.EmployeeID     = EmployeeID;
            //user
            User_DTO objUserInfo = new User_DTO();

            objUserInfo.UserID   = EmployeeID;
            objUserInfo.UserName = txtUsername.Text;
            objUserInfo.Role     = int.Parse(ddlRole.SelectedValue);
            Employee_BAL objImpl     = new Employee_BAL();
            User_BAL     objUserImpl = new User_BAL();
            var          data_path   = "/assets/global/employee/";

            if (objUserImpl.IsExists(objUserInfo.UserID, objUserInfo.UserName) == true)
            {
                litError.Text = "<div class='alert alert-danger'><button class='close' data-close='alert'></button><span>Tài khoản này đã tồn tại!</span></div>";
                return;
            }
            else
            {
                litError.Text = "";
            }
            if (objInfo.EmployeeID > 0)
            {
                if (fuImagePath.PostedFile != null && fuImagePath.FileName.Length > 0)
                {
                    if (!Directory.Exists(Server.MapPath(data_path)))
                    {
                        Directory.CreateDirectory(Server.MapPath(data_path));
                    }
                    string fileNameImage = Guid.NewGuid().ToString() + Path.GetExtension(fuImagePath.PostedFile.FileName.ToLower());
                    this.fuImagePath.PostedFile.SaveAs(Server.MapPath(data_path + fileNameImage));
                    objInfo.ImagePath = fileNameImage;
                    if (!string.IsNullOrEmpty(this.hddFileImage.Value))
                    {
                        string PathFile = Server.MapPath(data_path + hddFileImage.Value);
                        if (File.Exists(PathFile))
                        {
                            File.Delete(PathFile);
                        }
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(this.hddFileImage.Value))
                    {
                        if (this.hddRemoveImage.Value == "1")
                        {
                            string PathFile = Server.MapPath(data_path + this.hddFileImage.Value);
                            if (File.Exists(PathFile))
                            {
                                File.Delete(PathFile);
                            }
                            objInfo.ImagePath = "";
                        }
                        else
                        {
                            objInfo.ImagePath = hddFileImage.Value;
                        }
                    }
                }

                objImpl.Update(objInfo);
                objUserImpl.Update(objUserInfo);
            }
            else
            {
                if (fuImagePath.PostedFile != null && fuImagePath.FileName.Length > 0)
                {
                    if (!Directory.Exists(Server.MapPath(data_path)))
                    {
                        Directory.CreateDirectory(Server.MapPath(data_path));
                    }
                    string fileNameImage = Guid.NewGuid().ToString() + Path.GetExtension(fuImagePath.PostedFile.FileName.ToLower());
                    fuImagePath.PostedFile.SaveAs(Server.MapPath(data_path + fileNameImage));
                    objInfo.ImagePath = fileNameImage;
                }

                EmployeeID           = objImpl.Insert(objInfo);
                objUserInfo.UserID   = EmployeeID;
                objUserInfo.Password = StringHelper.MD5("123456");
                objUserInfo.IsLock   = false;
                objUserImpl.Insert(objUserInfo);
            }
            Response.Redirect("~/employee/listemployee");
        }