public JsonResult SingleProductAddSave(T_goodsGY model) { string name = Server.UrlDecode(Request.Cookies["Nickname"].Value); using (TransactionScope sc = new TransactionScope()) { model.create_date = DateTime.Now; model.create_Name = name; db.T_goodsGY.Add(model); try { int i = db.SaveChanges(); if (i > 0) { App_Code.GY gy = new App_Code.GY(); string cmd = ""; cmd = "{" + "\"appkey\":\"171736\"," + "\"method\":\"gy.erp.item.add\"," + "\"sessionkey\":\"f5885504d9c84d1d8146200a4841f4b7\"," + "\"code\":\"" + model.code + "\"," + "\"name\":\"" + model.name + "\"," + "\"simple_name\":\"" + model.simple_name + "\"," + "\"skus\":[]" + "}"; string sign = gy.Sign(cmd); string comcode = "{" + "\"appkey\":\"171736\"," + "\"method\":\"gy.erp.item.add\"," + "\"sessionkey\":\"f5885504d9c84d1d8146200a4841f4b7\"," + "\"code\":\"" + model.code + "\"," + "\"name\":\"" + model.name + "\"," + "\"simple_name\":\"" + model.simple_name + "\"," + "\"sign\":\"" + sign + "\"," + "\"skus\":[]" + "}"; string ret = gy.DoPost("http://api.guanyierp.com/rest/erp_open", comcode); JsonData jsonData = null; jsonData = JsonMapper.ToObject(ret); string sd = jsonData[0].ToString(); if (sd == "True") { sc.Complete(); return(Json(new { State = "Success" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { State = "Faile" }, JsonRequestBehavior.AllowGet)); } } } catch (DbEntityValidationException ex) { return(Json(new { State = "Faile", Message = ex.EntityValidationErrors.First().ValidationErrors.First().ErrorMessage }, JsonRequestBehavior.AllowGet)); } return(Json(new { State = "Faile" }, JsonRequestBehavior.AllowGet)); } }
public JsonResult ViewSingleProductsplitCheckSave(string code) { using (TransactionScope sc = new TransactionScope()) { T_goodsGY model = db.T_goodsGY.SingleOrDefault(a => a.code == code); model.isexamine = "1"; db.Entry <T_goodsGY>(model).State = System.Data.Entity.EntityState.Modified; try { int i = db.SaveChanges(); if (i > 0) { App_Code.GY gy = new App_Code.GY(); string cmd = ""; cmd = "{" + "\"appkey\":\"171736\"," + "\"method\":\"gy.erp.item.add\"," + "\"sessionkey\":\"f5885504d9c84d1d8146200a4841f4b7\"," + "\"code\":\"" + model.code + "\"," + "\"name\":\"" + model.name + "\"," + "\"simple_name\":\"" + model.simple_name + "\"," + "\"skus\":[]" + "}"; string sign = gy.Sign(cmd); string comcode = "{" + "\"appkey\":\"171736\"," + "\"method\":\"gy.erp.item.add\"," + "\"sessionkey\":\"f5885504d9c84d1d8146200a4841f4b7\"," + "\"code\":\"" + model.code + "\"," + "\"name\":\"" + model.name + "\"," + "\"simple_name\":\"" + model.simple_name + "\"," + "\"sign\":\"" + sign + "\"," + "\"skus\":[]" + "}"; string ret = gy.DoPost("http://api.guanyierp.com/rest/erp_open", comcode); JsonData jsonData = null; jsonData = JsonMapper.ToObject(ret); string sd = jsonData[0].ToString(); if (sd == "True") { sc.Complete(); return(Json(new { State = "Success" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { State = "Faile", Message = "审核失败" }, JsonRequestBehavior.AllowGet)); } } } catch (DbEntityValidationException ex) { return(Json(new { State = "Faile", Message = "审核失败" }, JsonRequestBehavior.AllowGet)); } return(Json(new { State = "Faile", Message = "审核失败" }, JsonRequestBehavior.AllowGet)); } }
public JsonResult QueryGoodsByBarCode(string BarCode) { T_goodsGY goodsModel = db.T_goodsGY.SingleOrDefault(a => a.barcode == BarCode); if (goodsModel != null) { return(Json(new { Name = goodsModel.name, Code = goodsModel.code }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { Name = "", Code = "" }, JsonRequestBehavior.AllowGet)); } }
public JsonResult ViewSingleProductsplitAddSave(T_goodsGY model) { string name = Server.UrlDecode(Request.Cookies["Nickname"].Value); using (TransactionScope sc = new TransactionScope()) { string theCode = model.TheCode; int splitNumber = int.Parse(model.splitNumber.ToString()); T_goodsGY GoodsGy = db.T_goodsGY.SingleOrDefault(a => a.TheCode == theCode && a.splitNumber == splitNumber); if (GoodsGy != null) { return(Json(new { State = "Faile", Message = "该产品及数量已拆分过" }, JsonRequestBehavior.AllowGet)); } model.create_date = DateTime.Now; model.create_Name = name; model.isexamine = "0"; model.ExamineName = "雨婷"; model.code = RandomNumberGoods("C"); db.T_goodsGY.Add(model); try { int i = db.SaveChanges(); if (i > 0) { sc.Complete(); return(Json(new { State = "Success" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { State = "Faile", Message = "保存失败" }, JsonRequestBehavior.AllowGet)); } } catch (DbEntityValidationException ex) { return(Json(new { State = "Faile", Message = ex.EntityValidationErrors.First().ValidationErrors.First().ErrorMessage }, JsonRequestBehavior.AllowGet)); } return(Json(new { State = "Faile" }, JsonRequestBehavior.AllowGet)); } }
public ContentResult GetRetreatgoodsGY(Lib.GridPager pager, string queryStr) { IQueryable <T_goodsGY> queryData = db.T_goodsGY.Where(a => a.combine == "False").AsQueryable(); if (!string.IsNullOrEmpty(queryStr)) { queryData = queryData.Where(a => a.name != null && a.name.Contains(queryStr) || a.code != null && a.code.Contains(queryStr)); } pager.totalRows = queryData.Count(); //分页 queryData = queryData.OrderBy(c => c.code).Skip((pager.page - 1) * pager.rows).Take(pager.rows); List <T_goodsGY> list = new List <T_goodsGY>(); foreach (var item in queryData) { T_goodsGY i = new T_goodsGY(); i = item; list.Add(i); } string json = "{\"total\":" + pager.totalRows + ",\"rows\":" + JsonConvert.SerializeObject(list) + "}"; return(Content(json)); }
public JsonResult ViewSingleProductPartsAddSave(T_goodsGY model) { string name = Server.UrlDecode(Request.Cookies["Nickname"].Value); using (TransactionScope sc = new TransactionScope()) { T_ProductClass ProductClassmodel = db.T_ProductClass.SingleOrDefault(a => a.ClassName == model.classify); string ClassCode = ProductClassmodel.ClassCode; T_ProductManufactor ProductManufactormodel = db.T_ProductManufactor.SingleOrDefault(a => a.ManufactorName == model.Manufactor); string ManufactorCode = ProductManufactormodel.ManufactorCode; string Specifications = model.Specifications; string code = "S" + ClassCode + ManufactorCode + Specifications; List <T_goodsGY> goodsList = db.T_goodsGY.Where(a => a.code == code).ToList(); if (goodsList.Count > 0) { return(Json(new { State = "Faile", Message = "该组合方式的配件已存在" }, JsonRequestBehavior.AllowGet)); } model.code = code; model.create_date = DateTime.Now; model.create_Name = name; db.T_goodsGY.Add(model); try { int i = db.SaveChanges(); if (i > 0) { App_Code.GY gy = new App_Code.GY(); string cmd = ""; cmd = "{" + "\"appkey\":\"171736\"," + "\"method\":\"gy.erp.item.add\"," + "\"sessionkey\":\"f5885504d9c84d1d8146200a4841f4b7\"," + "\"code\":\"" + model.code + "\"," + "\"name\":\"" + model.name + "\"," + "\"simple_name\":\"" + model.simple_name + "\"," + "\"skus\":[]" + "}"; string sign = gy.Sign(cmd); string comcode = "{" + "\"appkey\":\"171736\"," + "\"method\":\"gy.erp.item.add\"," + "\"sessionkey\":\"f5885504d9c84d1d8146200a4841f4b7\"," + "\"code\":\"" + model.code + "\"," + "\"name\":\"" + model.name + "\"," + "\"simple_name\":\"" + model.simple_name + "\"," + "\"sign\":\"" + sign + "\"," + "\"skus\":[]" + "}"; string ret = gy.DoPost("http://api.guanyierp.com/rest/erp_open", comcode); JsonData jsonData = null; jsonData = JsonMapper.ToObject(ret); string sd = jsonData[0].ToString(); if (sd == "True") { sc.Complete(); return(Json(new { State = "Success" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { State = "Faile", Message = "保存失败" }, JsonRequestBehavior.AllowGet)); } } } catch (DbEntityValidationException ex) { return(Json(new { State = "Faile", Message = "保存失败" }, JsonRequestBehavior.AllowGet)); } return(Json(new { State = "Faile", Message = "保存失败" }, JsonRequestBehavior.AllowGet)); } }
public ContentResult TBguanyi() { GY gy = new GY(); string cmd = "{" + "\"appkey\":\"171736\"," + "\"method\":\"gy.erp.items.get\"," + "\"page_no\":1," + "\"page_size\":50," + "\"sessionkey\":\"f5885504d9c84d1d8146200a4841f4b7\"" + "}"; string sign = gy.Sign(cmd); cmd = cmd.Replace("}", ",\"sign\":\"" + sign + "\"}"); string ret = gy.DoPost("http://api.guanyierp.com/rest/erp_open", cmd); JsonData jsonData = null; jsonData = JsonMapper.ToObject(ret); // jsonData["success"] int shuliang = int.Parse(jsonData["total"].ToString()); int i = 0; int yeshu = shuliang / 50 + (shuliang % 50 == 0 ? 0 : 1); for (int x = 1; x <= yeshu; x++) { cmd = "{" + "\"appkey\":\"171736\"," + "\"method\":\"gy.erp.items.get\"," + "\"page_no\":" + x + "," + "\"page_size\":50," + "\"sessionkey\":\"f5885504d9c84d1d8146200a4841f4b7\"" + "}"; sign = gy.Sign(cmd); cmd = cmd.Replace("}", ",\"sign\":\"" + sign + "\"}"); ret = gy.DoPost("http://api.guanyierp.com/rest/erp_open", cmd); jsonData = null; jsonData = JsonMapper.ToObject(ret); T_goodsGY model = new T_goodsGY(); int ss = 50; if (x == yeshu) { ss = int.Parse(shuliang.ToString().Substring(shuliang.ToString().Length - 2, 2)); } for (int z = 0; z < ss; z++) { i++; JsonData skus = jsonData["items"][z]; DateTime create_date = new DateTime(); string name = ""; string code = ""; string note = ""; string combine = ""; double weight = 0; string simple_name = ""; string category_code = ""; string category_name = ""; string supplier_code = ""; string item_unit_code = ""; double package_point = 0; double sales_point = 0; decimal sales_price = 0; decimal purchase_price = 0; decimal agent_price = 0; decimal cost_price = 0; string pic_url = ""; string stock_status_code = ""; if (skus["create_date"] != null) { create_date = DateTime.Parse(skus["create_date"].ToString()); } if (skus["name"] != null) { name = skus["name"].ToString(); } if (skus["code"] != null) { code = skus["code"].ToString(); } if (skus["note"] != null) { note = skus["note"].ToString(); } if (skus["combine"] != null) { combine = skus["combine"].ToString(); } if (skus["weight"] != null) { weight = double.Parse(skus["weight"].ToString()); } if (skus["simple_name"] != null) { simple_name = skus["simple_name"].ToString(); } if (skus["category_code"] != null) { category_code = skus["category_code"].ToString(); } if (skus["category_name"] != null) { category_name = skus["category_name"].ToString(); } if (skus["supplier_code"] != null) { supplier_code = skus["supplier_code"].ToString(); } if (skus["item_unit_code"] != null) { item_unit_code = skus["item_unit_code"].ToString(); } if (skus["package_point"] != null) { package_point = double.Parse(skus["package_point"].ToString()); } if (skus["sales_point"] != null) { sales_point = double.Parse(skus["sales_point"].ToString()); } if (skus["sales_price"] != null) { sales_price = decimal.Parse(skus["sales_price"].ToString()); } if (skus["purchase_price"] != null) { purchase_price = decimal.Parse(skus["purchase_price"].ToString()); } if (skus["agent_price"] != null) { agent_price = decimal.Parse(skus["agent_price"].ToString()); } if (skus["cost_price"] != null) { cost_price = decimal.Parse(skus["cost_price"].ToString()); } if (skus["pic_url"] != null) { pic_url = skus["pic_url"].ToString(); } if (skus["stock_status_code"] != null) { stock_status_code = skus["stock_status_code"].ToString(); } List <T_goodsGY> Querymodel = db.T_goodsGY.Where(a => a.code == code).ToList(); if (Querymodel.Count == 0) { model.create_date = create_date; model.name = name; model.code = code; model.note = note; model.weight = weight; model.combine = combine; model.simple_name = simple_name; model.category_code = category_code; model.category_name = category_name; model.supplier_code = supplier_code; model.item_unit_code = item_unit_code; model.package_point = package_point; model.sales_point = sales_point; model.sales_price = sales_price; model.purchase_price = purchase_price; model.agent_price = agent_price; model.cost_price = cost_price; model.stock_status_code = stock_status_code; model.pic_url = pic_url; db.T_goodsGY.Add(model); db.SaveChanges(); } } } if (i == shuliang) { return(Content(i.ToString())); } else { return(Content("0")); } }