示例#1
0
        public ActionResult <NhanVienDto> Login(TaiKhoanDto p)
        {
            NhanVienDto nv = NVservice.NhanVien_GetByUser(p.user);

            if (nv == null)
            {
                return(null);
            }

            if (nv.pass != p.password)
            {
                return(null);
            }

            if (nv.status != 1)
            {
                return(null);
            }
            // Ẩn thông tin nhân viên
            nv.pass     = "";
            nv.phone    = "";
            nv.address  = "";
            nv.mail     = "";
            nv.address  = "";
            nv.dateborn = new DateTime();
            nv.status   = -1;
            return(nv);
        }
示例#2
0
        public void NhanVien_Update(NhanVienDto NVdto)
        {
            var q = NVcontext.NhanVien_GetByUser(NVdto.user);

            if (q == null)
            {
                return;
            }
            NVdto.MappingNhanVien(q);
            NVcontext.NhanVien_Update(q);
        }
示例#3
0
 public static void MappingNhanVien(this NhanVienDto nvdto, NhanVien nv)
 {
     // q.permission_id = qdto.permission_id;
     nv.pass          = nvdto.pass;
     nv.full_name     = nvdto.full_name;
     nv.phone         = nvdto.phone;
     nv.mail          = nvdto.mail;
     nv.address       = nvdto.address;
     nv.sex           = nvdto.sex;
     nv.dateborn      = nvdto.dateborn;
     nv.permission_id = nvdto.permission_id;
     nv.status        = nvdto.status;
 }
示例#4
0
        private void frm_ThongTin_Load(object sender, EventArgs e)
        {
            _loginTaiKhoan = getDataChangePasswordFormFromMainForm();
            NhanVienDto _nvDTO = new NhanVienDto();
            NhanVienBus _nvBUS = new NhanVienBus();

            _nvDTO              = _nvBUS.ReadStaff(_loginTaiKhoan.MaNhanVien);
            txt_HoTen.Text      = _nvDTO.TenNhanVien;
            txt_MaNhanVien.Text = _nvDTO.MaNV.ToString();
            txt_ChucVu.Text     = _nvDTO.ChucVu.ToString();
            txt_NgaySinh.Text   = _nvDTO.NgaySinh.ToString("dd/MM/yyyy hh:mm:ss");
            txt_Email.Text      = _nvDTO.Email;
            txt_DiaChi.Text     = _nvDTO.DiaChi;
        }
 public int Insert(NhanVienDto obj)
 {
     SqlParameter[] para =
     {
         new SqlParameter("TenNV",      obj.Ten),
         new SqlParameter("NgaySinh",   obj.NgaySinh),
         new SqlParameter("DiaChi",     obj.DiaChi),
         new SqlParameter("CMND",       obj.Cmnd),
         new SqlParameter("ChucVu",     obj.ChucVu),
         new SqlParameter("LuongCoBan", obj.Luong),
         new SqlParameter("NgayTuyen",  obj.NgayTuyen)
     };
     return(provider.ExecuteSQL("NhanVien_Insert", para));
 }
示例#6
0
 public static NhanVien MappingNhanVien(this NhanVienDto nvdto)
 {
     return(new NhanVien {
         user = nvdto.user,
         pass = nvdto.pass,
         full_name = nvdto.full_name,
         phone = nvdto.phone,
         mail = nvdto.mail,
         address = nvdto.address,
         sex = nvdto.sex,
         dateborn = nvdto.dateborn,
         permission_id = nvdto.permission_id,
         status = nvdto.status,
     });
 }
示例#7
0
 public static bool CreateNewStaff(NhanVienDto _nhanVien)
 {
     try
     {
         using (QLSoTietKiemDBContext ql = new QLSoTietKiemDBContext())
         {
             ql.NhanVien.Add(_nhanVien);
             ql.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         Logger.WriteLogError("NhanVienDao CreateNewStaff", ex.ToString());
         return(false);
     }
 }
示例#8
0
        public bool CreateStaffAndAccount(string _staffName, string _staffShortName, bool _staffGender, DateTime _staffBirthday, int _staffJobtitle, int _staffPaymentStore, int _staffPermission, string _staffAddress, string _staffEmail, string _staffPhoneNumber, out string Message)
        {
            NhanVienDto _nhanVien = new NhanVienDto();

            _nhanVien.TenNhanVien = _staffName;
            _nhanVien.GioiTinh    = _staffGender;
            _nhanVien.NgaySinh    = _staffBirthday;
            _nhanVien.ChucVu      = _staffJobtitle;
            _nhanVien.MaQGD       = _staffPaymentStore;
            _nhanVien.DoiMatKhau  = false;
            _nhanVien.TrangThai   = true;
            _nhanVien.DiaChi      = _staffAddress;
            _nhanVien.Email       = _staffEmail;
            _nhanVien.SoDT        = _staffPhoneNumber;

            if (CreateNewStaff(_nhanVien))
            {
                TaiKhoanDto _taiKhoan = new TaiKhoanDto();
                _taiKhoan.TenDangNhap = TaiKhoanDao.GetAccountName(_staffShortName);
                _taiKhoan.MatKhau     = Helpers.EncryptMD5("123456a@", true);
                _taiKhoan.MaNhomTK    = _staffPermission;
                _taiKhoan.MaNhanVien  = _nhanVien.MaNV;
                _taiKhoan.TrangThai   = true;
                TaiKhoanBus _tkBUS = new TaiKhoanBus();
                if (_tkBUS.CreateNewAccount(_taiKhoan))
                {
                    Message = "Tạo tài khoản thành công.\nVui lòng đăng nhập với tên: " + _taiKhoan.TenDangNhap;
                    return(true);
                }
                else
                {
                    Message = "Có lỗi trong lúc tạo tài khoản cho nhân viên";
                    return(false);
                }
            }
            else
            {
                Message = "Có lỗi trong quá trình tạo nhâ viên mới";
                return(false);
            }
        }
示例#9
0
 public void UpdateNVDto([FromBody] NhanVienDto q)
 {
     NVservice.NhanVien_Update(q);
 }
示例#10
0
        public ActionResult <NhanVienDto> AddNVDto(NhanVienDto q)
        {
            NVservice.NhanVien_Add(q);

            return(CreatedAtAction(nameof(GetNVDto), new { user = q.user }, q));
        }
示例#11
0
 public int Update(NhanVienDto obj)
 {
     return(dao.Update(obj));
 }
示例#12
0
 public int Insert(NhanVienDto obj)
 {
     return(dao.Insert(obj));
 }
示例#13
0
        public void NhanVien_Add(NhanVienDto NVdto)
        {
            var q = NVdto.MappingNhanVien();

            NVcontext.NhanVien_Add(q);
        }
示例#14
0
 public bool CreateNewStaff(NhanVienDto _nhanVien)
 {
     return(NhanVienDao.CreateNewStaff(_nhanVien));
 }
示例#15
0
        private void Login()
        {
            string l_UserName  = txt_UserName.Text.Trim();
            string en_Password = string.Empty;

            if (!string.IsNullOrWhiteSpace(Properties.Settings.Default.userName) && Properties.Settings.Default.passWord == txt_Password.Text)
            {
                en_Password = Extensions.DecryptMD5(Properties.Settings.Default.passWord, true);
            }
            string l_Password = string.IsNullOrEmpty(en_Password) ? Extensions.EncryptMD5(txt_Password.Text, true).Trim(): Extensions.EncryptMD5(en_Password, true).Trim();

            if (string.IsNullOrEmpty(l_UserName) || string.IsNullOrEmpty(l_Password))
            {
                DialogResult dialogResult = MessageBox.Show("Tên đăng nhập hoặc mật khẩu không được trống!!!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                if (dialogResult == DialogResult.OK)
                {
                    if (string.IsNullOrEmpty(l_UserName))
                    {
                        txt_UserName.Focus();
                    }
                    if (string.IsNullOrEmpty(l_Password))
                    {
                        txt_Password.Focus();
                    }
                    if (string.IsNullOrEmpty(l_UserName) && string.IsNullOrEmpty(l_Password))
                    {
                        txt_UserName.Focus();
                    }
                }
            }
            else
            {
                try
                {
                    TaiKhoanBus _tk    = new TaiKhoanBus();
                    var         _login = _tk.Login(l_UserName, l_Password);
                    if (_login == null)
                    {
                        DialogResult dialogResult = MessageBox.Show("Không lấy được thông tin đăng nhập!!!", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                        if (dialogResult == DialogResult.Yes)
                        {
                            if (string.IsNullOrEmpty(l_UserName))
                            {
                                txt_UserName.Focus();
                            }
                            if (string.IsNullOrEmpty(l_Password))
                            {
                                txt_Password.Focus();
                            }
                            if (string.IsNullOrEmpty(l_UserName) && string.IsNullOrEmpty(l_Password))
                            {
                                txt_UserName.Focus();
                            }
                        }
                        else if (dialogResult == DialogResult.No)
                        {
                            Application.Exit();
                        }
                    }
                    else
                    {
                        _tkDto = _login;
                        NhanVienDto _nvDTO = new NhanVienDto();
                        NhanVienBus _nvBUS = new NhanVienBus();
                        _nvDTO = _nvBUS.ReadStaff(_tkDto.MaNhanVien);
                        if (_nvDTO != null)
                        {
                            if (!_nvDTO.DoiMatKhau)
                            {
                                DialogResult dialogResult = MessageBox.Show("Vui lòng đổi mật khẩu cho lần đầu tiên đăng nhập", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                                if (dialogResult == DialogResult.Yes)
                                {
                                    this.Hide();
                                    frm_DoiMatKhau_HeThong _frmChangPass = new frm_DoiMatKhau_HeThong();
                                    _frmChangPass.getDataChangePasswordFormFromLoginForm += delegate { return(_login); };//set data from login form
                                    _frmChangPass.Show();
                                }
                                else if (dialogResult == DialogResult.No)
                                {
                                    Application.Exit();
                                }
                            }
                            else
                            {
                                this.Hide();
                                if (chkRememberUser.Checked)
                                {
                                    if (Properties.Settings.Default.userName != string.Empty)
                                    {
                                        Properties.Settings.Default.Upgrade();
                                        Properties.Settings.Default.userName = l_UserName;
                                        Properties.Settings.Default.passWord = l_Password;
                                        Properties.Settings.Default.is_Check = chkRememberUser.Checked;
                                        Properties.Settings.Default.Save();
                                    }
                                    else
                                    {
                                        Properties.Settings.Default.userName = l_UserName;
                                        Properties.Settings.Default.passWord = l_Password;
                                        Properties.Settings.Default.is_Check = chkRememberUser.Checked;
                                        Properties.Settings.Default.Save();
                                    }
                                }
                                else
                                {
                                    Properties.Settings.Default.Reset();
                                    Properties.Settings.Default.Save();
                                }
                                frm_main _frmMain = new frm_main();
                                _frmMain.accountLoginOrchangePasswordDelegate += delegate { return(_login); };//Set data from form login
                                _frmMain.Show();
                            }
                        }
                        else
                        {
                            DialogResult dialogResult = MessageBox.Show("Vui lòng kiểm tra trạng thái nhân viên", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                            if (dialogResult == DialogResult.Yes)
                            {
                                if (string.IsNullOrEmpty(l_UserName))
                                {
                                    txt_UserName.Focus();
                                }
                                if (string.IsNullOrEmpty(l_Password))
                                {
                                    txt_Password.Focus();
                                }
                                if (string.IsNullOrEmpty(l_UserName) && string.IsNullOrEmpty(l_Password))
                                {
                                    txt_UserName.Focus();
                                }
                            }
                            else if (dialogResult == DialogResult.No)
                            {
                                Application.Exit();
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logger.WriteLogError("Login Login", ex.ToString());
                    DialogResult dialogResult = MessageBox.Show("Vui lòng kiểm tra trạng thái nhận viên", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
            }
        }