public DataOperation(List<Model.MigrationDataSet> mds, MainForm form) { this.mds = mds; this.connectionString = System.Configuration.ConfigurationSettings.AppSettings["MySqlConnectionString"]; prod = new Product(); pItem = new ProductItem(); pM = new PriceMaster(); iPrice = new ItemPrice(); categorySet = new ProductCategorySet(); pMap = new ProductMigrationMap(); _prodMgr = new ProductMgr(this.connectionString); _priceMgr = new PriceMasterMgr(this.connectionString); _prodItemMgr = new ProductItemMgr(this.connectionString); _itemPriceMgr = new ItemPriceMgr(this.connectionString); _vendorBrandMgr = new VendorBrandMgr(this.connectionString); _vendorMgr = new VendorMgr(this.connectionString); _pMap = new ProductMigrationMgr(this.connectionString); _productCategorySetMgr = new ProductCategorySetMgr(this.connectionString); _productNoticeSetMgr = new ProductNoticeSetMgr(this.connectionString); _productTagSetMgr = new ProductTagSetMgr(this.connectionString); _productPictureMgr = new ProductPictureMgr(this.connectionString); _proStatusHistoryMgr = new ProductStatusHistoryMgr(connectionString); _proSpecMgr = new ProductSpecMgr(connectionString); _siteMgr = new SiteMgr(connectionString); this.form = form; }
public ProductSpecMgr(string connectionStr) { _specDao = new BLL.gigade.Dao.ProductSpecDao(connectionStr); this.connectionStr = connectionStr; _proMgr = new BLL.gigade.Mgr.ProductMgr(connectionStr); _sqlDao = new Dao.MySqlDao(connectionStr); }
public HttpResponseBase GetVendorProductSpec() { string json = string.Empty; DataTable _dt = new DataTable(); ProductQuery query = new ProductQuery(); int totalCount = 0; try { query.Start = Convert.ToInt32(Request.Params["start"] ?? "0"); query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25"); query.Product_Id = Convert.ToUInt32(Request.Params["product_id"]); _IProductMgr = new ProductMgr(mySqlConnectionString); _dt = _IProductMgr.GetVendorProductSpec(query, out totalCount); IsoDateTimeConverter timeConverter = new IsoDateTimeConverter(); timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"; json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(_dt, Formatting.Indented, timeConverter) + "}"; } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false,totalCount:0,data:[]}"; } this.Response.Clear(); this.Response.Write(json.ToString()); this.Response.End(); return this.Response; }
public ProductCategorySetMgr(string conStr) { _categorySetDao = new ProductCategorySetDao(conStr); _proMgr = new ProductMgr(conStr); _sqlDao = new MySqlDao(conStr); }
/// <summary> /// 獲取商品數據 /// </summary> /// <returns></returns> public HttpResponseBase GetTrialProdCateList() { List<TrialProdCateQuery> store = new List<TrialProdCateQuery>(); string json = string.Empty; try { TrialProdCateQuery query = new TrialProdCateQuery(); #region 獲取query對象數據 query.Start = Convert.ToInt32(Request.Params["start"] ?? "0"); if (!string.IsNullOrEmpty(Request.Form["limit"])) { query.Limit = Convert.ToInt32(Request.Params["limit"]); } #endregion _trialProdMgr = new TrialProdCateMgr(mySqlConnectionString); _prodMgr = new ProductMgr(mySqlConnectionString); prodCateMgr = new ProductCategoryMgr(mySqlConnectionString);//實例化對象mgr _giftMgr = new PromotionsAmountGiftMgr(mySqlConnectionString); _trialMgr = new PromotionsAmountTrialMgr(mySqlConnectionString); int totalCount = 0; store = _trialProdMgr.Query(query, out totalCount); foreach (var item in store) { item.product_name = _prodMgr.QueryClassify(Convert.ToUInt32(item.product_id)).Product_Name; item.category_name = prodCateMgr.QueryAll(new ProductCategory { category_id = item.category_id }).FirstOrDefault().category_name; if (item.event_id.StartsWith("T1") || item.event_id.StartsWith("T2")) { int id = Convert.ToInt16(item.event_id.Substring(2).ToString()); item.event_name = _trialMgr.GetModel(id).name; } if (item.event_id.StartsWith("G3")) { int id = Convert.ToInt16(item.event_id.Substring(2).ToString()); item.event_name = _giftMgr.GetModel(id).name; } } IsoDateTimeConverter timeConverter = new IsoDateTimeConverter(); //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式 timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"; json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(store, Formatting.Indented, timeConverter) + "}";//返回json數據 } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase QueryProList(string priceMasterIds) { string json = string.Empty; try { _prodMgr = new ProductMgr(connectionString); int totalCount = 0; List<QueryandVerifyCustom> pros = _prodMgr.QueryByProSite(priceMasterIds); totalCount = pros.Count; json = new JObject( new JProperty("succes", true), new JProperty("totalCount", totalCount), new JProperty("item", new JArray( from p in pros select new JObject( new JProperty("price_master_id", p.price_master_id), new JProperty("product_image", p.product_image != "" ? (imgServerPath + prod50Path + GetDetailFolder(p.product_image) + p.product_image) : defaultImg), new JProperty("product_id", p.product_id), new JProperty("brand_name", p.brand_name), new JProperty("product_name", p.product_name), new JProperty("prod_sz", p.prod_sz), new JProperty("combination", p.combination), new JProperty("combination_id", p.combination_id), new JProperty("price_type", p.price_type), new JProperty("price_type_id", p.price_type_id), new JProperty("product_status", p.product_status), new JProperty("site_name", p.site_name), new JProperty("user_level", p.user_level), new JProperty("price", p.price), new JProperty("cost", p.cost), new JProperty("event_price", p.event_price), new JProperty("event_cost", p.event_cost), new JProperty("event_start", CommonFunction.GetNetTime(p.event_start).ToString("yyyy/MM/dd HH:mm:ss")), new JProperty("event_end", CommonFunction.GetNetTime(p.event_end).ToString("yyyy/MM/dd HH:mm:ss")), new JProperty("prepaid", p.prepaid) ))) ).ToString(); // json = "{succes:true,totalCount:" + totalCount + ",item:" + JsonConvert.SerializeObject(pros) + "}"; } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{succes:true,totalCount:0,item:[]}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase productPictrueTempSave() { string json = "{success:true}"; ProductTemp pTemp = new ProductTemp(); _productTempMgr = new ProductTempMgr(connectionString); _specTempMgr = new ProductSpecTempMgr(connectionString); _productPicMgr = new ProductPictureMgr(connectionString); _specMgr = new ProductSpecMgr(connectionString); if (string.IsNullOrEmpty(Request.Params["product_id"])) { if (!string.IsNullOrEmpty(Request.Params["image_InsertValue"])) pTemp.Product_Image = Request.Params["image_InsertValue"]; if (!string.IsNullOrEmpty(Request.Params["image_MobileValue"])) pTemp.Mobile_Image = Request.Params["image_MobileValue"];//如果手機說明圖有值,將值賦予Moibile_Image edit by wwei0216w 2015/3/18 if (!string.IsNullOrEmpty(Request.Params["productMedia"])) pTemp.product_media = Request.Params["productMedia"]; if (!string.IsNullOrEmpty(Request.Params["specify_Product_alt"])) pTemp.Product_alt = Request.Params["specify_Product_alt"];//add by wwei0216w 2015/4/9 pTemp.Writer_Id = (Session["caller"] as Caller).user_id; pTemp.Combo_Type = COMBO_TYPE; if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) { pTemp.Product_Id = Request.Form["OldProductId"]; } ProductSpecTemp pSpec = new ProductSpecTemp(); List<ProductSpecTemp> pSpecList = new List<ProductSpecTemp>(); if (!string.IsNullOrEmpty(Request.Params["spec_InsertValue"])) { string[] Values = Request.Form["spec_InsertValue"].ToString().Split(';'); for (int i = 0; i < Values.Length - 1; i++) { pSpec = new ProductSpecTemp(); pSpec.Writer_Id = (Session["caller"] as Caller).user_id; pSpec.product_id = pTemp.Product_Id; string[] perValue = Values[i].Split(','); if (!string.IsNullOrEmpty(perValue[0])) { pSpec.spec_image = perValue[0]; }; if (!string.IsNullOrEmpty(perValue[1])) { pSpec.spec_id = uint.Parse(perValue[1]); }; if (!string.IsNullOrEmpty(perValue[2])) { pSpec.spec_sort = uint.Parse(perValue[2]); }; if (!string.IsNullOrEmpty(perValue[3])) { pSpec.spec_status = uint.Parse(perValue[3]); }; pSpecList.Add(pSpec); } } List<ProductPictureTemp> picList = new List<ProductPictureTemp>(); _pPicTempMgr = new ProductPictureTempImplMgr(connectionString); ProductPictureTemp pPic = new ProductPictureTemp(); if (!string.IsNullOrEmpty(Request.Params["picture_InsertValue"])) { string[] Values = Request.Form["picture_InsertValue"].ToString().Split(';'); for (int i = 0; i < Values.Length - 1; i++) { pPic = new ProductPictureTemp(); string[] perValue = Values[i].Split(','); pPic.combo_type = COMBO_TYPE; pPic.writer_Id = (Session["caller"] as Caller).user_id; pPic.product_id = pTemp.Product_Id; if (!string.IsNullOrEmpty(perValue[0])) { pPic.image_filename = perValue[0]; }; if (!string.IsNullOrEmpty(perValue[1])) { pPic.image_sort = uint.Parse(perValue[1]); }; if (!string.IsNullOrEmpty(perValue[2])) { pPic.image_state = uint.Parse(perValue[2]); }; picList.Add(pPic); } } //關於手機APP的代碼部份 List<ProductPictureTemp> picAppList = new List<ProductPictureTemp>(); //IProductPictureTempImplAppMgr ppt = new ProductPictureAppTempImplMgr(connectionString); ProductPictureTemp pa = new ProductPictureTemp(); if (!string.IsNullOrEmpty(Request.Params["mobilePic_InsertValue"])) { string[] Values = Request.Form["mobilePic_InsertValue"].ToString().Split(';'); for (int i = 0; i < Values.Length - 1; i++) { pa = new ProductPictureTemp(); string[] AppValue = Values[i].Split(','); pa.combo_type = COMBO_TYPE; pa.writer_Id = (Session["caller"] as Caller).user_id; pa.product_id = pTemp.Product_Id; if (!string.IsNullOrEmpty(AppValue[0])) { pa.image_filename = AppValue[0]; }; if (!string.IsNullOrEmpty(AppValue[1])) { pa.image_sort = uint.Parse(AppValue[1]); }; if (!string.IsNullOrEmpty(AppValue[2])) { pa.image_state = uint.Parse(AppValue[2]); }; picAppList.Add(pa); } } try { int type = 1;//1:商品說明圖,2:手機App說明圖 int writer_id = (Session["caller"] as Caller).user_id; //保存至productTemp if (pTemp.Product_Image != "" || pTemp.product_media != "" || pTemp.Mobile_Image != "" || pTemp.Product_alt != "") { _productTempMgr.ProductTempUpdate(pTemp, "pic"); } //保存規格圖 _specTempMgr.Update(pSpecList, "image"); //保存說明圖 string oldProductId = "0"; if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) { oldProductId = Request.Form["OldProductId"]; } _pPicTempMgr.Save(picList, new ProductPictureTemp() { writer_Id = writer_id, combo_type = COMBO_TYPE, product_id = oldProductId }, type);// edit by wangwei0216w 註釋掉_pPicTempMgr.Save 以解決複製后不能讀取圖片路勁到數據庫 type = 2; _pPicTempMgr.Save(picAppList, new ProductPictureTemp() { writer_Id = writer_id, combo_type = COMBO_TYPE, product_id = oldProductId }, type); } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false,msg:\"" + Resources.Product.EDIT_FAIL + "\"}"; } } else//更新正式表 { Product p = new Product(); uint productId = uint.Parse(Request.Params["product_id"]); if (!string.IsNullOrEmpty(Request.Params["image_InsertValue"])) p.Product_Image = Request.Params["image_InsertValue"];//如果商品說明圖有值,將值賦予Product_Image if (!string.IsNullOrEmpty(Request.Params["image_MobileValue"])) p.Mobile_Image = Request.Params["image_MobileValue"];//如果手機說明圖有值,將值賦予Moibile_Image edit by wwei0216w 2015/3/18 if (!string.IsNullOrEmpty(Request.Params["productMedia"])) p.product_media = Request.Params["productMedia"]; if (!string.IsNullOrEmpty(Request.Params["specify_Product_alt"])) p.Product_alt = Request.Params["specify_Product_alt"];//add by wwei0216w 2015/4/9 p.Product_Id = productId; _productMgr = new ProductMgr(connectionString); ProductSpec pSpec = new ProductSpec(); List<ProductSpec> pSpecList = new List<ProductSpec>(); if (!string.IsNullOrEmpty(Request.Params["spec_InsertValue"])) { string[] Values = Request.Form["spec_InsertValue"].ToString().Split(';'); for (int i = 0; i < Values.Length - 1; i++) { pSpec = new ProductSpec(); pSpec.product_id = productId; string[] perValue = Values[i].Split(','); if (!string.IsNullOrEmpty(perValue[0])) { pSpec.spec_image = perValue[0]; }; if (!string.IsNullOrEmpty(perValue[1])) { pSpec.spec_id = uint.Parse(perValue[1]); }; if (!string.IsNullOrEmpty(perValue[2])) { pSpec.spec_sort = uint.Parse(perValue[2]); }; if (!string.IsNullOrEmpty(perValue[3])) { pSpec.spec_status = uint.Parse(perValue[3]); }; pSpecList.Add(pSpec); } } List<ProductPicture> picList = new List<ProductPicture>(); _productPicMgr = new ProductPictureMgr(connectionString); ProductPicture pPic = new ProductPicture(); if (!string.IsNullOrEmpty(Request.Params["picture_InsertValue"])) { string[] Values = Request.Form["picture_InsertValue"].ToString().Split(';'); for (int i = 0; i < Values.Length - 1; i++) { pPic = new ProductPicture(); string[] perValue = Values[i].Split(','); pPic.product_id = int.Parse(Request.Params["product_id"]); if (!string.IsNullOrEmpty(perValue[0])) { pPic.image_filename = perValue[0]; }; if (!string.IsNullOrEmpty(perValue[1])) { pPic.image_sort = uint.Parse(perValue[1]); }; if (!string.IsNullOrEmpty(perValue[2])) { pPic.image_state = uint.Parse(perValue[2]); }; picList.Add(pPic); } } //手機app圖檔 List<ProductPicture> appList = new List<ProductPicture>(); _productPicMgr = new ProductPictureMgr(connectionString); ProductPicture apppPic = new ProductPicture(); if (!string.IsNullOrEmpty(Request.Params["mobilePic_InsertValue"])) { string[] Values = Request.Form["mobilePic_InsertValue"].ToString().Split(';'); for (int i = 0; i < Values.Length - 1; i++) { apppPic = new ProductPicture(); string[] perValue = Values[i].Split(','); apppPic.product_id = int.Parse(Request.Params["product_id"]); if (!string.IsNullOrEmpty(perValue[0])) { apppPic.image_filename = perValue[0]; }; if (!string.IsNullOrEmpty(perValue[1])) { apppPic.image_sort = uint.Parse(perValue[1]); }; if (!string.IsNullOrEmpty(perValue[2])) { apppPic.image_state = uint.Parse(perValue[2]); }; appList.Add(apppPic); } } try { _productMgr.Update_Product_Spec_Picture(p, pSpecList, picList, appList); json = "{success:true,msg:\"" + Resources.Product.SAVE_SUCCESS + "\"}"; } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:true,msg:\"" + Resources.Product.SAVE_FAIL + "\"}"; } } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase fortuneQuery() { string resultStr = "{success:false}"; Caller _caller = (Session["caller"] as Caller); try { if (!string.IsNullOrEmpty(Request.Form["ProductId"])) { //product _productMgr = new ProductMgr(connectionString); Product pro = null; pro = _productMgr.Query(new Product { Product_Id = uint.Parse(Request.Params["ProductId"]) }).FirstOrDefault(); if (pro != null) { resultStr = "{success:true,data:" + JsonConvert.SerializeObject(pro) + "}"; } } else { //product_temp _productTempMgr = new ProductTempMgr(connectionString); ProductTemp result = null; ProductTemp query = new ProductTemp { Writer_Id = _caller.user_id, Combo_Type = COMBO_TYPE }; if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) { query.Product_Id = Request.Form["OldProductId"]; } result = _productTempMgr.GetProTemp(query); if (result != null) { resultStr = "{success:true,data:" + JsonConvert.SerializeObject(result) + "}"; } } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); } this.Response.Clear(); this.Response.Write(resultStr); this.Response.End(); return this.Response; }
public HttpResponseBase SaveDescription() { string json = string.Empty; try { string tags = Request.Form["Tags"] ?? ""; string notices = Request.Form["Notice"] ?? ""; JavaScriptSerializer jsSer = new JavaScriptSerializer(); if (!string.IsNullOrEmpty(Request.Form["ProductId"])) { uint product_id = uint.Parse(Request.Form["ProductId"]); _productMgr = new ProductMgr(connectionString); Product product = _productMgr.Query(new Product { Product_Id = product_id }).FirstOrDefault(); if (product != null) { product.Page_Content_1 = Request.Form["page_content_1"] ?? ""; product.Page_Content_2 = Request.Form["page_content_2"] ?? ""; product.Page_Content_3 = Request.Form["page_content_3"] ?? ""; product.Product_Keywords = Request.Form["product_keywords"] ?? ""; if (!string.IsNullOrEmpty(Request.Form["product_buy_limit"])) { product.Product_Buy_Limit = uint.Parse(Request.Form["product_buy_limit"]); } ArrayList sqls = new ArrayList(); sqls.Add(_productMgr.Update(product)); //TAG List<ProductTagSet> tagSets = jsSer.Deserialize<List<ProductTagSet>>(tags); tagSets.ForEach(m => m.product_id = product_id); _productTagSetMgr = new ProductTagSetMgr(""); sqls.Add(_productTagSetMgr.Delete(new ProductTagSet { product_id = product_id })); tagSets.ForEach(m => sqls.Add(_productTagSetMgr.Save(m))); //NOTICE List<ProductNoticeSet> noticeSets = jsSer.Deserialize<List<ProductNoticeSet>>(notices); noticeSets.ForEach(m => m.product_id = product_id); _productNoticeSetMgr = new ProductNoticeSetMgr(""); sqls.Add(_productNoticeSetMgr.Delete(new ProductNoticeSet { product_id = product_id })); noticeSets.ForEach(m => sqls.Add(_productNoticeSetMgr.Save(m))); _functionMgr = new FunctionMgr(connectionString); string function = Request.Params["function"] ?? ""; Function fun = _functionMgr.QueryFunction(function, "/ProductCombo"); int functionid = fun == null ? 0 : fun.RowId; HistoryBatch batch = new HistoryBatch { functionid = functionid }; batch.batchno = Request.Params["batch"] ?? ""; batch.kuser = (Session["caller"] as Caller).user_email; _tableHistoryMgr = new TableHistoryMgr(connectionString); if (_tableHistoryMgr.SaveHistory<Product>(product, batch, sqls)) { json = "{success:true}"; } else { json = "{success:false}"; } } } else { int writer_id = (Session["caller"] as Caller).user_id; string product_id = "0"; if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) { product_id = Request.Form["OldProductId"]; } ProductTemp proTemp = new ProductTemp(); proTemp.Page_Content_1 = Request.Form["page_content_1"] ?? ""; proTemp.Page_Content_2 = Request.Form["page_content_2"] ?? ""; proTemp.Page_Content_3 = Request.Form["page_content_3"] ?? ""; proTemp.Product_Keywords = Request.Form["product_keywords"] ?? ""; if (!string.IsNullOrEmpty(Request.Form["product_buy_limit"])) { proTemp.Product_Buy_Limit = uint.Parse(Request.Form["product_buy_limit"]); } proTemp.Writer_Id = writer_id; proTemp.Combo_Type = COMBO_TYPE; proTemp.Product_Id = product_id.ToString(); List<ProductTagSetTemp> tagTemps = jsSer.Deserialize<List<ProductTagSetTemp>>(tags); foreach (ProductTagSetTemp item in tagTemps) { item.Writer_Id = writer_id; item.Combo_Type = COMBO_TYPE; item.product_id = product_id; } List<ProductNoticeSetTemp> noticeTemps = jsSer.Deserialize<List<ProductNoticeSetTemp>>(notices); foreach (ProductNoticeSetTemp item in noticeTemps) { item.Writer_Id = writer_id; item.Combo_Type = COMBO_TYPE; item.product_id = product_id; } _productTempMgr = new ProductTempMgr(connectionString); if (_productTempMgr.DescriptionInfoSave(proTemp, tagTemps, noticeTemps)) { json = "{success:true}"; } else { json = "{success:false}"; } } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase GetSelectedCage() { string resultStr = "{success:false}"; try { string strCateId = string.Empty; if (!string.IsNullOrEmpty(Request.Params["ProductId"])) { #region 從正式表獲取 uint pid = uint.Parse(Request.Params["ProductId"]); _productMgr = new ProductMgr(connectionString); Product result = _productMgr.Query(new Product { Product_Id = pid }).FirstOrDefault(); if (result != null) { strCateId = result.Cate_Id; } #endregion } else { Caller _caller = (Session["caller"] as Caller); _productTempMgr = new ProductTempMgr(connectionString); ProductTemp query = new ProductTemp { Writer_Id = _caller.user_id, Combo_Type = COMBO_TYPE }; if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) { query.Product_Id = Request.Form["OldProductId"]; } ProductTemp tempResult = _productTempMgr.GetProTemp(query); if (tempResult != null) { strCateId = tempResult.Cate_Id; } } paraMgr = new ParameterMgr(connectionString); Parametersrc cate2Result = paraMgr.QueryUsed(new Parametersrc { ParameterType = "product_cate", ParameterCode = strCateId }).FirstOrDefault(); if (cate2Result != null) { Parametersrc cate1Result = paraMgr.QueryUsed(new Parametersrc { ParameterType = "product_cate", ParameterCode = cate2Result.TopValue.ToString() }).FirstOrDefault(); if (cate1Result != null) { StringBuilder stb = new StringBuilder("{"); stb.AppendFormat("cate1Name:\"{0}\",cate1Value:\"{1}\",cate1Rowid:\"{2}\",cate1TopValue:\"{3}\"", cate1Result.parameterName, cate1Result.ParameterCode, cate1Result.Rowid, cate1Result.TopValue); stb.AppendFormat(",cate2Name:\"{0}\",cate2Value:\"{1}\",cate2Rowid:\"{2}\",cate2TopValue:\"{3}\"", cate2Result.parameterName, cate2Result.ParameterCode, cate2Result.Rowid, cate2Result.TopValue); stb.Append("}"); resultStr = "{success:true,data:" + stb.ToString() + "}"; } } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); } this.Response.Clear(); this.Response.Write(resultStr); this.Response.End(); return this.Response; }
public HttpResponseBase SaveBaseInfo() { string json = "{success:true}"; int transportDays = -1;///初始化 uint product_mode = 0; uint brand_id = 0; try { string prod_name = (Request.Form["prod_name"] ?? "").Trim(); string prod_sz = (Request.Form["prod_sz"] ?? "").Trim(); if (!Product.CheckProdName(prod_name) || !Product.CheckProdName(prod_sz)) { json = "{success:false,msg:'" + Resources.Product.FORBIDDEN_CHARACTER + "'}"; this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; } ProductTemp pTemp = new ProductTemp(); _productTempMgr = new ProductTempMgr(connectionString); _productMgr = new ProductMgr(connectionString); Caller _caller = (Session["caller"] as Caller); Product p = new Product(); ///add by wwei0216w 2015/8/24 ///根據product_mode查找供應商對應的自出,寄倉,調度欄位,如果為0則不予保存 brand_id = uint.Parse(Request.Form["brand_id"]?? "0"); product_mode = uint.Parse(Request.Form["product_mode"]??"0");///獲得product_mode string msg = "寄倉"; IVendorImplMgr _vendorMgr = new VendorMgr(connectionString); List<Vendor> vendorList = _vendorMgr.GetArrayDaysInfo(brand_id); if (vendorList.Count > 0) { switch (product_mode) { case 1: transportDays = vendorList.FirstOrDefault<Vendor>().self_send_days; msg = "自出"; break; case 2: transportDays = vendorList.FirstOrDefault<Vendor>().stuff_ware_days; msg = "寄倉"; break; case 3: msg = "調度"; transportDays = vendorList.FirstOrDefault<Vendor>().dispatch_days; break; default: break; } } if (transportDays == 0) { json = "{success:false,msg:'" + msg + Resources.Product.TRANSPORT_DAYS + "'}"; this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; } //查詢product表。 if (Request.Params["product_id"] != "") { p.Product_Id = uint.Parse(Request.Params["product_id"]); p = _productMgr.Query(p)[0]; } uint product_sort = 0; string product_vendor_code = ""; uint product_start = 0; uint product_end = 0; uint expect_time = 0; uint product_freight_set = 0; int tax_type = 0; uint combination = 0; string expect_msg = string.Empty; int show_in_deliver = 0; int process_type = 0; int product_type = 0; uint recommedde_jundge = 0; uint recommedde_expend_day = 0; string recommededcheckall = string.Empty; int purchase_in_advance = 0; uint purchase_in_advance_start = 0; uint purchase_in_advance_end = 0; //庫存 if (!string.IsNullOrEmpty(Request.Params["ig_sh_InsertValue"])) { string[] Value = Request.Params["ig_sh_InsertValue"].Split(','); pTemp.Ignore_Stock = int.Parse(Value[0]); pTemp.Shortage = int.Parse(Value[1]); pTemp.stock_alarm = int.Parse(Value[2]); if (Request.Params["product_id"] != "") { p.Ignore_Stock = int.Parse(Value[0]); p.Shortage = int.Parse(Value[1]); p.stock_alarm = int.Parse(Value[2]); } } else { //brand_id = uint.Parse(Request.Form["brand_id"]); product_sort = uint.Parse(Request.Form["product_sort"]); product_vendor_code = Request.Form["product_vendor_code"]; product_start = uint.Parse(CommonFunction.GetPHPTime(Request.Form["product_start"]).ToString()); product_end = uint.Parse(CommonFunction.GetPHPTime(Request.Form["product_end"]).ToString()); expect_time = uint.Parse(CommonFunction.GetPHPTime(Request.Form["expect_time"]).ToString()); product_freight_set = uint.Parse(Request.Form["product_freight_set"]); tax_type = int.Parse(Request.Form["tax_type"]); combination = uint.Parse(Request.Form["combination"]); //product_mode = uint.Parse(Request.Params["product_mode"]); expect_msg = Request.Form["expect_msg"] ?? ""; //商品新增欄位 add by xiangwang0413w 2014/09/15 show_in_deliver = int.Parse(Request.Form["show_in_deliver"]); process_type = int.Parse(Request.Form["process_type"]); product_type = int.Parse(Request.Form["product_type"]); //add by dongya 2015/08/26 recommedde_jundge = uint.Parse(Request.Form["recommedde_jundge"]);//是否選擇了推薦商品屬性 1 表示推薦 recommedde_expend_day = 0; if (recommedde_jundge == 1) { if (!string.IsNullOrEmpty(Request.Params["recommededcheckall"])) { recommededcheckall = Request.Params["recommededcheckall"].ToString().TrimEnd(',');//選擇的所有的月數 } recommedde_expend_day = uint.Parse(Request.Form["recommedde_expend_day"]); } //add by dongya 2015/09/02 purchase_in_advance = Convert.ToInt32(Request.Form["purchase_in_advance"]); purchase_in_advance_start = uint.Parse(Request.Form["purchase_in_advance_start"]); purchase_in_advance_end = uint.Parse(Request.Form["purchase_in_advance_end"]); } if (string.IsNullOrEmpty(Request.Params["product_id"])) { pTemp.Brand_Id = brand_id; pTemp.Prod_Name = prod_name; pTemp.Prod_Sz = prod_sz; pTemp.Product_Name = pTemp.GetProductName(); pTemp.Product_Sort = product_sort; pTemp.Product_Vendor_Code = product_vendor_code; pTemp.Product_Start = product_start; pTemp.Product_End = product_end; pTemp.Expect_Time = expect_time; pTemp.Product_Freight_Set = product_freight_set; pTemp.Product_Mode = product_mode; pTemp.Tax_Type = tax_type; pTemp.Combination = combination; pTemp.expect_msg = expect_msg; pTemp.Combo_Type = COMBO_TYPE; pTemp.Create_Channel = 1;// 1:後台管理者(manage_user) edit by xiagnwang0413w 2014/08/09 //商品新增欄位 add by xiangwang0413w 2014/09/15 pTemp.Show_In_Deliver = show_in_deliver; pTemp.Process_Type = process_type; pTemp.Product_Type = product_type; //add by zhuoqin0830w 增加新的欄位 2015/03/17 pTemp.Deliver_Days = 3; pTemp.Min_Purchase_Amount = 1; pTemp.Safe_Stock_Amount = 1; pTemp.Extra_Days = 0; //add by dongya pTemp.recommedde_jundge = recommedde_jundge;//推薦商品 1表示推薦 0表示不推薦 pTemp.months = recommededcheckall;//以1,3,這樣的形式顯示 pTemp.expend_day = recommedde_expend_day; //add by dongya 2015/09/02 pTemp.purchase_in_advance = purchase_in_advance; pTemp.purchase_in_advance_start = purchase_in_advance_start; pTemp.purchase_in_advance_end = purchase_in_advance_end; if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) { pTemp.Product_Id = Request.Form["OldProductId"]; } //查找臨時表是否存在數據,存在:更新,不存在插入 pTemp.Writer_Id = _caller.user_id; pTemp.Product_Status = 0; if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) { pTemp.Product_Id = Request.Form["OldProductId"]; } ProductTemp query = new ProductTemp { Writer_Id = pTemp.Writer_Id, Combo_Type = COMBO_TYPE, Product_Id = pTemp.Product_Id }; ProductTemp pTempList = _productTempMgr.GetProTemp(query); if (pTempList == null) { //插入 int result = 0; result = _productTempMgr.baseInfoSave(pTemp); if (result >0) { json = "{success:true}"; } else { json = "{success:false}"; } } else { //更新 if (!string.IsNullOrEmpty(Request.Params["ig_sh_InsertValue"])) { _productTempMgr.ProductTempUpdate(pTemp, "stock"); } else { if (pTemp.Product_Mode != 2) { pTemp.Bag_Check_Money = 0; } else { pTemp.Bag_Check_Money = pTempList.Bag_Check_Money; } _productTempMgr.baseInfoUpdate(pTemp); } } } else { if (string.IsNullOrEmpty(Request.Params["ig_sh_InsertValue"])) { p.Brand_Id = brand_id; p.Prod_Name = prod_name; p.Prod_Sz = prod_sz; p.Product_Name = p.GetProductName(); p.Product_Sort = product_sort; p.Product_Vendor_Code = product_vendor_code; p.Product_Start = product_start; p.Product_End = product_end; p.Expect_Time = expect_time; p.Product_Freight_Set = product_freight_set; p.Product_Mode = product_mode; p.Tax_Type = tax_type; p.expect_msg = expect_msg;//預留商品信息 p.Combination = combination; //商品新增欄位 add by xiangwang0413w 2014/09/15 p.Show_In_Deliver = show_in_deliver; p.Process_Type = process_type; p.Product_Type = product_type; //add by zhuoqin0830w 增加新的欄位 2015/03/17 p.Deliver_Days = 3; p.Min_Purchase_Amount = 1; p.Safe_Stock_Amount = 1; p.Extra_Days = 0; p.off_grade = int.Parse(Request.Form["off-grade"]); //add by dongya p.recommedde_jundge = recommedde_jundge;//推薦商品 1表示推薦 0表示不推薦 p.months = recommededcheckall;//以1,3,這樣的形式顯示 p.expend_day = recommedde_expend_day; //add by dongya 0410j p.purchase_in_advance = purchase_in_advance; p.purchase_in_advance_start = purchase_in_advance_start; p.purchase_in_advance_end = purchase_in_advance_end; //更新正式表 p.Product_Id = uint.Parse(Request.Params["product_id"]); if (p.Product_Mode != 2) { p.Bag_Check_Money = 0; } #region ScheduleRelation int scheduleId = int.Parse(Request.Form["schedule_id"]); IScheduleRelationImplMgr _srMgr = new ScheduleRelationMgr(connectionString); _srMgr.Save(new ScheduleRelation { relation_table = "product", relation_id = (int)p.Product_Id, schedule_id = scheduleId }); #endregion } _tableHistoryMgr = new TableHistoryMgr(connectionString); _productMgr = new ProductMgr(connectionString); _categorySetMgr = new ProductCategorySetMgr(connectionString); ArrayList aList = new ArrayList(); aList.Add(_productMgr.Update(p)); aList.Add(_categorySetMgr.UpdateBrandId(new ProductCategorySet { Product_Id = p.Product_Id, Brand_Id = p.Brand_Id })); //add by wwei0216w 2015/2/24 品牌名稱變更后,product_category_set表所對應的品牌名稱也需要更新 _functionMgr = new FunctionMgr(connectionString); string function = Request.Params["function"] ?? ""; Function fun = _functionMgr.QueryFunction(function, "/ProductCombo"); int functionid = fun == null ? 0 : fun.RowId; HistoryBatch batch = new HistoryBatch { functionid = functionid }; batch.batchno = Request.Params["batch"] ?? ""; batch.kuser = (Session["caller"] as Caller).user_email; if (_tableHistoryMgr.SaveHistory<Product>(p, batch, aList)) { #region add by zhuoqin0830w 2015/06/25 判斷修改的商品是否是失格商品 1為失格 0為正常 if (!string.IsNullOrEmpty(Request.Params["product_id"])) { _productMgr.UpdateOff_Grade(p.Product_Id, p.off_grade); } #endregion //add by wwei0216 2015/1/9 刪除不符合條件的物品匹配模式 if (!p.CheckdStoreFreight()) { IProductDeliverySetImplMgr _productDeliverySetMgr = new ProductDeliverySetMgr(connectionString); _productDeliverySetMgr.Delete( new ProductDeliverySet { Freight_big_area = 1, Freight_type = 12 }, p.Product_Id); } #region 推薦商品屬性插入/修改recommended_product_attribute表中做記錄 add by dongya 2015/09/30 ----目前只針對單一商品 RecommendedProductAttributeMgr rProductAttributeMgr = new RecommendedProductAttributeMgr(connectionString); RecommendedProductAttribute rPA = new RecommendedProductAttribute(); rPA.product_id = Convert.ToUInt32(p.Product_Id); rPA.time_start = 0; rPA.time_end = 0; rPA.expend_day = recommedde_expend_day; rPA.months = recommededcheckall; rPA.combo_type = 2;//組合商品 //首先判斷表中是否對該product_id設置為推薦 int productId = Convert.ToInt32(rPA.product_id); if (rProductAttributeMgr.GetMsgByProductId(productId) > 0)//如果大於0,表示推薦表中存在數據 { if (recommedde_jundge == 1)//==1表示推薦 { rProductAttributeMgr.Update(rPA); } else if (recommedde_jundge == 0)//==0表示不推薦 { rProductAttributeMgr.Delete(productId); } } else { if (recommedde_jundge == 1)//==1表示推薦 { rProductAttributeMgr.Save(rPA); } } #endregion json = "{success:true,msg:'" + Resources.Product.SAVE_SUCCESS + "'}"; } else { json = "{success:false,msg:'" + Resources.Product.SAVE_FAIL + "'}"; } } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false,msg:'" + Resources.Product.SAVE_FAIL + "'}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
/// <summary> /// 匯出 /// </summary> /// <returns></returns> public HttpResponseBase ProductDetailExport() { string json = "false"; ProductQuery query = new ProductQuery(); _productMgr = new ProductMgr(connectionString); if (!string.IsNullOrEmpty(Request.Params["vendor_id"])) { query.Vendor_Id = uint.Parse(Request.Params["vendor_id"]); } if (!string.IsNullOrEmpty(Request.Params["brand_id"])) { query.Brand_Id = uint.Parse(Request.Params["brand_id"]); } if (!string.IsNullOrEmpty(Request.Params["product_status"])) { query.Product_Status = uint.Parse(Request.Params["product_status"]); } else { query.Product_Status = 999;//未選擇商品狀態 } if (!string.IsNullOrEmpty(Request.Params["creater"])) { query.create_username = Request.Params["creater"]; } if (!string.IsNullOrEmpty(Request.Params["timestart"])) { query.time_start = Convert.ToDateTime(Request.Params["timestart"]); } if (!string.IsNullOrEmpty(Request.Params["timeend"])) { query.time_end = Convert.ToDateTime(Request.Params["timeend"]); } if (!string.IsNullOrEmpty(Request.Params["search_content"])) { //支持空格,中英文逗號隔開 string content = Regex.Replace(Request.Params["search_content"].Trim(), "(\\s+)|(,)|(\\,)", ","); string[] contents = content.Split(','); int pid = 0; for (int i = 0; i < contents.Length; i++) { if (!string.IsNullOrEmpty(contents[i].Trim())) { if (query.pids == "" && query.Product_Name == "") { if (int.TryParse(contents[i], out pid)) { query.pids += Regex.Replace(contents[i].Trim(), "(\\s+)|(,)|(\\,)", ","); } else { query.Product_Name += Regex.Replace(contents[i].Trim(), "(\\s+)|(,)|(\\,)", ","); } } else { if (int.TryParse(contents[i], out pid)) { query.pids += "," + Regex.Replace(contents[i].Trim(), "(\\s+)|(,)|(\\,)", ","); } else { query.Product_Name += "," + Regex.Replace(contents[i].Trim(), "(\\s+)|(,)|(\\,)", ","); } } } else { continue; } } } string status = Request.Params["status"]; //判斷是不是已編輯 if (status == "0") { query.product_detail_text = string.Empty; } else if (status == "1") { query.product_detail_text = "1"; } else if (status == "2") { query.product_detail_text = "2"; } if (!string.IsNullOrEmpty(Request.Params["combination"])) { query.Combination = uint.Parse(Request.Params["combination"]); } #region 供應商狀態、品牌狀態 if (!string.IsNullOrEmpty(Request.Params["vendorState"])) { query.vendor_status = Convert.ToInt32(Request.Params["vendorState"]); } if (!string.IsNullOrEmpty(Request.Params["brandState"])) { query.brand_status = Convert.ToInt32(Request.Params["brandState"]); } #endregion query.IsPage = false; DataTable dtHZ = new DataTable(); string newExcelName = string.Empty; dtHZ.Columns.Add("供應商編號", typeof(String)); dtHZ.Columns.Add("供應商名稱", typeof(String)); dtHZ.Columns.Add("品牌名稱", typeof(String)); dtHZ.Columns.Add("商品編號", typeof(String)); dtHZ.Columns.Add("商品名稱", typeof(String)); dtHZ.Columns.Add("建立人", typeof(String)); dtHZ.Columns.Add("建立時間", typeof(String)); dtHZ.Columns.Add("修改人", typeof(String)); dtHZ.Columns.Add("修改時間", typeof(String)); try { int totalCount = 0; DataTable dt = _productMgr.GetProductList(query, out totalCount); foreach (DataRow dr_v in dt.Rows) { DataRow dr = dtHZ.NewRow(); dr[0] = dr_v["vendor_id"].ToString(); dr[1] = dr_v["vendor_name_full"].ToString(); dr[2] = dr_v["brand_name"].ToString(); dr[3] = dr_v["product_id"].ToString(); dr[4] = dr_v["product_name"].ToString(); dr[5] = dr_v["create_username"].ToString(); dr[6] = dr_v["detail_createdate"].ToString(); dr[7] = dr_v["update_username"].ToString(); dr[8] = dr_v["detail_updatedate"].ToString(); dtHZ.Rows.Add(dr); } string[] colname = new string[dtHZ.Columns.Count]; string filename = "product_detail" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"; ; newExcelName = Server.MapPath(excelPath_export) + filename; for (int i = 0; i < dtHZ.Columns.Count; i++) { colname[i] = dtHZ.Columns[i].ColumnName; } if (System.IO.File.Exists(newExcelName)) { System.IO.File.Delete(newExcelName); } ExcelHelperXhf.ExportDTtoExcel(dtHZ, "", newExcelName); //CsvHelper.ExportDataTableToCsv(dtHZ, newExcelName, colname, true); json = "{success:true,ExcelName:\'" + filename + "\'}"; } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase UpdateItemPrice() { string json = string.Empty; try { if (!PriceMaster.CheckProdName(Request.Form["product_name"])) { json = "{success:false,msg:'" + Resources.Product.FORBIDDEN_CHARACTER + "'}"; this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; } JavaScriptSerializer jsSer = new JavaScriptSerializer(); uint priceMasterId = uint.Parse(Request.Form["price_master_id"] ?? "0"); float default_bonus_percent = float.Parse(Request.Form["default_bonus_percent"] ?? "1"); float bonus_percent = float.Parse(Request.Form["bonus_percent"] ?? "1"); int same_price = (Request.Form["same_price"] ?? "") == "on" ? 1 : 0; int accumulated_bonus = (Request.Form["accumulated_bonus"] ?? "") == "on" ? 1 : 0; string start = Request.Form["event_start"] != null ? Request.Form["event_start"] : "0";//edit by zhuoqin0830w 2015/01/14 判斷時間是否為null string end = Request.Form["event_end"] != null ? Request.Form["event_end"] : "0";//edit by zhuoqin0830w 2015/01/14 判斷時間是否為null string bonus_start = Request.Form["bonus_percent_start"] ?? ""; string bonus_end = Request.Form["bonus_percent_end"] ?? ""; string valid_start = Request.Form["valid_start"] ?? "0";//edit by zhuoqin0830w 2015/01/28 判斷時間是否為null string valid_end = Request.Form["valid_end"] ?? "0";//edit by zhuoqin0830w 2015/01/28 判斷時間是否為null string items = Request.Form["Items"]; List<ItemPrice> newPrices = jsSer.Deserialize<List<ItemPrice>>(items); _priceMasterMgr = new PriceMasterMgr(connectionString); _priceMasterTsMgr = new PriceMasterTsMgr(""); PriceMaster priceMaster = _priceMasterMgr.Query(new PriceMaster { price_master_id = priceMasterId }).FirstOrDefault(); if (priceMaster != null) { #region 處理PriceMaster priceMaster.user_id = 0; priceMaster.product_name = PriceMaster.Product_Name_FM(Request.Form["productFormat"] ?? ""); priceMaster.same_price = same_price; priceMaster.accumulated_bonus = Convert.ToUInt32(accumulated_bonus); priceMaster.user_level = uint.Parse(Request.Form["user_level"] ?? "1"); if (!string.IsNullOrEmpty(start)) { priceMaster.event_start = Convert.ToUInt32(CommonFunction.GetPHPTime(start)); } if (!string.IsNullOrEmpty(end)) { priceMaster.event_end = Convert.ToUInt32(CommonFunction.GetPHPTime(end)); } if (!string.IsNullOrEmpty(bonus_start)) { priceMaster.bonus_percent_start = Convert.ToUInt32(CommonFunction.GetPHPTime(bonus_start)); } if (!string.IsNullOrEmpty(bonus_end)) { priceMaster.bonus_percent_end = Convert.ToUInt32(CommonFunction.GetPHPTime(bonus_end)); } if (!string.IsNullOrEmpty(valid_start)) { priceMaster.valid_start = Convert.ToInt32(CommonFunction.GetPHPTime(valid_start)); } if (!string.IsNullOrEmpty(valid_end)) { priceMaster.valid_end = Convert.ToInt32(CommonFunction.GetPHPTime(valid_end)); } if (!string.IsNullOrEmpty(Request.Form["user_id"])) { _usersMgr = new UsersMgr(connectionString); System.Data.DataTable dt_User = _usersMgr.Query(Request.Form["user_id"]); if (dt_User != null && dt_User.Rows.Count > 0) { priceMaster.user_id = Convert.ToUInt32(dt_User.Rows[0]["user_id"]); } } priceMaster.price = Convert.ToInt32(newPrices.Min(m => m.item_money)); priceMaster.event_price = Convert.ToInt32(newPrices.Min(m => m.event_money)); if (same_price == 0) { priceMaster.max_price = Convert.ToInt32(newPrices.Max(m => m.item_money)); priceMaster.max_event_price = Convert.ToInt32(newPrices.Max(m => m.event_money)); } priceMaster.cost = Convert.ToInt32(newPrices.Min(m => m.item_cost)); priceMaster.event_cost = Convert.ToInt32(newPrices.Min(m => m.event_cost)); priceMaster.bonus_percent = bonus_percent; priceMaster.default_bonus_percent = default_bonus_percent; priceMaster.price_status = 2;//申請審核 #endregion bool isExist = false; List<PriceMasterCustom> masterList = _priceMasterMgr.Query(new PriceMaster { site_id = priceMaster.site_id, user_id = priceMaster.user_id, user_level = priceMaster.user_level, product_id = priceMaster.product_id }); List<PriceMasterCustom> resultList = masterList.Where(p => p.price_master_id != priceMaster.price_master_id).ToList(); if (resultList != null && resultList.Count() > 0) { if (priceMaster.user_id != 0 || (priceMaster.user_id == 0 && resultList.Where(p => p.user_id == 0).Count() > 0)) { json = "{success:false,msg:'" + Resources.Product.SITE_EXIST + "'}"; isExist = true; } } if (!isExist) { ArrayList excuteSql = new ArrayList(); Product product = null; if (priceMaster.site_id == 1 && priceMaster.user_level == 1 && priceMaster.user_id == 0) { #region 處理Product _productMgr = new ProductMgr(connectionString); product = _productMgr.Query(new Product { Product_Id = priceMaster.product_id }).FirstOrDefault(); if (product != null) { product.Default_Bonus_Percent = default_bonus_percent; product.Bonus_Percent = bonus_percent; } excuteSql.Add(_productMgr.Update(product, 0)); #endregion #region 處理ProductItem //_productItemMgr = new ProductItemMgr(connectionString); //List<ProductItem> productItems = _productItemMgr.Query(new ProductItem { Product_Id = priceMaster.product_id }); //if (productItems != null) //{ // if (!string.IsNullOrEmpty(start)) // { // productItems.ForEach(m => m.Event_Product_Start = Convert.ToUInt32(CommonFunction.GetPHPTime(start))); // } // if (!string.IsNullOrEmpty(end)) // { // productItems.ForEach(m => m.Event_Product_End = Convert.ToUInt32(CommonFunction.GetPHPTime(end))); // } // newPrices.ForEach(m =>{ // ProductItem pi = productItems.Find(n => n.Item_Id == m.item_id); // pi.Item_Money = m.item_money; // pi.Item_Cost = m.item_cost; // pi.Event_Item_Money = m.event_money; // pi.Event_Item_Cost = m.event_cost; // }); // productItems.ForEach(m => excuteSql.Add(_productItemMgr.Update(m))); //} #endregion } //價格修改 申請審核 PriceUpdateApply priceUpdateApply = new PriceUpdateApply { price_master_id = priceMasterId }; priceUpdateApply.apply_user = Convert.ToUInt32((Session["caller"] as Caller).user_id); //價格審核記錄 PriceUpdateApplyHistory applyHistroy = new PriceUpdateApplyHistory(); applyHistroy.user_id = Convert.ToInt32(priceUpdateApply.apply_user); //applyHistroy.price_status = 1; //applyHistroy.type = 3; applyHistroy.price_status = 1; //edit by wwei0216w 2014/12/16 價格修改時 price_status為 2申請審核 applyHistroy.type = 1;//edit by wwei0216w 所作操作為 1:申請審核的操作 _priceUpdateApplyMgr = new PriceUpdateApplyMgr(connectionString); _priceUpdateApplyHistoryMgr = new PriceUpdateApplyHistoryMgr(connectionString); _tableHistoryMgr = new TableHistoryMgr(connectionString); bool result = true; int apply_id = _priceUpdateApplyMgr.Save(priceUpdateApply); if (apply_id != -1) { priceMaster.apply_id = Convert.ToUInt32(apply_id); applyHistroy.apply_id = apply_id; //excuteSql.Add(_priceMasterMgr.Update(priceMaster)); excuteSql.Add(_priceMasterTsMgr.UpdateTs(priceMaster)); //修改站台價格,不再更新price_master表,改為更新price_master_ts表 edit by xiangwang0413w 2014/07/21 excuteSql.Add(_priceUpdateApplyHistoryMgr.SaveSql(applyHistroy)); //item_price_id==0 新增規格,做新增動作 _itemPriceMgr = new ItemPriceMgr(connectionString); newPrices.FindAll(m => m.item_price_id == 0).ForEach(m => excuteSql.Add(_itemPriceMgr.Save(m))); _functionMgr = new FunctionMgr(connectionString); string function = Request.Params["function"] ?? ""; Function fun = _functionMgr.QueryFunction(function, "/Product/ProductSave"); int functionid = fun == null ? 0 : fun.RowId; HistoryBatch batch = new HistoryBatch { functionid = functionid }; batch.batchno = Request.Params["batch"] ?? ""; batch.kuser = (Session["caller"] as Caller).user_email; if (_tableHistoryMgr.SaveHistory<PriceMaster>(priceMaster, batch, excuteSql)) { //_itemPriceMgr = new ItemPriceMgr(""); _itemPriceTsMgr = new ItemPriceTsMgr(""); foreach (var item in newPrices.FindAll(m => m.item_price_id != 0)) { item.apply_id = (uint)apply_id;//细项与主项使用相同的apply_id excuteSql = new ArrayList(); //excuteSql.Add(_itemPriceMgr.Update(item)); excuteSql.Add(_itemPriceTsMgr.UpdateTs(item));//修改站台價格,不再更新item_price表,改為更新item_price_ts表 edit by xiangwang0413w 2014/07/21 if (!_tableHistoryMgr.SaveHistory<ItemPrice>(item, batch, excuteSql)) { result = false; } } } else { result = false; } } else { result = false; } //若為單一商品,則把product_item.export_flag改為2 edit by xiangwang0413w 2014/06/30 //if (result&&product != null && product.Combination == 1) //{ // _productItemMgr = new ProductItemMgr(connectionString); // ProductItem pro_Item = new ProductItem() { Product_Id = product.Product_Id, Export_flag = 2 }; // _productItemMgr.UpdateExportFlag(pro_Item); //} json = "{success:" + result.ToString().ToLower() + "}"; } } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false,msg:'" + Resources.Product.SAVE_FAIL + "'}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public ActionResult tempCategoryAdd(int categoryType, int coboType = 1) { COMBO_TYPE = coboType; string resultStr = "{success:true}"; string oldresult = Request["oldresult"];//add by wwei0216w 2014/12/26 需要刪除的選中項 if (string.IsNullOrEmpty(oldresult)) { resultStr = "{success:false}"; return Content(resultStr); } try { Caller _caller = (Session["caller"] as Caller); string tempStr = ""; string cate_id = ""; if (!string.IsNullOrEmpty(Request.Params["result"])) { tempStr = Request.Params["result"]; } if (!string.IsNullOrEmpty(Request.Params["cate_id"])) { cate_id = Request.Params["cate_id"]; } List<ProductCategorySetTemp> saveTempList = new List<ProductCategorySetTemp>(); JavaScriptSerializer js = new JavaScriptSerializer(); List<ProductCategorySetCustom> cateCustomList = js.Deserialize<List<ProductCategorySetCustom>>(tempStr); string deStr = ""; //if (categoryType == 2)//新類別 //{ // if (cateCustomList.Count() <= 0) // { // resultStr = "{success:false,msg:'新類別必選'}"; // return Content(resultStr); // } //} #region 將要刪除的id 拼成 '1,2,3'這種形式 List<ProductCategorySetCustom> deleteCategorySet = js.Deserialize<List<ProductCategorySetCustom>>(oldresult); if (deleteCategorySet.Count() > 0) { foreach (var item in deleteCategorySet) { deStr += item.Category_Id + ","; } deStr = deStr.Remove(deStr.Length - 1); } #endregion if (string.IsNullOrEmpty(tempStr)) { cateCustomList = new List<ProductCategorySetCustom>(); } if (!string.IsNullOrEmpty(Request.Params["ProductId"])) { #region 修改正式表 uint pid = uint.Parse(Request.Params["ProductId"]); _tableHistoryMgr = new TableHistoryMgr(connectionString); _categorySetMgr = new ProductCategorySetMgr(connectionString); _productMgr = new ProductMgr(connectionString); Product pro = new Product(); pro = _productMgr.Query(new Product { Product_Id = pid }).FirstOrDefault(); if (pro != null) { _functionMgr = new FunctionMgr(connectionString); string function = Request.Params["function"] ?? ""; Function fun = _functionMgr.QueryFunction(function, "/Product/ProductSave"); int functionid = fun == null ? 0 : fun.RowId; HistoryBatch batch = new HistoryBatch { functionid = functionid }; batch.batchno = Request.Params["batch"] ?? ""; batch.kuser = (Session["caller"] as Caller).user_email; ArrayList sqls = new ArrayList(); if (deStr != "") { sqls.Add(_categorySetMgr.Delete(new ProductCategorySet { Product_Id = pid }, deStr)); } if (categoryType == 1) { pro.Cate_Id = cate_id; } else if (categoryType == 2) //edit by wwei0216w 如果是新類別 就不進行報表修改 { pro.Prod_Classify = Convert.ToInt32(Request["prodClassify"]); //獲得對應館別ID _tableHistoryMgr.SaveHistory<Product>(pro, batch, null); } sqls.Add(_productMgr.Update(pro, _caller.user_id)); foreach (ProductCategorySetCustom item in cateCustomList) { item.Product_Id = pid; item.Brand_Id = pro.Brand_Id; sqls.Add(_categorySetMgr.Save(item)); } if (!_tableHistoryMgr.SaveHistory<ProductCategorySetCustom>(cateCustomList, batch, sqls)) { throw new Exception("there is no History be saved"); } //else //{ //若為單一商品,則把product_item.export_flag改為2 edit by xiangwang0413w 2014/06/30 // if (pro.Combination == 1) // { // _productItemMgr = new ProductItemMgr(connectionString); // ProductItem pro_Item = new ProductItem() { Product_Id = pro.Product_Id, Export_flag = 2 }; // _productItemMgr.UpdateExportFlag(pro_Item); // } //} } else { throw new Exception("None Product has being found"); } #endregion } else { #region 修改臨時表 string product_id = "0"; if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) { product_id = Request.Form["OldProductId"]; } _categoryTempSetMgr = new ProductCategorySetTempMgr(connectionString); _productTempMgr = new ProductTempMgr(connectionString); bool result = _categoryTempSetMgr.Delete(new ProductCategorySetTemp { Writer_Id = _caller.user_id, Combo_Type = COMBO_TYPE, Product_Id = product_id }, deStr); ProductTemp query = new ProductTemp { Writer_Id = _caller.user_id, Combo_Type = COMBO_TYPE, Product_Id = product_id }; ProductTemp proTemp = _productTempMgr.GetProTemp(query); ProductCategorySetTemp saveTemp; if (proTemp == null) { resultStr = "{success:false}"; } else { foreach (ProductCategorySetCustom item in cateCustomList) { saveTemp = new ProductCategorySetTemp(); saveTemp.Writer_Id = _caller.user_id; saveTemp.Product_Id = product_id; saveTemp.Category_Id = item.Category_Id; saveTemp.Brand_Id = proTemp.Brand_Id; saveTemp.Combo_Type = COMBO_TYPE; saveTempList.Add(saveTemp); } if (!_categoryTempSetMgr.Save(saveTempList)) { resultStr = "{success:false}"; } } proTemp.Combo_Type = COMBO_TYPE; proTemp.Product_Id = product_id; if (categoryType == 1) { proTemp.Cate_Id = cate_id; } else if (categoryType == 2) //edit by wwei0216w 如果是新類別 就不進行報表修改 { proTemp.Prod_Classify = Convert.ToInt32(Request["prodClassify"]); //獲得對應館別ID } if (!_productTempMgr.CategoryInfoUpdate(proTemp)) { resultStr = "{success:false}"; } #endregion } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); resultStr = "{success:false}"; return Content(resultStr); } return Content(resultStr); ////this.Response.Clear(); ////this.Response.Write(resultStr); ////this.Response.End(); ////return this.Response; }
public ActionResult GetProdClassify(uint productId = 0, uint oldProductId = 0, int coboType = 1) { Product product; if (productId == 0)// { string tempPoroductId = oldProductId == 0 ? "0" : oldProductId.ToString(); _productTempMgr = new ProductTempMgr(connectionString); product = _productTempMgr.GetProTemp(new ProductTemp { Writer_Id = (Session["caller"] as Caller).user_id, Combo_Type = coboType, Product_Id = tempPoroductId }); } else { _productMgr = new ProductMgr(connectionString); product = _productMgr.Query(new Product { Product_Id = productId }).FirstOrDefault(); } return Json(new { product.Prod_Classify }); }
public HttpResponseBase GetVendor() { Vendor v = new Vendor(); string json = string.Empty; try { _productMgr = new ProductMgr(connectionString); DataTable dt = _productMgr.GetVendor(v); json = "{success:true,data:" + JsonConvert.SerializeObject(dt, Formatting.Indented) + "}";//返回json數據 } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false,data:[]}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase GetProductDetialText() { ProductQuery query = new ProductQuery(); string json = string.Empty; DataTable result = new DataTable(); string notFind = string.Empty; try { _productMgr = new ProductMgr(connectionString); if (!string.IsNullOrEmpty(Request.Params["product_IDS"])) { result = _productMgr.GetProductDetialText(query, Request.Params["product_IDS"], out notFind); if (result != null) { for (int i = 0; i < result.Rows.Count; i++) { result.Rows[i][0] = result.Rows[i][0].ToString().Replace("<br/>", "\n"); } json = "{success:true,data:" + JsonConvert.SerializeObject(result, Newtonsoft.Json.Formatting.Indented) + "}"; } else { json = "{success:false,data:" + JsonConvert.SerializeObject(notFind, Newtonsoft.Json.Formatting.Indented) + "}"; } } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false,data:[]}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase UpdatePrice() { string json = string.Empty; try { if (!string.IsNullOrEmpty(Request.Form["ProductId"])) { _productMgr = new ProductMgr(connectionString); Product pro = _productMgr.Query(new Product { Product_Id = uint.Parse(Request.Form["ProductId"]) }).FirstOrDefault(); if (!string.IsNullOrEmpty(Request.Form["product_price_list"])) { pro.Product_Price_List = uint.Parse(Request.Form["product_price_list"]); } if (!string.IsNullOrEmpty(Request.Form["bag_check_money"])) { pro.Bag_Check_Money = uint.Parse(Request.Form["bag_check_money"]); } pro.show_listprice = Convert.ToUInt32((Request.Form["show_listprice"] ?? "") == "on" ? 1 : 0); _functionMgr = new FunctionMgr(connectionString); string function = Request.Params["function"] ?? ""; Function fun = _functionMgr.QueryFunction(function, "/Product/ProductSave"); int functionid = fun == null ? 0 : fun.RowId; HistoryBatch batch = new HistoryBatch { functionid = functionid }; batch.batchno = Request.Params["batch"] ?? ""; batch.kuser = (Session["caller"] as Caller).user_email; ArrayList sqls = new ArrayList(); sqls.Add(_productMgr.Update(pro)); _tableHistoryMgr = new TableHistoryMgr(connectionString); bool result = _tableHistoryMgr.SaveHistory<Product>(pro, batch, sqls); //若為單一商品,則把product_item.export_flag改為2 edit by xiangwang0413w 2014/06/30 //if (result&&pro.Combination == 1) //{ // _productItemMgr = new ProductItemMgr(connectionString); // ProductItem pro_Item = new ProductItem() { Product_Id = pro.Product_Id, Export_flag = 2 }; // _productItemMgr.UpdateExportFlag(pro_Item); //} json = "{success:" + result.ToString().ToLower() + "}"; } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase StockSave() { ProductItemTemp piTemp = new ProductItemTemp(); _productItemMgr = new ProductItemMgr(connectionString); ProductItem pItem = new ProductItem(); string[] Value = Request.Params["ig_sh_InsertValue"].Split(','); string json = "{success:true}"; _productItemTempMgr = new ProductItemTempMgr(connectionString); int writeId = (Session["caller"] as Caller).user_id; _tableHistoryMgr = new TableHistoryMgr(connectionString); List<ProductItemTemp> piTempList = new List<ProductItemTemp>(); List<ProductItem> pItemList = new List<ProductItem>(); //edit by wwei0216w 2015/6/11 修改原因:之前代碼在判斷時會做出誤判,因為spilt用(,)進行分割,導致字符串中本來是用(,)時,也被分割 if (!string.IsNullOrEmpty(Request.Form["InsertValue"])) { List<ProductItem> list = JsonConvert.DeserializeObject<List<ProductItem>>(Request.Form["InsertValue"].ToString()); foreach (var p_item in list) { piTemp = new ProductItemTemp(); pItem = new ProductItem(); piTemp.Writer_Id = writeId; if (!string.IsNullOrEmpty(p_item.Item_Id.ToString())) { piTemp.Item_Id = p_item.Item_Id; pItem.Item_Id = p_item.Item_Id; }; if (Request.Params["product_id"] != "") { pItem.Product_Id = uint.Parse(Request.Params["product_id"]); pItem = _productItemMgr.Query(pItem)[0]; } if (!string.IsNullOrEmpty(p_item.Spec_Id_1.ToString())) { piTemp.Spec_Id_1 = p_item.Spec_Id_1; pItem.Spec_Id_1 = p_item.Spec_Id_1; }; if (!string.IsNullOrEmpty(p_item.Spec_Id_2.ToString())) { piTemp.Spec_Id_2 = p_item.Spec_Id_2; pItem.Spec_Id_2 = p_item.Spec_Id_2; }; if (!string.IsNullOrEmpty(p_item.Item_Stock.ToString())) { piTemp.Item_Stock = p_item.Item_Stock; pItem.Item_Stock = p_item.Item_Stock; }; if (!string.IsNullOrEmpty(p_item.Item_Alarm.ToString())) { piTemp.Item_Alarm = p_item.Item_Alarm; pItem.Item_Alarm = p_item.Item_Alarm; }; if (!string.IsNullOrEmpty(p_item.Barcode.ToString())) { piTemp.Barcode = p_item.Barcode; pItem.Barcode = p_item.Barcode; }; if (!string.IsNullOrEmpty(p_item.Item_Code.ToString())) { piTemp.Item_Code = p_item.Item_Code; pItem.Item_Code = p_item.Item_Code; } if (!string.IsNullOrEmpty(p_item.Erp_Id.ToString())) { piTemp.Erp_Id = p_item.Erp_Id; pItem.Erp_Id = p_item.Erp_Id; } // add by zhuoqin0830w 2014/02/05 增加備註 if (!string.IsNullOrEmpty(p_item.Remark.ToString())) { piTemp.Remark = p_item.Remark; pItem.Remark = p_item.Remark; } // add by zhuoqin0830w 2014/03/20 增加運達天數 if (!string.IsNullOrEmpty(p_item.Arrive_Days.ToString())) { piTemp.Arrive_Days = p_item.Arrive_Days; pItem.Arrive_Days = p_item.Arrive_Days; } piTempList.Add(piTemp); pItemList.Add(pItem); } //string[] Values = Request.Form["InsertValue"].ToString().Split(';'); //for (int i = 0; i < Values.Length - 1; i++) //{ // piTemp = new ProductItemTemp(); // pItem = new ProductItem(); // piTemp.Writer_Id = writeId; // string[] perValue = Values[i].Split(','); // //查詢product_item數據 // if (!string.IsNullOrEmpty(perValue[5])) { piTemp.Item_Id = uint.Parse(perValue[5]); pItem.Item_Id = uint.Parse(perValue[5]); }; // if (Request.Params["product_id"] != "") // { // pItem.Product_Id = uint.Parse(Request.Params["product_id"]); // pItem = _productItemMgr.Query(pItem)[0]; // } // if (!string.IsNullOrEmpty(perValue[0])) { piTemp.Spec_Id_1 = uint.Parse(perValue[0]); pItem.Spec_Id_1 = uint.Parse(perValue[0]); }; // if (!string.IsNullOrEmpty(perValue[1])) { piTemp.Spec_Id_2 = uint.Parse(perValue[1]); pItem.Spec_Id_2 = uint.Parse(perValue[1]); }; // if (!string.IsNullOrEmpty(perValue[2])) { piTemp.Item_Stock = int.Parse(perValue[2]); pItem.Item_Stock = int.Parse(perValue[2]); }; // if (!string.IsNullOrEmpty(perValue[3])) { piTemp.Item_Alarm = uint.Parse(perValue[3]); pItem.Item_Alarm = uint.Parse(perValue[3]); }; // if (!string.IsNullOrEmpty(perValue[4])) { piTemp.Barcode = perValue[4]; pItem.Barcode = perValue[4]; }; // if (!string.IsNullOrEmpty(perValue[6])) { piTemp.Item_Code = perValue[6]; pItem.Item_Code = perValue[6]; } // if (!string.IsNullOrEmpty(perValue[7])) { piTemp.Erp_Id = perValue[7]; pItem.Erp_Id = perValue[7]; } // // add by zhuoqin0830w 2014/02/05 增加備註 // if (!string.IsNullOrEmpty(perValue[8])) { piTemp.Remark = perValue[8]; pItem.Remark = perValue[8]; } // // add by zhuoqin0830w 2014/03/20 增加運達天數 // if (!string.IsNullOrEmpty(perValue[9])) { piTemp.Arrive_Days = int.Parse(perValue[9]); pItem.Arrive_Days = int.Parse(perValue[9]); } // piTempList.Add(piTemp); // pItemList.Add(pItem); //} } //判斷單一商品是新增還是修改 if (!string.IsNullOrEmpty(Request.Params["product_id"])) {//修改單一商品時執行 Product p = new Product(); _functionMgr = new FunctionMgr(connectionString); string function = Request.Params["function"] ?? ""; Function fun = _functionMgr.QueryFunction(function, "/Product/ProductSave"); int functionid = fun == null ? 0 : fun.RowId; HistoryBatch batch = new HistoryBatch { functionid = functionid }; batch.batchno = Request.Params["batch"] ?? ""; batch.kuser = (Session["caller"] as Caller).user_email; //更新product _productMgr = new ProductMgr(connectionString); Product Query = new Product(); //查詢product表。 Query.Product_Id = uint.Parse(Request.Params["product_id"]); p = _productMgr.Query(Query)[0]; p.Shortage = int.Parse(Value[1]); p.Ignore_Stock = int.Parse(Value[0]); p.outofstock_days_stopselling=int.Parse(Value[2]); json = "{success:true,msg:'" + Resources.Product.SAVE_SUCCESS + "'}"; try { foreach (var item in pItemList) { ArrayList arrList = new ArrayList(); arrList.Add(_productItemMgr.Update(item)); _tableHistoryMgr.SaveHistory<ProductItem>(item, batch, arrList); } ArrayList proList = new ArrayList(); proList.Add(_productMgr.Update(p)); _tableHistoryMgr.SaveHistory<Product>(p, batch, proList); //若為單一商品,則把product_item.export_flag改為2 edit by xiangwang0413w 2014/06/30 //if (p.Combination == 1) //{ // _productItemMgr = new ProductItemMgr(connectionString); // ProductItem pro_Item = new ProductItem() { Product_Id = p.Product_Id, Export_flag = 2 }; // _productItemMgr.UpdateExportFlag(pro_Item); //} } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false,msg:'" + Resources.Product.SAVE_FAIL + "'}"; } } else {//新增單一商品時 try { //更新product_temp _productTempMgr = new ProductTempMgr(connectionString); ProductTemp pTemp = new ProductTemp(); pTemp.Ignore_Stock = int.Parse(Value[0]); pTemp.Shortage = int.Parse(Value[1]); pTemp.outofstock_days_stopselling = int.Parse(Value[2]); pTemp.Writer_Id = writeId; pTemp.Combo_Type = COMBO_TYPE; if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) { pTemp.Product_Id = Request.Form["OldProductId"]; } _productTempMgr.ProductTempUpdate(pTemp, "stock"); piTempList.ForEach(m => { m.Product_Id = pTemp.Product_Id; }); _productItemTempMgr.UpdateStockAlarm(piTempList); } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false,msg:'" + Resources.Product.SAVE_FAIL + "'}"; } } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase GetProductByCategorySet() { string resultStr = "{success:false}"; try { _productMgr = new ProductMgr(connectionString); ProductQuery query = new ProductQuery(); query.isjoincate = true; query.IsPage = true; query.Start = int.Parse(Request.Form["start"] ?? "0"); if (!string.IsNullOrEmpty(Request.Form["limit"])) { query.Limit = Convert.ToInt32(Request.Form["limit"].ToString()); } else { query.Limit = 500; } uint isTryUint = 0; if (uint.TryParse(Request.Params["status"].ToString(), out isTryUint)) { query.Product_Status = Convert.ToUInt32(Request.Params["status"].ToString()); } if (uint.TryParse(Request.Params["brand_id"].ToString(), out isTryUint)) { query.Brand_Id = Convert.ToUInt32(Request.Params["brand_id"].ToString()); } else { if (!string.IsNullOrEmpty(Request.Params["class_id"])) { VendorBrandSetMgr vbsMgr = new VendorBrandSetMgr(connectionString); VendorBrandSet vbs = new VendorBrandSet(); vbs.class_id = Convert.ToUInt32(Request.Form["class_id"]); List<VendorBrandSet> vbsList = vbsMgr.Query(vbs); foreach (VendorBrandSet item in vbsList) { query.brandArry += item.brand_id; query.brandArry += ","; } query.brandArry = query.brandArry.Substring(0, query.brandArry.Length - 1); } } if (!string.IsNullOrEmpty(Request.Params["keyCode"].ToString())) { string keyCode = Request.Params["keyCode"].ToString(); keyCode = keyCode.Replace(",", ","); keyCode = Regex.Replace(keyCode, @"\s+", ","); if (keyCode.Substring(keyCode.Length - 1).Equals(",")) { keyCode = keyCode.Substring(0, keyCode.Length - 1); } string[] ProductID = keyCode.Split(','); try { for (int i = 0; i < ProductID.Length; i++) { int ID = int.Parse(ProductID[i]); } query.Product_Id = 0; query.Product_Id_In = keyCode; } catch (Exception) { query.Product_Name = Request.Params["keyCode"].ToString(); } } //if (!string.IsNullOrEmpty(Request.Params["keyCode"].ToString())) //{ // if (uint.TryParse(Request.Params["keyCode"].ToString(), out isTryUint)) // { // query.Product_Id = Convert.ToUInt32(Request.Params["keyCode"].ToString()); // } // else // { // query.Product_Name = Request.Params["keyCode"].ToString(); // } //} if (string.IsNullOrEmpty(Request.Params["category_id"].ToString())) { if (uint.TryParse(Request.Params["comboFrontCage_hide"].ToString(), out isTryUint)) { query.category_id = Convert.ToUInt32(Request.Params["comboFrontCage_hide"].ToString()); } } else { if (uint.TryParse(Request.Params["category_id"].ToString(), out isTryUint)) { query.category_id = Convert.ToUInt32(Request.Params["category_id"].ToString()); } } int totalCount = 0; List<ProductDetailsCustom> prods = _productMgr.GetAllProList(query, out totalCount); resultStr = "{succes:true,totalCount:" + totalCount + ",item:" + JsonConvert.SerializeObject(prods) + "}"; } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); resultStr = "{succes:false,totalCount:0,item:[]}"; } this.Response.Clear(); this.Response.Write(resultStr); this.Response.End(); return this.Response; }
public HttpResponseBase QueryProduct() { string json = string.Empty; try { if (!string.IsNullOrEmpty(Request.Form["ProductId"])) { uint product_id = 0; if (uint.TryParse(Request.Form["ProductId"], out product_id)) { _productMgr = new ProductMgr(connectionString); Product product = _productMgr.Query(new Product { Product_Id = product_id }).FirstOrDefault(); if (product.Product_alt == "") { product.Product_alt = product.Product_Name; }//add by wwei0216w 2015/4/15 //如果商品說明為空則將商品名稱賦予product_alt if (product != null) { if (!string.IsNullOrEmpty(product.Product_Image)) { product.Product_Image = imgServerPath + prodPath + GetDetailFolder(product.Product_Image) + product.Product_Image; } else { product.Product_Image = imgServerPath + "/product/nopic_150.jpg"; } if (!string.IsNullOrEmpty(product.Mobile_Image))//edit by wwei0216w 2015/3/18 添加關於手機說明圖的操作 { prodPath = prodMobile640; //add by wwei0216w 2015/4/1 添加原因:手機圖片要放在640*640路徑下 product.Mobile_Image = imgServerPath + prodPath + GetDetailFolder(product.Mobile_Image) + product.Mobile_Image; } else { product.Mobile_Image = imgServerPath + "/product/nopic_150.jpg"; } } json = "{success:true,data:" + JsonConvert.SerializeObject(product) + "}"; } else { json = "[]"; } } else { _productTempMgr = new ProductTempMgr(connectionString); int writerId = (Session["caller"] as Caller).user_id; ProductTemp query = new ProductTemp { Writer_Id = writerId, Combo_Type = COMBO_TYPE }; if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) { query.Product_Id = Request.Form["OldProductId"]; } ProductTemp proTemp = _productTempMgr.GetProTemp(query); if (proTemp.Product_alt == "") { proTemp.Product_alt = proTemp.Product_Name; }//add by wwei0216w 2015/4/15 //如果商品說明為空則將商品名稱賦予product_alt if (proTemp != null) { if (proTemp.Product_Image != "") { proTemp.Product_Image = imgServerPath + prodPath + GetDetailFolder(proTemp.Product_Image) + proTemp.Product_Image; } else { proTemp.Product_Image = imgServerPath + "/product/nopic_150.jpg"; } if (proTemp.Mobile_Image != "") { proTemp.Mobile_Image = imgServerPath + prodPath + GetDetailFolder(proTemp.Mobile_Image) + proTemp.Mobile_Image; } else { proTemp.Mobile_Image = imgServerPath + "/product/nopic_150.jpg"; } } json = "{success:true,data:" + JsonConvert.SerializeObject(proTemp) + "}"; } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "[]"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public ActionResult ProductDeliverySetSave(string proDeliverySets, int comboType, int oldProductId = 0) { string json = string.Empty; try { List<ProductDeliverySet> lists = JsonConvert.DeserializeObject<List<ProductDeliverySet>>(proDeliverySets); Caller _caller = Session["caller"] as Caller; #region 驗證是否可以選擇本島店配 //在做商品保存和修改時,驗證: //商品運送方式=常溫 && 出貨方式=寄倉 &&combination=單一商品時 //才可以點本島宅配! //add by xiangwang0413w 2014/12/17 if (lists.Find(p => p.Freight_type == 12) != null) { Product prod; if (lists[0].Product_id == 0) { _productTempMgr = new ProductTempMgr(connectionString); prod = _productTempMgr.GetProTemp(new ProductTemp { Writer_Id = _caller.user_id, Combo_Type = comboType, Product_Id = oldProductId.ToString() }); } else { _productMgr = new ProductMgr(connectionString); prod = _productMgr.Query(new Product { Product_Id = (uint)lists[0].Product_id }).First(); } if (!prod.CheckdStoreFreight()) { return Json(new { success = false, msg = Resources.Product.SHOP_TRANSPORT_NOT }); } } #endregion bool result = false; if (lists[0].Product_id == 0)//新增臨時表 { _productDeliverySetTempMgr = new ProductDeliverySetTempMgr(connectionString); List<ProductDeliverySetTemp> tempProDeliSets = new List<ProductDeliverySetTemp>(); lists.ForEach(m => { tempProDeliSets.Add(new ProductDeliverySetTemp { Product_id = oldProductId, Freight_big_area = m.Freight_big_area, Freight_type = m.Freight_type, Writer_Id = _caller.user_id, Combo_Type = comboType }); }); result = _productDeliverySetTempMgr.Save(tempProDeliSets, tempProDeliSets[0].Product_id, tempProDeliSets[0].Combo_Type, tempProDeliSets[0].Writer_Id); } else//修改正式表 { _productDeliverySetMgr = new ProductDeliverySetMgr(connectionString); result = _productDeliverySetMgr.Save(lists, lists[0].Product_id); } json = "{success:" + result.ToString().ToLower() + "}"; } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false,msg:'" + Resources.Product.SAVE_FAIL + "'}"; } return Content(json); }
public HttpResponseBase tempCategoryAdd() { Caller _caller = (Session["caller"] as Caller); string resultStr = "{success:true}"; string tempStr = Request.Params["result"]; string cate_id = Request.Params["cate_id"]; string deStr = Request["oldresult"] == null ? "0" : Request["oldresult"]; List<ProductCategorySetTemp> saveTempList = new List<ProductCategorySetTemp>(); try { JavaScriptSerializer js = new JavaScriptSerializer(); List<ProductCategorySetCustom> cateCustomList = js.Deserialize<List<ProductCategorySetCustom>>(tempStr); if (string.IsNullOrEmpty(tempStr)) { cateCustomList = new List<ProductCategorySetCustom>(); } if (!string.IsNullOrEmpty(Request.Params["ProductId"])) { #region 修改正式表 uint pid = uint.Parse(Request.Params["ProductId"]); _tableHistoryMgr = new TableHistoryMgr(connectionString); _categorySetMgr = new ProductCategorySetMgr(connectionString); _productMgr = new ProductMgr(connectionString); Product pro = new Product(); pro = _productMgr.Query(new Product { Product_Id = pid }).FirstOrDefault(); pro.Cate_Id = cate_id; _functionMgr = new FunctionMgr(connectionString); string function = Request.Params["function"] ?? ""; Function fun = _functionMgr.QueryFunction(function, "/ProductCombo"); int functionid = fun == null ? 0 : fun.RowId; HistoryBatch batch = new HistoryBatch { functionid = functionid }; batch.batchno = Request.Params["batch"] ?? ""; batch.kuser = (Session["caller"] as Caller).user_email; ArrayList sqls = new ArrayList(); sqls.Add(_categorySetMgr.Delete(new ProductCategorySet { Product_Id = pid })); sqls.Add(_productMgr.Update(pro)); foreach (ProductCategorySetCustom item in cateCustomList) { item.Product_Id = pid; item.Brand_Id = pro.Brand_Id; sqls.Add(_categorySetMgr.Save(item)); } if (!_tableHistoryMgr.SaveHistory<ProductCategorySetCustom>(cateCustomList, batch, sqls)) { resultStr = "{success:false}"; } #endregion } else { #region 修改臨時表 string product_id = "0"; if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) { product_id = Request.Form["OldProductId"]; } _categoryTempSetMgr = new ProductCategorySetTempMgr(connectionString); _productTempMgr = new ProductTempMgr(connectionString); if (string.IsNullOrEmpty(tempStr)) { bool result = _categoryTempSetMgr.Delete(new ProductCategorySetTemp { Writer_Id = _caller.user_id, Combo_Type = COMBO_TYPE, Product_Id = product_id }, deStr); } else { ProductCategorySetTemp saveTemp; ProductTemp query = new ProductTemp { Writer_Id = _caller.user_id, Combo_Type = COMBO_TYPE, Product_Id = product_id.ToString() }; ProductTemp proTemp = _productTempMgr.GetProTemp(query); foreach (ProductCategorySetCustom item in cateCustomList) { saveTemp = new ProductCategorySetTemp(); saveTemp.Writer_Id = _caller.user_id; saveTemp.Product_Id = product_id; saveTemp.Category_Id = item.Category_Id; saveTemp.Brand_Id = proTemp.Brand_Id; saveTemp.Combo_Type = COMBO_TYPE; saveTempList.Add(saveTemp); } if (!_categoryTempSetMgr.Save(saveTempList)) { resultStr = "{success:false}"; } } if (!_productTempMgr.CategoryInfoUpdate(new ProductTemp { Writer_Id = _caller.user_id, Cate_Id = cate_id, Combo_Type = COMBO_TYPE, Product_Id = product_id.ToString() })) { resultStr = "{success:false}"; } #endregion } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); resultStr = "{success:false}"; } this.Response.Clear(); this.Response.Write(resultStr); this.Response.End(); return this.Response; }
public HttpResponseBase productcategoryinto() { string json = string.Empty; DTExcel.Clear(); DTExcel.Columns.Clear(); string newName = string.Empty; DTExcel.Columns.Add("產品ID", typeof(String)); DTExcel.Columns.Add("類別ID", typeof(String)); DTExcel.Columns.Add("不能匯入的原因", typeof(String)); int result = 0; int count = 0;//總匯入數 int errorcount = 0; int chongfucount = 0; StringBuilder strsql = new StringBuilder(); try { if (Request.Files["ImportFileMsg"] != null && Request.Files["ImportFileMsg"].ContentLength > 0) { HttpPostedFileBase excelFile = Request.Files["ImportFileMsg"]; //FileManagement fileManagement = new FileManagement(); newName = Server.MapPath(excelPath) + excelFile.FileName; excelFile.SaveAs(newName); DataTable dt = new DataTable(); dt = CsvHelper.ReadCsvToDataTable(newName, true); _productMgr = new ProductMgr(connectionString); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { try { int a = Convert.ToInt32(dr[0]);//產品ID int b = Convert.ToInt32(dr[1]);//類別ID if (_productMgr.Yesornoexist(a, b) > 0)//大於1表示該數據庫內存在該值 { DataRow drtwo = DTExcel.NewRow(); drtwo[0] = dr[0].ToString(); drtwo[1] = dr[1].ToString(); drtwo[2] = "數據庫中該行數據已存在"; DTExcel.Rows.Add(drtwo); chongfucount++; continue; //someproduct_id = someproduct_id + a + ','; //someproduct_categroy_id = someproduct_categroy_id + b + ','; } else//當數據不存在時進行添加數據 { int product_id = _productMgr.Yesornoexistproduct(a); int category_id = _productMgr.Yesornoexistproductcategory(b); if (product_id > 0 && category_id > 0) { count++; strsql.AppendFormat(@"insert into product_category_set(product_id,category_id)values('{0}','{1}');", a, b); continue; } else if (product_id == 0 && category_id == 0) { DataRow drtwo = DTExcel.NewRow(); drtwo[0] = dr[0].ToString(); drtwo[1] = dr[1].ToString(); drtwo[2] = "類別ID和產品ID在類別表和產品表中均不存在"; DTExcel.Rows.Add(drtwo); errorcount++; continue; } else if (product_id > 0 && category_id == 0) { DataRow drtwo = DTExcel.NewRow(); drtwo[0] = dr[0].ToString(); drtwo[1] = dr[1].ToString(); drtwo[2] = "類別ID在類別表中不存在"; DTExcel.Rows.Add(drtwo); errorcount++; continue; } else if (product_id == 0 && category_id > 0) { DataRow drtwo = DTExcel.NewRow(); drtwo[0] = dr[0].ToString(); drtwo[1] = dr[1].ToString(); drtwo[2] = "產品ID在產品表中不存在"; DTExcel.Rows.Add(drtwo); errorcount++; continue; } } } catch { DataRow drtwo = DTExcel.NewRow(); drtwo[0] = dr[0].ToString(); drtwo[1] = dr[1].ToString(); drtwo[2] = "數據異常"; DTExcel.Rows.Add(drtwo); errorcount++; continue; } } if (strsql.ToString().Trim() != "") { result = _productMgr.Updateproductcategoryset(strsql.ToString()); if (result > 0) { json = "{success:true,total:" + count + ",error:" + errorcount + ",repeat:" + chongfucount + "}"; } else { json = "{success:false}"; } } else { json = "{success:true,total:" + 0 + ",error:" + errorcount + ",repeat:" + chongfucount + "}"; } } else { json = "{success:true,total:" + 0 + ",error:" + 0 + ",repeat:" + 0 + "}"; } } } catch (Exception ex) { newName = string.Empty; DTExcel.Clear(); DTExcel.Columns.Clear(); Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false,data:" + "" + "}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase fortuneSave() { string resultStr = "{success:true}"; Caller _caller = (Session["caller"] as Caller); try { if (!string.IsNullOrEmpty(Request.Form["ProductId"])) { #region 保存正式表 _productMgr = new ProductMgr(connectionString); Product pro = _productMgr.Query(new Product { Product_Id = uint.Parse(Request.Form["ProductId"]) }).FirstOrDefault(); pro.Fortune_Quota = uint.Parse(Request.Params["Fortune_Quota"]); pro.Fortune_Freight = uint.Parse(Request.Params["Fortune_Freight"]); if (!_productMgr.ExecUpdate(pro)) { resultStr = "{success:false}"; } #endregion } else { #region 保存臨時表 ProductTemp pTemp = new ProductTemp(); pTemp.Fortune_Quota = uint.Parse(Request.Params["Fortune_Quota"]); pTemp.Fortune_Freight = uint.Parse(Request.Params["Fortune_Freight"]); pTemp.Writer_Id = _caller.user_id; pTemp.Combo_Type = COMBO_TYPE; if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) { pTemp.Product_Id = Request.Form["OldProductId"]; } _productTempMgr = new ProductTempMgr(connectionString); bool saveFortuneTempResult = _productTempMgr.FortuneInfoSave(pTemp); if (!saveFortuneTempResult) { resultStr = "{success:false}"; } #endregion } } catch (Exception ex) { resultStr = "{success:false}"; Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); } this.Response.Clear(); this.Response.Write(resultStr); this.Response.End(); return this.Response; }
/// <summary> /// 獲得排序 /// </summary> /// <param name="brand_id"></param> /// <returns></returns> public ActionResult GetProductSortNum(uint brand_id) { _productMgr = new ProductMgr(connectionString); return Content(_productMgr.GetProductSort(brand_id).ToString()); }
public HttpResponseBase Temp2Pro() { string json = string.Empty; try { int writerId = (Session["caller"] as Caller).user_id; _productMgr = new ProductMgr(connectionString); string product_id = "0"; if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) { product_id = Request.Form["OldProductId"]; } int productId = _productMgr.TempMove2Pro(writerId, COMBO_TYPE, product_id); if (productId != -1) { json = "{success:true,productId:" + productId + ",msg:'" + Resources.Product.SAVE_SUCCESS + "'}"; } else { json = "{success:false,msg:'" + Resources.Product.SAVE_FAIL + "'}"; } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false,msg:'" + Resources.Product.SAVE_FAIL + "'}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
/// <summary> /// 列表頁 /// </summary> /// <returns></returns> public HttpResponseBase GetProductList() { ProductQuery query = new ProductQuery(); string json = string.Empty; try { int totalCount = 0; query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量 query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");//用於分頁的變量 _productMgr = new ProductMgr(connectionString); if (!string.IsNullOrEmpty(Request.Params["vendor_id"])) { query.Vendor_Id = uint.Parse(Request.Params["vendor_id"]); } if (!string.IsNullOrEmpty(Request.Params["brand_id"])) { query.Brand_Id = uint.Parse(Request.Params["brand_id"]); } if (!string.IsNullOrEmpty(Request.Params["product_status"])) { query.Product_Status = uint.Parse(Request.Params["product_status"]); } else { query.Product_Status = 999;//未選擇商品狀態 } if (!string.IsNullOrEmpty(Request.Params["creater"])) { query.create_username = Request.Params["creater"]; } if (!string.IsNullOrEmpty(Request.Params["timestart"])) { query.time_start = Convert.ToDateTime(Request.Params["timestart"]); } if (!string.IsNullOrEmpty(Request.Params["timeend"])) { query.time_end = Convert.ToDateTime(Request.Params["timeend"]); } if (!string.IsNullOrEmpty(Request.Params["search_content"])) { //支持空格,中英文逗號隔開 string content = Regex.Replace(Request.Params["search_content"].Trim(), "(\\s+)|(,)|(\\,)", ","); string[] contents = content.Split(','); int pid = 0; for (int i = 0; i < contents.Length; i++) { if (!string.IsNullOrEmpty(contents[i].Trim())) { if (query.pids == "" && query.Product_Name == "") { if (int.TryParse(contents[i], out pid)) { query.pids += Regex.Replace(contents[i].Trim(), "(\\s+)|(,)|(\\,)", ","); } else { query.Product_Name += Regex.Replace(contents[i].Trim(), "(\\s+)|(,)|(\\,)", ","); } } else { if (int.TryParse(contents[i], out pid)) { query.pids += "," + Regex.Replace(contents[i].Trim(), "(\\s+)|(,)|(\\,)", ","); } else { query.Product_Name += "," + Regex.Replace(contents[i].Trim(), "(\\s+)|(,)|(\\,)", ","); } } } else { continue; } } } string status = Request.Params["status"]; //判斷是不是已編輯 if (status == "0") { query.product_detail_text = string.Empty; } else if (status == "1") { query.product_detail_text = "1"; } else if (status == "2") { query.product_detail_text = "2"; } if (!string.IsNullOrEmpty(Request.Params["combination"])) { // Convert.ToUInt32(Request.Params["combination"]) != 0 query.Combination = uint.Parse(Request.Params["combination"]); } #region 供應商狀態、品牌狀態 if (!string.IsNullOrEmpty(Request.Params["vendorState"])) { query.vendor_status = Convert.ToInt32(Request.Params["vendorState"]); } if (!string.IsNullOrEmpty(Request.Params["brandState"])) { query.brand_status = Convert.ToInt32(Request.Params["brandState"]); } #endregion DataTable dt = _productMgr.GetProductList(query, out totalCount); IsoDateTimeConverter timeConverter = new IsoDateTimeConverter(); //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式 timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"; //listUser是准备转换的对象 json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(dt, Formatting.Indented, timeConverter) + "}";//返回json數據 } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:true,totalCount:0,data:[]}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase GetProdName() { string json = string.Empty; try { _prodMgr = new ProductMgr(mySqlConnectionString); int isTranUint = 0; int pid = 0; int cid = 0; int bid = 0; if (!string.IsNullOrEmpty(Request.Params["product_id"]) && int.TryParse(Request.Params["product_id"], out isTranUint)) { pid = Convert.ToInt32(Request.Params["product_id"]); } if (!string.IsNullOrEmpty(Request.Params["class_id"]) && int.TryParse(Request.Params["class_id"], out isTranUint)) { cid = Convert.ToInt32(Request.Params["class_id"]); } if (!string.IsNullOrEmpty(Request.Params["brand_id"]) && int.TryParse(Request.Params["brand_id"], out isTranUint)) { bid = Convert.ToInt32(Request.Params["brand_id"]); } string prodName = _prodMgr.GetNameForID(pid, cid, bid); if (!string.IsNullOrEmpty(prodName)) { json = "{success:true,\"prod_name\":\"" + prodName + "\"}";//返回json數據 } else { json = "{success:false,\"prod_name\":\"\"}";//返回json數據 } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false,\"prod_name\":\"\"}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
/// <summary> /// 更新商品詳情文字 /// </summary> /// <returns></returns> public HttpResponseBase UpdateProductDetail() { Product p = new Product(); Product old_p = new Product(); string json = string.Empty; try { _productMgr = new ProductMgr(connectionString); if (!string.IsNullOrEmpty(Request.Params["product_id"])) { p.Product_Id = uint.Parse(Request.Params["product_id"]); old_p = _productMgr.Query(new Product { Product_Id = p.Product_Id }).FirstOrDefault(); } p.product_detail_text = Request.Params["product_detail_text"]; if (!string.IsNullOrEmpty(p.product_detail_text)) { p.product_detail_text = p.product_detail_text.Replace("\\", "\\\\"); p.product_detail_text = p.product_detail_text.Replace("\n", "<br/>"); } Caller _caller = (Session["caller"] as Caller); if (old_p != null) { if (old_p.detail_createdate == DateTime.MinValue)//新增 { p.detail_createdate = DateTime.Now; p.detail_created = _caller.user_id; p.detail_update = p.detail_created; p.detail_updatedate = p.detail_createdate; } else { p.detail_created = old_p.detail_created; p.detail_createdate = old_p.detail_createdate; p.detail_update = _caller.user_id; p.detail_updatedate = DateTime.Now; } } int i = _productMgr.UpdateProductDeatail(p); if (i > 0) { json = "{success:true,msg:'修改成功!'}";//返回json數據 } else { json = "{success:false,msg:'修改失敗!'}"; } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false,msg:'異常!'}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }