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 List<Product> Query(Product query) { try { StringBuilder strSql = new StringBuilder("select p.product_id,p.brand_id,product_vendor_code,product_name,prod_sz,product_price_list,product_spec,spec_title_1,spec_title_2,product_image,"); strSql.Append("product_freight_set,product_buy_limit,product_status,product_hide,product_mode,product_sort,product_start,product_end,page_content_1,page_content_2,"); strSql.Append("page_content_3,product_keywords,product_recommend,product_password,product_total_click,expect_time,product_image,product_createdate,product_updatedate,"); strSql.Append("product_ipfrom,goods_area,goods_image1,goods_image2,city,bag_check_money,combination,bonus_percent,default_bonus_percent,bonus_percent_start,"); strSql.Append("bonus_percent_end,tax_type,cate_id,fortune_quota,fortune_freight,product_media,ignore_stock,shortage,stock_alarm,price_type,user_id,show_listprice,expect_msg,"); strSql.Append("detail_created,detail_createdate,detail_update,detail_updatedate,");//add by shuangshuang0420j 20150513 16:26 商品詳情文字更動時間 strSql.Append("process_type,show_in_deliver,prepaid,product_type,prod_name,prod_sz,prod_classify,vb.vendor_id,cp.course_id,p.safe_stock_amount,p.deliver_days,p.min_purchase_amount,p.extra_days, mobile_image,sr.schedule_id,product_alt,s.`desc`,p.off_grade, purchase_in_advance,purchase_in_advance_start,purchase_in_advance_end,rpa.months,rpa.expend_day,p.outofstock_days_stopselling from product p ");//edit by wwei0216 查詢的屬性多加一個mobile_image 2015/3/18 strSql.Append(" left join vendor_brand vb ON p.brand_id = vb.brand_id "); strSql.Append(" left join course_product cp on p.product_id=cp.product_id"); strSql.Append(" left join schedule_relation sr ON sr.relation_id = p.product_id AND sr.relation_table = 'product'"); strSql.Append(" LEFT JOIN schedule s ON s.schedule_id = sr.schedule_id"); strSql.Append(" LEFT JOIN recommended_product_attribute rpa on rpa.product_id=p.product_id "); strSql.Append(" where 1=1 "); if (query.Product_Id != 0) { strSql.AppendFormat(" and p.product_id={0}", query.Product_Id); } return _dbAccess.getDataTableForObj<Product>(strSql.ToString()); } catch (Exception ex) { throw new Exception("ProductDao.Query-->" + ex.Message, ex); } }
public Model.Custom.OrderComboAddCustom OrderQuery(Product query, uint user_level, uint user_id, uint site_id) { try { return _productDao.OrderQuery(query, user_level, user_id, site_id); } catch (Exception ex) { throw new Exception("ProductMgr.OrderQuery-->" + ex.Message, ex); } }
public string UpdateProductStatus(Product pt) { try { return _iproductRemoveReason.UpdateProductStatus(pt); } catch (Exception ex) { throw new Exception("ProductRemoveReasonMgr-->UpdateProductStatus-->" + ex.Message, ex); } }
public bool ProductCateUpdate(List<ProductCategorySet> cateList, Product proModel) { try { ArrayList sqls = new ArrayList(); sqls.Add(_categorySetDao.Delete(cateList[0])); foreach (ProductCategorySet item in cateList) { sqls.Add(_categorySetDao.Save(item)); } sqls.Add(_proMgr.Update(proModel)); return _sqlDao.ExcuteSqls(sqls); } catch (Exception ex) { throw new Exception("ProductCategorySetMgr-->ProductCateUpdate-->" + ex.Message, ex); } }
public string Save(Product product) { return _productDao.Save(product); }
public bool UpdateSaleStatusByCondition(Product p) { try { Int64 dateTime = CommonFunction.GetPHPTime(DateTime.Now.ToString()); MySqlDao sqldao = new MySqlDao(connectionStr); ArrayList list = new ArrayList(); string str = _productDao.UpdateSaleStatusByCondition(dateTime, p); if (str != "") { list.Add(str); return sqldao.ExcuteSqls(list); } else { return false; } } catch (Exception ex) { throw new Exception("productMgr-->UpdateSaleStatusByCondition" + ex.Message, ex); } }
public bool UpdateIpodCheck(IpodQuery query,IpoNvdQuery ipoNvd_query) { Boolean result = false; try { ArrayList aList = new ArrayList(); ITableHistoryImplMgr _tableHistoryMgr = new TableHistoryMgr(conStr);//實例化歷史記錄的類 Int64 n_Time = BLL.gigade.Common.CommonFunction.GetPHPTime(); Function myFun = new Function(); myFun.FunctionCode = "/WareHouse/Check"; List<Function> funList = _functionMgr.Query(myFun); int functionid = funList.Count == 0 ? 0 : funList[0].RowId; HistoryBatch batch = new HistoryBatch { functionid = functionid }; batch.kuser = query.user_email; //獲取添加IpoNvd的SQL string ipoNvdSql = _IpodDao.GetInsertIpoNvdSql(ipoNvd_query); aList.Add(ipoNvdSql); //獲取歷史記錄SQL string Check = _IpodDao.UpdateIpodCheck(query); //獲取修改庫存SQL string Stock = string.Empty; ProductItem item = new ProductItem(); item = _IpodDao.GetStockHistorySql(query, out Stock); batch.batchno = n_Time + "_" + query.change_user + "_" + item.Product_Id; if (item != null) { item.Item_Stock = query.item_stock; aList.Add(Stock); aList.Add(Check); result = _tableHistoryMgr.SaveHistory<ProductItem>(item, batch, aList); } //獲取修改商品Ignore SQL string Ignore_Stock = string.Empty; Product product = new Product(); product = _IpodDao.GetIgnoreHistorySql(query, out Ignore_Stock); if (product != null) { product.Ignore_Stock = 0; aList.Clear(); aList.Add(Ignore_Stock); result = _tableHistoryMgr.SaveHistory<Product>(product, batch, aList); } return result; } catch (Exception ex) { throw new Exception("IpoMgr-->UpdateIpodCheck-->" + ex.Message, ex); } }
public int GetProductType(Product query) { StringBuilder sbSql = new StringBuilder(); try { sbSql.AppendFormat("SELECT combination FROM product WHERE product_id='{0}';", query.Product_Id); DataTable _dt = _dbAccess.getDataTable(sbSql.ToString()); if (_dt.Rows.Count > 0) { return Convert.ToInt32(_dt.Rows[0][0]); } else { return 0; } } catch (Exception ex) { throw new Exception("ProductDao.GetProductType-->" + ex.Message + sbSql.ToString(), ex); } }
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 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 int UpdateProductDeatail(Product p) { try { return _productDao.UpdateProductDeatail(p); } catch (Exception ex) { throw new Exception("ProductMgr.UpdateProductDeatail-->" + ex.Message, ex); } }
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 int GetDefaultArriveDays(Product prod) { return _productDao.GetDefaultArriveDays(prod); }
public List<Product> GetProductName(Product p) { try { return _productDao.GetProductName(p); } catch (Exception ex) { throw new Exception("ProductMgr.GetProductName-->" + ex.Message, ex); } }
/// <summary> /// 批量更新狀態 /// </summary> /// <param name="p">更新條件</param> /// <returns></returns> //public bool UpdateSaleStatusByBatch(Product p) //{ // StringBuilder sb = new StringBuilder(); // try // { // p.Vendor_Id = 2; // List<Product> list = _productDao.Query(new Product { Vendor_Id=p.Vendor_Id}); // List<Product> updateList = new List<Product>(); // ArrayList listSql = new ArrayList(); // foreach (Product _p in list) // { // updateList.Add(UpdateSaleStatus(_p.Product_Id)); // listSql.Add(UpdateColumn(_p, "sale_status")); // } // MySqlDao _sqlDao = new MySqlDao(connectionStr); // return _sqlDao.ExcuteSqls(listSql); // } // catch (Exception ex) // { // throw new Exception("ProductMgr-->UpdateSaleStatusByBatch" + ex.Message,ex); // } //} //add by wwei0216w 2015/1/28 /// <summary> /// 更新product表中的某一個具體列的值 /// </summary> /// <returns>sql語句</returns> public string UpdateColumn(Product p, string columnName) { try { return _productDao.UpdateColumn(p, columnName); } catch (Exception ex) { throw new Exception("ProductMgr-->UpdateColumn" + ex.Message, ex); } }
public string Save(Product product) { product.Replace4MySQL(); StringBuilder strSql = new StringBuilder("insert into product( "); strSql.Append(" `product_id`,`brand_id`,`product_vendor_code`,"); strSql.Append(" `product_name`,`product_price_list`,`product_spec`,`spec_title_1`,`spec_title_2`,"); strSql.Append(" `product_freight_set`,`product_buy_limit`,`product_status`,`product_hide`,"); strSql.Append(" `product_mode`,`product_sort`,`product_start`,`product_end`,`page_content_1`,`page_content_2`,"); strSql.Append(" `page_content_3`,`product_keywords`,`product_recommend`,`product_password`,"); strSql.Append(" `product_total_click`,`expect_time`,`product_image`,`product_createdate`,`product_updatedate`,"); strSql.Append(" `product_ipfrom`,`goods_area`,`goods_image1`,`goods_image2`,`city`,"); strSql.Append(" `bag_check_money`,`combination`,`bonus_percent`,`default_bonus_percent`,`bonus_percent_start`,`bonus_percent_end`,`tax_type`,`cate_id`,"); strSql.Append(" `fortune_quota`,`fortune_freight`,`ignore_stock`,`shortage`,`stock_alarm`,`price_type`,`user_id`,`show_listprice`,`expect_msg`) values ({0},"); strSql.AppendFormat(" '{0}','{1}',", product.Brand_Id, product.Product_Vendor_Code); strSql.AppendFormat(" '{0}','{1}','{2}','{3}','{4}',", product.Product_Name, product.Product_Price_List, product.Product_Spec, product.Spec_Title_1, product.Spec_Title_2); strSql.AppendFormat(" '{0}','{1}','{2}','{3}',", product.Product_Freight_Set, product.Product_Buy_Limit, product.Product_Status, product.Product_Hide == false ? 0 : 1); strSql.AppendFormat(" '{0}','{1}','{2}','{3}','{4}','{5}',", product.Product_Mode, product.Product_Sort, product.Product_Start, product.Product_End, product.Page_Content_1, product.Page_Content_2); strSql.AppendFormat(" '{0}','{1}','{2}','{3}',", product.Page_Content_3, product.Product_Keywords, product.Product_Recommend, product.Product_Password); strSql.AppendFormat(" '{0}','{1}','{2}','{3}','{4}',", product.Product_Total_Click, product.Expect_Time, product.Product_Image, product.Product_Createdate, product.Product_Updatedate); strSql.AppendFormat(" '{0}','{1}','{2}','{3}','{4}',", product.Product_Ipfrom, product.Goods_Area, product.Goods_Image1, product.Goods_Image2, product.City); strSql.AppendFormat(" '{0}','{1}','{2}','{3}','{4}',", product.Bag_Check_Money, product.Combination, product.Bonus_Percent, product.Default_Bonus_Percent, product.Bonus_Percent_Start); strSql.AppendFormat(" '{0}','{1}','{2}','{3}','{4}',", product.Bonus_Percent_End, product.Tax_Type, product.Cate_Id, product.Fortune_Quota, product.Fortune_Freight); strSql.AppendFormat(" '{0}','{1}','{2}','{3}',", product.Ignore_Stock, product.Shortage, product.stock_alarm, product.Price_type); strSql.AppendFormat(" '{0}','{1}','{2}');select @@identity;", product.user_id, product.show_listprice, product.expect_msg); return strSql.ToString(); }
/// <summary> /// 編輯商品詳情文字 /// </summary> /// <param name="p"></param> /// <returns></returns> public int UpdateProductDeatail(Product p) { StringBuilder sql = new StringBuilder(); p.Replace4MySQL(); sql.AppendFormat(@"UPDATE product SET product_detail_text='{0}' ,detail_created='{1}',detail_createdate='{2}',detail_update='{3}',detail_updatedate='{4}' ", p.product_detail_text, p.detail_created, Common.CommonFunction.DateTimeToString(p.detail_createdate), p.detail_update, Common.CommonFunction.DateTimeToString(p.detail_updatedate)); sql.AppendFormat(@" WHERE product_id='{0}'; ", p.Product_Id); try { return _dbAccess.execCommand(sql.ToString()); } catch (Exception ex) { throw new Exception("ProductDao-->UpdateProductDeatail" + ex.Message + sql.ToString(), ex); } }
/// <summary> /// 獲取商品數據 /// </summary> /// <returns></returns> public HttpResponseBase UpdateTrialProdCate() { List<TrialProdCateQuery> storeLi = new List<TrialProdCateQuery>(); string json = string.Empty; try { _pcsMgr = new ProductCategorySetMgr(mySqlConnectionString); _trialProdMgr = new TrialProdCateMgr(mySqlConnectionString); //獲取新館類別 prodCateMgr = new ProductCategoryMgr(mySqlConnectionString);//實例化對象mgr List<ProductCategory> category = prodCateMgr.QueryAll(new ProductCategory { category_display = 0 });//獲取所有的類別 顯示的隱藏的 ProductCategory useCate = prodCateMgr.QueryAll(new ProductCategory { category_father_id = 754, category_name = "用品館" }).FirstOrDefault(); string cateUseStr = string.Empty;//設定對象獲取用品館所有子類別 GetAllCategory_id(category, useCate.category_id, ref cateUseStr);//設定對象獲取用品館所有子類別 顯示的 ProductCategory eatCate = prodCateMgr.QueryAll(new ProductCategory { category_father_id = 754, category_name = "食品館" }).FirstOrDefault(); string cateEatStr = string.Empty;//設定對象獲取食品館所有子類別 GetAllCategory_id(category, eatCate.category_id, ref cateEatStr);//設定對象獲取食品館所有子類別 顯示的 _prodMgr = new ProductMgr(mySqlConnectionString); //找到商品 List<TrialProdCateQuery> store = _trialProdMgr.UadateTrialProd(); Product prodModel = new Product(); //找到商品新館所有類別 foreach (var item in store) { if (item.product_id != 0) { prodModel = _prodMgr.QueryClassify(Convert.ToUInt32(item.product_id)); DataTable dt = new DataTable(); if (prodModel != null) { if (prodModel.Prod_Classify == 10) { item.type = 1; dt = _pcsMgr.GetCateByProds(item.product_id.ToString(), cateEatStr); //找到大類類別 bool isTrue = false; if (dt.Rows.Count != 0) { foreach (DataRow row in dt.Rows) { ProductCategory pcModel = new ProductCategory(); GetFatherCategory_id(category, ref isTrue, eatCate.category_id, Convert.ToUInt32(row["category_id"]), ref pcModel); if (isTrue && pcModel != null) { if (item.category_id == 0) { item.category_id = pcModel.category_id; storeLi.Add(item); } else { if (pcModel.category_id != item.category_id) { TrialProdCateQuery queryItem = new TrialProdCateQuery(); queryItem.product_id = item.product_id; queryItem.event_id = item.event_id; queryItem.type = item.type; queryItem.start_date = item.start_date; queryItem.end_date = item.end_date; queryItem.category_id = pcModel.category_id; List<TrialProdCateQuery> CFLi = storeLi.FindAll(p => p.category_id == queryItem.category_id && p.product_id == queryItem.product_id && p.type == queryItem.type && p.event_id == queryItem.event_id).ToList(); if (CFLi.Count == 0) { storeLi.Add(queryItem); } } } } } } } else if (prodModel.Prod_Classify == 20) { item.type = 2; dt = _pcsMgr.GetCateByProds(item.product_id.ToString(), cateUseStr); //找到大類類別 bool isTrue = false; if (dt.Rows.Count != 0) { foreach (DataRow row in dt.Rows) { ProductCategory pcModel = new ProductCategory(); GetFatherCategory_id(category, ref isTrue, useCate.category_id, Convert.ToUInt32(row["category_id"]), ref pcModel); if (isTrue && pcModel != null) { if (item.category_id == 0) { item.category_id = pcModel.category_id; storeLi.Add(item); } else { if (pcModel.category_id != item.category_id) { TrialProdCateQuery queryItem = new TrialProdCateQuery(); queryItem.product_id = item.product_id; queryItem.event_id = item.event_id; queryItem.type = item.type; queryItem.start_date = item.start_date; queryItem.end_date = item.end_date; queryItem.category_id = pcModel.category_id; List<TrialProdCateQuery> CFLi = storeLi.FindAll(p => p.category_id == queryItem.category_id && p.product_id == queryItem.product_id && p.type == queryItem.type && p.event_id == queryItem.event_id).ToList(); if (CFLi.Count == 0) { storeLi.Add(queryItem); } } } } } } } } } } //插入數據到主表trial_prod_cate if (_trialProdMgr.InsertTrialProd(storeLi)) { 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 int GetProductType(Product query) { try { return _productDao.GetProductType(query); } catch (Exception ex) { throw new Exception("ProductMgr-->GetProductType" + ex.Message, ex); } }
public HttpResponseBase specTempSave() { string resultStr = "{success:true}"; bool result = true; try { Caller _caller = (Session["caller"] as Caller); string specType = Request.Params["specType"]; string spec1Name = Request.Params["spec1Name"]; string spec1Result = Request.Params["spec1Result"]; string spec2Name = ""; string spec2Result; _specMgr = new ProductSpecMgr(connectionString); _specTempMgr = new ProductSpecTempMgr(connectionString); _productTempMgr = new ProductTempMgr(connectionString); _productItemMgr = new ProductItemMgr(connectionString); _productItemTempMgr = new ProductItemTempMgr(connectionString); _serialMgr = new SerialMgr(connectionString); if (!string.IsNullOrEmpty(Request.Params["ProductId"])) { uint proId = uint.Parse(Request.Params["ProductId"]); _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; #region 正式表修改 List<ProductSpec> spec1List = null; List<ProductSpec> spec2List = null; List<ProductSpec> specUpdateList = new List<ProductSpec>(); List<ProductSpec> specAddList = new List<ProductSpec>(); JavaScriptSerializer jss = new JavaScriptSerializer(); spec1List = jss.Deserialize<List<ProductSpec>>(spec1Result); if (spec1List != null) { //規格一處理 spec1List.ForEach(m => { m.product_id = proId; m.spec_type = 1; if (m.spec_id != 0) { specUpdateList.Add(m); } else { specAddList.Add(m); } }); } //規格二處理 if (specType.Equals("2")) { spec2Name = Request.Params["spec2Name"]; spec2Result = Request.Params["spec2Result"]; spec2List = jss.Deserialize<List<ProductSpec>>(spec2Result); spec2List.ForEach(m => { m.product_id = proId; m.spec_type = 2; if (m.spec_id != 0) { specUpdateList.Add(m); } else { specAddList.Add(m); } }); } Product proModel = new Product(); _productMgr = new ProductMgr(connectionString); _tableHistoryMgr = new TableHistoryMgr(connectionString); proModel = _productMgr.Query(new Product { Product_Id = proId }).FirstOrDefault(); proModel.Spec_Title_1 = spec1Name; proModel.Spec_Title_2 = spec2Name; if (specUpdateList.Count() > 0) { for (int i = 0, j = specUpdateList.Count(); i < j; i++) { ArrayList sqls = new ArrayList(); sqls.Add(_specMgr.Update(specUpdateList[i])); if (i == 0) { sqls.Add(_productMgr.Update(proModel)); } if (!_tableHistoryMgr.SaveHistory<ProductSpec>(specUpdateList[i], batch, sqls)) { result = false; } } } if (specAddList.Count() > 0) { List<ProductItem> saveItemList = new List<ProductItem>(); List<ProductSpec> spec1ExistList = spec1List.Where(m => m.spec_id != 0).ToList(); //規格一中原本就存在的規格 specAddList.ForEach(p => p.spec_id = uint.Parse(_serialMgr.NextSerial(18).ToString())); ProductItem saveTemp; List<PriceMaster> list_price = new List<PriceMaster>(); PriceMasterMgr pm = new PriceMasterMgr(connectionString); list_price = pm.GetPriceMasterInfoByID2(proId.ToString());//獲取同一個ID下其他產品的價格信息 PriceMaster _p = list_price.FirstOrDefault();//add by wangwei0216w 2014/9/19 獲取同一個ID下其他產品的信息 //List<ProductItem> pro_list = new List<ProductItem>(); //ProductItemMgr pig = new ProductItemMgr(connectionString); //pro_list = pig.GetProductItemByID(Convert.ToInt32(proId)); //ProductItem _product = pro_list.FirstOrDefault();//獲取同一個ID下其他產品的信息 foreach (var m in specAddList) { if (specType.Equals("1")) { if (m.spec_type == 1) { saveTemp = new ProductItem(); if (_p.same_price == 1) //add by wangwei 0216w 2014/9/19 如果同價 就將價格賦予新增規格 { //saveTemp.Item_Cost = Convert.ToUInt32(_p.cost); //saveTemp.Item_Money = Convert.ToUInt32(_p.price); } else { resultStr = "{success:true,Msg:true}"; } saveTemp.Spec_Id_1 = m.spec_id; saveTemp.Product_Id = proId; // saveTemp.Item_Stock = 10; saveTemp.Item_Alarm = 1; saveItemList.Add(saveTemp); } else { saveTemp = new ProductItem(); if (_p.same_price == 1) //add by wangwei 0216w 2014/9/19 如果同價 就將價格賦予新增規格 { //saveTemp.Item_Cost = Convert.ToUInt32(_p.cost); //saveTemp.Item_Money = Convert.ToUInt32(_p.price); } else { resultStr = "{success:true,Msg:true}"; } saveTemp.Spec_Id_2 = m.spec_id; saveTemp.Product_Id = proId; //saveTemp.Item_Stock = 10; saveTemp.Item_Alarm = 1; saveItemList.Add(saveTemp); } } else { if (m.spec_type == 1) { foreach (ProductSpec item in spec2List) { saveTemp = new ProductItem(); if (_p.same_price == 1) //add by wangwei 0216w 2014/9/19 如果同價 就將價格賦予新增規格 { //saveTemp.Item_Cost = Convert.ToUInt32(_p.cost); //saveTemp.Item_Money = Convert.ToUInt32(_p.price); } else { resultStr = "{success:true,Msg:true}"; } saveTemp.Spec_Id_1 = m.spec_id; saveTemp.Spec_Id_2 = item.spec_id; //saveTemp.Item_Stock = 10; saveTemp.Item_Alarm = 1; saveTemp.Product_Id = proId; saveItemList.Add(saveTemp); } } else { foreach (ProductSpec item2 in spec1ExistList) { saveTemp = new ProductItem(); if (_p.same_price == 1) //add by wangwei 0216w 2014/9/19 如果同價 就將價格賦予新增規格 { //saveTemp.Item_Cost = Convert.ToUInt32(_p.cost); //saveTemp.Item_Money = Convert.ToUInt32(_p.price); } else { resultStr = "{success:true,Msg:true}"; } saveTemp.Spec_Id_1 = item2.spec_id; saveTemp.Spec_Id_2 = m.spec_id; //saveTemp.Item_Stock = 10; saveTemp.Item_Alarm = 1; saveTemp.Product_Id = proId; saveItemList.Add(saveTemp); } } } } _specMgr.Save(specAddList); _productItemMgr.Save(saveItemList); ProductItem pro; if (proModel.Product_Status != 0) //add by wangwei0216w 2014/9/18 作用:將Export_flag的值設置為1 { pro = new ProductItem() { Product_Id = proModel.Product_Id, Export_flag = 1 }; _productItemMgr.UpdateExportFlag(pro); } if (result) //如果之前保存規格,插入臨時表登操作有誤,則不執行插入itemprice的操作 { List<ProductItem> item_list = _productItemMgr.GetProductNewItem_ID(Convert.ToInt32(proModel.Product_Id)); //得到product_item的新增ID ItemPrice i = new ItemPrice(); ItemPriceMgr ipm = new ItemPriceMgr(connectionString); ArrayList liststr = new ArrayList(); foreach (PriceMaster p in list_price) { foreach (ProductItem pi in item_list) { if (p.same_price == 1) { i.price_master_id = p.price_master_id; i.item_id = pi.Item_Id; i.item_money = Convert.ToUInt32(p.price); i.item_cost = Convert.ToUInt32(p.cost); i.event_cost = Convert.ToUInt32(p.event_cost); i.event_money = Convert.ToUInt32(p.event_price); } else { i.price_master_id = p.price_master_id; i.item_id = pi.Item_Id; i.item_money = 0; i.item_cost = 0; i.event_money = 0; i.event_cost = 0; resultStr = "{success:true,Msg:true}"; } liststr.Add(ipm.Save(i)); } } ipm.AddItemPricBySpec(liststr, connectionString); } } //若為單一商品,則把product_item.export_flag改為2 edit by xiangwang0413w 2014/06/30 //if (proModel.Combination == 1) //{ // _productItemMgr = new ProductItemMgr(connectionString); // ProductItem pro_Item = new ProductItem() { Product_Id = proModel.Product_Id, Export_flag = 2 }; // _productItemMgr.UpdateExportFlag(pro_Item); //} #endregion } else { #region 臨時表修改 _productTempMgr = new ProductTempMgr(connectionString); //add by xiangwang 2014.09.26 可修改庫存預設值為99 string product_id = "0"; if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) { product_id = Request.Form["OldProductId"]; } //add by xiangwang 2014.09.26 可修改庫存預設值為99 ProductTemp query = _productTempMgr.GetProTemp(new ProductTemp { Writer_Id = _caller.user_id, Combo_Type = COMBO_TYPE, Product_Id = product_id }); if (!specType.Equals("0") && !string.IsNullOrEmpty(specType)) { #region 有規格 List<ProductSpecTemp> spec1List; List<ProductSpecTemp> spec2List; List<ProductSpecTemp> specAllList = new List<ProductSpecTemp>(); JavaScriptSerializer jss = new JavaScriptSerializer(); spec1List = jss.Deserialize<List<ProductSpecTemp>>(spec1Result); foreach (ProductSpecTemp item in spec1List) { // specid = _serialMgr.NextSerial(18); //item.spec_id = uint.Parse(specid.ToString()); item.Writer_Id = _caller.user_id; item.product_id = product_id; item.spec_type = 1; item.spec_image = ""; specAllList.Add(item); } if (specType.Equals("2")) { spec2Name = Request.Params["spec2Name"]; spec2Result = Request.Params["spec2Result"]; spec2List = jss.Deserialize<List<ProductSpecTemp>>(spec2Result); foreach (ProductSpecTemp item in spec2List) { // specid = _serialMgr.NextSerial(18); //item.spec_id = uint.Parse(specid.ToString()); item.Writer_Id = _caller.user_id; item.product_id = product_id; item.spec_type = 2; item.spec_image = ""; specAllList.Add(item); } } List<ProductSpecTemp> tempList = _specTempMgr.Query(new ProductSpecTemp { Writer_Id = _caller.user_id, product_id = product_id }); if (tempList == null || tempList.Count() <= 0) { #region 保存 specAllList.ForEach(p => p.spec_id = uint.Parse(_serialMgr.NextSerial(18).ToString())); bool saveSpecResult = _specTempMgr.Save(specAllList); if (saveSpecResult) { _productItemTempMgr.Delete(new ProductItemTemp { Writer_Id = _caller.user_id, Product_Id = product_id }); #region 保存ProductItemTemp List<ProductSpecTemp> specAllResultList = _specTempMgr.Query(new ProductSpecTemp { Writer_Id = _caller.user_id, product_id = product_id }); List<ProductSpecTemp> spec1ResultList = specAllResultList.Where(m => m.spec_type == 1).ToList(); List<ProductSpecTemp> spec2ResultList = specAllResultList.Where(m => m.spec_type == 2).ToList(); List<ProductItemTemp> saveItemList = new List<ProductItemTemp>(); if (specType.Equals("1")) { foreach (ProductSpecTemp specTemp1 in spec1ResultList) { ProductItemTemp itemTemp = new ProductItemTemp(); itemTemp.Writer_Id = _caller.user_id; itemTemp.Product_Id = product_id; itemTemp.Spec_Id_1 = specTemp1.spec_id; //itemTemp.Item_Stock = 10; itemTemp.Item_Alarm = 1; saveItemList.Add(itemTemp); } } else if (specType.Equals("2")) { foreach (ProductSpecTemp specTemp1 in spec1ResultList) { foreach (ProductSpecTemp specTemp2 in spec2ResultList) { ProductItemTemp itemTemp = new ProductItemTemp(); itemTemp.Writer_Id = _caller.user_id; itemTemp.Product_Id = product_id; itemTemp.Spec_Id_1 = specTemp1.spec_id; itemTemp.Spec_Id_2 = specTemp2.spec_id; //itemTemp.Item_Stock = 10; itemTemp.Item_Alarm = 1; itemTemp.Item_Code = ""; itemTemp.Barcode = ""; saveItemList.Add(itemTemp); } } } //add by xiangwang 2014.09.26 可修改庫存預設值為99 //saveItemList.ForEach(m => m.SetDefaultItemStock(query)); bool saveItemResult = _productItemTempMgr.Save(saveItemList); if (!saveItemResult) { result = false; } #endregion } else { result = false; } #endregion } else { #region 更新 string strSpecInit = Request.Params["specInit"]; string[] specs = strSpecInit.Split(','); List<ProductSpecTemp> addList = specAllList.Where(p => p.spec_id == 0).ToList(); if (addList.Count() > 0) { addList.ForEach(p => p.spec_id = uint.Parse(_serialMgr.NextSerial(18).ToString())); List<ProductSpecTemp> specAllResultList = _specTempMgr.Query(new ProductSpecTemp { Writer_Id = _caller.user_id, product_id = product_id }); List<ProductSpecTemp> spec1ResultList = specAllResultList.Where(m => m.spec_type == 1).ToList(); List<ProductSpecTemp> spec2ResultList = specAllResultList.Where(m => m.spec_type == 2).ToList(); List<ProductItemTemp> saveItemList = new List<ProductItemTemp>(); foreach (ProductSpecTemp item in addList) { if (specType.Equals("1")) { if (item.spec_type == 1) { ProductItemTemp saveTemp = new ProductItemTemp(); saveTemp.Writer_Id = _caller.user_id; saveTemp.Spec_Id_1 = item.spec_id; saveTemp.Product_Id = product_id; //saveTemp.Item_Stock = 10; saveTemp.Item_Alarm = 1; saveItemList.Add(saveTemp); } else { ProductItemTemp saveTemp = new ProductItemTemp(); saveTemp.Writer_Id = _caller.user_id; saveTemp.Spec_Id_2 = item.spec_id; saveTemp.Product_Id = product_id; // saveTemp.Item_Stock = 10; saveTemp.Item_Alarm = 1; saveItemList.Add(saveTemp); } } else { if (item.spec_type == 1) { foreach (ProductSpecTemp item1 in spec2ResultList) { ProductItemTemp saveTemp = new ProductItemTemp(); saveTemp.Writer_Id = _caller.user_id; saveTemp.Spec_Id_1 = item.spec_id; saveTemp.Spec_Id_2 = item1.spec_id; //saveTemp.Item_Stock = 10; saveTemp.Item_Alarm = 1; saveTemp.Product_Id = product_id; saveItemList.Add(saveTemp); } foreach (ProductSpecTemp item1 in addList.Where(p => p.spec_type == 2).ToList()) { ProductItemTemp saveTemp = new ProductItemTemp(); saveTemp.Writer_Id = _caller.user_id; saveTemp.Spec_Id_1 = item.spec_id; saveTemp.Spec_Id_2 = item1.spec_id; //saveTemp.Item_Stock = 10; saveTemp.Item_Alarm = 1; saveTemp.Product_Id = product_id; saveItemList.Add(saveTemp); } } else { foreach (ProductSpecTemp item2 in spec1ResultList) { ProductItemTemp saveTemp = new ProductItemTemp(); saveTemp.Writer_Id = _caller.user_id; saveTemp.Spec_Id_1 = item2.spec_id; saveTemp.Spec_Id_2 = item.spec_id; saveTemp.Product_Id = product_id; // saveTemp.Item_Stock = 10; saveTemp.Item_Alarm = 1; saveItemList.Add(saveTemp); } } } } _specTempMgr.Save(addList); //add by xiangwang 2014.09.26 可修改庫存預設值為99 //saveItemList.ForEach(m => m.SetDefaultItemStock(query)); _productItemTempMgr.Save(saveItemList); } if (specs.Length > 0) { List<ProductSpecTemp> updateList = new List<ProductSpecTemp>(); foreach (string initSpecId in specs) { ProductSpecTemp nowItem = specAllList.Where(p => p.spec_id == uint.Parse(initSpecId)).FirstOrDefault(); if (nowItem != null) { updateList.Add(nowItem); } else { ProductItemTemp delTemp = new ProductItemTemp { Writer_Id = _caller.user_id, Product_Id = product_id }; uint spectype = _specTempMgr.Query(new ProductSpecTemp { spec_id = uint.Parse(initSpecId), product_id = product_id })[0].spec_type; if (spectype == 1) { delTemp.Spec_Id_1 = uint.Parse(initSpecId); } else if (spectype == 2) { delTemp.Spec_Id_2 = uint.Parse(initSpecId); } if (!_productItemTempMgr.Delete(delTemp)) { result = false; } if (!_specTempMgr.Delete(new ProductSpecTemp { spec_id = uint.Parse(initSpecId), Writer_Id = _caller.user_id, product_id = product_id })) { result = false; } DeletePicOnServer(false, true, false, uint.Parse(initSpecId), product_id); } } if (!_specTempMgr.Update(updateList, "spec")) { result = false; } } #endregion } #region 更新Product ProductTemp proTemp = new ProductTemp(); proTemp.Writer_Id = _caller.user_id; proTemp.Product_Spec = uint.Parse(specType); proTemp.Spec_Title_1 = spec1Name; proTemp.Spec_Title_2 = spec2Name; proTemp.Combo_Type = COMBO_TYPE; proTemp.Product_Id = product_id; bool saveProductResult = _productTempMgr.SpecInfoSave(proTemp); if (!saveProductResult) { result = false; } #endregion #endregion } else { #region 無規格 List<ProductItemTemp> saveList = new List<ProductItemTemp>(); //如果原數據有規格 if (query.Product_Spec != 0) { //刪除服務器上對應的圖片 DeletePicOnServer(false, true, false, 0, product_id); _productItemTempMgr.Delete(new ProductItemTemp { Writer_Id = _caller.user_id, Product_Id = product_id }); _specTempMgr.Delete(new ProductSpecTemp { Writer_Id = _caller.user_id, product_id = product_id }); _productTempMgr.SpecInfoSave(new ProductTemp { Product_Spec = 0, Spec_Title_1 = "", Spec_Title_2 = "", Writer_Id = _caller.user_id, Combo_Type = COMBO_TYPE, Product_Id = product_id }); saveList = new List<ProductItemTemp>(); saveList.Add(new ProductItemTemp { Writer_Id = _caller.user_id, Product_Id = product_id/*, Item_Stock = 10*/, Item_Alarm = 1 }); } else { List<ProductItemTemp> itemQuery = _productItemTempMgr.Query(new ProductItemTemp { Writer_Id = _caller.user_id, Product_Id = product_id }); if (itemQuery.Count() <= 0) { saveList = new List<ProductItemTemp>(); saveList.Add(new ProductItemTemp { Writer_Id = _caller.user_id, Product_Id = product_id, /*Item_Stock = 10,*/ Item_Alarm = 1 }); // _productItemTempMgr.Save(saveList); } } //add by xiangwang 2014.09.26 可修改庫存預設值為99 //saveList.ForEach(m => m.SetDefaultItemStock(query)); _productItemTempMgr.Save(saveList); #endregion } #endregion #region 調度或自出商品,商品庫存預設為99 var proditemTemp = new ProductItemTemp { Product_Id = product_id, Writer_Id = _caller.user_id }; proditemTemp.SetDefaultItemStock(query); _productItemTempMgr.UpdateItemStock(proditemTemp); #endregion } } catch (Exception ex) { result = 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); } if (!result) { resultStr = "{success:false,Msg:false}"; } this.Response.Clear(); this.Response.Write(resultStr); this.Response.End(); return this.Response; }
/// <summary> /// 多表更新 /// </summary> /// <param name="p">product表</param> /// <param name="pIList">ProductSpec表</param> /// <param name="pSList">ProductPicture</param> /// <returns></returns> public bool Update_Product_Spec_Picture(Product p, List<ProductSpec> pSList, List<ProductPicture> pPList, List<ProductPicture> appList = null) { ArrayList sqlList = new ArrayList(); _productSpecMgr = new ProductSpecMgr(connectionStr); List<Product> pList = _productDao.Query(p); pList[0].Product_Image = p.Product_Image; pList[0].product_media = p.product_media; pList[0].Mobile_Image = p.Mobile_Image; // edit by wwei0216w 2015/3/18 添加關於Mobile的修改 pList[0].Product_alt = p.Product_alt; if (p.Product_Image != "" || p.product_media != "" || p.Mobile_Image != "" || p.Product_alt != "")// edit by wwei0216w 2015/3/18 添加關於Mobile的修改 { sqlList.Add(_productDao.Update(pList[0])); } //ProductSpec表 foreach (var item in pSList) { //查詢product_item表 ProductSpec spec = _productSpecMgr.query(int.Parse(item.spec_id.ToString())); spec.spec_image = item.spec_image; spec.spec_sort = item.spec_sort; spec.spec_status = item.spec_status; sqlList.Add(_productSpecMgr.Update(spec)); } //ProductPicture表 sqlList.Add(_productPicDao.Delete(int.Parse(p.Product_Id.ToString()))); foreach (var item in pPList) { sqlList.Add(_productPicDao.Save(item)); } sqlList.Add(_productPicDao.Delete(int.Parse(p.Product_Id.ToString()), 2)); //1:商品說明表 2:手機app圖檔表 foreach (var item in appList) { sqlList.Add(_productPicDao.Save(item, 2)); } MySqlDao mySqlDao = new MySqlDao(connectionStr); return mySqlDao.ExcuteSqls(sqlList); }
/// <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; }
/// <summary> /// 根據productid獲取商品信息 /// </summary> /// <param name="p"></param> /// <returns></returns> public List<Product> GetProductName(Product p) { StringBuilder sb = new StringBuilder(); try { sb.AppendFormat("select * from product where product_id='{0}';", p.Product_Id); return _dbAccess.getDataTableForObj<Product>(sb.ToString()); } catch (Exception ex) { throw new Exception("ProductDao-->GetProductName" + ex.Message + sb.ToString(), ex); } }
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; }
public int GetDefaultArriveDays(Product prod) { try { int defaultArriveDays = 0; string strSql = string.Format(@"select p.product_mode,v.self_send_days,v.stuff_ware_days,v.dispatch_days from product p inner join vendor_brand vb on p.brand_id=vb.brand_id inner join vendor v on vb.vendor_id=v.vendor_id where p.product_id='{0}';", prod.Product_Id); DataTable dt = _dbAccess.getDataTable(strSql); if (dt.Rows.Count > 0) { switch (Convert.ToInt32(dt.Rows[0]["product_mode"])) { case 1: defaultArriveDays = Convert.ToInt32(dt.Rows[0]["self_send_days"]); break; case 2: defaultArriveDays = Convert.ToInt32(dt.Rows[0]["stuff_ware_days"]); break; case 3: defaultArriveDays = Convert.ToInt32(dt.Rows[0]["dispatch_days"]); break; } } return defaultArriveDays; } catch (Exception ex) { throw new Exception("ProductDao-->GetDefaultArriveDays" + ex.Message, ex); } }
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 List<Product> Query(Product query) { return _productDao.Query(query); }
public bool ProductMigration(Product pro, List<PriceMaster> priceMasters, List<ProductItem> items, List<List<ItemPrice>> itemPrices, ArrayList sqls, ArrayList specs) { string proSql = _productDao.Save(pro); ArrayList prices = new ArrayList(); if (priceMasters != null) { PriceMasterMgr priceMasterMgr = new PriceMasterMgr(""); foreach (var item in priceMasters) { prices.Add(priceMasterMgr.SaveNoProId(item)); } } ArrayList proItems = new ArrayList(); if (items != null) { ProductItemMgr productItemMgr = new ProductItemMgr(""); foreach (var item in items) { proItems.Add(productItemMgr.SaveSql(item)); } } ArrayList itemPrice = new ArrayList(); if (itemPrices != null) { ArrayList temp; ItemPriceMgr itemPriceMgr = new ItemPriceMgr(""); foreach (var item in itemPrices) { temp = new ArrayList(); foreach (var p in item) { temp.Add(itemPriceMgr.SaveNoItemId(p)); } itemPrice.Add(temp); } } return _productDao.ProductMigration(proSql, prices, proItems, itemPrice, sqls, specs); }
public DataTable GetProductDetialText(Product p) { StringBuilder sql = new StringBuilder(); DataTable _dt = new DataTable(); try { sql.AppendFormat(@"SELECT product_detail_text FROM product WHERE product_id={0}", p.Product_Id); _dt = _dbAccess.getDataTable(sql.ToString()); } catch (Exception ex) { throw new Exception("ProductDao-->GetProductDetialText" + ex.Message + sql.ToString(), ex); } return _dt; }