[HttpPost]// 保存new product public string Save(string json) { dl_basic_users user = Session["user"] as dl_basic_users; decimal userid1 = user.userid; JsonObject obj = new JsonObject(json); decimal com_price = decimal.Parse(obj["com_price"].Value.ToString()); decimal com_belong = userid1; string com_name = obj["com_name"].Value.ToString(); string com_number = obj["com_number"].Value.ToString(); string option1 = obj["option1"].Value.ToString(); decimal com_postage = decimal.Parse(obj["com_postage"].Value.ToString()); string com_content = obj["com_content"].Value.ToString(); string option2 = obj["option2"].Value.ToString(); System.DateTime com_starttime = new System.DateTime(); com_starttime = DateTime.Now; //decimal shop_ID string comment = obj["com_comment"].Value.ToString(); try { using (var db = new NCtecanEntities()) { var product = new t_f_commodity() { com_price = com_price, com_belong = com_belong, com_name = com_name, com_number = com_number, com_postage = com_postage, com_content = com_content, com_starttime = com_starttime, comment = comment, option1 = option1, option2 = option2, isdel = false }; db.t_f_commodity.Add(product); db.SaveChanges(); return("success"); } } catch (Exception ex) { return(ex.Message); } }
public ActionResult Edit(string id) { NCtecanEntities db = new NCtecanEntities(); List <SelectListItem> product = new List <SelectListItem>(); var m = from a in db.sys_role where a.rid == 4 || a.rid == 5 || a.rid == 6 || a.rid == 7 || a.rid == 8 || a.rid == 9 select new { rid = a.option1, rolename = a.rolename }; foreach (var o in m) { product.Add(new SelectListItem { Text = o.rolename, Value = o.rid.ToString() }); } ViewData["product"] = new SelectList(product, "Value", "Text"); decimal productid = decimal.Parse(id); t_f_commodity dd = db.t_f_commodity.Where(s => s.com_ID == productid).First(); ViewData["com_ID"] = dd.com_ID; //商品ID ViewData["com_price"] = dd.com_price; //商品价格 ViewData["com_belong"] = dd.com_belong; //商品所属用户 ViewData["com_name"] = dd.com_name; //商品名称 ViewData["com_number"] = dd.com_number; //商品数量 ViewData["com_postage"] = dd.com_postage; //商品邮费 ViewData["com_content"] = dd.com_content; //商品图片 ViewData["com_state"] = dd.com_state; //商品状态 ViewData["com_starttime"] = dd.com_starttime; //新增时间 ViewData["comment"] = dd.comment; //商品介绍 ViewData["option1"] = dd.option1; //商品类别 ViewData["option2"] = dd.option2; //商品重量 return(View()); }