예제 #1
0
        public NhanVien Get_NhanVien_by_ID(int id)
        {
            QLCH_Model DB        = new QLCH_Model();
            var        li_method = DB.NhanViens.Where(p => p.id == id).FirstOrDefault();;

            return(li_method);
        }
예제 #2
0
        // các hàm tương tác với đối tượng NhanVien
        public List <NhanVien> Get_NhanViens()
        {
            QLCH_Model DB        = new QLCH_Model();
            var        li_method = DB.NhanViens.Select(p => p);

            return(li_method.ToList());
        }
예제 #3
0
        public List <NhanVien> Search_by_Name(string name)
        {
            QLCH_Model DB        = new QLCH_Model();
            var        li_method = DB.NhanViens.Where(p => p.Name.Contains(name));

            return(li_method.ToList());
        }
예제 #4
0
        public int Get_Lastest_ID()
        {
            QLCH_Model DB = new QLCH_Model();

            try
            {
                return(DB.NhanViens.OrderByDescending(p => p.id).First().id);
            }
            catch (InvalidOperationException)
            {
                return(0);
            }
        }
예제 #5
0
        public void Delete_Staff(int id)
        {
            QLCH_Model db = new QLCH_Model();

            id = db.NhanViens.Where(p => p.id == id).Select(p => p.id).FirstOrDefault();
            foreach (NhanVien i in db.NhanViens)
            {
                if (i.id == id)
                {
                    db.NhanViens.Remove(i);
                }
            }
            db.SaveChanges();
        }
예제 #6
0
        public void Add_Staff(string name, string gender, DateTime dob, string cmnd, string quequan, string diachi, string email, string phone)
        {
            QLCH_Model DB = new QLCH_Model();
            NhanVien   n  = new NhanVien
            {
                Name    = name,
                Gender  = gender,
                DOB     = dob,
                CMND    = cmnd,
                QueQuan = quequan,
                DiaChi  = diachi,
                Email   = email,
                Phone   = phone
            };

            DB.NhanViens.Add(n);
            DB.SaveChanges();
        }
예제 #7
0
        public void Edit_Staff(int id, string name, string gender, DateTime dob, string cmnd, string quequan, string diachi, string email, string phone, string pass)
        {
            QLCH_Model db = new QLCH_Model();
            NhanVien   nv = db.NhanViens.Where(p => p.id == id).FirstOrDefault();

            nv.Name    = name;
            nv.Gender  = gender;
            nv.DOB     = dob;
            nv.CMND    = cmnd;
            nv.QueQuan = quequan;
            nv.DiaChi  = diachi;
            nv.Email   = email;
            nv.Phone   = phone;
            if (pass != "")
            {
                Account ac = db.Accounts.Where(p => p.idNhanVien == id).FirstOrDefault();
                ac.PassWord = pass;
            }
            db.SaveChanges();
        }