public ActionResult Update() { string id = Request["id"] ?? ""; string bianhao = Request["bianhao"] ?? ""; string mingcheng = Request["mingcheng"] ?? ""; string gongsi = Request["gongsi"] ?? ""; string miaoshu = Request["miaoshu"] ?? ""; string col1 = Request["col1"] ?? ""; string makedate = Request["makedate"] ?? ""; string makeman = Request["makeman"] ?? ""; int uid = int.Parse(id); try { base_bumen p = ob_base_bumenservice.GetEntityById(base_bumen => base_bumen.ID == uid); p.Bianhao = bianhao.Trim(); p.Mingcheng = mingcheng.Trim(); p.Gongsi = gongsi == "" ? 0 : int.Parse(gongsi); p.Miaoshu = miaoshu.Trim(); p.Col1 = col1.Trim(); p.MakeDate = makedate == "" ? DateTime.Now : DateTime.Parse(makedate); p.MakeMan = makeman == "" ? 0 : int.Parse(makeman); ob_base_bumenservice.UpdateEntity(p); ViewBag.saveok = ViewAddTag.ModifyOk; } catch (Exception ex) { Console.WriteLine(ex.Message); ViewBag.saveok = ViewAddTag.ModifyNo; } return(RedirectToAction("Edit", new { id = uid })); }
public ActionResult Save() { string id = Request["id"] ?? ""; string bianhao = Request["bianhao"] ?? ""; string mingcheng = Request["mingcheng"] ?? ""; string gongsi = Request["gongsi"] ?? ""; string miaoshu = Request["miaoshu"] ?? ""; string col1 = Request["col1"] ?? ""; string makedate = Request["makedate"] ?? ""; string makeman = Request["makeman"] ?? ""; try { base_bumen ob_base_bumen = new base_bumen(); ob_base_bumen.Bianhao = bianhao.Trim(); ob_base_bumen.Mingcheng = mingcheng.Trim(); ob_base_bumen.Gongsi = gongsi == "" ? 0 : int.Parse(gongsi); ob_base_bumen.Miaoshu = miaoshu.Trim(); ob_base_bumen.Col1 = col1.Trim(); ob_base_bumen.MakeDate = makedate == "" ? DateTime.Now : DateTime.Parse(makedate); ob_base_bumen.MakeMan = makeman == "" ? 0 : int.Parse(makeman); ob_base_bumen = ob_base_bumenservice.AddEntity(ob_base_bumen); ViewBag.base_bumen = ob_base_bumen; } catch (Exception ex) { Console.WriteLine(ex.Message); } return(RedirectToAction("Index")); }
public ActionResult Edit(int id) { base_bumen tempData = ob_base_bumenservice.GetEntityById(base_bumen => base_bumen.ID == id && base_bumen.IsDelete == false); ViewBag.base_bumen = tempData; if (tempData == null) { return(View()); } else { base_bumenViewModel base_bumenviewmodel = new base_bumenViewModel(); base_bumenviewmodel.ID = tempData.ID; base_bumenviewmodel.Bianhao = tempData.Bianhao; base_bumenviewmodel.Mingcheng = tempData.Mingcheng; base_bumenviewmodel.Gongsi = tempData.Gongsi; base_bumenviewmodel.Miaoshu = tempData.Miaoshu; base_bumenviewmodel.Col1 = tempData.Col1; base_bumenviewmodel.MakeDate = tempData.MakeDate; base_bumenviewmodel.MakeMan = tempData.MakeMan; return(View(base_bumenviewmodel)); } }