public ActionResult ModalInsertUpdate(int id) { sys_center model = new sys_center(); if (id > 0) { model = ct.GetByID(id); } return(PartialView(model)); }
public JsonResult Save(int id, string code, string name, string mobile, string director, string brandname, string address) { SystemMessage.MessageLogin message = new SystemMessage.MessageLogin(); sys_center model = new sys_center(); model.id = id; model.code = code; model.name = name; model.mobile = mobile; model.director = director; model.brandname = brandname; model.address = address; if (model.id == 0) { model.isdelete = false; model.created_at = DateTime.Now; model.created_by = Env.GetUser().username; int ids = ct.Insert(model); if (ids > 0) { message.IsSuccess = true; message.Message = SystemMessageConst.AddSuccess; } else { message.IsSuccess = false; message.Message = SystemMessageConst.AddError; } } else { model.update_at = DateTime.Now; model.update_by = Env.GetUser().username; if (ct.Update(model)) { message.IsSuccess = true; message.Message = SystemMessageConst.UpdateSuccess; } else { message.IsSuccess = false; message.Message = SystemMessageConst.UpdateError; } } return(Json(new { result = message }, JsonRequestBehavior.AllowGet)); }
public int Insert(sys_center model) { try { db.sys_center.Add(model); db.SaveChanges(); return(model.id); } catch (Exception ex) { Common.Common.Util.write_log(ex.Message.ToLower(), "center.txt"); return(0); } }
public bool Update(sys_center model) { try { var ct = db.sys_center.Find(model.id); ct.name = model.name; ct.code = model.code; ct.brandname = model.brandname; ct.address = model.address; ct.update_at = DateTime.Now; ct.update_by = model.update_by; ct.director = model.director; ct.mobile = model.mobile; db.SaveChanges(); return(true); } catch (Exception ex) { Common.Common.Util.write_log(ex.Message.ToLower(), "center.txt"); return(false); } }