Example #1
0
        public JsonResult CapNhatDanhSachChamCong(string maNhanVien, string caLamViec, string ngay, string thoiGianVao, string thoiGianRa)
        {
            var chamCong = chamCongbll.TimKiemChiTietChamCong(maNhanVien, caLamViec, DateTime.Parse(ngay));
            int status   = 0;
            ScriptFunctionsDataContext function = new ScriptFunctionsDataContext();

            if (chamCong == null)
            {
                ChamCong cc = new ChamCong()
                {
                    MaChamCong  = function.auto_maChamCong(),
                    CaLamViec   = caLamViec,
                    ThoiGianRa  = TimeSpan.Parse(thoiGianRa),
                    ThoiGianVao = TimeSpan.Parse(thoiGianVao),
                    Ngay        = DateTime.Parse(ngay),
                    MaNhanVien  = maNhanVien,
                };
                if (chamCongbll.ThemMoi(cc) == true)
                {
                    status = 1;
                }
                else
                {
                    status = 2;
                }
            }
            else
            {
                chamCong.ThoiGianRa  = TimeSpan.Parse(thoiGianRa);
                chamCong.ThoiGianVao = TimeSpan.Parse(thoiGianVao);

                if (chamCongbll.CapNhat(chamCong) == true)
                {
                    status = 3;
                }
                else
                {
                    status = 4;
                }
            }
            return(Json(new
            {
                status = status
            }, JsonRequestBehavior.AllowGet));
        }