public ActionResult Edit([Bind(Include = "PopID,Date,FacID,PopTotal,PopNew,PopLeft,PopLeft3")] FacPopulation facPopulation) { if (ModelState.IsValid) { _db.Entry(facPopulation).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Factory = new SelectList(_db.Factories, "FacID", "FacName", facPopulation.FacID); return(View(facPopulation)); }
public ActionResult Permissionsubmit(FormCollection chk) { PCGEntities db = new PCGEntities(); string[] values = chk.GetValues("HaveSelect");//取得要的權限的工廠名字 for (var i = 0; i < values.Count(); i++) { int FacNo = Convert.ToInt32(values[i]); var queryzoneID = from f in db.Factories //查出挑出一項的zoneID where f.FacNo == FacNo select f.ZoneID; var queryFacNo = from f in db.Factories //查出挑出一項的zoneID where f.FacNo == FacNo select f.FacNo; var queryemp = (from em in db.Administrators orderby em.EmployeeID descending select em.EmployeeID).Take(1); //查出現在最高值 var maxstringemp = queryemp; //取得新增之後的emp名 int MaxIntEmp = maxstringemp.First(); int IntFacNo = queryFacNo.First(); int IntZone = (int)queryzoneID.First(); Permission per = new Permission(); per.EmployeeID = MaxIntEmp; per.ZoneID = IntZone; per.FacNo = IntFacNo; db.Entry(per).State = EntityState.Added; db.SaveChanges(); } return(RedirectToAction("PMSTART")); }
public ActionResult Delete(Administrators ad) { PCGEntities db = new PCGEntities(); db.Entry(ad).State = EntityState.Deleted; db.SaveChanges(); return(RedirectToAction("PMSTART")); }
public ActionResult Create([Bind(Include = "ancID,publisher,ancDate,ancTitle,ancContent")] Announcement announcement) { if (ModelState.IsValid) { _db.Announcement.Add(announcement); _db.SaveChanges(); return(RedirectToAction("Index")); } return(View(announcement)); }
public ActionResult Edit([Bind(Include = "FacNo,FacID,FacName,ZoneID,EditTime,Supervisor")] Factories factories) { if (ModelState.IsValid) { string dateString = DateTime.Now.ToString("yyyy/MM/dd HH:mm"); string pattern = "yyyy/MM/dd HH:mm"; DateTime parsedDate; if (DateTime.TryParseExact(dateString, pattern, null, DateTimeStyles.None, out parsedDate)) { factories.EditTime = parsedDate; } _db.Entry(factories).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Supervisor = new SelectList(_db.Administrators, "EmployeeID", "Name", factories.Supervisor); ViewBag.ZoneID = new SelectList(_db.Zone, "ZoneID", "Country", factories.ZoneID); return(View(factories)); }
public ActionResult Edit(PersonInformation edit) { PCGEntities db = new PCGEntities(); Administrators ad2 = db.Administrators.Find(edit.EmployeeID); ad2.FacID = edit.FacID; ad2.Character = edit.Character; ad2.Name = edit.Name; ad2.Email = edit.Email; ad2.Account = edit.Account; ad2.Password = edit.Password; db.Entry(ad2).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Edit")); //PCGEntities db = new PCGEntities(); //db.Entry(ad).State = EntityState.Modified; //db.SaveChanges(); //return View(ad); }
public ActionResult ADDAD(PersonInformation ad, FormCollection chk) { TempData["Name"] = ad.Name; TempData["Character"] = ad.Character; TempData["Email"] = ad.Email; TempData["Account"] = ad.Account; TempData["Password"] = ad.Password; if (string.IsNullOrEmpty(ad.Name)) { this.ModelState.AddModelError("Name", "Nmae不可為空白"); TempData["Nameerror"] = "Name不可為空白"; } if (string.IsNullOrEmpty(ad.Character)) { this.ModelState.AddModelError("Charactererror", "Character不可為空白"); TempData["Charactererror"] = "Character不可為空白"; } if (string.IsNullOrEmpty(ad.Email)) { this.ModelState.AddModelError("Emailerror", "Email不可為空白"); TempData["Emailerror"] = "Email不可為空白"; } if (string.IsNullOrEmpty(ad.Account)) { this.ModelState.AddModelError("Account", "Account不可為空白"); TempData["Accounterror"] = "Account不可為空白"; } if (string.IsNullOrEmpty(ad.Password)) { this.ModelState.AddModelError("Password", "Password不可為空白"); TempData["Passworderror"] = "Password不可為空白"; } if (ModelState.IsValid) { PCGEntities db = new PCGEntities(); Administrators ad2 = new Administrators(); ad2.FacID = ad.FacID; ad2.Character = ad.Character; ad2.Name = ad.Name; ad2.Email = ad.Email; ad2.Account = ad.Account; ad2.Password = ad.Password; db.Entry(ad2).State = EntityState.Added; db.SaveChanges(); string[] values = chk.GetValues("HaveSelect");//取得要的權限的工廠名字 for (var i = 0; i < values.Count(); i++) { int FacNo = Convert.ToInt32(values[i]); var queryzoneID = from f in db.Factories //查出挑出一項的zoneID where f.FacNo == FacNo select f.ZoneID; var queryFacNo = from f in db.Factories //查出挑出一項的zoneID where f.FacNo == FacNo select f.FacNo; var queryemp = (from em in db.Administrators orderby em.EmployeeID descending select em.EmployeeID).Take(1); //查出現在最高值 var maxstringemp = queryemp; //取得新增之後的emp名 int MaxIntEmp = maxstringemp.First(); int IntFacNo = queryFacNo.First(); int IntZone = (int)queryzoneID.First(); Permission per = new Permission(); per.EmployeeID = MaxIntEmp; per.ZoneID = IntZone; per.FacNo = IntFacNo; db.Entry(per).State = EntityState.Added; db.SaveChanges(); } TempData["Name"] = null; TempData["Character"] = null; TempData["Email"] = null; TempData["Account"] = null; TempData["Password"] = null; return(RedirectToAction("PMSTART")); } return(Redirect("ADDAD")); }