// PUT: api/NhanVienApi/5
        public string Put(string maNhanVien, string hoTen,
                          string ngaySinh, string gioiTinh, string sdt,
                          string diaChi, string luong, string maDVL, string ngayKyHopDong)
        {
            if (hoTen == null || hoTen == "" ||
                ngaySinh == null || ngaySinh == "" || gioiTinh == null || gioiTinh == "" || sdt == null || sdt == "" ||
                diaChi == null || diaChi == "" || luong == null || luong == "" || maDVL == null || maDVL == "" ||
                ngayKyHopDong == null || ngayKyHopDong == "")
            {
                return("Sửa thất bại! Vui lòng nhập đầy đủ các thông tin bắt buộc!");
            }
            if (gioiTinh == "1")
            {
                gioiTinh = "Nam";
            }
            else
            {
                gioiTinh = "Nữ";
            }

            ngaySinh      = ngaySinh.Split('-')[0] + "/" + ngaySinh.Split('-')[1] + "/" + ngaySinh.Split('-')[2];
            ngayKyHopDong = ngayKyHopDong.Split('-')[0] + "/" + ngayKyHopDong.Split('-')[1] + "/" + ngayKyHopDong.Split('-')[2];

            //Them ne
            if (NhanVienModel.UpdateNhanVien(maNhanVien, hoTen, ngaySinh, gioiTinh, sdt, diaChi, luong, maDVL, ngayKyHopDong))
            {
                return("Sửa thành công!");
            }
            else
            {
                return("Sửa thất bại!");
            }
        }
Пример #2
0
        public bool ThemNhanVien(NhanVienModel nv)
        {
            try
            {
                NhanVien nhanVien = new NhanVien();
                nhanVien.MaNhanVien   = nv.MaNV;
                nhanVien.HoTenNV      = nv.HoTenNV;
                nhanVien.NgayVL       = nv.NgayVL;
                nhanVien.DiaChi       = nv.DiaChi;
                nhanVien.GioiTinh     = nv.GioiTinh;
                nhanVien.NgaySinh     = nv.NgaySinh;
                nhanVien.SDT          = nv.SDT;
                nhanVien.Email        = nv.Email;
                nhanVien.DuongDanHinh = nv.DuongDanHinh;
                nhanVien.TinhTrang    = nv.TinhTrang;
                nhanVien.ChucVu       = nv.ChucVu;
                db.NhanViens.InsertOnSubmit(nhanVien);
                db.SubmitChanges();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);

                throw;
            }
        }
        public ResponseModel UpdateInfo(string connectString, NhanVienModel model, int accId)
        {
            var result = new ResponseModel();

            result.IsSuccess = true;
            using (var db = new HMSEntities(connectString))
            {
                var acc = db.H_Account.FirstOrDefault(x => !x.IsDeleted && x.Id == accId);
                if (acc != null)
                {
                    var nv = db.H_NhanVien.FirstOrDefault(x => !x.IsDeleted && x.Id == acc.NhanVienId);
                    if (nv != null)
                    {
                        nv.Name    = model.Ten;
                        nv.Address = model.DiaChi;
                        nv.Phone   = model.DienThoai;
                        nv.Note    = model.Note;
                        db.SaveChanges();
                    }
                    else
                    {
                        result.IsSuccess = false;
                        result.sms       = "Nhân viên đã bị xóa hoặc không tồn tại trong hệ thống.!";
                    }
                }
                return(result);
            }
        }
Пример #4
0
        //In hóa đơn

        public ActionResult InHoaDon(string MaDonDatHang)
        {
            int mddh = Convert.ToInt32(MaDonDatHang);

            DonDatHangModel donDatHangModel = new DonDatHangModel();
            DonDatHang      donDatHang      = donDatHangModel.GetDonDatHangByMa(mddh);

            if (donDatHang.MaKH != 0)
            {
                Khachhang kh = new KhachHangModel().GetKhachHangByMa(donDatHang.MaKH);
                ViewBag.KhachHang = kh;
            }
            if (donDatHang.MaNV != 0)
            {
                NhanVien nv = new NhanVienModel().GetNhanVienByMa(donDatHang.MaNV);
                ViewBag.NhanVien = nv;
            }
            ViewBag.DonDatHang = donDatHang;
            if (donDatHang.TrangThaiDonDichVu != 0)
            {
                List <ChiTietDonDichVu> listchitietdondichvu = new ChiTietDonDichVuModel().GetDataDichVu(mddh);
                ViewBag.ListDV = listchitietdondichvu;
            }
            if (donDatHang.TrangThaiDonSanPham != 0)
            {
                List <ChiTietDonDat> listchitietdondat = new ChiTietDonDatModel().GetDataSanPham(mddh);
                ViewBag.ListSP = listchitietdondat;
            }

            return(View());
        }
        // GET: Admin/NhanVien/Details/5
        public ActionResult Details(string maNhanVien)
        {
            var iplNhanVien = new NhanVienModel();
            var model       = iplNhanVien.GetByMaNhanVien(maNhanVien);

            return(View(model));
        }
        //
        // GET: /Admin/NhanVien/

        public ActionResult Index()
        {
            var iplNV = new NhanVienModel();
            var model = iplNV.ListAll();

            return(View(model));
        }
Пример #7
0
        private NhanVienModel FulfilmentFild(NhanVienModel value)
        {
            if (value != null)
            {
                value.MaNhanVien  = txtMaNhanVien.Text;
                value.TenNhanVien = txtTenNhanVien.Text;
                value.DiaChi      = txtDiaChi.Text;
                value.DienThoai   = txtDienThoai.Text;
                value.GioiTinh    = txtGioiTinh.Text;
                value.NgaySinh    = txtNgaySinh.Text.ToDateTime();
                value.MaCV        = txtMaCV.Text;
            }
            else
            {
                value = new NhanVienModel {
                    MaNhanVien  = txtMaNhanVien.Text,
                    TenNhanVien = txtTenNhanVien.Text,
                    DiaChi      = txtDiaChi.Text,
                    DienThoai   = txtDienThoai.Text,
                    GioiTinh    = txtGioiTinh.Text,
                    NgaySinh    = txtNgaySinh.Text.ToDateTime(),
                    MatKhau     = txtMatKhau.Text.ToEncrypt(),
                    MaCV        = txtMaCV.Text
                };
            }

            return(value);
        }
Пример #8
0
        public bool SuaNhanVien(NhanVienModel nv)
        {
            try
            {
                NhanVien nhanVien = db.NhanViens.FirstOrDefault(t => t.MaNhanVien.Equals(nv.MaNV));
                nhanVien.MaNhanVien   = nv.MaNV;
                nhanVien.HoTenNV      = nv.HoTenNV;
                nhanVien.NgayVL       = nv.NgayVL;
                nhanVien.DiaChi       = nv.DiaChi;
                nhanVien.GioiTinh     = nv.GioiTinh;
                nhanVien.NgaySinh     = nv.NgaySinh;
                nhanVien.SDT          = nv.SDT;
                nhanVien.CMND         = nv.CMND;
                nhanVien.Email        = nv.Email;
                nhanVien.DuongDanHinh = nv.DuongDanHinh;
                if (nv.TinhTrangAsString.Equals("Đang làm"))
                {
                    nhanVien.TinhTrang = 1;
                }
                else
                {
                    nhanVien.TinhTrang = 0;
                }
                nhanVien.ChucVu = nv.ChucVu;
                db.SubmitChanges();
                return(true);
            }
            catch (Exception)
            {
                return(false);

                throw;
            }
        }
        // POST: api/NhanVienApi
        public string Post(string taiKhoan, string matKhau, string hoTen,
                           string ngaySinh, string gioiTinh, string sdt,
                           string diaChi, string luong, string maDVL, string ngayKyHopDong)
        {
            if (taiKhoan == null || taiKhoan == "" || matKhau == null || matKhau == "" || hoTen == null || hoTen == "" ||
                ngaySinh == null || ngaySinh == "" || gioiTinh == null || gioiTinh == "" || sdt == null || sdt == "" ||
                diaChi == null || diaChi == "" || luong == null || luong == "" || maDVL == null || maDVL == "" ||
                ngayKyHopDong == null || ngayKyHopDong == "")
            {
                return("Thêm thất bại! Vui lòng nhập đầy đủ các thông tin bắt buộc!");
            }
            if (gioiTinh == "1")
            {
                gioiTinh = "Nam";
            }
            else
            {
                gioiTinh = "Nữ";
            }

            ngaySinh      = ngaySinh.Split('-')[0] + "/" + ngaySinh.Split('-')[1] + "/" + ngaySinh.Split('-')[2];
            ngayKyHopDong = ngayKyHopDong.Split('-')[0] + "/" + ngayKyHopDong.Split('-')[1] + "/" + ngayKyHopDong.Split('-')[2];

            matKhau = AccountModel.CalculateMD5Hash(taiKhoan + "" + matKhau);

            //Them ne
            if (NhanVienModel.InsertNhanVien(taiKhoan, matKhau, hoTen, ngaySinh, gioiTinh, sdt, diaChi, luong, maDVL, ngayKyHopDong))
            {
                return("Thêm thành công!");
            }
            else
            {
                return("Thêm thất bại!");
            }
        }
Пример #10
0
 public ActionResult Index(NhanVienModel model)
 {
     /*var tendn = collection["username"];
      * var matkhau = collection["password"];
      *
      * if (String.IsNullOrEmpty(tendn))
      * {
      *  ViewData["Loi1"] = "Phải nhập tên tài khoản";
      * }
      * else if (String.IsNullOrEmpty(matkhau))
      * {
      *  ViewData["Loi2"] = "Phải nhập mật khẩu";
      * }*/
     if (ModelState.IsValid)
     {
         ConnectClass cc = new ConnectClass();
         NHANVIEN     kq = cc.Login(model.USERNAME, model.PASS);
         if (kq != null)
         {
             Session["TaiKhoanAdmin"] = kq;
             Session["ABC"]           = kq.TENHIENTHI;
             FormsAuthentication.SetAuthCookie(model.USERNAME, true);
             return(RedirectToAction("Test", "Test1"));
         }
         else
         {
             ViewBag.Thongbao = " Tên Đăng Nhập or Mật khẩu Không đúng...";
         }
         ///ViewData["Loi3"] = " Tên Đăng Nhập or Mật khẩu Không đúng...";
     }
     return(View());
 }
        // GET: Admin/NhanVien
        public ActionResult Index(int id, string q)
        {
            try
            {
                //
                int pageLeghth = 10;
                //Model
                NhanVienModel   nhanvien        = new NhanVienModel();
                List <NHANVIEN> listNhanVienPre = nhanvien.ListAll();
                //search
                List <NHANVIEN> listNhanVien;
                if (q != "" && q != null)
                {
                    listNhanVien = new List <NHANVIEN>();
                    foreach (var item in listNhanVienPre)
                    {
                        try
                        {
                            if (item.MANHANVIEN.Contains(q) || item.ACCOUNT.HOTEN.ToString().Contains(q) || item.ACCOUNT.SDT.ToString().Contains(q) ||
                                item.ACCOUNT.TAIKHOAN.Contains(q) || item.ACCOUNT.DIACHI.Contains(q) || item.NGAYKYHOPDONG.Value.ToString("dd/MM/yyyy").Contains(q) ||
                                item.LUONG.ToString().Contains(q))
                            {
                                listNhanVien.Add(item);
                            }
                        }
                        catch { }
                    }
                }
                else
                {
                    listNhanVien = listNhanVienPre;
                }

                //Chia theo page
                int start = pageLeghth * (id - 1) + 1;
                int end   = pageLeghth * id;
                if (start > listNhanVien.Count)
                {
                    start = (listNhanVien.Count / pageLeghth) * pageLeghth + 1;
                    end   = start + listNhanVien.Count % pageLeghth - 1;
                }
                else if (end > listNhanVien.Count)
                {
                    end = listNhanVien.Count;
                }
                List <NHANVIEN> model       = listNhanVien.GetRange(start - 1, end - (start - 1));
                int             SoLuongPage = listNhanVien.Count % pageLeghth == 0 ? listNhanVien.Count / pageLeghth : listNhanVien.Count / pageLeghth + 1;
                //int SoLuongPage = 10;
                ViewBag.SoLuongPage = SoLuongPage;

                ViewBag.CurrentPage = id < SoLuongPage ? id : SoLuongPage;
                ViewBag.Query       = q;
                return(View(model));
            }
            catch
            {
                return(null);
            }
        }
Пример #12
0
        public ActionResult CreateNhanVien()
        {
            var model = new NhanVienModel();

            model.SelectChiNhanh = new SelectList(db.ChiNhanhs, "Id", "TenChiNhanh", 0);
            model.SelectChucVu   = new SelectList(db.LoaiSanPhams, "Id", "TenChucVu", 0);
            return(View(model));
        }
Пример #13
0
        public static NhanVienModel toModel(this NhanVien e)
        {
            var m = new NhanVienModel();

            m.Id      = e.Id;
            m.HoVaTen = e.HoVaTen;
            return(m);
        }
Пример #14
0
        public int UpdateNhanVien(NhanVienModel nv)
        {
            var nhanvien = db.NhanViens.Find(nv.Id);

            nhanvien.MaChucVu = nv.MaChucVu;
            db.SaveChanges();
            return(nhanvien.Id);
        }
Пример #15
0
 public nhanvienController(NguoiDung ng)
 {
     this.nguoiDung = ng;
     nhanVien       = new NhanVienModel(ng);
     GetTb();
     setLable();
     getTieuDung();
 }
Пример #16
0
        private bool CheckExists(NhanVienModel User, HMSEntities db)
        {
            H_NhanVien obj = null;

            if (!string.IsNullOrEmpty(User.Ma))
            {
                obj = db.H_NhanVien.FirstOrDefault(x => !x.IsDeleted && x.Id != User.Id && x.Code.Trim().ToUpper().Equals(User.Ma.Trim().ToUpper()));
            }
            return(obj != null ? true : false);
        }
        // GET: Admin/TinhLuongNhanVien/Details/5
        public ActionResult Details(string maNhanVien, string trangThaiThanhToan)
        {
            var iplNhanVien = new NhanVienModel();
            var model       = iplNhanVien.GetByMaNhanVien(maNhanVien);

            model.GetChamCongNhanVien();
            model.trangThaiThanhToan = trangThaiThanhToan;

            return(View(model));
        }
Пример #18
0
        // GET: AdminNhanVien
        public ActionResult Index(int page = 1, int pagesize = 10)
        {
            NhanVien        nhanVien      = new NhanVien();
            NhanVienModel   nhanVienModel = new NhanVienModel();
            List <NhanVien> lsnv          = nhanVienModel.GetData();

            //ViewBag.NhanVien = nhanVienModel.GetNhanVienByEmail("*****@*****.**");
            ViewBag.NhanVien = nhanVienModel.GetNhanVienByMa(1);
            ViewBag.ListNV   = lsnv;
            return(View(lsnv.ToPagedList(page, pagesize)));
        }
 // DELETE: api/NhanVienApi/5
 public string Delete(string maNhanVien)
 {
     if (NhanVienModel.DeleteNhanVien(maNhanVien))
     {
         return("Xóa thành công!");
     }
     else
     {
         return("Xóa thất bại!");
     }
 }
        // GET: Admin/TinhLuongNhanVien

        public ActionResult Index()
        {
            var iplNhanVien = new NhanVienModel();
            var model       = iplNhanVien.ListAllConLamViec();

            foreach (var item in model)
            {
                item.GetChamCongNhanVien();
            }
            return(View(model));
        }
 public string Put(string maNhanVien, string taiKhoan, string matKhau)
 {
     matKhau = AccountModel.CalculateMD5Hash(taiKhoan + "" + matKhau);
     if (NhanVienModel.UpdateTaiKhoanNhanVien(maNhanVien, taiKhoan, matKhau))
     {
         return("Sửa thành công!");
     }
     else
     {
         return("Sửa thất bại!");
     }
 }
Пример #22
0
        public ActionResult CreateNhanVien(NhanVienModel model)
        {
            var nhanvien = new ChuoiCuaHangTraSua.Models.EF.NhanVien();

            nhanvien.HoTen       = model.HoTen;
            nhanvien.TenDangNhap = model.TenDangNhap;
            nhanvien.MatKhau     = ChuoiCuaHangTraSua.Common.Encrytor.MD5Hash("123456");
            nhanvien.MaChucVu    = model.MaChucVu;
            nhanvien.MaChiNhanh  = model.MaChiNhanh;
            db.NhanViens.Add(nhanvien);
            db.SaveChanges();
            return(RedirectToAction("Index", "NhanVienAdmin"));
        }
Пример #23
0
        public int AddNhanVien(NhanVienModel nv)
        {
            var nhanvien = new DoAn.Models.EF.NhanVien();

            nhanvien.TenDangNhap = nv.TenDangNhap;
            nhanvien.HoTen       = nv.HoTen;
            nhanvien.MaChiNhanh  = nv.MaChiNhanh;
            nhanvien.MaChucVu    = 3;
            nhanvien.MatKhau     = DoAn.Common.Function.Encrytor.MD5Hash("123456");
            db.NhanViens.Add(nhanvien);
            db.SaveChanges();
            return(nhanvien.Id);
        }
Пример #24
0
        public ActionResult ThemMoiBaiViet(BaiViet std)
        {
            BaiVietModel baiVietModel = new BaiVietModel();
            NhanVien     nhanVien     = new NhanVienModel().GetNhanVienByEmail(Session["ADMIN_SESSION"].ToString());


            std.MaNV    = nhanVien.MaNV;
            std.NgayTao = DateTime.Now;

            baiVietModel.ThemBaiViet(std);

            return(Json(new { data = "", JsonRequestBehavior.AllowGet }));
        }
Пример #25
0
        public JsonResult List(string txtSearch, int?page)
        {
            var session_nhanvien = (DoAn.Common.Session.NhanVienSession)Session[DoAn.Common.Constants.NHANVIEN_SESSION];

            var list = db.NhanViens.Where(x => x.MaChiNhanh == session_nhanvien.MaChiNhanh && x.MaChucVu != 3).OrderByDescending(x => x.Id).ToList();

            int pageSize = 5;

            if (!String.IsNullOrEmpty(txtSearch))
            {
                ViewBag.txtSearch = txtSearch;
                list = list.Where(x => x.MaChiNhanh == session_nhanvien.MaChiNhanh && x.MaChucVu != 3 && x.HoTen.Contains(txtSearch)).OrderByDescending(x => x.Id).ToList();
            }
            var data = new List <NhanVienModel>();
            int i    = 0;

            foreach (var item in list)
            {
                i++;
                var itemmodel = new NhanVienModel();
                itemmodel.STT         = i;
                itemmodel.Id          = item.Id;
                itemmodel.HoTen       = item.HoTen;
                itemmodel.TenDangNhap = item.TenDangNhap;
                itemmodel.DiaChi      = item.DiaChi;
                itemmodel.SDT         = item.SDT;
                itemmodel.TenChucVu   = db.ChucVus.FirstOrDefault(x => x.Id == item.MaChucVu).TenChucVu;
                itemmodel.Luong       = String.Format("{0:0,0}", db.ChucVus.FirstOrDefault(x => x.Id == item.MaChucVu).Luong);
                data.Add(itemmodel);
            }
            if (page > 0)
            {
                page = page;
            }
            else
            {
                page = 1;
            }
            int start = (int)(page - 1) * pageSize;

            ViewBag.pageCurrent = page;
            int   totalPage    = data.Count();
            float totalNumsize = (totalPage / (float)pageSize);
            int   numSize      = (int)Math.Ceiling(totalNumsize);

            ViewBag.numSize = numSize;
            var datamodel = data.Skip(start).Take(pageSize);

            return(Json(new { data = datamodel, pageCurrent = page, numSize = numSize }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult DoiMatKhau(NhanVienModel model)
        {
            var session = (ChuoiCuaHangTraSua.Common.NhanVienLogin)Session[ChuoiCuaHangTraSua.Common.Constants.NHANVIEN_SESSION];

            if (session != null)
            {
                var nhanvien = db.NhanViens.Find(session.UserId);
                nhanvien.MatKhau = ChuoiCuaHangTraSua.Common.Encrytor.MD5Hash(model.MatKhau);
                db.SaveChanges();
                ViewBag.DoiMatKhau = "Bạn đã đổi mật khẩu thành công";
            }

            return(View());
        }
Пример #27
0
        public ActionResult Index()
        {
            var session_nhanvien = (DoAn.Common.Session.NhanVienSession)Session[DoAn.Common.Constants.NHANVIEN_SESSION];

            if (session_nhanvien != null)
            {
                var model = new NhanVienModel();
                model.SelectChucVu = new SelectList(db.ChucVus.Where(x => x.Id != 1 && x.Id != 3), "Id", "TenChucVu", 0);
                return(View(model));
            }
            else
            {
                return(RedirectToAction("DangNhapNhanVien", "Login"));
            }
        }
Пример #28
0
        public ActionResult Index()
        {
            var session = (DoAn.Common.Session.UserLogin)Session[DoAn.Common.Constants.USER_SESSION];

            if (session != null)
            {
                var model = new NhanVienModel();
                model.SelectChiNhanh = new SelectList(db.ChiNhanhs, "Id", "TenChiNhanh", 0);
                return(View(model));
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
Пример #29
0
        public ActionResult DangNhap(string Email, string MatKhau)
        {
            NhanVienModel nhanVienModel = new NhanVienModel();


            var result = nhanVienModel.DangNhap(Email, CreateMD5(MatKhau));

            if (!String.IsNullOrEmpty(result))
            {
                Session.Add(SessionHelper.ADMIN_SESSION, Email);

                return(RedirectToAction("Index", "AdminHome"));
            }
            else
            {
                ModelState.AddModelError("", "Tên đăng nhập hoặc mật khẩu không đúng");
            }
            return(View());
        }
Пример #30
0
        /// <summary>
        ///     Posts the view.
        /// </summary>
        /// <param name="value">The value.</param>
        public void PostView(IEnumerable <NhanVienModel> value)
        {
            currentModelList = value;

            dataGridView.Columns.Clear();
            var c = new DataGridViewCheckBoxColumn {
                Name = "CB", HeaderText = "", Width = 24, AutoSizeMode = DataGridViewAutoSizeColumnMode.None, ReadOnly = true
            };

            dataGridView.Columns.Add(c);

            dataGridView.DataSource = new BindingSource {
                DataSource = value
            };
            dataGridView.Columns["ID"].Display(false);
            dataGridView.Columns["MatKhau"].Display(false);
            dataGridView.Columns["CongViecID"].Display(false);
            dataGridView.Columns["CongViec"].Display(false);
            dataGridView.Columns["NgaySinh"].Display(false);
            //if(dataGridView.Columns["MaNhanVien"]!=null)
            //    dataGridView.Columns["MaNhanVien"].DisplayIndex = 0;
            //if(dataGridView.Columns["TenNhanVien"]!=null)
            //    dataGridView.Columns["TenNhanVien"].DisplayIndex = 1;
            //if(dataGridView.Columns["GioiTinh"]!=null)
            //    dataGridView.Columns["GioiTinh"].DisplayIndex = 3;
            if (dataGridView.Columns["NgaySinhModel"] != null)
            {
                dataGridView.Columns["NgaySinhModel"].DisplayIndex = 4;
            }


            dataGridView.ClearSelection();
            dataGridView.DataBindingComplete += new DataGridViewBindingCompleteEventHandler(dgvCommandos_DataBindingComplete);
            dataGridView.CurrentCell          = null;
            bntLuu.Enabled    = true;
            bntTaoMoi.Enabled = false;

            bntSuaMatKhau.Visible = false;
            txtMatKhau.Visible    = (!bntSuaMatKhau.Visible);
            txtMatKhau2.Visible   = (!bntSuaMatKhau.Visible);

            currentModel = null;
        }