public static List<DonVi> listall()
 {
     QuanLyLuongEntities model = new QuanLyLuongEntities();
     List<DonVi> list = new List<DonVi>();
     list = (from n in model.DonVis select n).ToList();
     return list;
 }
        public bool suachuyenbac(LichSuChuyenBac lichsuchuyenbac)
        {
            QuanLyLuongEntities csdl = new QuanLyLuongEntities();
            try
            {

                LichSuChuyenBac ls = csdl.LichSuChuyenBacs.SingleOrDefault(n => n.id == lichsuchuyenbac.id );
                ls.MaHeSo = lichsuchuyenbac.MaHeSo;
                ls.NgayChuyen = lichsuchuyenbac.NgayChuyen;

                csdl.SaveChanges();
                var nhanvien = from p in csdl.NhanViens
                               where p.MaNV == lichsuchuyenbac.MaNV
                               select p;
                foreach (NhanVien nv in nhanvien)
                {
                    nv.MaHeSo = lichsuchuyenbac.MaHeSo;
                    nv.MaNgach = lichsuchuyenbac.Mangach;
                }
                csdl.SaveChanges();

            }
            catch
            {
                return false;
            }
            return true;
        }
Esempio n. 3
0
        public bool themchuyenbac(LichSuChuyenBac lichsuchuyenbac)
        {
            QuanLyLuongEntities db = new QuanLyLuongEntities();

            try
            {
                LichSuChuyenBac lscb = new LichSuChuyenBac {
                    MaNV = lichsuchuyenbac.MaNV, MaHeSo = lichsuchuyenbac.MaHeSo, Mangach = lichsuchuyenbac.Mangach, NgayChuyen = lichsuchuyenbac.NgayChuyen
                };
                db.LichSuChuyenBacs.Add(lscb);
                db.SaveChanges();

                var nhanvien = from p in db.NhanViens
                               where p.MaNV == lichsuchuyenbac.MaNV
                               select p;
                foreach (NhanVien nv in nhanvien)
                {
                    nv.MaHeSo  = lichsuchuyenbac.MaHeSo;
                    nv.MaNgach = lichsuchuyenbac.Mangach;
                }
                db.SaveChanges();
            }
            catch
            {
                return(false);
            }
            return(true);
        }
Esempio n. 4
0
        private void btSua_Click(object sender, EventArgs e)
        {
            QuanLyLuongEntities csdl = new QuanLyLuongEntities();

            if (txttths.Text == "")
            {
                MessageBox.Show("Vui lòng chọn nhân viên muốn sửa!");
            }
            else
            {
                var    u     = from b in csdl.LichSuChuyenBacs where b.MaNV == txtttma.Text select b;
                int    idmax = u.Max(b => b.id);
                string gttim = idmax.ToString();
                int    VT    = dataGridView1.CurrentCell.RowIndex;
                if (dataGridView1.Rows[VT].Cells[0].Value.ToString() != gttim)
                {
                    MessageBox.Show("Đây không phải hệ số mới cập nhật của nhân viên!!");
                }
                else

                {
                    int CT    = dataGridView1.CurrentCell.RowIndex;
                    int idtim = int.Parse(dataGridView1.Rows[CT].Cells[0].Value.ToString());
                    SuaLichSuChuyenBac frmsua = new SuaLichSuChuyenBac();
                    delPassData        del    = new delPassData(frmsua.Laydulieu);
                    laymasua           lms    = new laymasua(frmsua.Layma);
                    del(this.txtttma);
                    lms(this.txtid);
                    frmsua.Show();
                }
            }
        }
Esempio n. 5
0
        public bool suachuyenbac(LichSuChuyenBac lichsuchuyenbac)
        {
            QuanLyLuongEntities csdl = new QuanLyLuongEntities();

            try
            {
                LichSuChuyenBac ls = csdl.LichSuChuyenBacs.SingleOrDefault(n => n.id == lichsuchuyenbac.id);
                ls.MaHeSo     = lichsuchuyenbac.MaHeSo;
                ls.NgayChuyen = lichsuchuyenbac.NgayChuyen;

                csdl.SaveChanges();
                var nhanvien = from p in csdl.NhanViens
                               where p.MaNV == lichsuchuyenbac.MaNV
                               select p;
                foreach (NhanVien nv in nhanvien)
                {
                    nv.MaHeSo  = lichsuchuyenbac.MaHeSo;
                    nv.MaNgach = lichsuchuyenbac.Mangach;
                }
                csdl.SaveChanges();
            }
            catch
            {
                return(false);
            }
            return(true);
        }
Esempio n. 6
0
        public static List <LichSuChuyenBac> listall()
        {
            QuanLyLuongEntities    db   = new QuanLyLuongEntities();
            List <LichSuChuyenBac> list = new List <LichSuChuyenBac>();

            list = ((from lscb in db.LichSuChuyenBacs.ToList()
                     from hslpc in db.HeSoLuongPhuCaps.ToList()
                     from ngach in db.NgachLuongs.ToList()
                     from nv in db.NhanViens.ToList()
                     where lscb.MaNV == nv.MaNV && lscb.MaHeSo == hslpc.MaHeSo && hslpc.MaNgach == ngach.MaNgach
                     select new LichSuChuyenBac()
            {
                id = lscb.id,
                MaNV = nv.MaNV,
                TenNV = nv.HoTen,
                MaHeSo = hslpc.MaHeSo,
                Tenheso = hslpc.TenHeSo,
                Mangach = ngach.MaNgach,
                Tenngach = ngach.TenNgach,
                NienHan = ngach.NienHan,
                Heso = hslpc.HeSo,
                NgayChuyen = lscb.NgayChuyen
            }).ToList());

            return(list);
        }
        public static List<LichSuChuyenBac> listall()
        {
            QuanLyLuongEntities db = new QuanLyLuongEntities();
            List<LichSuChuyenBac> list = new List<LichSuChuyenBac>();
            list = ((from lscb in db.LichSuChuyenBacs.ToList()
                     from hslpc in db.HeSoLuongPhuCaps.ToList()
                     from ngach in db.NgachLuongs.ToList()
                     from nv in db.NhanViens.ToList()
                     where lscb.MaNV == nv.MaNV && lscb.MaHeSo == hslpc.MaHeSo && hslpc.MaNgach == ngach.MaNgach
                     select new LichSuChuyenBac()
                     {
                         id = lscb.id,
                         MaNV = nv.MaNV,
                         TenNV = nv.HoTen,
                         MaHeSo = hslpc.MaHeSo,
                         Tenheso = hslpc.TenHeSo,
                         Mangach = ngach.MaNgach,
                         Tenngach = ngach.TenNgach,
                         NienHan = ngach.NienHan,
                         Heso = hslpc.HeSo,
                         NgayChuyen = lscb.NgayChuyen

                     }).ToList());

            return list;
        }
Esempio n. 8
0
        private void btSua_Click(object sender, EventArgs e)
        {
            QuanLyLuongEntities db = new QuanLyLuongEntities();
            string macv            = dataGridView1.CurrentRow.Cells[1].Value.ToString();

            if (suaten.Text != "" && suahs.Text != "")
            {
                _chucvu.MaChucVu  = macv;
                _chucvu.TenChucVu = suaten.Text;
                _chucvu.HeSoCV    = Convert.ToDouble(suahs.Text);
                if (_bizchucvu.BizTimKiem(_chucvu) == true)
                {
                    MessageBox.Show("Sửa thành công");
                }
                else
                {
                    MessageBox.Show("Sửa thất bại");
                }

                db.SaveChanges();
                load();
            }
            else
            {
                MessageBox.Show("Vui lòng chọn thông tin cần sửa!!");
            }
        }
 //Load danh sách
 public static List<ChucVu> listall()
 {
     QuanLyLuongEntities model = new QuanLyLuongEntities();
     List<ChucVu> list = new List<ChucVu>();
     list = (from n in model.ChucVus select n).ToList();
     return list;
 }
        public static List <DonVi> listall()
        {
            QuanLyLuongEntities model = new QuanLyLuongEntities();
            List <DonVi>        list  = new List <DonVi>();

            list = (from n in model.DonVis select n).ToList();
            return(list);
        }
 //đổ DL vào gridview
 public List <NgachLuong> LayDuLieuNgach()
 {
     try
     {
         entity = new QuanLyLuongEntities();
         List <NgachLuong> list = new List <NgachLuong>();
         var ds = from ngach in entity.NgachLuongs
                  select ngach;
         list = ds.ToList();
         return(list);
     }
     catch (Exception ex)
     {
         throw;
     }
 }
        //đổ DL vào gridview
        public List<NgachLuong> LayDuLieuNgach()
        {
            try
            {
                entity = new QuanLyLuongEntities();
                List<NgachLuong> list = new List<NgachLuong>();
                var ds = from ngach in entity.NgachLuongs
                         select ngach;
                list = ds.ToList();
                return list;
            }
            catch (Exception ex)
            {

                throw;
            }
        }
 //Lấy DL đổ vào gridview
 public List <NhanVien> LayDuLieuNV()
 {
     try
     {
         db = new QuanLyLuongEntities();
         List <NhanVien> list = new List <NhanVien>();
         list = db.NhanViens.SqlQuery("select * from dbo.Nhanvien nv" +
                                      " left join dbo.Chucvu cv on nv.machucvu=cv.machucvu" +
                                      " left join dbo.Donvi dv on nv.madonvi=dv.madonvi" +
                                      " left join dbo.NgachLuong ngach on nv.mangach=ngach.mangach").ToList();
         return(list);
     }
     catch (Exception ex)
     {
         throw;
     }
 }
 //Lấy DL đổ vào grid
 public List <HeSoLuongPhuCap> LayDuLieu()
 {
     try
     {
         entity = new QuanLyLuongEntities();
         List <HeSoLuongPhuCap> list = new List <HeSoLuongPhuCap>();
         var ds = from hsl in entity.HeSoLuongPhuCaps
                  join ngach in entity.NgachLuongs on hsl.MaNgach equals ngach.MaNgach
                  select hsl;
         list = ds.ToList();
         return(list);
     }
     catch (Exception ex)
     {
         throw;
     }
 }
        public bool Suachucvu(ChucVu chucvu)
        {
            QuanLyLuongEntities csdl = new QuanLyLuongEntities();

            try
            {
                ChucVu cv = csdl.ChucVus.SingleOrDefault(n => n.MaChucVu == chucvu.MaChucVu);
                cv.TenChucVu = chucvu.TenChucVu;
                cv.HeSoCV    = chucvu.HeSoCV;
                csdl.SaveChanges();
            }
            catch
            {
                return(false);
            }
            return(true);
        }
        public List <LoaiDonVi> LayLoai()
        {
            QuanLyLuongEntities db = new QuanLyLuongEntities();

            try
            {
                List <LoaiDonVi> list = new List <LoaiDonVi>();
                var ds = from dv in db.LoaiDonVis
                         join loaidv in db.LoaiDonVis on dv.MaLoai equals loaidv.MaLoai
                         select dv;
                list = ds.ToList();
                return(list);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public List<NgachLuong> LayNgach()
        {
            QuanLyLuongEntities db = new QuanLyLuongEntities();
            try
            {
                List<NgachLuong> list = new List<NgachLuong>();
                var ds = from nl in db.NgachLuongs
                         join ngach in db.NgachLuongs on nl.MaNgach equals ngach.MaNgach
                         select nl;
                list = ds.ToList();
                return list;
            }
            catch (Exception)
            {

                throw;
            }
        }
        //Lấy DL đổ vào grid
        public List<HeSoLuongPhuCap> LayDuLieu()
        {
            try
            {
                entity = new QuanLyLuongEntities();
                List<HeSoLuongPhuCap> list = new List<HeSoLuongPhuCap>();
                var ds = from hsl in entity.HeSoLuongPhuCaps
                         join ngach in entity.NgachLuongs on hsl.MaNgach equals ngach.MaNgach
                         select hsl;
                list = ds.ToList();
                return list;
            }
            catch (Exception ex)
            {

                throw;
            }
        }
Esempio n. 19
0
        public List <NgachLuong> LayNgach()
        {
            QuanLyLuongEntities db = new QuanLyLuongEntities();

            try
            {
                List <NgachLuong> list = new List <NgachLuong>();
                var ds = from nl in db.NgachLuongs
                         join ngach in db.NgachLuongs on nl.MaNgach equals ngach.MaNgach
                         select nl;
                list = ds.ToList();
                return(list);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public bool Suachucvu(ChucVu chucvu)
        {
            QuanLyLuongEntities csdl = new QuanLyLuongEntities();
            try
            {

                ChucVu cv = csdl.ChucVus.SingleOrDefault(n => n.MaChucVu == chucvu.MaChucVu);
                cv.TenChucVu = chucvu.TenChucVu;
                cv.HeSoCV = chucvu.HeSoCV;
                csdl.SaveChanges();

            }
            catch
            {
                return false;
            }
            return true;
        }
        public List<LoaiDonVi> LayLoai()
        {
            QuanLyLuongEntities db = new QuanLyLuongEntities();

            try
            {
                List<LoaiDonVi> list = new List<LoaiDonVi>();
                var ds = from dv in db.LoaiDonVis
                         join loaidv in db.LoaiDonVis on dv.MaLoai equals loaidv.MaLoai
                         select dv;
                list = ds.ToList();
                return list;
            }
            catch (Exception)
            {

                throw;
            }
        }
Esempio n. 22
0
        public List <LoaiDonVi> TimKiem(string ma, string ten)
        {
            QuanLyLuongEntities db    = new QuanLyLuongEntities();
            List <LoaiDonVi>    KQTim = new List <LoaiDonVi>();

            try
            {
                if (ma != "" && ten != "")
                {
                    KQTim = (from ldv in db.LoaiDonVis.ToList()
                             where ldv.MaLoai.Contains(ma) && ldv.TenLoai.Contains(ten)

                             select ldv).ToList();
                }
                else if (ma == "" && ten != "")
                {
                    KQTim = (from ldv in db.LoaiDonVis.ToList()
                             where ldv.TenLoai.Contains(ten)

                             select ldv).ToList();
                }

                else if (ma != "" && ten == "")
                {
                    KQTim = (from ldv in db.LoaiDonVis.ToList()
                             where ldv.MaLoai.Contains(ma)

                             select ldv).ToList();
                }
                else if (ma == "" && ten == "")
                {
                    KQTim = (from ldv in db.LoaiDonVis.ToList()
                             select ldv).ToList();
                }


                return(KQTim);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public List<LoaiDonVi> TimKiem(string ma, string ten)
        {
            QuanLyLuongEntities db = new QuanLyLuongEntities();
            List<LoaiDonVi> KQTim = new List<LoaiDonVi>();
            try
            {
                if (ma != "" && ten != "" )
                {
                    KQTim = (from ldv in db.LoaiDonVis.ToList()
                             where ldv.MaLoai.Contains(ma) && ldv.TenLoai.Contains(ten)

                             select ldv).ToList();
                }
                else if (ma == "" && ten != "")
                {
                    KQTim = (from ldv in db.LoaiDonVis.ToList()
                             where ldv.TenLoai.Contains(ten)

                             select ldv).ToList();
                }

                else if (ma != "" && ten == "" )
                {
                    KQTim = (from ldv in db.LoaiDonVis.ToList()
                             where ldv.MaLoai.Contains(ma)

                             select ldv).ToList();
                }
                else if (ma == "" && ten == "")
                {
                    KQTim = (from ldv in db.LoaiDonVis.ToList()
                             select ldv).ToList();
                }

                return KQTim;
            }
            catch (Exception)
            {

                throw;
            }
        }
        public bool Suadonvi(DonVi donvi)
        {
            QuanLyLuongEntities csdl = new QuanLyLuongEntities();

            try
            {
                DonVi dv = csdl.DonVis.SingleOrDefault(n => n.MaDonVi == donvi.MaDonVi);
                dv.TenDonVi    = donvi.TenDonVi;
                dv.MaLoai      = donvi.MaLoai;
                dv.DienThoai   = donvi.DienThoai;
                dv.DiaChi      = donvi.DiaChi;
                dv.ChucNang    = donvi.ChucNang;
                dv.NhiemVu     = donvi.NhiemVu;
                dv.NamThanhLap = dv.NamThanhLap;
                csdl.SaveChanges();
            }
            catch
            {
                return(false);
            }
            return(true);
        }
        public bool Suadonvi(DonVi donvi)
        {
            QuanLyLuongEntities csdl = new QuanLyLuongEntities();
            try
            {

                DonVi dv = csdl.DonVis.SingleOrDefault(n => n.MaDonVi == donvi.MaDonVi);
                dv.TenDonVi = donvi.TenDonVi;
                dv.MaLoai = donvi.MaLoai;
                dv.DienThoai = donvi.DienThoai;
                dv.DiaChi = donvi.DiaChi;
                dv.ChucNang = donvi.ChucNang;
                dv.NhiemVu = donvi.NhiemVu;
                dv.NamThanhLap = dv.NamThanhLap;
                csdl.SaveChanges();

            }
            catch
            {
                return false;
            }
            return true;
        }
        public List<DonVi> TimKiem(string ma , string ten , string loai)
        {
            QuanLyLuongEntities db = new QuanLyLuongEntities();
            List<DonVi> KQTim = new List<DonVi>();
            try
            {
                if (ma != "" && ten != "" && loai != "")
                {
                    KQTim = (from dv in db.DonVis.ToList()
                              where dv.MaDonVi.Contains(ma) && dv.TenDonVi.Contains(ten) && dv.MaLoai == loai

                             select dv).ToList() ;
                }
                else if(ma == "" && ten != "" && loai != "")
                {
                    KQTim = (from dv in db.DonVis.ToList()
                             where  dv.TenDonVi.Contains(ten) && dv.MaLoai == loai

                             select dv).ToList();
                }

                else if (ma != "" && ten == "" && loai != "")
                {
                    KQTim = (from dv in db.DonVis.ToList()
                             where dv.MaDonVi.Contains(ma) &&  dv.MaLoai == loai

                             select dv).ToList();
                }
                else if (ma != "" && ten != "" && loai == "")
                {
                    KQTim = (from dv in db.DonVis.ToList()
                             where dv.MaDonVi.Contains(ma) && dv.TenDonVi.Contains(ten)

                             select dv).ToList();
                }
                else if (ma != "" && ten == "" && loai == "")
                {
                    KQTim = (from dv in db.DonVis.ToList()
                             where dv.MaDonVi.Contains(ma)

                             select dv).ToList();
                }
                else if (ma == "" && ten != "" && loai == "")
                {
                    KQTim = (from dv in db.DonVis.ToList()
                             where  dv.TenDonVi.Contains(ten)

                             select dv).ToList();
                }
                else if (ma == "" && ten == "" && loai != "")
                {
                    KQTim = (from dv in db.DonVis.ToList()
                             where  dv.MaLoai == loai

                             select dv).ToList();
                }

                return KQTim;
            }
            catch (Exception)
            {

                throw;
            }
        }
        //Tim chuc vu
        public List<ChucVu> TimKiem(string ma, string ten, string heso)
        {
            QuanLyLuongEntities db = new QuanLyLuongEntities();
            List<ChucVu> KQTim = new List<ChucVu>();
            try
            {
                double hesotim;
                if (ma != "" && ten != "" && heso != "")
                {
                    hesotim = Convert.ToDouble(heso);
                    KQTim = (from dv in db.ChucVus.ToList()
                             where dv.MaChucVu.Contains(ma) && dv.TenChucVu.Contains(ten) && dv.HeSoCV == hesotim

                             select dv).ToList();
                }
                else if (ma == "" && ten != "" && heso != "")
                {
                    hesotim = Convert.ToDouble(heso);
                    KQTim = (from dv in db.ChucVus.ToList()
                             where dv.TenChucVu.Contains(ten) && dv.HeSoCV == hesotim

                             select dv).ToList();
                }

                else if (ma != "" && ten == "" && heso != "")
                {
                    hesotim = Convert.ToDouble(heso);
                    KQTim = (from dv in db.ChucVus.ToList()
                             where dv.MaChucVu.Contains(ma) && dv.HeSoCV == hesotim

                             select dv).ToList();
                }
                else if (ma != "" && ten != "" && heso == "")
                {
                    KQTim = (from dv in db.ChucVus.ToList()
                             where dv.MaChucVu.Contains(ma) && dv.TenChucVu.Contains(ten)

                             select dv).ToList();
                }
                else if (ma != "" && ten == "" && heso == "")
                {
                    KQTim = (from dv in db.ChucVus.ToList()
                             where dv.MaChucVu.Contains(ma)

                             select dv).ToList();
                }
                else if (ma == "" && ten != "" && heso == "")
                {
                    KQTim = (from dv in db.ChucVus.ToList()
                             where dv.TenChucVu.Contains(ten)

                             select dv).ToList();
                }
                else if (ma == "" && ten == "" && heso != "")
                {
                    hesotim = Convert.ToDouble(heso);
                    KQTim = (from dv in db.ChucVus.ToList()
                             where dv.HeSoCV == hesotim

                             select dv).ToList();
                }

                return KQTim;
            }
            catch (Exception)
            {

                throw;
            }
        }
        //Tim chuc vu
        public List <ChucVu> TimKiem(string ma, string ten, string heso)
        {
            QuanLyLuongEntities db    = new QuanLyLuongEntities();
            List <ChucVu>       KQTim = new List <ChucVu>();

            try
            {
                double hesotim;
                if (ma != "" && ten != "" && heso != "")
                {
                    hesotim = Convert.ToDouble(heso);
                    KQTim   = (from dv in db.ChucVus.ToList()
                               where dv.MaChucVu.Contains(ma) && dv.TenChucVu.Contains(ten) && dv.HeSoCV == hesotim

                               select dv).ToList();
                }
                else if (ma == "" && ten != "" && heso != "")
                {
                    hesotim = Convert.ToDouble(heso);
                    KQTim   = (from dv in db.ChucVus.ToList()
                               where dv.TenChucVu.Contains(ten) && dv.HeSoCV == hesotim

                               select dv).ToList();
                }

                else if (ma != "" && ten == "" && heso != "")
                {
                    hesotim = Convert.ToDouble(heso);
                    KQTim   = (from dv in db.ChucVus.ToList()
                               where dv.MaChucVu.Contains(ma) && dv.HeSoCV == hesotim

                               select dv).ToList();
                }
                else if (ma != "" && ten != "" && heso == "")
                {
                    KQTim = (from dv in db.ChucVus.ToList()
                             where dv.MaChucVu.Contains(ma) && dv.TenChucVu.Contains(ten)

                             select dv).ToList();
                }
                else if (ma != "" && ten == "" && heso == "")
                {
                    KQTim = (from dv in db.ChucVus.ToList()
                             where dv.MaChucVu.Contains(ma)

                             select dv).ToList();
                }
                else if (ma == "" && ten != "" && heso == "")
                {
                    KQTim = (from dv in db.ChucVus.ToList()
                             where dv.TenChucVu.Contains(ten)

                             select dv).ToList();
                }
                else if (ma == "" && ten == "" && heso != "")
                {
                    hesotim = Convert.ToDouble(heso);
                    KQTim   = (from dv in db.ChucVus.ToList()
                               where dv.HeSoCV == hesotim

                               select dv).ToList();
                }


                return(KQTim);
            }
            catch (Exception)
            {
                throw;
            }
        }
        //Lấy DL đổ vào gridview
        public List<NhanVien> LayDuLieuNV()
        {
            try
            {
                db = new QuanLyLuongEntities();
                List<NhanVien> list = new List<NhanVien>();
                list = db.NhanViens.SqlQuery("select * from dbo.Nhanvien nv" +
                                                " left join dbo.Chucvu cv on nv.machucvu=cv.machucvu" +
                                                " left join dbo.Donvi dv on nv.madonvi=dv.madonvi" +
                                                " left join dbo.NgachLuong ngach on nv.mangach=ngach.mangach").ToList();
                return list;
            }
            catch (Exception ex)
            {

                throw;
            }
        }
        public List<LichSuChuyenBac> timkiem(string tim, string tungay, string denngay)
        {
            QuanLyLuongEntities db = new QuanLyLuongEntities();
            List<LichSuChuyenBac> KQTim = new List<LichSuChuyenBac>();
            try
            {
                if (tim != "")
                {
                    DateTime ngaytu = Convert.ToDateTime(tungay);
                    DateTime ngayden = Convert.ToDateTime(denngay);

                    KQTim = ((from lscb in db.LichSuChuyenBacs.ToList()
                              from hslpc in db.HeSoLuongPhuCaps.ToList()
                              from ngach in db.NgachLuongs.ToList()
                              from nv in db.NhanViens.ToList()
                              where lscb.MaNV == nv.MaNV && lscb.MaHeSo == hslpc.MaHeSo && hslpc.MaNgach == ngach.MaNgach && nv.MaNV.Contains(tim) && ngaytu <= lscb.NgayChuyen && lscb.NgayChuyen <= ngayden
                              select new LichSuChuyenBac()
                              {
                                  id = lscb.id,
                                  MaNV = nv.MaNV,
                                  TenNV = nv.HoTen,
                                  MaHeSo = hslpc.MaHeSo,
                                  Tenheso = hslpc.TenHeSo,
                                  Mangach = ngach.MaNgach,
                                  Tenngach = ngach.TenNgach,
                                  NienHan = ngach.NienHan,
                                  Heso = hslpc.HeSo,
                                  NgayChuyen = lscb.NgayChuyen

                              }).ToList());

                }
                else if (tim == "")
                {

                    DateTime ngaytu = Convert.ToDateTime(tungay);
                    DateTime ngayden = Convert.ToDateTime(denngay);

                    KQTim = ((from lscb in db.LichSuChuyenBacs.ToList()
                              from hslpc in db.HeSoLuongPhuCaps.ToList()
                              from ngach in db.NgachLuongs.ToList()
                              from nv in db.NhanViens.ToList()
                              where lscb.MaNV == nv.MaNV && lscb.MaHeSo == hslpc.MaHeSo && hslpc.MaNgach == ngach.MaNgach && ngaytu <= lscb.NgayChuyen && lscb.NgayChuyen <= ngayden
                              select new LichSuChuyenBac()
                              {
                                  id = lscb.id,
                                  MaNV = nv.MaNV,
                                  TenNV = nv.HoTen,
                                  MaHeSo = hslpc.MaHeSo,
                                  Tenheso = hslpc.TenHeSo,
                                  Mangach = ngach.MaNgach,
                                  Tenngach = ngach.TenNgach,
                                  NienHan = ngach.NienHan,
                                  Heso = hslpc.HeSo,
                                  NgayChuyen = lscb.NgayChuyen

                              }).ToList());

                }

                return KQTim;
            }
            catch (Exception)
            {

                throw;
            }
        }
Esempio n. 31
0
        public List <LichSuChuyenBac> timkiem(string tim, string tungay, string denngay)
        {
            QuanLyLuongEntities    db    = new QuanLyLuongEntities();
            List <LichSuChuyenBac> KQTim = new List <LichSuChuyenBac>();

            try
            {
                if (tim != "")
                {
                    DateTime ngaytu  = Convert.ToDateTime(tungay);
                    DateTime ngayden = Convert.ToDateTime(denngay);

                    KQTim = ((from lscb in db.LichSuChuyenBacs.ToList()
                              from hslpc in db.HeSoLuongPhuCaps.ToList()
                              from ngach in db.NgachLuongs.ToList()
                              from nv in db.NhanViens.ToList()
                              where lscb.MaNV == nv.MaNV && lscb.MaHeSo == hslpc.MaHeSo && hslpc.MaNgach == ngach.MaNgach && nv.MaNV.Contains(tim) && ngaytu <= lscb.NgayChuyen && lscb.NgayChuyen <= ngayden
                              select new LichSuChuyenBac()
                    {
                        id = lscb.id,
                        MaNV = nv.MaNV,
                        TenNV = nv.HoTen,
                        MaHeSo = hslpc.MaHeSo,
                        Tenheso = hslpc.TenHeSo,
                        Mangach = ngach.MaNgach,
                        Tenngach = ngach.TenNgach,
                        NienHan = ngach.NienHan,
                        Heso = hslpc.HeSo,
                        NgayChuyen = lscb.NgayChuyen
                    }).ToList());
                }
                else if (tim == "")
                {
                    DateTime ngaytu  = Convert.ToDateTime(tungay);
                    DateTime ngayden = Convert.ToDateTime(denngay);

                    KQTim = ((from lscb in db.LichSuChuyenBacs.ToList()
                              from hslpc in db.HeSoLuongPhuCaps.ToList()
                              from ngach in db.NgachLuongs.ToList()
                              from nv in db.NhanViens.ToList()
                              where lscb.MaNV == nv.MaNV && lscb.MaHeSo == hslpc.MaHeSo && hslpc.MaNgach == ngach.MaNgach && ngaytu <= lscb.NgayChuyen && lscb.NgayChuyen <= ngayden
                              select new LichSuChuyenBac()
                    {
                        id = lscb.id,
                        MaNV = nv.MaNV,
                        TenNV = nv.HoTen,
                        MaHeSo = hslpc.MaHeSo,
                        Tenheso = hslpc.TenHeSo,
                        Mangach = ngach.MaNgach,
                        Tenngach = ngach.TenNgach,
                        NienHan = ngach.NienHan,
                        Heso = hslpc.HeSo,
                        NgayChuyen = lscb.NgayChuyen
                    }).ToList());
                }

                return(KQTim);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public bool themchuyenbac(LichSuChuyenBac lichsuchuyenbac)
        {
            QuanLyLuongEntities db = new QuanLyLuongEntities();
            try
            {
                LichSuChuyenBac lscb = new LichSuChuyenBac { MaNV = lichsuchuyenbac.MaNV, MaHeSo = lichsuchuyenbac.MaHeSo, Mangach = lichsuchuyenbac.Mangach, NgayChuyen = lichsuchuyenbac.NgayChuyen };
                db.LichSuChuyenBacs.Add(lscb);
                db.SaveChanges();

                var nhanvien = from p in db.NhanViens
                               where p.MaNV == lichsuchuyenbac.MaNV
                               select p;
                foreach (NhanVien nv in nhanvien)
                {
                    nv.MaHeSo = lichsuchuyenbac.MaHeSo;
                    nv.MaNgach = lichsuchuyenbac.Mangach;
                }
                db.SaveChanges();
            }
            catch
            {
                return false;
            }
            return true;
        }