public string UpdateBell(string id) { HttpCookie cookie = Request.Cookies["id"]; int fEmployeeId = Convert.ToInt32(cookie.Value); int fid = Convert.ToInt32(id); EIP_DBEntities db = new EIP_DBEntities(); var listt = (from n in db.tNotifies where n.fId == fid select n).FirstOrDefault(); listt.fType = 1; db.SaveChanges(); var list = from n in db.tNotifies where n.fEmployeeId == fEmployeeId select new { n.fId, n.fType, n.fTitle, n.fContent, n.fTime }; string json = JsonConvert.SerializeObject(list); return(json); }
public string RemoveCalendar(string id) { HttpCookie cookie = Request.Cookies["id"]; int empid = Convert.ToInt32(cookie.Value); int fid = Convert.ToInt32(id); string json = ""; EIP_DBEntities db = new EIP_DBEntities(); var del = (from c in db.tCalendars where c.fId == fid select c).FirstOrDefault(); db.tCalendars.Remove(del); db.SaveChanges(); var list = from b in db.tCalendars where b.fEmployeeId == empid select new { b.fId, b.fContent, b.fStart, b.fEnd, b.fTitle, }; json = JsonConvert.SerializeObject(list); return(json); }
public string UpdateBell(string type) { HttpCookie cookie = Request.Cookies["id"]; int fid = Convert.ToInt32(cookie.Value); EIP_DBEntities db = new EIP_DBEntities(); var listt = from n in db.tNotifies where n.fType == 0 && n.fEmployeeId == fid select n; foreach (var item in listt) { item.fType = Convert.ToInt32(type); } db.SaveChanges(); var list = from n in db.tNotifies where n.fEmployeeId == fid select new { n.fType, n.fTitle, n.fContent }; string json = JsonConvert.SerializeObject(list); return(json); }
public ActionResult start(string room) { EIP_DBEntities db = new EIP_DBEntities(); var days = db.tMetting_date.Where(c => c.fRoom == room).Join(db.tEmployees, o => o.fEmployeeId, p => p.fEmployeeId, (o, p) => new { id = o.fId, EmployeeId = o.fEmployeeId, Borrower = p.fName, Reason = o.fReason, starttime = o.fStarttime, start = o.fDate, endtime = o.fEndtime, end = o.fDate, Depatment = p.fDepartment }); var day = from d in days.ToList() select new { id = d.id, title = d.Reason, description = "借用人:" + d.Borrower, start = (d.start.Value + d.starttime.Value).ToString("yyyy-MM-ddTHH:mm:ss"), end = (d.end.Value + d.endtime.Value).ToString("yyyy-MM-ddTHH:mm:ss"), color = getcolor(d.Depatment) }; return(new ContentResult() { Content = JsonSerializer.Serialize(day), ContentEncoding = Encoding.UTF8, ContentType = "json" }); }
public ActionResult clickDaydata(string room, string day) { EIP_DBEntities db = new EIP_DBEntities(); var click = DateTime.Parse(day); //}); var dayss = from o in db.tMetting_date from p in db.tEmployees where o.fEmployeeId == p.fEmployeeId && o.fRoom == room && o.fDate == click select new { id = o.fId, date = o.fDate.ToString(), Borrower = p.fName, Reason = o.fReason, starttime = o.fStarttime.ToString(), room = o.fRoom, endtime = o.fEndtime.ToString(), }; return(new ContentResult() { Content = JsonSerializer.Serialize(dayss), ContentEncoding = Encoding.UTF8, ContentType = "json" }); }
public ActionResult Getdata() { using (EIP_DBEntities db = new EIP_DBEntities()) { List <tEmployee> empList = db.tEmployees.ToList(); var hello = from p in db.tEmployees.ToList() select new { fEmployeeId = p.fEmployeeId, fName = p.fName, fIdent = p.fIdent, fPassword = p.fPassword, fDepartment = p.fDepartment, fTitle = p.fTitle, fEmail = p.fEmail, //fBirth=p.fBirth.Year+"-"+p.fBirth.Month+"-"+ p.fBirth.Day, fBirth = p.fBirth.Year + "-" + p.fBirth.Month + "-" + p.fBirth.Day, fPhonePersonal = p.fPhonePersonal, fState = p.fState, fAuth = p.fAuth, }; return(Json(new { data = hello }, JsonRequestBehavior.AllowGet)); } }
public string InsertBell(string title, string content, string id) { int fid = Convert.ToInt32(id); tNotify tn = new tNotify(); tn.fContent = content; tn.fTitle = title; tn.fType = 0; tn.fTime = DateTime.Now; tn.fEmployeeId = fid; EIP_DBEntities db = new EIP_DBEntities(); db.tNotifies.Add(tn); db.SaveChanges(); var list = from n in db.tNotifies where n.fEmployeeId == fid select new { n.fTime, n.fTitle, n.fContent, n.fType }; string json = JsonConvert.SerializeObject(list); return(json); }
public ActionResult Login(FormCollection fc) { EIP_DBEntities db = new EIP_DBEntities(); try { string a = fc["acc"]; var em = (from e in db.tEmployees where e.fIdent == a select new { e.fEmployeeId, e.fIdent, e.fAuth, e.fName, e.fPassword }).FirstOrDefault(); if (fc["acc"].ToString() == em.fIdent && fc["pw"].ToString() == em.fPassword) { Session["name" + em.fEmployeeId] = em.fName; HttpCookie cookie = new HttpCookie("id"); cookie.Value = em.fEmployeeId.ToString(); Response.Cookies.Add(cookie); Session["auth" + em.fEmployeeId] = em.fAuth; return(RedirectToAction("Index", "Index")); } } catch { ViewBag.info = "帳號密碼錯誤"; return(View()); } return(View()); }
public string InsertBell(string title, string content) { HttpCookie cookie = Request.Cookies["id"]; int fid = Convert.ToInt32(cookie.Value); tNotify tn = new tNotify(); tn.fContent = content; tn.fTitle = title; tn.fType = 0; tn.fEmployeeId = 100; EIP_DBEntities db = new EIP_DBEntities(); db.tNotifies.Add(tn); db.SaveChanges(); var list = from n in db.tNotifies where n.fEmployeeId == fid select new { n.fTitle, n.fContent, n.fType }; string json = JsonConvert.SerializeObject(list); return(json); }
public string RemoveBoard(string id) { HttpCookie cookie = Request.Cookies["id"]; int fid = Convert.ToInt32(id); string json = ""; EIP_DBEntities db = new EIP_DBEntities(); var del = (from c in db.tBillboards where c.fId == fid select c).FirstOrDefault(); db.tBillboards.Remove(del); db.SaveChanges(); var list = from b in db.tBillboards select new { b.fId, b.fContent, b.fTitle, b.fType, b.fEmployeeId, b.fPostTime }; json = JsonConvert.SerializeObject(list); return(json); }
public string GetEmployeeName(string id) { int fid = Convert.ToInt32(id); EIP_DBEntities db = new EIP_DBEntities(); var list = (from e in db.tEmployees where e.fEmployeeId == fid select e).FirstOrDefault(); return(list.fName); }
public string InsertCalendar(string id, string start, string end, string title, string content) { HttpCookie cookie = Request.Cookies["id"]; int empid = Convert.ToInt32(cookie.Value); EIP_DBEntities db = new EIP_DBEntities(); string json = ""; IQueryable list; if (string.IsNullOrEmpty(id)) { tCalendar tc = new tCalendar(); tc.fTitle = title; tc.fContent = content; tc.fStart = start; tc.fEnd = end; tc.fEmployeeId = empid; tc.fSort = "0"; db.tCalendars.Add(tc); db.SaveChanges(); list = from c in db.tCalendars where c.fEmployeeId == tc.fEmployeeId select new { c.fId, c.fTitle, c.fStart, c.fEnd, c.fSort }; json = JsonConvert.SerializeObject(list); return(json); } //現有行事曆 int fid = Convert.ToInt32(id); var listu = (db.tCalendars.Where(x => x.fId == fid)).FirstOrDefault(); listu.fStart = start; listu.fEnd = end; listu.fTitle = title; listu.fContent = content; db.SaveChanges(); list = from c in db.tCalendars where c.fEmployeeId == empid select new { c.fId, c.fContent, c.fTitle, c.fStart, c.fEnd, c.fSort }; json = JsonConvert.SerializeObject(list); return(json); }
public ActionResult getdep() { EIP_DBEntities db = new EIP_DBEntities(); var dep = db.tEmployees.Select(p => new { name = p.fName, title = p.fTitle, dep = p.fDepartment, fid = p.fEmployeeId }).Distinct(); return(new ContentResult() { Content = JsonSerializer.Serialize(dep), ContentEncoding = Encoding.UTF8, ContentType = "json" }); }
public string InsertBoard(string id, string title, string content, string type) { string json = ""; HttpCookie cookie = Request.Cookies["id"]; tBillboard tb = new tBillboard(); IQueryable list; EIP_DBEntities db = new EIP_DBEntities(); if (string.IsNullOrEmpty(id)) { tb.fContent = content; tb.fTitle = title; tb.fType = type; tb.fPostTime = DateTime.Now.ToString(); tb.fEmployeeId = Convert.ToInt32(cookie.Value); db.tBillboards.Add(tb); db.SaveChanges(); list = from b in db.tBillboards select new { b.fId, b.fTitle, b.fContent, b.fPostTime, b.fEmployeeId, b.fType }; json = JsonConvert.SerializeObject(list); return(json); } int fid = Convert.ToInt32(id); var listu = (db.tBillboards.Where(x => x.fId == fid)).FirstOrDefault(); listu.fContent = content; listu.fTitle = title; listu.fType = type; listu.fPostTime = DateTime.Now.ToString(); db.SaveChanges(); list = from b in db.tBillboards select new { b.fId, b.fTitle, b.fContent, b.fPostTime, b.fEmployeeId, b.fType }; json = JsonConvert.SerializeObject(list); return(json); }
public string ShowBoard() { EIP_DBEntities db = new EIP_DBEntities(); var list = from b in db.tBillboards select new { b.fId, b.fTitle, b.fContent, b.fPostTime, b.fType, b.fEmployeeId }; string json = JsonConvert.SerializeObject(list); return(json); }
public ActionResult getteammeber() { EIP_DBEntities db = new EIP_DBEntities(); var teammeber = from a in db.tTeamMembers from b in db.tEmployees from c in db.tProjects where a.fEmployeeId == b.fEmployeeId && a.fProjectId == c.fProjectId select new { proid = a.fProjectId, emp = b.fName, empid = a.fEmployeeId }; return(new ContentResult() { Content = JsonSerializer.Serialize(teammeber), ContentEncoding = Encoding.UTF8, ContentType = "json" }); }
public string getpunchtime() { HttpCookie cookie = Request.Cookies["id"]; int empId = Convert.ToInt32(cookie.Value); DateTime Today = DateTime.Now; EIP_DBEntities db = new EIP_DBEntities(); var record = db.tPunchtimes.AsEnumerable() .Where(m => m.fDatetime.Date == Today.Date && m.fEmployeeId == empId).LastOrDefault(); if (record != null) { return(record.fId.ToString()); } else { return(null); } }
public ActionResult getproject() { EIP_DBEntities db = new EIP_DBEntities(); var project = from a in db.tTeamMembers group a by a.fProjectId into g select new { projectid = g.Key }; var projectname = from a in db.tProjects from b in project.ToList() where b.projectid == a.fProjectId select new { proid = b.projectid, proname = a.fProjectName }; return(new ContentResult() { Content = JsonSerializer.Serialize(projectname), ContentEncoding = Encoding.UTF8, ContentType = "json" }); }
public string ShowBell() { HttpCookie cookie = Request.Cookies["id"]; loginController lc = new loginController(); int fid = Convert.ToInt32(cookie.Value); EIP_DBEntities db = new EIP_DBEntities(); var list = from b in db.tNotifies where b.fEmployeeId == fid select new { b.fType, b.fTitle, b.fContent, b.fEmployeeId }; string json = JsonConvert.SerializeObject(list); return(json); }
public ActionResult clickevent(string id) { EIP_DBEntities db = new EIP_DBEntities(); int i = Convert.ToInt32(id); var userlist = db.tMetting_date.Where(p => p.fId == i).Select(p => new { fid = p.fId, date = p.fDate.ToString(), reason = p.fReason, room = p.fRoom, starttime = p.fStarttime.ToString(), endtime = p.fEndtime.ToString() }); return(new ContentResult() { Content = JsonSerializer.Serialize(userlist), ContentEncoding = Encoding.UTF8, ContentType = "json" }); }
public ActionResult startlist(string room, string user) { EIP_DBEntities db = new EIP_DBEntities(); int u = Convert.ToInt32(user); var userid = db.tEmployees.Where(p => p.fEmployeeId == u).First(); var userlist = from o in db.tMetting_date from p in db.tEmployees where o.fEmployeeId == p.fEmployeeId && o.fRoom == room && o.fEmployeeId == u select new { id = o.fId, date = o.fDate.ToString(), Borrower = p.fName, reason = o.fReason, room = o.fRoom, starttime = o.fStarttime.ToString(), endtime = o.fEndtime.ToString(), }; var t = from o in db.tEmployees where o.fEmployeeId == u select new { Borrower = o.fName }; if (userlist.Count() == 0) { return(new ContentResult() { Content = JsonSerializer.Serialize(t), ContentEncoding = Encoding.UTF8, ContentType = "json" }); } return(new ContentResult() { Content = JsonSerializer.Serialize(userlist), ContentEncoding = Encoding.UTF8, ContentType = "json" }); }
public string ShowCalendar(string id) { HttpCookie cookie = Request.Cookies["id"]; int fid = Convert.ToInt32(id); string json = ""; EIP_DBEntities db = new EIP_DBEntities(); IQueryable list; if (string.IsNullOrEmpty(id)) { int empid = Convert.ToInt32(cookie.Value); list = from b in db.tCalendars where b.fEmployeeId == empid select new { b.fId, b.fContent, b.fStart, b.fEnd, b.fTitle, b.fSort, }; json = JsonConvert.SerializeObject(list); return(json); } list = from b in db.tCalendars where b.fId == fid select new { b.fId, b.fContent, b.fStart, b.fEnd, b.fTitle, }; json = JsonConvert.SerializeObject(list); return(json); }
public ActionResult Login(FormCollection fc) { EIP_DBEntities db = new EIP_DBEntities(); bool valid = false; if (fc["isDemo"].ToString() == "t") { valid = true; } else if (Request.Form["g-recaptcha-response"] == "") { ViewBag.info = "請確認是否為機器人"; return(View()); } else { var req = (HttpWebRequest)HttpWebRequest.Create("https://www.google.com/recaptcha/api/siteverify"); string posStr = "secret=6Lcay9YZAAAAAEl_1BQukIB0AJiZtrXJyONKenmu&response=" + Request.Form["g-recaptcha-response"] + "&remoteip=" + Request.Url.Host; byte[] byteStr = Encoding.UTF8.GetBytes(posStr); req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded"; using (Stream streamArr = req.GetRequestStream()) { streamArr.Write(byteStr, 0, byteStr.Length); } using (var res = (HttpWebResponse)req.GetResponse()) { using (StreamReader getJson = new StreamReader(res.GetResponseStream())) { string json = getJson.ReadToEnd(); JavaScriptSerializer js = new JavaScriptSerializer(); recaptcha data = js.Deserialize <recaptcha>(json); valid = Convert.ToBoolean(data.success); } } } if (valid) { try { string acc = fc["acc"]; var em = (from e in db.tEmployees where e.fIdent == acc select new { e.fEmployeeId, e.fIdent, e.fAuth, e.fTitle, e.fName, e.fDepartment, e.fPassword }).FirstOrDefault(); if (fc["acc"].ToString() == em.fIdent && fc["pw"].ToString() == em.fPassword) { Session["name" + em.fEmployeeId] = em.fName; Session["auth" + em.fEmployeeId] = em.fAuth; Session["department" + em.fEmployeeId] = em.fDepartment; Session["title" + em.fEmployeeId] = em.fTitle; HttpCookie cookie = new HttpCookie("id"); cookie.Value = em.fEmployeeId.ToString(); Response.Cookies.Add(cookie); return(RedirectToAction("Index", "Index")); } } catch { ViewBag.info = "帳號密碼錯誤"; return(View()); } ViewBag.info = "帳號密碼錯誤"; return(View()); } else { ViewBag.info = "機器人驗證失敗"; return(View()); } }