protected void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                UserInfo user = new UserInfo();
                user.UserID = ConvertUtility.ToInt32(Request.QueryString["uid"]);

                user.TTGDHoTenVoChong = txtHoTenVoChong.Text.Trim();
                user.TTGDNamSinhVoChong = txtNamSinhVoChong.Text.Trim();
                user.TTGDNgheNgiep = txtNgheNghiepNoiCongTac.Text.Trim();

                user.TTGDHoTenCon = txtHoTenCon.Text.Trim();
                user.TTGDNamSinhCon = txtNamSinhCon.Text.Trim();
                user.TTGDGioiTinhCon = txtGioiTinhCon.Text.Trim();

                user.TTGDNguoiLienHe = txtNguoiLienHe.Text.Trim();

                UserController.UpdateUserThongTinGiaDinh(user);

                lblUpdateStatus.Text = MiscUtility.MSG_UPDATE_SUCCESS;

            }
            catch (Exception ex)
            {
                lblUpdateStatus.Text = ex.Message;
            }
        }
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                UserInfo user = new UserInfo();

                user.UserID = ConvertUtility.ToInt32(Request.QueryString["uid"]);

                user.DCNSQDSo = txtQuyetDinhSo1.Text.Trim();
                user.DCNSNgay = txtNgay1.Text.Trim();
                user.DCNSNgayHieuLuc = txtNgayHieuLuc1.Text.Trim();
                user.DCNSChiTiet = txtChiTietDieuChinh1.Text.Trim();

                user.DCNSQDSo1 = txtQuyetDinhSo2.Text.Trim();
                user.DCNSNgay1 = txtNgay2.Text.Trim();
                user.DCNSNgayHieuLuc1 = txtNgayHieuLuc2.Text.Trim();
                user.DCNSChiTiet1 = txtChiTietDieuChinh2.Text.Trim();

                user.DCNSQDSo2 = txtQuyetDinhSo2.Text.Trim();
                user.DCNSNgay2 = txtNgay2.Text.Trim();
                user.DCNSNgayHieuLuc2 = txtNgayHieuLuc2.Text.Trim();
                user.DCNSChiTiet2 = txtChiTietDieuChinh2.Text.Trim();

                UserController.UpdateUserDieuChinhNhanSu(user);

                lblUpdateStatus.Text = MiscUtility.MSG_UPDATE_SUCCESS;

            }
            catch (Exception ex)
            {
                lblUpdateStatus.Text = ex.Message;
            }
        }
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            returnUrl = Server.UrlEncode(Request.RawUrl);
            HttpCookie memInfoUser = Request.Cookies["name"];
            HttpCookie memInfoPass = Request.Cookies["pass"];
            if(AuthenticateUtility.IsAuthenticated())
            {

                if (CurrentUser == null) CurrentUser = UserController.GetUser(AuthenticateUtility.GetUsername());
                if (CurrentUser == null) Response.Redirect("/Login.aspx?returnurl=" + returnUrl);
            }else
            {
                if (memInfoPass != null && memInfoUser.Expires != null)
                {
                    UserInfo next = UserController.ValidateUser(memInfoUser.Value, memInfoPass.Value);
                    if(AuthenticateUtility.LoginUser(memInfoUser.Value, true))
                    if (next!=null) CurrentUser = UserController.GetUser(memInfoUser.Value);
                    else
                        Response.Redirect("/Login.aspx?returnurl=" + returnUrl);
                }
                else {
                    Response.Redirect("/Login.aspx?returnurl=" + returnUrl);
                }

            }
        }
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                UserInfo user = new UserInfo();

                user.UserID = ConvertUtility.ToInt32(Request.QueryString["uid"]);

                user.HocVanBangCap = txtBangCap.Text.Trim();
                user.HocVanNoiDaoTao = txtNoiDaoTao.Text.Trim();
                user.HocVanChuyenNganh = txtChuyenNganh.Text.Trim();
                user.HocVanCacKhoaHocKhac = txtCacKhoaHocKhac.Text.Trim();
                user.HocVanNgoaiNgu = txtNgoaiNgu.Text.Trim();

                user.ToChucDoanHiepHoi = txtToChucDoanThe.Text.Trim();
                user.ToChucNgayGiaNhap = txtNgayGiaNhap.Text.Trim();
                user.ToChucNoiKetNap = txtNoiKetNap.Text.Trim();

                user.KhenThuongGiaiThuong = txtGiaiThuong.Text.Trim();
                user.KhenThuongToChucTrao = txtToChucTraoThuong.Text.Trim();
                user.KhenThuongNamTrao = txtNamTraoThuong.Text.Trim();

                UserController.UpdateUserHocVanToChucDoanTheKhenThuong(user);

                lblUpdateStatus.Text = MiscUtility.MSG_UPDATE_SUCCESS;

            }
            catch (Exception ex)
            {
                lblUpdateStatus.Text = ex.Message;
            }
        }
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            returnUrl = Server.UrlEncode(Request.RawUrl);
            HttpCookie memInfoUser = Request.Cookies["nametemp"];
            HttpCookie memInfoPass = Request.Cookies["passtemp"];
            if(AuthenticateUtility.IsAuthenticatedTemp())
            {
                CurrentUserTemp = UserController.GetUser(AuthenticateUtility.GetUsernameTemp());

                if (CurrentUserTemp == null)
                {
                    Response.Redirect("/Login.aspx?returnurl=" + returnUrl);
                }
            }
            else
            {
                if (memInfoPass != null && memInfoUser != null)
                {
                    UserInfo info = UserController.ValidateUser(memInfoUser.Value, memInfoPass.Value);
                    //set cookies
                    if (AuthenticateUtility.LoginUserTemp(memInfoUser.Value, true, info))
                    {
                        if (info != null)
                        {
                            CurrentUserTemp = info;
                        }
                        else
                        {
                            Response.Redirect("/Login.aspx?returnurl=" + returnUrl);
                        }
                    }
                }
                else
                {
                    Response.Redirect("/Login.aspx?returnurl=" + returnUrl);
                }
            }
        }
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                UserInfo user = new UserInfo();

                user.UserID = ConvertUtility.ToInt32(Request.QueryString["uid"]);

                user.HDLD3NgayKyGiaHan = txtNgayKyGiaHan3.Text.Trim();
                user.HDLD3NguoiKyGiaHan = txtNguoiKyGiaHan3.Text.Trim();
                user.HDLD3QDSo = txtQuyetDinhSo3.Text.Trim();
                user.HDLD3NgayHieuLuc = txtNgayHieuLuc3.Text.Trim();
                user.HDLD3NgayHetHan = txtNgayHetHan3.Text.Trim();
                user.HDLD3ThoiHan = txtThoiHan3.Text.Trim();

                user.HDLD4NgayKyGiaHan = txtNgayKyGiaHan4.Text.Trim();
                user.HDLD4NguoiKyGiaHan = txtNguoiKyGiaHan4.Text.Trim();
                user.HDLD4QDSo = txtQuyetDinhSo4.Text.Trim();
                user.HDLD4NgayHieuLuc = txtNgayHieuLuc4.Text.Trim();
                user.HDLD4NgayHetHan = txtNgayHetHan4.Text.Trim();
                user.HDLD4ThoiHan = txtThoiHan4.Text.Trim();

                user.HDLD5NgayKyGiaHan = txtNgayKyGiaHan5.Text.Trim();
                user.HDLD5NguoiKyGiaHan = txtNguoiKyGiaHan5.Text.Trim();
                user.HDLD5QDSo = txtQuyetDinhSo5.Text.Trim();
                user.HDLD5NgayHieuLuc = txtNgayHieuLuc5.Text.Trim();
                user.HDLD5NgayHetHan = txtNgayHetHan5.Text.Trim();
                user.HDLD5ThoiHan = txtThoiHan5.Text.Trim();

                UserController.UpdateUserHDLDGH345(user);

                lblUpdateStatus.Text = MiscUtility.MSG_UPDATE_SUCCESS;

            }
            catch (Exception ex)
            {
                lblUpdateStatus.Text = ex.Message;
            }
        }
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                UserInfo user = new UserInfo();

                user.UserID = ConvertUtility.ToInt32(Request.QueryString["uid"]);

                user.HDLDSHD = txtSoHopDong.Text.Trim();
                user.HDLDNguoiKy = txtNguoiKyHopDong.Text.Trim();
                user.HDLDNgayKy = txtNgayKyHopDong.Text.Trim();
                user.HDLDNgayHieuLuc = txtNgayHieuLuc.Text.Trim();
                user.HDLDNgayHetHan = txtNgayHetHan.Text.Trim();
                user.HDLDLoaiHopDong = txtLoaiHopDong.Text.Trim();

                user.HDLD1NgayKyGiaHan = txtNgayKyGiaHan1.Text.Trim();
                user.HDLD1NguoiKyGiaHan = txtNguoiKyGiaHan1.Text.Trim();
                user.HDLD1QDSo = txtQuyetDinhSo1.Text.Trim();
                user.HDLD1NgayHieuLuc = txtNgayHieuLuc1.Text.Trim();
                user.HDLD1NgayHetHan = txtNgayHetHan1.Text.Trim();
                user.HDLD1ThoiHan = txtThoiHan1.Text.Trim();

                user.HDLD2NgayKyGiaHan = txtNgayKyGiaHan2.Text.Trim();
                user.HDLD2NguoiKyGiaHan = txtNguoiKyGiaHan2.Text.Trim();
                user.HDLD2QDSo = txtQuyetDinhSo2.Text.Trim();
                user.HDLD2NgayHieuLuc = txtNgayHieuLuc2.Text.Trim();
                user.HDLD2NgayHetHan = txtNgayHetHan2.Text.Trim();
                user.HDLD2ThoiHan = txtThoiHan2.Text.Trim();

                UserController.UpdateUserHDLDGH1GH2(user);

                lblUpdateStatus.Text = MiscUtility.MSG_UPDATE_SUCCESS;

            }
            catch (Exception ex)
            {
                lblUpdateStatus.Text = ex.Message;
            }
        }
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                UserInfo user = new UserInfo();

                user.UserID = ConvertUtility.ToInt32(Request.QueryString["uid"]);

                user.SoDienThoaiMobile = txtMobile.Text.Trim();
                user.SoDienThoaiHome = txtHome.Text.Trim();

                user.EmailVNG = txtVmgEmail.Text.Trim();
                user.EmailCaNhan = txtEmailCaNhan.Text.Trim();

                user.CMNDSo = txtSoCMND.Text.Trim();
                user.CMNDNgayCap = txtNgayCapCMND.Text.Trim();
                user.CMNDNoiCap = txtNoiCapCMND.Text.Trim();

                user.HoChieuSo = txtSoHoChieu.Text.Trim();
                user.HoChieuNgayCap = txtNgayCapHoChieu.Text.Trim();
                user.HoChieuNoiCap = txtNoiCapHoChieu.Text.Trim();

                user.TKNNSo = txtSoTKNH.Text.Trim();
                user.TKNNNganHang = txtNganHang.Text.Trim();
                user.TKNNChiNhanh = txtChiNhanh.Text.Trim();

                user.MaSoThueCaNhan = txtMaSoThueCaNhan.Text.Trim();

                UserController.UpdateUserThongTinMoRong(user);

                lblUpdateStatus.Text = MiscUtility.MSG_UPDATE_SUCCESS;

            }
            catch (Exception ex)
            {
                lblUpdateStatus.Text = ex.Message;
            }
        }
        public static bool LoginUserTemp(string _username, bool _rememberAccount, UserInfo info)
        {
            LogoutUser();
            FormsAuthentication.Initialize();
            FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, MEMBER_PREFIX_TEMP + _username, DateTime.Now, DateTime.Now.AddMinutes(45), _rememberAccount, "", FormsAuthentication.FormsCookiePath);
            Trace.Write(FormsAuthentication.FormsCookiePath + FormsAuthentication.FormsCookieName);
            HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket));
            HttpContext.Current.Response.SetCookie(cookie);

            FormsAuthentication.Initialize();
            ticket = new FormsAuthenticationTicket(1, MEMBER_PREFIX + _username, DateTime.Now, DateTime.Now.AddMinutes(45), _rememberAccount, "", FormsAuthentication.FormsCookiePath);
            Trace.Write(FormsAuthentication.FormsCookiePath + FormsAuthentication.FormsCookieName);
            cookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket));
            HttpContext.Current.Response.SetCookie(cookie);

            //UserInfo info = UserController.GetUser(_username);
            if (info != null)
            {
                string _password = info.Password;
                HttpContext.Current.Response.Cookies.Get("nametemp").Value = _username;
                HttpContext.Current.Response.Cookies.Get("passtemp").Value = _password;
                HttpContext.Current.Response.Cookies["nametemp"].Expires = DateTime.Now.AddMinutes(60);
                HttpContext.Current.Response.Cookies["passtemp"].Expires = DateTime.Now.AddMinutes(60);

                HttpContext.Current.Response.Cookies.Get("name").Value = _username;
                HttpContext.Current.Response.Cookies.Get("pass").Value = _password;
                HttpContext.Current.Response.Cookies["name"].Expires = DateTime.Now.AddDays(1);
                HttpContext.Current.Response.Cookies["pass"].Expires = DateTime.Now.AddDays(1);

                return true;
            }
            else
            {
                return false;
            }
        }
 public override void UpdateUserThongTinMoRong(UserInfo user)
 {
     SqlHelper.ExecuteNonQuery(this.ConnectionString, "NhanVien_UpdateThongTinMoRong",
             user.UserID,
             user.Username,
             user.Password,
             user.DisplayName,
             user.IsAdmin,
             user.IsSuperAdmin,
             user.MaSo,
             user.HoTen,
             user.IDChucVu,
             user.IDTrungTam,
             user.IDPhong,
             user.NgaySinh,
             user.NoiSinh,
             user.NguyenQuan,
             user.QuocTich,
             user.DanToc,
             user.TonGiao,
             user.GioiTinh,
             user.DiaChiThuongChu,
             user.DiaChiTamChu);
 }
 public override void UpdateUserThongTinGiaDinh(UserInfo user)
 {
     SqlHelper.ExecuteNonQuery(this.ConnectionString, "NhanVien_UpdateThongTinGiaDinh",
             user.UserID,
             user.TTGDHoTenVoChong,
             user.TTGDNamSinhVoChong,
             user.TTGDNgheNgiep,
             user.TTGDHoTenCon,
             user.TTGDNamSinhCon,
             user.TTGDGioiTinhCon,
             user.TTGDNguoiLienHe);
 }
 public override void UpdateUserQuaTrinhLamViec(UserInfo user)
 {
     SqlHelper.ExecuteNonQuery(this.ConnectionString, "NhanVien_UpdateQuaTrinhLamViec",
             user.UserID,
             user.QTLVCongTy,
             user.QTLVChucDanh,
             user.QTLVLyDoChuyenDoi,
             user.BHXHThoiGianDong,
             user.BHXHSoSo,
             user.BHXHGhiChu);
 }
 public override void UpdateUserHocVanToChucDoanTheKhenThuong(UserInfo user)
 {
     SqlHelper.ExecuteNonQuery(this.ConnectionString, "NhanVien_UpdateHocVanToChucDoanTheKhenThuong",
             user.UserID,
             user.HocVanBangCap,
             user.HocVanNoiDaoTao,
             user.HocVanChuyenNganh,
             user.HocVanCacKhoaHocKhac,
             user.HocVanNgoaiNgu,
             user.ToChucDoanHiepHoi,
             user.ToChucNgayGiaNhap,
             user.ToChucNoiKetNap,
             user.KhenThuongGiaiThuong,
             user.KhenThuongToChucTrao,
             user.KhenThuongNamTrao);
 }
 public override void UpdateUserHDLDGH345(UserInfo user)
 {
     SqlHelper.ExecuteNonQuery(this.ConnectionString, "NhanVien_UpdateHDLDGH345",
             user.UserID,
             user.HDLD3NgayKyGiaHan,
             user.HDLD3NguoiKyGiaHan,
             user.HDLD3QDSo,
             user.HDLD3NgayHieuLuc,
             user.HDLD3NgayHetHan,
             user.HDLD3ThoiHan,
             user.HDLD4NgayKyGiaHan,
             user.HDLD4NguoiKyGiaHan,
             user.HDLD4QDSo,
             user.HDLD4NgayHieuLuc,
             user.HDLD4NgayHetHan,
             user.HDLD4ThoiHan,
             user.HDLD5NgayKyGiaHan,
             user.HDLD5NguoiKyGiaHan,
             user.HDLD5QDSo,
             user.HDLD5NgayHieuLuc,
             user.HDLD5NgayHetHan,
             user.HDLD5ThoiHan);
 }
 public override void UpdateUserHDLDGH1GH2(UserInfo user)
 {
     SqlHelper.ExecuteNonQuery(this.ConnectionString, "NhanVien_UpdateHDLDGH1GH2",
             user.UserID,
             user.HDLDSHD,
             user.HDLDNguoiKy,
             user.HDLDNgayKy,
             user.HDLDNgayHieuLuc,
             user.HDLDNgayHetHan,
             user.HDLDLoaiHopDong,
             user.HDLD1NgayKyGiaHan,
             user.HDLD1NguoiKyGiaHan,
             user.HDLD1QDSo,
             user.HDLD1NgayHieuLuc,
             user.HDLD1NgayHetHan,
             user.HDLD1ThoiHan,
             user.HDLD2NgayKyGiaHan,
             user.HDLD2NguoiKyGiaHan,
             user.HDLD2QDSo,
             user.HDLD2NgayHieuLuc,
             user.HDLD2NgayHetHan,
             user.HDLD2ThoiHan);
 }
 public override void UpdateUserDieuChinhNhanSu(UserInfo user)
 {
     SqlHelper.ExecuteNonQuery(this.ConnectionString, "NhanVien_UpdateCacDieuChinhNhanSu",
             user.UserID,
             user.DCNSQDSo,
             user.DCNSNgay,
             user.DCNSNgayHieuLuc,
             user.DCNSChiTiet,
             user.DCNSQDSo1,
             user.DCNSNgay1,
             user.DCNSNgayHieuLuc1,
             user.DCNSChiTiet1,
             user.DCNSQDSo2,
             user.DCNSNgay2,
             user.DCNSNgayHieuLuc2,
             user.DCNSChiTiet2);
 }
 public override int AddUser(UserInfo user)
 {
     return (int)SqlHelper.ExecuteScalar(this.ConnectionString, "NhanVien_Insert",
             user.Username,
             user.Password,
             user.DisplayName,
             user.IsAdmin,
             user.IsSuperAdmin,
             user.MaSo,
             user.HoTen,
             user.IDChucVu,
             user.IDTrungTam,
             user.IDPhong,
             user.NgaySinh,
             user.NoiSinh,
             user.NguyenQuan,
             user.QuocTich,
             user.DanToc,
             user.TonGiao,
             user.GioiTinh,
             user.DiaChiThuongChu,
             user.DiaChiTamChu,
             user.TrangThai);
 }
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                try
                {
                    int userId = ConvertUtility.ToInt32(Request.QueryString["uid"]);

                    UserInfo user = new UserInfo();
                    user.Username = txtUsername.Text.Trim();
                    user.DisplayName = txtDisplayName.Text.Trim();
                    user.IsAdmin = chkIsAdmin.Checked;
                    user.IsSuperAdmin = chkIsSuperAdmin.Checked;

                    user.MaSo = txtMaSo.Text.Trim();
                    user.HoTen = txtFullName.Text.Trim();
                    user.NgaySinh = ConvertUtility.ToDateTime(txtNgaySinh.Text.Trim());
                    user.GioiTinh = ConvertUtility.ToInt32(dropGioiTinh.SelectedValue);
                    user.IDChucVu = ConvertUtility.ToInt32(dropChucVu.SelectedValue);
                    user.IDTrungTam = ConvertUtility.ToInt32(dropTrungTam.SelectedValue);
                    user.IDPhong = ConvertUtility.ToInt32(dropPhong.SelectedValue);
                    user.NoiSinh = txtNoiSinh.Text.Trim();
                    user.NguyenQuan = txtNguyenQuan.Text.Trim();
                    user.QuocTich = txtQuocTich.Text.Trim();

                    user.DanToc = txtDanToc.Text.Trim();
                    user.TonGiao = txtTonGiao.Text.Trim();
                    user.DiaChiThuongChu = txtDiaChiThuongChu.Text.Trim();
                    user.DiaChiTamChu = txtDiaChiTamChu.Text.Trim();
                    user.TrangThai = ConvertUtility.ToInt32(dropTrangThai.SelectedValue);

                    if (userId > 0)
                    {
                        user.UserID = userId;
                        UserController.UpdateUser(user);

                        lblUpdateStatus.Text = MiscUtility.MSG_UPDATE_SUCCESS;
                    }
                    else
                    {
                        if (txtPassword.Text.Trim() != txtPasswordConfirm.Text.Trim())
                        {
                            return;
                        }
                        user.Password = SecurityMethod.MD5Encrypt(txtPassword.Text.Trim());
                        userId = UserController.AddUser(user);

                        if (userId > 0)
                        {
                            RoleController.AddUserToRole(userId, AppEnv.DEFAULT_ROLE, AppEnv.PortalId());

                            Response.Redirect(AppEnv.AdminUrlParams("createuser") + "&uid=" + userId);
                        }
                        else
                        {
                            lblUpdateStatus.Text = "Tên đăng nhập lại đã tồn tại.";
                        }
                    }

                }
                catch (Exception ex)
                {
                    lblUpdateStatus.Text = ex.Message;
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            idDotDanhGia = ConvertUtility.ToInt32(Request.QueryString["idDotDanhGia"]);
            idNhanVien = ConvertUtility.ToInt32(Request.QueryString["idNhanVien"]);

            if (!IsPostBack)
            {
                dropDotDanhGia.DataSource = DotDanhGiaController.GetAll(1);
                dropDotDanhGia.DataBind();

                if (idDotDanhGia > 0)
                {
                    dropDotDanhGia.SelectedValue = idDotDanhGia.ToString();
                }
                dtBoPhanHoTro = BoPhanController.BoPhan_GetAllActive();
                dropBoPhanHoTro.Items.Clear();
                dropBoPhanHoTro.DataSource = dtBoPhanHoTro;
                dropBoPhanHoTro.DataBind();
            }

            if (idDotDanhGia == 0)
            {
                Response.Redirect(AppEnv.AdminUrlParams("kehoachnhanvien") + "&idDotDanhGia=" + dropDotDanhGia.SelectedValue + "&idNhanVien=" + CurrentUser.UserID);
            }

            if (CurrentUser.RoleID == (int)Constants.Role.NhanVien || CurrentUser.RoleID == (int)Constants.Role.NhanVienKD)
            {
                btnYeuCauLamLaiKeHoach.Visible = false;
            }
            else
            {
                btnYeuCauLamLaiKeHoach.Visible = true;
            }

            #region Check authenticate

            userInfo = UserController.GetUser(idNhanVien);
            if (userInfo == null)
            {
                Response.Redirect(AppEnv.AdminUrlParams("accessdeny"));
            }

            if (CurrentUser.RoleID == (int)Constants.Role.NhanVien || CurrentUser.RoleID == (int)Constants.Role.NhanVienKD)
            {
                if (CurrentUser.UserID != idNhanVien)
                {
                    Response.Redirect(AppEnv.AdminUrlParams("accessdeny"));
                }
            }

            #endregion

            btnSumit.OnClientClick = "return confirm('Bạn có chắc chắn gửi kế hoạch hay không ?')";
        }