public JsonResult Search(int page, int pageSize, string ngay, string maNhanVien) { List <LichLamViecModel> lstLichLamViec = nhanVienbll.TimLichLamViecTheoNgay(maNhanVien, DateTime.Parse(ngay)) as List <LichLamViecModel>; int totalRow = lstLichLamViec.Count(); List <LichLamViecModel> lst = new List <LichLamViecModel>(); foreach (var item in lstLichLamViec) { LichLamViecModel lich = new LichLamViecModel() { MaNhanVien = item.MaNhanVien, TenNhanVien = item.TenNhanVien, NgayLamViec = item.NgayLamViec, TenCaLamViec = item.TenCaLamViec, ThoiGianRa = item.ThoiGianRa, ThoiGianVao = item.ThoiGianVao }; lst.Add(lich); } return(Json(new { data = lst.Skip((page - 1) * pageSize).Take(pageSize), total = totalRow, status = true }, JsonRequestBehavior.AllowGet)); }
public ActionResult CapNhatLichLamViec() { string userId = User.Identity.GetUserId(); LichLamViecModel lichLamViec = dbContext.DangKyLichLamViec.Single(c => c.idUser.CompareTo(userId) == 0); lichLamViec.heading = "edit schedule"; return(View("DangKyLichLamViec", lichLamViec)); }
public ActionResult CapNhatLichLamViec(LichLamViecModel lichLamViec) { string userId = lichLamViec.idUser; connect.Open(); string stringSQL = string.Format("update dbo.LichLamViecModels set sang2='{0}',sang3='{1}',sang4='{2}',sang5='{3}',sang6='{4}',sang7='{5}',sangCN='{6}',chieu2='{7}',chieu3='{8}',chieu4='{9}',chieu5='{10}',chieu6='{11}',chieu7='{12}',chieuCN='{13}',userName='******' where idLich='{15}'", lichLamViec.sang2, lichLamViec.sang3, lichLamViec.sang4, lichLamViec.sang5, lichLamViec.sang6, lichLamViec.sang7, lichLamViec.sangCN, lichLamViec.chieu2, lichLamViec.chieu3, lichLamViec.chieu4, lichLamViec.chieu5, lichLamViec.chieu6, lichLamViec.chieu7, lichLamViec.chieuCN, lichLamViec.userName, lichLamViec.idLich); SqlCommand commandSQL = new SqlCommand(stringSQL, connect); commandSQL.ExecuteNonQuery(); return(RedirectToAction("Index", "Home")); }
public ActionResult DangKyLichLamViec(LichLamViecModel lichLamViec) { string userId = User.Identity.GetUserId(); lichLamViec.idUser = userId; lichLamViec.idLich = userId + "_" + DateTime.Now.ToString(); String userName = User.Identity.GetUserName(); lichLamViec.userName = userName; dbContext.DangKyLichLamViec.Add(lichLamViec); dbContext.SaveChanges(); return(RedirectToAction("Index", "Home")); }