public JsonResult SignInDemoSave() { var 員工編號 = Convert.ToInt32(Request.Cookies["AutoLg"]["id"]); var 中文姓名 = Server.UrlDecode(Request.Cookies["AutoLg"]["Name"]); var 現在日期 = new DateTime(2021, 4, 15); var 模擬上班打卡時間 = new DateTime(2021, 4, 15, 8, 30, 0); var 模擬下班打卡時間 = new DateTime(2021, 4, 15, 18, 30, 0); using (dbEIPEntities db = new dbEIPEntities()) { 打卡系統 v = new 打卡系統(); var v1 = db.打卡系統.Where(a => a.員工編號 == 員工編號 && a.打卡日期 == 現在日期).FirstOrDefault(); if (v1 == null) { v.員工編號 = 員工編號; v.班打卡時間 = 模擬上班打卡時間; v.打卡日期 = new DateTime(2021, 4, 15); v.中文姓名 = 中文姓名; v.ThemeColor = "gray"; sr.Create(v); } else { v1.員工編號 = 員工編號; v1.打卡日期 = new DateTime(2021, 4, 15); v1.中文姓名 = 中文姓名; v1.班打卡時間 = 模擬下班打卡時間; v1.ThemeColor = "green"; sr.Update(v1); } } return(Json("", JsonRequestBehavior.AllowGet)); }
public JsonResult SaveEvent(行事曆 e) { var status = false; using (dbEIPEntities db = new dbEIPEntities()) { if (e.EventID > 0) { //Update the event var v = db.行事曆.Where(a => a.EventID == e.EventID).FirstOrDefault(); if (v != null) { v.Subject = e.Subject; v.Start = e.Start; v.End = e.End; v.Description = e.Description; v.IsFullDay = e.IsFullDay; v.ThemeColor = e.ThemeColor; } } else { db.行事曆.Add(e); } db.SaveChanges(); status = true; } return(new JsonResult { Data = new { status = status } }); }
// ---------------------------以下Fullcalendar方法----------------------------// public JsonResult GetEvents() { using (dbEIPEntities db = new dbEIPEntities()) { var events = db.行事曆.ToList(); return(new JsonResult { Data = events, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } }
public JsonResult DeleteEvent(int eventID) { var status = false; using (dbEIPEntities db = new dbEIPEntities()) { var v = db.行事曆.Where(a => a.EventID == eventID).FirstOrDefault(); if (v != null) { db.行事曆.Remove(v); db.SaveChanges(); status = true; } } return(new JsonResult { Data = new { status = status } }); }
DbSet <Table> dbTable = null; // EntityFramework 的屬性 public EIPRepository() { db = new dbEIPEntities(); // 建立StoreDBEntities的實體 dbTable = db.Set <Table>(); }