// GET: BillPropertyModels/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BillPropertyModels billPropertyModels = db.BillProperties.Find(id); if (billPropertyModels == null) { return(HttpNotFound()); } List <CodeMethod> list = CodeMethod.GetCodeMethod(); List <SelectListItem> item = list.Select(c => new SelectListItem { Value = c.Id, Text = c.Description }).ToList(); foreach (var tmp in item) { if (billPropertyModels.CodeMethod == tmp.Text) { tmp.Selected = true; break; } } ViewBag.List = item; return(View(billPropertyModels)); }
// GET: BillPropertyModels/Create public ActionResult Create() { List <CodeMethod> list = CodeMethod.GetCodeMethod(); List <SelectListItem> item = list.Select(c => new SelectListItem { Value = c.Id, Text = c.Description }).ToList(); ViewBag.List = item; return(View()); }
// GET: ParamCodes/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ParamCodes paramCodes = db.ParamCodes.Find(id); List <Params> paramList = db.Params.ToList(); List <CodeMethod> list = CodeMethod.GetCodeMethod(); List <SelectListItem> item = list.Select(c => new SelectListItem { Value = c.Id, Text = c.Description }).ToList(); foreach (SelectListItem tmp in item) { if (tmp.Text == paramCodes.ParamName) { tmp.Selected = true; } } ViewBag.List = item; List <SelectListItem> item2 = paramList.Select(c => new SelectListItem { Value = c.ParamName, Text = c.ParamName }).ToList(); foreach (SelectListItem tmp in item2) { if (tmp.Text == paramCodes.CodeMethod) { tmp.Selected = true; } } ViewBag.List2 = item2; if (paramCodes == null) { return(HttpNotFound()); } return(View(paramCodes)); }
// GET: ParamCodes/Create public ActionResult Create() { List <Params> paramList = db.Params.ToList(); List <CodeMethod> list = CodeMethod.GetCodeMethod(); List <SelectListItem> item = list.Select(c => new SelectListItem { Value = c.Id, Text = c.Description }).ToList(); ViewBag.List = item; List <SelectListItem> item2 = paramList.Select(c => new SelectListItem { Value = c.ParamName, Text = c.ParamName }).ToList(); ViewBag.List2 = item2; return(View()); }
public ActionResult Edit(ParamCodes paramCode) { if (ModelState.IsValid) { ParamCodes paramCodes = db.ParamCodes.Find(paramCode.Id); switch (paramCode.CodeMethod) { case CodeMethod.Month: paramCodes.Year = 4; paramCodes.Month = 2; paramCodes.Day = 0; paramCodes.SerialNumber = 4; break; case CodeMethod.Serial: paramCodes.Year = 0; paramCodes.Month = 0; paramCodes.Day = 0; paramCodes.SerialNumber = this.GetSerialNumbers(paramCodes.Code); break; case CodeMethod.Manual: paramCodes.Year = 0; paramCodes.Month = 0; paramCodes.Day = 0; paramCodes.SerialNumber = 0; break; case CodeMethod.Five: paramCodes.Year = 0; paramCodes.Month = 0; paramCodes.Day = 0; paramCodes.SerialNumber = 6; break; default: paramCodes.Year = 4; paramCodes.Month = 2; paramCodes.Day = 2; paramCodes.SerialNumber = 2; break; } paramCodes.ChangePerson = this.Name; paramCodes.ChangeTime = DateTime.Now; paramCodes.CodeMethod = paramCode.CodeMethod; paramCodes.Code = paramCode.Code; paramCodes.ParamName = paramCode.ParamName; db.SaveChanges(); return(RedirectToAction("Index")); } else { List <Params> paramList = db.Params.ToList(); List <CodeMethod> list = CodeMethod.GetCodeMethod(); List <SelectListItem> item = list.Select(c => new SelectListItem { Value = c.Id, Text = c.Description }).ToList(); foreach (SelectListItem tmp in item) { if (tmp.Text == paramCode.ParamName) { tmp.Selected = true; } } ViewBag.List = item; List <SelectListItem> item2 = paramList.Select(c => new SelectListItem { Value = c.ParamName, Text = c.ParamName }).ToList(); foreach (SelectListItem tmp in item2) { if (tmp.Text == paramCode.CodeMethod) { tmp.Selected = true; } } ViewBag.List2 = item2; return(View(paramCode)); } }