using KJD_Web.Utils; using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace KJD_Web.BLL { public class ProductManage { public string AddProduct(string inputData) { if (!string.IsNullOrEmpty(inputData)) { string user_name = RegexUtils.GetStringQuery(ref inputData, "user_name"); string spu_id = RegexUtils.GetStringQuery(ref inputData, "spu_id"); string skc_id = RegexUtils.GetStringQuery(ref inputData, "skc_id"); string cat_id = RegexUtils.GetStringQuery(ref inputData, "cat_id"); string cat_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "cat_name")); string product_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "product_name")); string product_json = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "product_json")); string size_json = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "size_json")); string main_img = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "main_img")); string notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "notes")); //string sss = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "product_json")); int r2 = 0; int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2); if (string.IsNullOrEmpty(user_name)) { return "{\"code\":500,\"msg\":\"没有用户名\"}"; } string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; MysqlUtils mySql = new MysqlUtils(conn); string sql = ""; sql = "insert into kjd.product (spu_id,skc_id,cat_id,cat_name,product_name,product_json,size_json,main_img,notes,add_time,mdy_time) " + "values ('" + spu_id + "','" + skc_id + "','" + cat_id + "','" + cat_name + "','" + product_name + "','" + product_json + "','" + size_json + "','" + main_img + "','" + notes + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "');"; var rst = mySql.ExecuteNonQuery(sql); mySql.Close(); if (rst) { return "{\"code\":200,\"msg\":\"success\"}"; } else { return "{\"code\":500,\"msg\":\"" + mySql.Message + "\"}"; } } return "{\"code\":19999,\"msg\":\"未知错误\"}"; } } }