Ejemplo n.º 1
0
 public FrmCaEdit(CaLamViec ca)
 {
     InitializeComponent();
     current = ca;
     spnGioBatDau.Text = ca.GioBatDau.Hours.ToString();
     spnPhutBatDau.Text = ca.GioBatDau.Minutes.ToString();
     spnGioKetThuc.Text = ca.GioKetThuc.Hours.ToString();
     spnPhutKetThuc.Text = ca.GioKetThuc.Minutes.ToString();
 }
 public static CODE_RESULT_RETURN Update(CaLamViec c)
 {
     using (var db = DBContext.GetContext()) {
         var trung = db.CaLamViec.FirstOrDefault(ca => (ca.GioBatDau > c.GioBatDau && ca.GioBatDau < c.GioKetThuc)
             ||
             (ca.GioKetThuc > c.GioBatDau && ca.GioKetThuc < c.GioKetThuc));
         if (trung != null)
             return CODE_RESULT_RETURN.MaTrung;
         var c1 = db.CaLamViec.Find(c.MaCa);
         if (c1 != null) {
             c1.GioBatDau = c.GioBatDau;
             c1.GioKetThuc = c.GioKetThuc;
             db.SaveChanges();
             return CODE_RESULT_RETURN.ThanhCong;
         }
         return CODE_RESULT_RETURN.ThatBai;
     }
 }
 internal static List<HistoryNhanVien> GetToDay(int maPhong = -1, bool isCheckin = true, CaLamViec caHienTai = null)
 {
     using (var db = DBContext.GetContext())
     {
         var start = DateTimeUtil.StartOfDay(DateTime.Now);
         var end = DateTimeUtil.EndOfDay(DateTime.Now);
         var data = db.HistoryNhanVien.Include(h => h.NhanVien.PhongTap).Include(h=>h.Ca).Where(h => h.ThoiGian >= start
             && h.ThoiGian <= end
             && h.IsCheckin == isCheckin
             );
         if (maPhong != -1)
         {
             data = data.Where(d => d.NhanVien.PhongTap.MaPhongTap == maPhong);
         }
         return data.ToList();
     }
 }