예제 #1
0
        protected void btnAddUser_Click(object sender, EventArgs e)
        {
            DM_USER  sysUser  = new DM_USER();
            DateTime testdate = new DateTime();

            loiNgayThang.Visible = false;
            try
            {
                if (checkUser(txtUserName.Text, int.Parse(cmbDonVi.Value.ToString())))
                {
                    DM_USER User = new DM_USER {
                        USERNAME = txtUserName.Text
                    };
                    // Password:
                    string password = txtPassword.Text;
                    if (!string.IsNullOrEmpty(password))
                    {
                        User.PASSWORD = DM_USER.Encrypt(password);
                    }
                    User.HOTEN  = txtHoTen.Text;
                    User.DIACHI = txtDiaChi.Text;
                    if (txtNgaySinh.Text.Trim() != "")
                    {
                        if (txtNgaySinh.Text.Split('/').Length == 3)
                        {
                            if (DateTime.TryParse(txtNgaySinh.Text, out testdate))
                            {
                                User.NGAYSINH = DateTime.Parse(txtNgaySinh.Text);
                            }
                        }
                        else
                        {
                            loiNgayThang.Visible = true;
                            return;
                        }
                    }
                    else
                    {
                        User.NGAYSINH = DateTime.Now;
                    }
                    User.EMAIL       = txtEmail.Text;
                    User.XACNHAN     = false;
                    User.SODT        = txtPhone.Text;
                    sysUser.IS_ADMIN = 0;

                    User.IDMA_DVIQLY = int.Parse(cmbDonVi.Value.ToString());
                    _IDM_USERService.InsertDM_USER(User);
                    ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script language='javascript'>alert('Đăng ký tài khoảng thành công! Vui lòng chờ xác nhận');</script>");
                }
                else
                {
                    lblError.Visible = true;
                    throw new Exception(string.Format("Trùng tên! Vui lòng nhập lại."));
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message;
            }
        }
예제 #2
0
        public DM_USER CheckLogIn(string userName, string passWord, string MA_DVI)
        {
            DM_USER result = _dm_userDataAccess.DM_UserNameAndIDOrganization(MA_DVI, userName);

            if (result.PASSWORD == DM_USER.Encrypt(passWord))
            {
                return(result);
            }
            return(null);
        }
예제 #3
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            string msg = "";

            if (checkRetypePassword(ref msg))
            {
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Cập nhật thành công.');", true);
            }
            else
            {
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('Đã xảy ra lỗi. " + msg + " vui lòng nhập lại.');", true);
                return;
            }

            MTCSYT.SYS_Session session = (MTCSYT.SYS_Session)Session["SYS_Session"];
            session.User.PASSWORD = DM_USER.Encrypt(txtPassWordNew.Text);
            _userService.UpdateDM_USER_PASSWORD(session.User, session.User.MA_DVIQLY);
            //WriteLog("Thay đổi mật khẩu", Action.Update);
        }
예제 #4
0
 protected void btnCo_Click(object sender, EventArgs e)
 {
     MTCSYT.SYS_Session session = (MTCSYT.SYS_Session)Session["SYS_Session"];
     if (GridUser.FocusedRowIndex > -1)
     {
         DM_USER sysUser = (DM_USER)GridUser.GetRow(GridUser.FocusedRowIndex);
         sysUser.PASSWORD = DM_USER.Encrypt("123");
         _IDM_USERService.UpdateDM_USER_PASSWORD(sysUser, session.User.MA_DVIQLY);
         pcThongBao.ShowOnPageLoad = false;
     }
     else
     {
         GridUser.FocusedRowIndex = 0;
         DM_USER sysUser = (DM_USER)GridUser.GetRow(GridUser.FocusedRowIndex);
         sysUser.PASSWORD = DM_USER.Encrypt("123");
         if (sysUser != null)
         {
             _IDM_USERService.UpdateDM_USER_PASSWORD(sysUser, session.User.MA_DVIQLY);
         }
         pcThongBao.ShowOnPageLoad = false;
     }
 }
예제 #5
0
        protected void btnAddUser_Click(object sender, EventArgs e)
        {
            DM_USER  sysUser  = new DM_USER();
            DateTime testdate = new DateTime();
            //loiNgayThang.Visible = false;
            List <SYS_Roles> lstRole = new List <SYS_Roles>();

            try
            {
                if (Session["SYSUser"] != null)
                {
                    sysUser         = (DM_USER)Session["SYSUser"];
                    sysUser.XACNHAN = cbxActive.Checked;
                    sysUser.HOTEN   = txtHoTen.Text;
                    sysUser.DIACHI  = txtDiaChi.Text;
                    sysUser.SODT    = txtPhone.Text;
                    //if (txtNgaySinh.Text.Trim() != "")
                    //{
                    //    if (txtNgaySinh.Text.Split('/').Length == 3)
                    //    {
                    //        if (DateTime.TryParse(txtNgaySinh.Text.Split('/')[1] + "/" + txtNgaySinh.Text.Split('/')[0] + "/" + txtNgaySinh.Text.Split('/')[2], out testdate))
                    //            sysUser.NGAYSINH = DateTime.Parse(txtNgaySinh.Text.Split('/')[1] + "/" + txtNgaySinh.Text.Split('/')[0] + "/" + txtNgaySinh.Text.Split('/')[2]);
                    //    }
                    //    else
                    //    {
                    //        loiNgayThang.Visible = true;
                    //        return;
                    //    }
                    //}
                    //else
                    sysUser.NGAYSINH = DateTime.Now;
                    sysUser.USERNAME = txtUserName.Text;
                    //sysUser.IDparts = int.Parse(cmbLinhVuc.Value.ToString());
                    sysUser.EMAIL = txtEmail.Text;

                    sysUser.IS_ADMIN = 0;
                    sysUser.CHUCDANH = txtChucVuFix.Text;
                    SYS_Roles sysRoles = new SYS_Roles();
                    sysRoles.ID = int.Parse(cbxNhomQuyen.Value.ToString());

                    lstRole.Add(sysRoles);
                    sysUser.RoleGroup = cbxNhomQuyen.Text;

                    sysUser.Roles       = sysRoles;
                    sysUser.IDMA_DVIQLY = int.Parse(cmbDonVi.Value.ToString());
                    _IDM_USERService.UpdateSYS_UserAll(sysUser);
                    Session["SYSUser"]       = null;
                    lblPassword.Visible      = true;
                    txtPassword.Visible      = true;
                    pcAddUser.ShowOnPageLoad = false;
                    Page_Load(sender, e);
                }
                else
                {
                    if (checkUser(txtUserName.Text, int.Parse(cmbDonVi.Value.ToString())))
                    {
                        TreeListOrganization.FocusedNode.GetValue("IDMA_DVIQLY");
                        DM_USER User = new DM_USER {
                            USERNAME = txtUserName.Text
                        };
                        // Password:
                        string password = txtPassword.Text;
                        if (!string.IsNullOrEmpty(password))
                        {
                            User.PASSWORD = DM_USER.Encrypt(password);
                        }
                        User.HOTEN  = txtHoTen.Text;
                        User.DIACHI = txtDiaChi.Text;
                        //if (txtNgaySinh.Text.Trim() != "")
                        //{
                        //    if (txtNgaySinh.Text.Split('/').Length == 3)
                        //    {
                        //        if (DateTime.TryParse(txtNgaySinh.Text.Split('/')[1] + "/" + txtNgaySinh.Text.Split('/')[0] + "/" + txtNgaySinh.Text.Split('/')[2], out testdate))
                        //            sysUser.NGAYSINH = DateTime.Parse(txtNgaySinh.Text.Split('/')[1] + "/" + txtNgaySinh.Text.Split('/')[0] + "/" + txtNgaySinh.Text.Split('/')[2]);
                        //    }
                        //    else
                        //    {
                        //        loiNgayThang.Visible = true;
                        //        return;
                        //    }
                        //}
                        //else
                        User.NGAYSINH    = DateTime.Now;
                        User.EMAIL       = txtEmail.Text;
                        User.XACNHAN     = cbxActive != null ? cbxActive.Checked : false;
                        User.SODT        = txtPhone.Text;
                        User.CHUCDANH    = txtChucVuFix.Text;
                        sysUser.IS_ADMIN = 0;

                        SYS_Roles sysRoles = new SYS_Roles();
                        sysRoles.ID = int.Parse(cbxNhomQuyen.Value.ToString());
                        lstRole.Add(sysRoles);
                        sysUser.RoleGroup = cbxNhomQuyen.Text;

                        User.Roles = sysRoles;

                        //User.IDparts = int.Parse(cmbLinhVuc.Value.ToString());
                        User.IDMA_DVIQLY = int.Parse(cmbDonVi.Value.ToString());
                        _IDM_USERService.InsertSYS_UserAll(User);

                        //thêm user vào cmis

                        pcAddUser.ShowOnPageLoad = false;
                        GridUser_CustomCallback(null, null);
                        //WriteLog("Insert " + txtUserName.Text, Action.Create);
                    }
                    else
                    {
                        lblError.Visible = true;
                        throw new Exception(string.Format("Trùng tên! Vui lòng nhập lại."));
                        //lblError.Text = "Trùng tên! Vui lòng nhập lại.";
                    }
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message;
                // throw new Exception(string.Format("Trùng tên! Vui lòng nhập lại."));
            }
        }