Exemplo n.º 1
0
        public static bool AddCV(ClassCongViec cv)
        {
            try
            {
                using (var _context = new DBManageContext())
                {
                    ClassCongViec congviec = new ClassCongViec {
                        MaCV = cv.MaCV, TenCV = cv.TenCV, ChiTiet = cv.ChiTiet
                    };

                    _context.tbCongViec.Add(congviec);
                    _context.SaveChanges();

                    var dbcv = (from c in _context.tbCongViec
                                where c.MaCV == cv.MaCV
                                select c).Single();

                    foreach (var i in cv.listDA)
                    {
                        var dbda = (from d in _context.tbDuAn
                                    where d.MaDA == i.MaDA
                                    select d).Single();
                        dbcv.listDA.Add(dbda);
                    }
                    _context.tbCongViec.AddOrUpdate(dbcv);
                    _context.SaveChanges();
                }
            }
            catch
            {
                return(false);
            }
            return(true);
        }
 public static List <ClassNhanVien> GetListNV()
 {
     using (var _context = new DBManageContext())
     {
         var nv = (from nvien in _context.tbNhanVien.AsEnumerable()
                   select new
         {
             MaNV = nvien.MaNV,
             TenNV = nvien.TenNV,
             GioiTinh = nvien.GioiTinh,
             DiaChi = nvien.DiaChi,
             NgaySinh = nvien.NgaySinh,
             SDT = nvien.SDT,
             Email = nvien.Email,
             MaChucVu = nvien.MaChucVu
         }).Select(x => new ClassNhanVien
         {
             MaNV     = x.MaNV,
             TenNV    = x.TenNV,
             GioiTinh = x.GioiTinh,
             DiaChi   = x.DiaChi,
             NgaySinh = x.NgaySinh,
             SDT      = x.SDT,
             Email    = x.Email,
             MaChucVu = x.MaChucVu
         }).ToList();
         return(nv);
     }
 }
Exemplo n.º 3
0
        public static bool UpdatelistCV(ClassDuAn da)
        {
            try
            {
                using (var _context = new DBManageContext())
                {
                    var dbda = (from d in _context.tbDuAn
                                where d.MaDA == da.MaDA
                                select d).Single();

                    foreach (ClassCongViec cv in dbda.listCV.ToList())
                    {
                        dbda.listCV.Remove(cv);
                    }

                    foreach (var cv in da.listCV)
                    {
                        var dbcv = (from c in _context.tbCongViec
                                    where c.MaCV == cv.MaCV
                                    select c).Single();

                        dbda.listCV.Add(dbcv);
                    }

                    _context.tbDuAn.AddOrUpdate(dbda);
                    _context.SaveChanges();
                    return(true);
                }
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 4
0
 public static bool UpdateCV(ClassCongViec cv)
 {
     try
     {
         using (var _context = new DBManageContext())
         {
             ClassCongViec congviec = new ClassCongViec {
                 MaCV = cv.MaCV, TenCV = cv.TenCV, ChiTiet = cv.ChiTiet
             };
             foreach (var d in cv.listDA)
             {
                 var dbda = (from da in _context.tbDuAn
                             where da.MaDA == d.MaDA
                             select da).Single();
                 congviec.listDA.Add(dbda);
             }
             _context.tbCongViec.AddOrUpdate(congviec);
             _context.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
Exemplo n.º 5
0
 public static List <ClassCongViec> GetListCV()
 {
     using (var _context = new DBManageContext())
     {
         var cv = (from c in _context.tbCongViec.Include("listDA")
                   select c).ToList();
         return(cv);
     }
 }
Exemplo n.º 6
0
        public static List <ClassDuAn> GetListDA()
        {
            using (var _context = new DBManageContext())
            {
                var da = _context.tbDuAn.Include("listCV").ToList();

                return(da);
            }
        }
Exemplo n.º 7
0
 public static List <ClassChucVu> GetListCVu()
 {
     using (var _context = new DBManageContext())
     {
         var cvu = (from c in _context.tbChucVu
                    select c).ToList();
         return(cvu);
     }
 }
        public static bool UpdateNvien(ClassNhanVien nvien)
        {
            try
            {
                using (var _context = new DBManageContext())
                {
                    var dbnv = (from nv in _context.tbNhanVien.Include("listCVLam").Include("listCVXong")
                                where nv.MaNV == nvien.MaNV
                                select nv).Single();

                    foreach (var cvgiao in dbnv.listCVLam.ToList())
                    {
                        dbnv.listCVLam.Remove(cvgiao);
                    }
                    foreach (var cvxong in dbnv.listCVXong.ToList())
                    {
                        dbnv.listCVXong.Remove(cvxong);
                    }

                    foreach (var permistask in nvien.listCVLam)
                    {
                        var dbcv = (from cv in _context.tbCongViec
                                    where cv.MaCV == permistask.MaCV
                                    select cv).Single();
                        dbnv.listCVLam.Add(dbcv);
                    }

                    foreach (var finistask in nvien.listCVXong)
                    {
                        var dbcv = (from cv in _context.tbCongViec
                                    where cv.MaCV == finistask.MaCV
                                    select cv).Single();
                        dbnv.listCVXong.Add(dbcv);
                    }

                    dbnv.TienDo = dbnv.listCVXong.Count.ToString() + '/' + dbnv.listCVLam.Count.ToString();
                    dbnv.Luong  = 1000000 * dbnv.listCVXong.Count;
                    dbnv.MaDA   = nvien.MaDA;

                    _context.tbNhanVien.AddOrUpdate(dbnv);
                    _context.SaveChanges();
                    return(true);
                }
            }
            catch
            {
                return(false);
            }
        }
 public static bool AddNV(ClassNhanVien nv)
 {
     try
     {
         using (var _context = new DBManageContext())
         {
             _context.tbNhanVien.Add(nv);
             _context.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
Exemplo n.º 10
0
 public static bool UpdateChucVu(ClassChucVu cvu)
 {
     try
     {
         using (var _context = new DBManageContext())
         {
             _context.tbChucVu.AddOrUpdate(cvu);
             _context.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
Exemplo n.º 11
0
 public static ClassNhanVien GetNV(string MaNhanVien)
 {
     using (var _context = new DBManageContext())
     {
         var nv = (from n in _context.tbNhanVien.Include("ListCVLam").Include("ListCVXong")
                   where MaNhanVien == n.MaNV
                   select n).ToList();
         if (nv.Count == 1)
         {
             return(nv[0]);
         }
         else
         {
             return(null);
         }
     }
 }
Exemplo n.º 12
0
 public static bool UpdateDA(ClassDuAn da)
 {
     try
     {
         using (var _context = new DBManageContext())
         {
             _context.tbDuAn.AddOrUpdate(da);
             _context.SaveChanges();
             return(true);
         }
     }
     catch (Exception e)
     {
         System.Windows.MessageBox.Show(e.Message);
         return(false);
     }
 }
Exemplo n.º 13
0
 public static ClassChucVu GetCVu(string MaChucVu)
 {
     using (var _context = new DBManageContext())
     {
         var cv = (from d in _context.tbChucVu
                   where MaChucVu == d.MaChucVu
                   select d).ToList();
         if (cv.Count == 1)
         {
             return(cv[0]);
         }
         else
         {
             return(null);
         }
     }
 }
Exemplo n.º 14
0
 public static ClassCongViec GetCV(string MaCV)
 {
     using (var _context = new DBManageContext())
     {
         var cv = (from d in _context.tbCongViec.Include("listDA").Include("listNVLam").Include("listNVXong")
                   where MaCV == d.MaCV
                   select d).ToList();
         if (cv.Count == 1)
         {
             return(cv[0]);
         }
         else
         {
             return(null);
         }
     }
 }
Exemplo n.º 15
0
 public static ClassDuAn GetDuAn(string MaDa)
 {
     using (var _context = new DBManageContext())
     {
         var da = (from d in _context.tbDuAn.Include("listCV")
                   where MaDa == d.MaDA
                   select d).ToList();
         if (da.Count == 1)
         {
             return(da[0]);
         }
         else
         {
             return(null);
         }
     }
 }
Exemplo n.º 16
0
 public static bool DeleteCVu(string machucvu)
 {
     try
     {
         using (var _context = new DBManageContext())
         {
             var cv = (from c in _context.tbChucVu
                       where c.MaChucVu == machucvu
                       select c).Single();
             _context.tbChucVu.Remove(cv);
             _context.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
Exemplo n.º 17
0
 public static bool DeleteDuAn(string MaDa)
 {
     try
     {
         using (var _context = new DBManageContext())
         {
             var da = (from d in _context.tbDuAn
                       where MaDa == d.MaDA
                       select d).Single();
             _context.tbDuAn.Remove(da);
             _context.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
Exemplo n.º 18
0
 public static bool DeleteNV(string Manv)
 {
     try
     {
         using (var _context = new DBManageContext())
         {
             var dbnv = (from nv in _context.tbNhanVien
                         where nv.MaNV == Manv
                         select nv).Single();
             _context.tbNhanVien.Remove(dbnv);
             _context.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
Exemplo n.º 19
0
 public static bool DeleteCV(ClassCongViec cv)
 {
     try
     {
         using (var _context = new DBManageContext())
         {
             var task = (from t in _context.tbCongViec
                         where t.MaCV == cv.MaCV
                         select t).Single();
             _context.tbCongViec.Remove(task);
             _context.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
Exemplo n.º 20
0
 public static List <ClassNhanVien> GetLuongNV()
 {
     using (var _context = new DBManageContext())
     {
         var nvien = (from nv in _context.tbNhanVien.AsEnumerable()
                      select new
         {
             MaNV = nv.MaNV,
             TenNV = nv.TenNV,
             TienDo = nv.TienDo,
             Luong = nv.Luong
         }).Select(x => new ClassNhanVien
         {
             MaNV   = x.MaNV,
             TenNV  = x.TenNV,
             TienDo = x.TienDo,
             Luong  = x.Luong
         }).ToList();
         return(nvien);
     }
 }
Exemplo n.º 21
0
 public static List <ClassNhanVien> GetListNvien()
 {
     using (var _context = new DBManageContext())
     {
         var nv = (from nvien in _context.tbNhanVien.Include("listCVLam").Include("listCVXong").AsEnumerable()
                   select new
         {
             MaNV = nvien.MaNV,
             MaDA = nvien.MaDA,
             listCVLam = nvien.listCVLam,
             listCVXong = nvien.listCVXong,
             TienDo = nvien.TienDo
         }).Select(x => new ClassNhanVien
         {
             MaNV       = x.MaNV,
             MaDA       = x.MaDA,
             listCVLam  = x.listCVLam,
             listCVXong = x.listCVXong,
             TienDo     = x.TienDo
         }).ToList();
         return(nv);
     }
 }
Exemplo n.º 22
0
        public static bool AddDuAn(ClassDuAn da)
        {
            try
            {
                using (var _context = new DBManageContext())
                {
                    _context.tbDuAn.Add(da);
                    _context.SaveChanges();
                    return(true);
                }
                //using (var _context = new DBManageContext())
                //{
                //    //lay du an
                //    var dbda = (from proj in _context.tbDuAn
                //                where proj.MaDA == da.MaDA
                //                select proj).Single();

                //    foreach (ClassCongViec cv in da.listCV)
                //    {
                //        //lay congviec tu sql
                //        var dbcv = (from d in _context.tbCongViec
                //                    where d.MaCV == cv.MaCV
                //                    select d).Single();
                //        //them vao listcv cua dbda
                //        dbda.listCV.Add(dbcv);
                //    }
                //    _context.tbDuAn.AddOrUpdate(dbda);
                //    _context.SaveChanges();
                //    return true;
                //}
            }
            catch
            {
                return(false);
            }
        }