public async Task <ActionResult> EditAddWorkUnit(int?id) { if (Session["LoginUserID"] == null) { return(RedirectToAction("Login", "Account")); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } FactoryDailyWork dailyWork = await db.FactoryDailyWorks.FindAsync(id); if (dailyWork == null) { return(HttpNotFound()); } var factoryDailyWorkUnitData = new FactoryDailyWorkUnitData(); factoryDailyWorkUnitData.DailyWork = dailyWork; // ViewBag.WorkUnits = db.FactoryWorkUnits.Where(w => w.StartDate <= dailyWork.Date && (w.Complete == false || w.EndDate >= dailyWork.Date)).ToList(); if (Convert.ToInt32(Session["CurrentCulture"]) == 2) { ViewBag.ProjectID = new SelectList(db.Projects.OrderByDescending(p => p.Date), "ID", "NameKr"); } else { ViewBag.ProjectID = new SelectList(db.Projects.OrderByDescending(p => p.Date), "ID", "NameVn"); } return(View(factoryDailyWorkUnitData)); }
public async Task <ActionResult> EditAddWorkUnit(FactoryDailyWorkUnitData factoryDailyWorkUnitData) { if (Session["LoginUserID"] == null) { return(RedirectToAction("Login", "Account")); } if (ModelState.IsValid) { // db.Entry(materialBuyData).State = EntityState.Modified; FactoryDailyWork dailyWork = db.FactoryDailyWorks.FirstOrDefault(m => m.ID == factoryDailyWorkUnitData.DailyWork.ID); factoryDailyWorkUnitData.WorkUnit.FactoryDailyWorkID = factoryDailyWorkUnitData.DailyWork.ID; // factoryDailyWorkUnitData.WorkUnit.Date = (DateTime)factoryDailyWorkUnitData.DailyWork..Date; FactoryWorkUnit workTemp = db.FactoryWorkUnits.FirstOrDefault(e => e.NoteVn.Equals(factoryDailyWorkUnitData.WorkUnit.NoteVn)); if (workTemp != null) { factoryDailyWorkUnitData.WorkUnit.NoteKr = workTemp.NoteKr; } else { factoryDailyWorkUnitData.WorkUnit.NoteKr = factoryDailyWorkUnitData.WorkUnit.NoteVn; } db.FactoryWorkUnits.Add(factoryDailyWorkUnitData.WorkUnit); dailyWork.FactoryWorkUnits.Add(factoryDailyWorkUnitData.WorkUnit); await db.SaveChangesAsync(); return(RedirectToAction("EditAddWorkUnit", new { id = factoryDailyWorkUnitData.DailyWork.ID })); } return(View(factoryDailyWorkUnitData)); }
public async Task <ActionResult> DeleteConfirmed(int id) { FactoryDailyWork factoryDailyWork = await db.FactoryDailyWorks.FindAsync(id); db.FactoryDailyWorks.Remove(factoryDailyWork); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
// GET: FactoryDailyWork/Delete/5 public async Task <ActionResult> Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } FactoryDailyWork factoryDailyWork = await db.FactoryDailyWorks.FindAsync(id); if (factoryDailyWork == null) { return(HttpNotFound()); } return(View(factoryDailyWork)); }
public async Task <ActionResult> Edit([Bind(Include = "ID,ProparingPersonID,Date,NoteVn,NoteKr,Translate")] FactoryDailyWork factoryDailyWork) { if (ModelState.IsValid) { db.Entry(factoryDailyWork).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index", new { translate = Session["Translate"] })); } var employees = db.Employees.Where(e => e.ResignID == null); ViewBag.ProparingPersonID = new SelectList(employees, "ID", "Name", factoryDailyWork.ProparingPersonID); return(View(factoryDailyWork)); }
public async Task <ActionResult> Create([Bind(Include = "ID,ProparingPersonID,Date,NoteVn,NoteKr,Translate")] FactoryDailyWork factoryDailyWork) { if (ModelState.IsValid) { db.FactoryDailyWorks.Add(factoryDailyWork); await db.SaveChangesAsync(); // return RedirectToAction("Index"); return(RedirectToAction("EditAddWorkUnit", new { id = factoryDailyWork.ID })); } var employees = db.Employees.Where(e => e.ResignID == null); ViewBag.ProparingPersonID = new SelectList(employees, "ID", "Name", factoryDailyWork.ProparingPersonID); return(View(factoryDailyWork)); }
// GET: FactoryDailyWork/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } FactoryDailyWork factoryDailyWork = await db.FactoryDailyWorks.FindAsync(id); if (factoryDailyWork == null) { return(HttpNotFound()); } var employees = db.Employees.Where(e => e.ResignID == null); ViewBag.ProparingPersonID = new SelectList(employees, "ID", "Name", factoryDailyWork.ProparingPersonID); return(View(factoryDailyWork)); }