/// <summary>
        /// Chuyển sang form quản lý người dùng
        /// </summary>
        /// <Modified>
        ///     Author      Date        Comments
        ///     Cuongdb    14/2/2008    Tạo mới
        /// </Modified>
        private void lnklblNguoiDung_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Visible = false;
            HeThong_NguoiDung_QuanLy frmQLyNguoiDung = new HeThong_NguoiDung_QuanLy(mFormGoi);

            frmQLyNguoiDung.ShowDialog(mFormGoi);
        }
Пример #2
0
        /// <summary>
        /// Tien hanh cap nhat, tao moi nguoi dung
        /// </summary>
        /// <Modified>
        ///     Author      Date        Comments
        ///     Cuongdb    16/2/2008    Tạo mới
        ///     LamDS       21/05/2008  Thêm điều kiện kiểm tra người dùng đã tồn tại chưa
        /// </Modified>
        private void btnTaoMoi_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtTenTruyCap.Text.Trim() == "")
                {
                    new MessageBoxBA().Show("Bạn chưa nhập tên truy cập", "Thông báo", MessageBoxButtonsBA.OK, MessageBoxIconBA.Information);
                    txtTenTruyCap.Focus();
                    return;
                }
                if (txtHoTen.Text.Trim() == "")
                {
                    new MessageBoxBA().Show("Bạn chưa nhập họ tên người dùng", "Thông báo", MessageBoxButtonsBA.OK, MessageBoxIconBA.Information);
                    txtHoTen.Focus();
                    return;
                }
                if (cbGioiTinh.Text == "")
                {
                    new MessageBoxBA().Show("Bạn chưa chọn giới tính", "Thông báo", MessageBoxButtonsBA.OK, MessageBoxIconBA.Information);
                    cbGioiTinh.Focus();
                    return;
                }
                Log objLog = new Log();
                //Kiem tra ma nguoi dung
                // neu co ma nguoi dung truyen vao thi tien hanh cap nhat thong tin nguoi dung
                if (strUser_ID != "")
                {
                    objUser.UserName = txtTenTruyCap.Text.Trim();
                    // if (ChucVuKhongHopLe()) return;
                    objUser.PassWordOld = strPasswordOld;
                    objUser.PassWord    = txtMatKhau.Text.Trim();
                    objUser.FullName    = txtHoTen.Text.Trim();
                    if (chkNgungSuDung.Checked)
                    {
                        objUser.Status = "0";
                    }
                    else
                    {
                        objUser.Status = "1";
                    }
                    objUser.LDAPAdsPath   = txtEXT.Text.Trim();
                    objUser.SecurityLevel = 0;
                    objUser.DiaChi        = txtDiaChi.Text.Trim();
                    objUser.DienThoai     = txtDienThoai.Text.Trim();
                    objUser.NgaySinh      = dtNgaySinh.Value;
                    objUser.QueQuan       = txtQueQuan.Text.Trim();
                    string strGoiTinh = cbGioiTinh.Text;
                    if (strGoiTinh.ToUpper() == "NAM")
                    {
                        objUser.GioiTinh = true;
                    }
                    else
                    {
                        objUser.GioiTinh = false;
                    }
                    int chucVuID = 0;
                    if (cbChucVu.SelectedValue != null)
                    {
                        int.TryParse(cbChucVu.SelectedValue.ToString(), out chucVuID);
                    }
                    objUser.ChucVUID = chucVuID;

                    int phongID = 0;
                    if (cbPhong.SelectedValue != null)
                    {
                        int.TryParse(cbPhong.SelectedValue.ToString(), out phongID);
                    }
                    objUser.PhongID = phongID;

                    objUser.Email      = txtEmail.Text.Trim();
                    objUser.TrungTamID = 0;// int.Parse(cbTrungTam.SelectedValue.ToString());
                    if (txtMatKhau.Text != strPasswordOld)
                    {
                        //Kiểm tra password strength
                        if (Users.CheckPasswordStrength(txtMatKhau.Text) == false)
                        {
                            new MessageBoxBA().Show(Users.NOT_VALID_PASSWORD_STRENGTH, "Thông báo", MessageBoxButtonsBA.OK, MessageBoxIconBA.Warning);
                            txtMatKhau.Select();
                            return;
                        }
                        //Kiểm tra xác nhận mật khẩu
                        if (txtMatKhau.Text.Trim() != txtXacNhanMatKhau.Text.Trim())
                        {
                            new MessageBoxBA().Show("Đề nghị bạn xác nhận chính xác mật khẩu", "Thông báo", MessageBoxButtonsBA.OK, MessageBoxIconBA.Warning);
                            txtXacNhanMatKhau.Select();
                            return;
                        }
                    }
                    var intResult = objUser.UpdateUsers();
                    if (intResult == 0)
                    {
                        LoadThongTinNguoiDung(strUser_ID);
                        objLog.WriteLog(ThongTinDangNhap.USER_ID, HanhDongGhiLog.QuanLyNguoiDung_Sua,
                                        DateTime.Now,
                                        "Sửa thông tin người dùng " + objUser.UserName);
                        new MessageBoxBA().Show("Cập nhật thành công thông tin thay đổi của người dùng", "Thông báo", MessageBoxButtonsBA.OK, Taxi.MessageBox.MessageBoxIconBA.Information);
                        Close();
                        HeThong_NguoiDung_QuanLy frmQuanLy = (HeThong_NguoiDung_QuanLy)Owner;
                        frmQuanLy.LoadUserData(frmQuanLy.CurentPhongBanID);
                    }
                    else
                    {
                        // Thong bao loi
                        new MessageBoxBA().Show("Cập nhật thất bại", "Thông báo", MessageBoxButtonsBA.OK, MessageBoxIconBA.Error);
                    }
                }
                else
                {
                    // tao moi nguoi dung he thong
                    objUser.UserName = txtTenTruyCap.Text.Trim();
                    // Nếu tên truy cập đã tồn tại thì không cho phép tạo mới
                    DataTable dtUser = objUser.GetUserInfo(objUser.UserName);
                    if (dtUser.Rows.Count > 0)
                    {
                        new MessageBoxBA().Show("Không thể tạo mới người dùng do tên truy cập đã tồn tại", "Thông báo",
                                                MessageBoxButtonsBA.OK, Taxi.MessageBox.MessageBoxIconBA.Error);
                        return;
                    }
                    //if (ChucVuKhongHopLe()) return;
                    objUser.PassWord      = txtMatKhau.Text.Trim();
                    objUser.FullName      = txtHoTen.Text.Trim();
                    objUser.Status        = "1";
                    objUser.LDAPAdsPath   = txtEXT.Text.Trim();
                    objUser.SecurityLevel = 0;
                    objUser.DiaChi        = txtDiaChi.Text.Trim();
                    objUser.DienThoai     = txtDienThoai.Text.Trim();
                    objUser.NgaySinh      = dtNgaySinh.Value;
                    objUser.QueQuan       = txtQueQuan.Text.Trim();
                    string strGoiTinh = cbGioiTinh.Text;
                    if (strGoiTinh.ToUpper() == "NAM")
                    {
                        objUser.GioiTinh = true;
                    }
                    else
                    {
                        objUser.GioiTinh = false;
                    }
                    int chucVuID = 0;
                    if (cbChucVu.SelectedValue != null)
                    {
                        int.TryParse(cbChucVu.SelectedValue.ToString(), out chucVuID);
                    }
                    objUser.ChucVUID = chucVuID;

                    int phongID = 0;
                    if (cbPhong.SelectedValue != null)
                    {
                        int.TryParse(cbPhong.SelectedValue.ToString(), out phongID);
                    }
                    objUser.PhongID    = phongID;
                    objUser.Email      = txtEmail.Text.Trim();
                    objUser.TrungTamID = 1;// int.Parse(cbTrungTam.SelectedValue.ToString());
                    if (txtMatKhau.Text.Trim() != txtXacNhanMatKhau.Text.Trim())
                    {
                        new MessageBoxBA().Show("Đề nghị bạn xác nhận lại chính xác mật khẩu", "Thông báo", MessageBoxButtonsBA.OK, MessageBoxIconBA.Warning);
                        txtXacNhanMatKhau.Focus();
                        return;
                    }
                    var intResult = objUser.InsertUsers();
                    if (intResult == 0)
                    {
                        new MessageBoxBA().Show("Tạo mới thành công người dùng", "Thông báo", MessageBoxButtonsBA.OK, MessageBoxIconBA.Information);
                        objLog.WriteLog(ThongTinDangNhap.USER_ID, HanhDongGhiLog.QuanLyNguoiDung_ThemMoi, DateTime.Now, "Thêm mới người dùng " + objUser.UserName);
                        Close();
                        HeThong_NguoiDung_QuanLy frmQuanLy = (HeThong_NguoiDung_QuanLy)Owner;
                        frmQuanLy.LoadUserData(frmQuanLy.CurentPhongBanID);
                    }
                    else
                    {
                        // Thong bao tao moi that bai
                        new MessageBoxBA().Show("Tạo mới thất bại", "Thông báo", MessageBoxButtonsBA.OK, MessageBoxIconBA.Error);
                    }
                }
            }
            catch (Exception ex)
            {
                LogError.WriteLogError("btnTaoMoi_Click", ex);
            }
        }