public int Delete(ProductComboTemp delTemp) { StringBuilder stb = new StringBuilder("set sql_safe_updates = 0;delete from product_combo_temp where 1=1 "); if (delTemp.Writer_Id != 0) { stb.AppendFormat("and writer_id = {0}", delTemp.Writer_Id); } stb.AppendFormat(" and parent_id='{0}';set sql_safe_updates = 1;", uint.Parse(delTemp.Parent_Id) ); return _access.execCommand(stb.ToString()); }
/// <summary> /// 刪除組合商品的規格和價格數據 /// </summary> /// <param name="delTemp"></param> /// <returns></returns> public bool Delete(ProductComboTemp delTemp) { try { ArrayList sqls = new ArrayList(); sqls.Add(_tempDao.TempDelete(delTemp)); //刪除item_price_temp中的數據 ItemPriceTempMgr itemPriceMgr = new ItemPriceTempMgr(""); sqls.Add(itemPriceMgr.Delete(delTemp.Parent_Id, delTemp.Combo_Type, delTemp.Writer_Id)); //刪除price_master_temp中的數據 PriceMasterTempMgr priceMasterTempMgr = new PriceMasterTempMgr(""); sqls.Add(priceMasterTempMgr.Delete(new PriceMasterTemp { writer_Id = delTemp.Writer_Id, product_id = delTemp.Parent_Id, combo_type = delTemp.Combo_Type })); return _mySql.ExcuteSqls(sqls); } catch (Exception ex) { throw new Exception("ProductComboTempMgr.Delete-->" + ex.Message, ex); } }
public string TempDelete(ProductComboTemp query) {//edit jialei 20140917 加判斷writerId StringBuilder strSql = new StringBuilder("set sql_safe_updates = 0; delete from product_combo_temp where 1=1"); if (query.Writer_Id != 0) { strSql.AppendFormat(" and writer_id = {0}", query.Writer_Id); } //strSql.AppendFormat(" and parent_id='{0}';set sql_safe_updates= 1;", query.Parent_Id); strSql.AppendFormat(" and parent_id='{0}';set sql_safe_updates= 1;", query.Parent_Id);//edit by wangwei0216w 改回原先代碼 return strSql.ToString(); }
public string groupNameQuery() { string json = string.Empty; try { if (!string.IsNullOrEmpty(Request.Params["ProductId"])) { List<ProductCombo> resultList = null; _combMgr = new ProductComboMgr(connectionString); resultList = _combMgr.groupNumQuery(new ProductCombo { Parent_Id = int.Parse(Request.Params["ProductId"]) }); json = JsonConvert.SerializeObject(resultList); } else { List<ProductComboTemp> resultList = null; Caller _caller = (Session["caller"] as Caller); _combTempMgr = new ProductComboTempMgr(connectionString); ProductComboTemp query = new ProductComboTemp { Writer_Id = _caller.user_id }; //複製商品時 if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) { query.Parent_Id = Request.Form["OldProductId"]; } resultList = _combTempMgr.groupNumQuery(query); json = JsonConvert.SerializeObject(resultList); } } 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); } return json; }
/// <summary> /// 供應商商品審核時將商品臨時表中的組合商品數據添加到琥正式表中 /// </summary> /// <param name="proComboTemp">組合商品對象</param> /// <returns>此操作的sql語句</returns> public string Vendor_TempMoveCombo(ProductComboTemp proComboTemp) { try { return _tempDao.Vendor_TempMoveCombo(proComboTemp); } catch (Exception ex) { throw new Exception("ProductComboTempMgr.Vendor_TempMoveCombo-->" + ex.Message, ex); } }
public string VendorSaveFromCombo(ProductComboTemp proComboTemp, string old_id) {//20140905 複製供應商 try { return _tempDao.VendorSaveFromCombo(proComboTemp, old_id); } catch (Exception ex) { throw new Exception("ProductComboTempMgr.VendorSaveFromCombo-->" + ex.Message, ex); } }
public List<ProductComboTemp> groupNumQueryByVendor(ProductComboTemp query) { try { return _tempDao.groupNumQueryByVendor(query); } catch (Exception ex) { throw new Exception("ProductComboTempMgr.groupNumQueryByVendor-->" + ex.Message, ex); } }
public string SaveFromCombo(ProductComboTemp proComboTemp) { try { return _tempDao.SaveFromCombo(proComboTemp); } catch (Exception ex) { throw new Exception("ProductComboTempMgr.SaveFromCombo-->" + ex.Message, ex); } }
public int Vendor_TempMove2Pro(int writerId, int combo_type, string product_Id, ProductTemp pt) { ArrayList sqls = new ArrayList(); int product_id = 0; ProductTempMgr proTempMgr = new ProductTempMgr(""); ProductTemp proTemp = new ProductTemp { Combo_Type = combo_type, Product_Id = product_Id, Create_Channel = 2 };//1:後台管理者(manage_user) edit by xiagnwang0413w 2014/08/09 string movePro = proTempMgr.Vendor_MoveProduct(proTemp); sqls.Add(proTempMgr.Vendor_Delete(proTemp)); ProductNoticeSetTempMgr proNoticeSetTempMgr = new ProductNoticeSetTempMgr(""); ProductNoticeSetTemp proNoticeSetTemp = new ProductNoticeSetTemp { Combo_Type = combo_type, product_id = product_Id }; sqls.Add(proNoticeSetTempMgr.Vendor_MoveNotice(proNoticeSetTemp)); sqls.Add(proNoticeSetTempMgr.Vendor_Delete(proNoticeSetTemp)); ProductTagSetTempMgr proTagSetTempMgr = new ProductTagSetTempMgr(""); ProductTagSetTemp proTagSetTemp = new ProductTagSetTemp { Combo_Type = combo_type, product_id = product_Id }; sqls.Add(proTagSetTempMgr.Vendor_MoveTag(proTagSetTemp)); sqls.Add(proTagSetTempMgr.Vendor_Delete(proTagSetTemp)); ProductPictureTempImplMgr proPicTempMgr = new ProductPictureTempImplMgr(""); ProductPictureTemp proPictureTemp = new ProductPictureTemp { combo_type = combo_type, product_id = product_Id }; sqls.Add(proPicTempMgr.Vendor_MoveToProductPicture(proPictureTemp)); sqls.Add(proPicTempMgr.Vendor_Delete(proPictureTemp)); ProductCategorySetTempMgr proCateSetTempMgr = new ProductCategorySetTempMgr(""); ProductCategorySetTemp proCategorySetTemp = new ProductCategorySetTemp { Combo_Type = combo_type, Product_Id = product_Id.ToString() }; sqls.Add(proCateSetTempMgr.Vendor_TempMoveCategory(proCategorySetTemp)); sqls.Add(proCateSetTempMgr.Vendor_TempDelete(proCategorySetTemp)); //product_status_history.type 1,申請審核 2,核可 3,駁回 4,下架 5,新建商品 6,上架 7,系統移轉建立 8,取消送審 parametertype='verify_operate_type' //product_status_history.product_status 0,新建立商品 1,申請審核 2,審核通過 5,上架 6,下架 20,供應商新建商品 parametertype='product_status' ProductStatusHistoryMgr proStatusHistoryMgr = new ProductStatusHistoryMgr(""); sqls.Add(proStatusHistoryMgr.SaveNoProductId(new ProductStatusHistory { product_status = 20, user_id = Convert.ToUInt32(pt.Writer_Id), type = 5 }));//供應商新建立商品 sqls.Add(proStatusHistoryMgr.SaveNoProductId(new ProductStatusHistory { product_status = 0, user_id = Convert.ToUInt32(writerId), type = 2 })); //管理員核可 ItemPriceTempMgr itemTempPriceMgr = new ItemPriceTempMgr(""); sqls.Add(itemTempPriceMgr.Vendor_Delete(product_Id, combo_type, 0)); PriceMasterTempMgr priceMasterTempMgr = new PriceMasterTempMgr(""); PriceMasterTemp priceMasterTemp = new PriceMasterTemp { product_id = product_Id, combo_type = combo_type }; sqls.Add(priceMasterTempMgr.Vendor_Delete(priceMasterTemp)); //判斷是單一商品還是組合商品 if (combo_type == 1) {//單一商品 IProductItemImplDao piDao = new ProductItemDao(connectionStr); ProductItemTempMgr proItemTempMgr = new ProductItemTempMgr(""); ProductItemTemp proItemTemp = new ProductItemTemp { Product_Id = product_Id }; string selItem = proItemTempMgr.VendorQuerySql(proItemTemp); string moveItem = proItemTempMgr.VendorMoveProductItem(proItemTemp);//方法修改了writerId sqls.Add(proItemTempMgr.DeleteVendorSql(proItemTemp)); ProductSpecTempMgr proSpecTempMgr = new ProductSpecTempMgr(""); ProductSpecTemp proSpecTemp = new ProductSpecTemp { product_id = product_Id }; sqls.Add(proSpecTempMgr.VendorTempMoveSpec(proSpecTemp)); sqls.Add(proSpecTempMgr.VendorTempDelete(proSpecTemp)); string priceMaster = priceMasterTempMgr.VendorMove2PriceMaster(priceMasterTemp); ItemPriceMgr itemPriceMgr = new ItemPriceMgr(""); string itemPrice = itemPriceMgr.SaveFromItem(pt.Writer_Id, pt.Product_Id); // add 處理price_mater_temp and product_combo_temp sqls.Add(proTempMgr.VendorEditCM(proTemp)); product_id = _productDao.TempMove2Pro(movePro, "", moveItem, "", selItem, priceMaster, itemPrice, sqls); if (product_id > 0) { piDao.UpdateErpId(product_id.ToString()); } return product_id; } else {//組合商品 ProductComboTempMgr pcTempMgr = new ProductComboTempMgr(""); ProductComboTemp proComboTemp = new ProductComboTemp { Parent_Id = product_Id }; sqls.Add(pcTempMgr.Vendor_TempMoveCombo(proComboTemp)); sqls.Add(pcTempMgr.TempDeleteByVendor(proComboTemp)); string selPrice = priceMasterTempMgr.SelectChild(priceMasterTemp); string priceMaster = priceMasterTempMgr.VendorMove2PriceMaster(priceMasterTemp); ItemPriceTempMgr itemPriceTempMgr = new ItemPriceTempMgr(""); string itemPrice = itemPriceTempMgr.VendorMove2ItemPrice(); sqls.Add(itemPriceTempMgr.Vendor_Delete(product_Id, combo_type, 0)); return _productDao.TempMove2Pro(movePro, "", "", "", selPrice, priceMaster, itemPrice, sqls); } //記錄的sql語句 //insert into product(product_id,brand_id,product_vendor_code,product_name,product_price_list,product_spec,spec_title_1,spec_title_2,product_freight_set,product_buy_limit,product_status,product_hide,product_mode,product_sort,product_start,product_end,page_content_1,page_content_2,page_content_3,product_keywords,product_recommend,product_password,product_total_click,expect_time,product_image,product_createdate,product_updatedate,product_ipfrom,goods_area,goods_image1,goods_image2,city,bag_check_money,combination,bonus_percent,default_bonus_percent,bonus_percent_start,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,create_channel ) select 15164 as product_id,brand_id,product_vendor_code,product_name,product_price_list,product_spec,spec_title_1,spec_title_2,product_freight_set,product_buy_limit,'0' as product_status,product_hide,product_mode,product_sort,product_start,product_end,page_content_1,page_content_2,page_content_3,product_keywords,product_recommend,product_password,product_total_click,expect_time,product_image,1411033321 as product_createdate,product_updatedate,product_ipfrom,goods_area,goods_image1,goods_image2,city,bag_check_money,combination,bonus_percent,default_bonus_percent,bonus_percent_start,bonus_percent_end,tax_type,cate_id,fortune_quota,fortune_freight,product_media,ignore_stock,shortage,stock_alarm,price_type,writer_id,show_listprice,expect_msg,create_channel from product_temp where 1=1 and combo_type=2 and create_channel=2 and product_id='T578'; //select price_master_id,product_id,child_id from price_master_temp where 1=1 and combo_type=2 and product_id='T578'; //insert into price_master(`product_id`,`site_id`,`user_level`,`user_id`,`product_name`,`accumulated_bonus`,`bonus_percent`,`default_bonus_percent`,`same_price`,`event_start`,`event_end`,`price_status`,`price`,`event_price`,`child_id`,`cost`,`event_cost`,`bonus_percent_start`,`bonus_percent_end`,`max_price`,`max_event_price`,`valid_start`,`valid_end`) //select 15164 as product_id,site_id,user_level,user_id,product_name,accumulated_bonus,bonus_percent,default_bonus_percent,same_price,event_start,event_end,price_status,price,event_price,15164 as child_id,cost,event_cost,bonus_percent_start,bonus_percent_end,max_price,max_event_price,valid_start,valid_end from price_master_temp where 1=1 and combo_type=2 and product_id='T578';select @@identity; //insert into item_price(`price_master_id`,`item_id`,`item_money`,`item_cost`,`event_money`,`event_cost`) select 5699 as price_master_id,item_id,item_money,item_cost,event_money,event_cost from item_price_temp where price_master_id=1751 //set sql_safe_updates = 0;update price_master set child_id=15164 where price_master_id=5699; set sql_safe_updates = 1; //set sql_safe_updates = 0;delete from product_temp where product_id='T578';set sql_safe_updates = 1 //insert into product_notice_set(product_id,notice_id) select 15164 as product_id,notice_id from product_notice_set_temp where 1=1 and combo_type = 2 and product_id='T578'; //set sql_safe_updates=0;delete from product_notice_set_temp where product_id='T578';set sql_safe_updates=1; //insert into product_tag_set(`product_id`,`tag_id`) select 15164 as product_id,tag_id from product_tag_set_temp where 1=1 and combo_type=2 and product_id='T578'; //set sql_safe_updates=0;delete from product_tag_set_temp where product_id='T578';set sql_safe_updates=1; //insert into product_picture(product_id,image_filename,image_sort,image_state,image_createdate) select 15164 as product_id,image_filename,image_sort,image_state,image_createdate from product_picture_temp where 1=1 and product_id='T578' and combo_type=2; //set sql_safe_updates=0; delete from product_picture_temp where product_id='T578';set sql_safe_updates = 1; //insert into product_category_set(product_id,category_id,brand_id) select 15164 as product_id,category_id,brand_id from product_category_set_temp where 1=1 and product_id='T578' and combo_type = 2 //set sql_safe_updates = 0; delete from product_category_set_temp where 1=1 and combo_type = 2 and product_id='T578';set sql_safe_updates = 1; //set sql_safe_updates = 0; insert into product_status_history (`product_id`,`user_id`,`create_time`,`type`,`product_status`,`remark`) values (15164,0,now(),5,20,'');set sql_safe_updates = 1; //set sql_safe_updates = 0; insert into product_status_history (`product_id`,`user_id`,`create_time`,`type`,`product_status`,`remark`) values (15164,122,now(),2,0,'');set sql_safe_updates = 1; //set sql_safe_updates=0;delete item_price_temp from price_master_temp left join item_price_temp on item_price_temp.price_master_id=price_master_temp.price_master_id where 1=1 and price_master_temp.product_id='T578' and price_master_temp.combo_type=2 ;set sql_safe_updates=1; //set sql_safe_updates = 0;delete from price_master_temp where 1=1 and product_id='T578' and combo_type=2;set sql_safe_updates = 1; //insert into product_combo(`parent_id`,`child_id`,`s_must_buy`,`g_must_buy`,`pile_id`,`buy_limit`) select 15164 as parent_id,child_id,s_must_buy,g_must_buy,pile_id,buy_limit from product_combo_temp where 1=1 and parent_id='T578'; //set sql_safe_updates = 0; delete from product_combo_temp where writer_id = 0 and parent_id='T578'; set sql_safe_updates= 1; //set sql_safe_updates=0;delete item_price_temp from price_master_temp left join item_price_temp on item_price_temp.price_master_id=price_master_temp.price_master_id where 1=1 and price_master_temp.product_id='T578' and price_master_temp.combo_type=2 ;set sql_safe_updates=1; //SELECT * from product where product_id='15164' }
public int SaveByVendor(ProductComboTemp saveTemp) { StringBuilder stb = new StringBuilder(); try { stb.Append("insert into product_combo_temp (`writer_id`,`parent_id`,`child_id`,`s_must_buy`,`g_must_buy`,`pile_id`,`buy_limit`)"); stb.AppendFormat(" values({0},'{1}','{2}',{3},{4},{5},{6})", saveTemp.Writer_Id, saveTemp.Parent_Id, saveTemp.Child_Id, saveTemp.S_Must_Buy, saveTemp.G_Must_Buy, saveTemp.Pile_Id, saveTemp.Buy_Limit); return _access.execCommand(stb.ToString()); } catch (Exception ex) { throw new Exception("ProductComboTempDao-->SaveByVendor-->" + ex.Message + stb.ToString(), ex); } }
public int Save(ProductComboTemp saveTemp) { StringBuilder stb = new StringBuilder("insert into product_combo_temp (`writer_id`,`parent_id`,`child_id`,`s_must_buy`,`g_must_buy`,`pile_id`,`buy_limit`)"); stb.AppendFormat(" values({0},{1},'{2}',{3},{4},{5},{6})", saveTemp.Writer_Id, saveTemp.Parent_Id, saveTemp.Child_Id, saveTemp.S_Must_Buy, saveTemp.G_Must_Buy, saveTemp.Pile_Id, saveTemp.Buy_Limit); return _access.execCommand(stb.ToString()); }
public int DeleteByVendor(ProductComboTemp delTemp) { StringBuilder strSql = new StringBuilder(); try { strSql.Append("set sql_safe_updates = 0; delete from product_combo_temp "); strSql.AppendFormat("where writer_id = {0}", delTemp.Writer_Id); if (!string.IsNullOrEmpty(delTemp.Parent_Id)) { strSql.AppendFormat(" and parent_id='{0}' ", delTemp.Parent_Id); } strSql.Append("; set sql_safe_updates= 1;"); return _access.execCommand(strSql.ToString()); } catch (Exception ex) { throw new Exception("ProductComboTempDao-->DeleteByVendor-->" + ex.Message + strSql.ToString(), ex); } }
public string TempDeleteByVendor(ProductComboTemp query) { StringBuilder strSql = new StringBuilder(); try { strSql.Append("set sql_safe_updates = 0; delete from product_combo_temp where 1=1"); if (query.Writer_Id != 0) { strSql.AppendFormat(" and writer_id = {0}", query.Writer_Id); } if (!string.IsNullOrEmpty(query.Parent_Id)) { strSql.AppendFormat(" and parent_id='{0}'", query.Parent_Id); } strSql.Append(" ;set sql_safe_updates= 1;"); return strSql.ToString(); } catch (Exception ex) { throw new Exception("ProductComboTempDao-->TempDeleteByVendor-->" + ex.Message + strSql.ToString(), ex); } }
public string SaveFromCombo(ProductComboTemp proComboTemp) { StringBuilder strSql = new StringBuilder("insert into product_combo_temp(`writer_id`,`parent_id`,`child_id`"); strSql.Append(",`s_must_buy`,`g_must_buy`,`pile_id`,`buy_limit`) select "); strSql.AppendFormat("{0} as writer_id,parent_id,child_id,s_must_buy,g_must_buy,pile_id,buy_limit from product_combo where parent_id='{1}'", proComboTemp.Writer_Id, proComboTemp.Parent_Id); return strSql.ToString(); }
public HttpResponseBase combSpecTempDelete() { string resultStr = "{success:false}"; try { _combTempMgr = new ProductComboTempMgr(connectionString); BLL.gigade.Model.Vendor vendorModel = (BLL.gigade.Model.Vendor)Session["vendor"]; int write_Id = Convert.ToInt32(vendorModel.vendor_id); ProductComboTemp delete = new ProductComboTemp { Writer_Id = write_Id, Combo_Type = COMBO_TYPE }; if (!string.IsNullOrEmpty(Request.Form["ProductId"])) { delete.Parent_Id = Request.Form["ProductId"].ToString(); } //複製商品時 //if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) //{ // delete.Parent_Id = Request.Form["OldProductId"].ToString(); //} _combTempMgr.DeleteByVendor(delete); resultStr = "{success:true}"; } 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); } Response.Clear(); Response.Write(resultStr); Response.End(); return this.Response; }
public int TempMove2Pro(int writerId, int combo_type, string product_Id) { ArrayList sqls = new ArrayList(); int product_id = 0; ProductTempMgr proTempMgr = new ProductTempMgr(""); ProductTemp proTemp = new ProductTemp { Writer_Id = writerId, Combo_Type = combo_type, Product_Id = product_Id, Create_Channel = 1 };//1:後台管理者(manage_user) edit by xiagnwang0413w 2014/08/09 string movePro = proTempMgr.MoveProduct(proTemp); sqls.Add(proTempMgr.Delete(proTemp)); /*********start*********/ //將ProductDeliverySetTemp表數據導入正式表 edit by xiangwang0413w 2014/11/06 IProductDeliverySetTempImplMgr _proDelSetTemp = new ProductDeliverySetTempMgr(""); var proDelSetTemp = new ProductDeliverySetTemp { Writer_Id = writerId, Combo_Type = combo_type, Product_id = int.Parse(product_Id) }; sqls.Add(_proDelSetTemp.MoveProductDeliverySet(proDelSetTemp)); sqls.Add(_proDelSetTemp.Delete(proDelSetTemp)); /*******end***********/ ProductNoticeSetTempMgr proNoticeSetTempMgr = new ProductNoticeSetTempMgr(""); ProductNoticeSetTemp proNoticeSetTemp = new ProductNoticeSetTemp { Writer_Id = writerId, Combo_Type = combo_type, product_id = product_Id }; sqls.Add(proNoticeSetTempMgr.MoveNotice(proNoticeSetTemp)); sqls.Add(proNoticeSetTempMgr.Delete(proNoticeSetTemp)); ProductTagSetTempMgr proTagSetTempMgr = new ProductTagSetTempMgr(""); ProductTagSetTemp proTagSetTemp = new ProductTagSetTemp { Writer_Id = writerId, Combo_Type = combo_type, product_id = product_Id }; sqls.Add(proTagSetTempMgr.MoveTag(proTagSetTemp)); sqls.Add(proTagSetTempMgr.Delete(proTagSetTemp)); ProductPictureTempImplMgr proPicTempMgr = new ProductPictureTempImplMgr(""); ProductPictureTemp proPictureTemp = new ProductPictureTemp { writer_Id = writerId, combo_type = combo_type, product_id = product_Id }; sqls.Add(proPicTempMgr.MoveToProductPicture(proPictureTemp, 1));//更新說明圖表 sqls.Add(proPicTempMgr.MoveToProductPicture(proPictureTemp, 2));//更新APP圖表 sqls.Add(proPicTempMgr.Delete(proPictureTemp, 1));//刪除說明圖臨時表 sqls.Add(proPicTempMgr.Delete(proPictureTemp, 2)); //刪除app臨時表 add by wwei0216w 2014/11/11 ProductCategorySetTempMgr proCateSetTempMgr = new ProductCategorySetTempMgr(""); ProductCategorySetTemp proCategorySetTemp = new ProductCategorySetTemp { Writer_Id = writerId, Combo_Type = combo_type, Product_Id = product_Id.ToString() }; sqls.Add(proCateSetTempMgr.TempMoveCategory(proCategorySetTemp)); sqls.Add(proCateSetTempMgr.TempDelete(proCategorySetTemp)); ProductStatusHistoryMgr proStatusHistoryMgr = new ProductStatusHistoryMgr(""); sqls.Add(proStatusHistoryMgr.SaveNoProductId(new ProductStatusHistory { product_status = 0, user_id = Convert.ToUInt32(writerId), type = 5 })); ItemPriceTempMgr itemTempPriceMgr = new ItemPriceTempMgr(""); sqls.Add(itemTempPriceMgr.Delete(product_Id, combo_type, writerId)); PriceMasterTempMgr priceMasterTempMgr = new PriceMasterTempMgr(""); PriceMasterTemp priceMasterTemp = new PriceMasterTemp { writer_Id = writerId, product_id = product_Id, combo_type = combo_type }; sqls.Add(priceMasterTempMgr.Delete(priceMasterTemp)); //判斷是單一商品還是組合商品 if (combo_type == 1) {//單一商品 IProductItemImplDao piDao = new ProductItemDao(connectionStr); ProductItemTempMgr proItemTempMgr = new ProductItemTempMgr(""); ProductItemTemp proItemTemp = new ProductItemTemp { Writer_Id = writerId, Product_Id = product_Id }; string selItem = proItemTempMgr.QuerySql(proItemTemp); string moveItem = proItemTempMgr.MoveProductItem(proItemTemp); sqls.Add(proItemTempMgr.DeleteSql(proItemTemp)); /*************start*課程相關*****************/ //CourseDetailItem ICourseDetailItemTempImplMgr _cdItemMgr = new CourseDetailItemTempMgr(""); string moveCourDetaItem = _cdItemMgr.MoveCourseDetailItem(writerId); sqls.Add(_cdItemMgr.DeleteSql(writerId)); //CourseProduct ICourseProductTempImplMgr _courProdTempMgr = new CourseProductTempMgr(""); var courProdTemp = new CourseProductTemp { Writer_Id = writerId, Product_Id = uint.Parse(product_Id) }; string moveCourProd = _courProdTempMgr.MoveCourseProduct(courProdTemp); sqls.Add(_courProdTempMgr.DeleteSql(courProdTemp)); /*************end**********************************/ ProductSpecTempMgr proSpecTempMgr = new ProductSpecTempMgr(""); ProductSpecTemp proSpecTemp = new ProductSpecTemp { Writer_Id = writerId, product_id = product_Id }; sqls.Add(proSpecTempMgr.TempMoveSpec(proSpecTemp)); sqls.Add(proSpecTempMgr.TempDelete(proSpecTemp)); string priceMaster = priceMasterTempMgr.Move2PriceMaster(priceMasterTemp); ItemPriceMgr itemPriceMgr = new ItemPriceMgr(""); string itemPrice = itemPriceMgr.SaveFromItem(writerId, product_Id); product_id = _productDao.TempMove2Pro(movePro, moveCourProd, moveItem, moveCourDetaItem, selItem, priceMaster, itemPrice, sqls); //把商品推薦屬性臨時表中的數據moveto商品推薦屬性表中,然後刪除商品推薦臨時表 通過product_id指定商品推薦屬性對應的商品 #region 推薦商品屬性插入recommended_product_attribute表中做記錄 if (_rProductAttribute.ExsitInTemp(writerId, int.Parse(product_Id), combo_type) > 0)//判斷臨時表中是否存在 product_Id為傳入的productId { DataTable _dt = _rProductAttribute.GetTempList(writerId, int.Parse(product_Id), combo_type); RecommendedProductAttribute rPA = new RecommendedProductAttribute(); rPA.product_id = Convert.ToUInt32(product_id); rPA.time_start = 0; rPA.time_end = 0; rPA.expend_day = Convert.ToUInt32(_dt.Rows[0]["expend_day"]); rPA.months = _dt.Rows[0]["months"].ToString(); rPA.combo_type = 1; if (_rProductAttribute.GetMsgByProductId(product_id) > 0)//如果大於0,表示推薦表中存在數據 { if (_rProductAttribute.Update(rPA) > 0) { _rProductAttribute.DeleteTemp(writerId, int.Parse(product_Id), combo_type);//刪除臨時表中的數據 } } else { if (_rProductAttribute.Save(rPA) > 0) { _rProductAttribute.DeleteTemp(writerId, int.Parse(product_Id), combo_type);//刪除臨時表中的數據 } } } #endregion if (product_id > 0) { piDao.UpdateErpId(product_id.ToString()); } return product_id; } else {//組合商品 ProductComboTempMgr pcTempMgr = new ProductComboTempMgr(""); ProductComboTemp proComboTemp = new ProductComboTemp { Writer_Id = writerId, Parent_Id = product_Id }; sqls.Add(pcTempMgr.TempMoveCombo(proComboTemp)); sqls.Add(pcTempMgr.TempDelete(proComboTemp)); string selPrice = priceMasterTempMgr.SelectChild(priceMasterTemp); string priceMaster = priceMasterTempMgr.Move2PriceMasterByMasterId(); ItemPriceTempMgr itemPriceTempMgr = new ItemPriceTempMgr(""); string itemPrice = itemPriceTempMgr.Move2ItemPrice(); sqls.Add(itemPriceTempMgr.Delete(product_Id, combo_type, writerId)); product_id = _productDao.TempMove2Pro(movePro, "", "", "", selPrice, priceMaster, itemPrice, sqls); //把商品推薦屬性臨時表中的數據moveto商品推薦屬性表中,然後刪除商品推薦臨時表 通過product_id指定商品推薦屬性對應的商品 #region 推薦商品屬性插入recommended_product_attribute表中做記錄 if (_rProductAttribute.ExsitInTemp(writerId, int.Parse(product_Id), combo_type) > 0)//判斷臨時表中是否存在 product_Id為傳入的productId { DataTable _dt = _rProductAttribute.GetTempList(writerId, int.Parse(product_Id), combo_type); RecommendedProductAttribute rPA = new RecommendedProductAttribute(); rPA.product_id = Convert.ToUInt32(product_id); rPA.time_start = 0; rPA.time_end = 0; rPA.expend_day = Convert.ToUInt32(_dt.Rows[0]["expend_day"]); rPA.months = _dt.Rows[0]["months"].ToString(); rPA.combo_type = 2; if (_rProductAttribute.GetMsgByProductId(product_id) > 0)//如果大於0,表示推薦表中存在數據 { if (_rProductAttribute.Update(rPA) > 0) { _rProductAttribute.DeleteTemp(writerId, int.Parse(product_Id), combo_type);//刪除臨時表中的數據 } } else { if (_rProductAttribute.Save(rPA) > 0) { _rProductAttribute.DeleteTemp(writerId, int.Parse(product_Id), combo_type);//刪除臨時表中的數據 } } } return product_id; #endregion } }
/// <summary> /// 獲取群組信息 /// </summary> /// <param name="query">ProductComboTemp model對象</param> /// <returns> List<ProductComboTemp> </returns> public List<ProductComboTemp> groupNumQueryByVendor(ProductComboTemp query) { StringBuilder strSql = new StringBuilder(); try { strSql.Append("select pile_id,g_must_buy,buy_limit from product_combo_temp where 1=1"); if (query.Writer_Id != 0) { strSql.AppendFormat(" and writer_id = {0}", query.Writer_Id); } if (!string.IsNullOrEmpty(query.Parent_Id)) { strSql.AppendFormat(" and parent_id='{0}' ", query.Parent_Id); } strSql.Append(" group by pile_id,g_must_buy,buy_limit"); return _access.getDataTableForObj<ProductComboTemp>(strSql.ToString()); } catch (Exception ex) { throw new Exception("ProductComboTempDao-->groupNumQueryByVendor-->" + ex.Message + strSql.ToString(), ex); } }
/// <summary> /// 刪除子商品對應價格數據 /// </summary> /// <returns></returns> public bool comboChildPriceDel(ProductComboTemp delTemp) { ArrayList sqls = new ArrayList(); ItemPriceTempMgr itemPriceMgr = new ItemPriceTempMgr(""); sqls.Add(itemPriceMgr.ChildDelete(delTemp.Parent_Id, delTemp.Combo_Type, delTemp.Writer_Id)); PriceMasterTempMgr priceMasterMgr = new PriceMasterTempMgr(""); sqls.Add(priceMasterMgr.ChildDelete(new PriceMasterTemp { writer_Id = delTemp.Writer_Id, product_id = delTemp.Parent_Id.ToString(), combo_type = delTemp.Combo_Type })); return _mySql.ExcuteSqls(sqls); }
public string VendorSaveFromCombo(ProductComboTemp proComboTemp, string old_id) {//20140905 複製供應商 StringBuilder strSql = new StringBuilder("insert into product_combo_temp"); strSql.AppendFormat("(`writer_id`,`parent_id`,`child_id`,`s_must_buy`,`g_must_buy`,`pile_id`,`buy_limit`) select "); strSql.AppendFormat("{0} as writer_id,'{1}' as parent_id,child_id,s_must_buy,g_must_buy,pile_id,buy_limit ", proComboTemp.Writer_Id, proComboTemp.Parent_Id); uint productid = 0; if (uint.TryParse(old_id, out productid)) { strSql.AppendFormat(" from product_combo where parent_id={0};", productid); } else { strSql.AppendFormat(" from product_combo_temp where parent_id='{0}';", old_id); } return strSql.ToString(); }
public string TempDeleteByVendor(ProductComboTemp query) { try { return _tempDao.TempDeleteByVendor(query); } catch (Exception ex) { throw new Exception("ProductComboTempMgr.TempDeleteByVendor-->" + ex.Message, ex); } }
public List<ProductTemp> QueryChildStatusVendor(ProductComboTemp query) { StringBuilder sql = new StringBuilder(); try { //子商品為正式單一商品時 //add 判斷運費和運送方式 StringBuilder productcom = new StringBuilder(); productcom.AppendFormat("(SELECT product_id,product_name,prod_sz,brand_id,product_status,product_mode,product_freight_set from product_temp pt where product_id='{0}') UNION ", query.Parent_Id); StringBuilder productSql = new StringBuilder(); productSql.Append("select c.child_id as product_id ,p.product_name,p.prod_sz,p.brand_id,p.product_status,p.product_mode,p.product_freight_set "); productSql.Append(" from product p "); productSql.Append(" inner join product_combo_temp c on p.product_id = c.child_id where 1=1"); if (query.Writer_Id != 0) { productSql.AppendFormat(" and c.writer_id = {0}", query.Writer_Id); } if (!string.IsNullOrEmpty(query.Parent_Id)) { productSql.AppendFormat(" and parent_id='{0}' ", query.Parent_Id); } //子商品為供應商新建立的已經完成的單一商品時 StringBuilder productTempSql = new StringBuilder(); productTempSql.Append("select ct.child_id as product_id ,pt.product_name,pt.prod_sz,pt.brand_id,pt.product_status,pt.product_mode,pt.product_freight_set "); productTempSql.Append(" from product_temp pt "); productTempSql.Append(" inner join product_combo_temp ct on pt.product_id = ct.child_id where 1=1 "); if (query.Writer_Id != 0) { productTempSql.AppendFormat(" and ct.writer_id = {0}", query.Writer_Id); } if (!string.IsNullOrEmpty(query.Parent_Id)) { productTempSql.AppendFormat(" and parent_id='{0}' ", query.Parent_Id); } sql.Append(productcom + "(" + productSql + ")" + " UNION " + "(" + productTempSql + ")"); return _access.getDataTableForObj<ProductTemp>(sql.ToString()); } catch (Exception ex) { throw new Exception("ProductComboTempDao-->QueryChildStatusVendor-->" + ex.Message + sql.ToString(), ex); } }
/// <summary> /// 刪除組合商品的父商品和子商品價格數據 /// </summary> /// <param name="delTemp"></param> /// <returns></returns> public bool comboPriceDeleteByVendor(ProductComboTemp delTemp) { ArrayList sqls = new ArrayList(); try { //刪除item_price_temp子商品的數據中的數據 ItemPriceTempMgr itemPriceMgr = new ItemPriceTempMgr(""); sqls.Add(itemPriceMgr.DeleteByVendor(delTemp.Parent_Id, delTemp.Combo_Type, delTemp.Writer_Id)); //刪除price_master_temp中的數據 PriceMasterTempMgr priceMasterTempMgr = new PriceMasterTempMgr(""); sqls.Add(priceMasterTempMgr.DeleteByVendor(new PriceMasterTemp { writer_Id = delTemp.Writer_Id, product_id = delTemp.Parent_Id, combo_type = delTemp.Combo_Type })); return _mySql.ExcuteSqls(sqls); } catch (Exception ex) { throw new Exception("ProductComboTempMgr.comboPriceDeleteByVendor-->" + ex.Message + sqls.ToString(), ex); } }
/// <summary> /// 供應商商品審核時將商品臨時表中的組合商品數據添加到琥正式表中 /// </summary> /// <param name="proComboTemp">組合商品對象</param> /// <returns>此操作的sql語句</returns> public string Vendor_TempMoveCombo(ProductComboTemp proComboTemp) { StringBuilder stb = new StringBuilder("insert into product_combo(`parent_id`,`child_id`,`s_must_buy`,`g_must_buy`,`pile_id`,`buy_limit`) "); stb.Append("select {0} as parent_id,child_id,s_must_buy,g_must_buy,pile_id,buy_limit from product_combo_temp where 1=1 "); stb.AppendFormat(" and parent_id='{0}';", proComboTemp.Parent_Id); return stb.ToString(); }
public List<ProductTemp> QueryChildStatusVendor(ProductComboTemp query) { try { return _tempDao.QueryChildStatusVendor(query); } catch (Exception ex) { throw new Exception("ProductComboTempMgr.QueryChildStatusVendor-->" + ex.Message, ex); } }
public List<ProductComboTemp> groupNumQuery(ProductComboTemp query) { StringBuilder strSql = new StringBuilder("select pile_id,g_must_buy,buy_limit from product_combo_temp "); strSql.AppendFormat("where writer_id = {0}", query.Writer_Id); strSql.AppendFormat(" and parent_id='{0}'", query.Parent_Id); strSql.Append(" group by pile_id,g_must_buy,buy_limit"); return _access.getDataTableForObj<ProductComboTemp>(strSql.ToString()); }
public string groupNameQuery() { string json = string.Empty; try { string ParentId = string.Empty; if (!string.IsNullOrEmpty(Request.Params["ProductId"])) { ParentId = Request.Params["ProductId"]; } List<ProductComboTemp> resultList = null; _combTempMgr = new ProductComboTempMgr(connectionString); ProductComboTemp query = new ProductComboTemp(); query.Parent_Id = ParentId; resultList = _combTempMgr.groupNumQueryByVendor(query); json = JsonConvert.SerializeObject(resultList); } 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); } return json; }
public string groupNameQuery() { string json = string.Empty; try { BLL.gigade.Model.Vendor vendorModel = (BLL.gigade.Model.Vendor)Session["vendor"]; string ParentId = string.Empty; uint pid = 0; if (!string.IsNullOrEmpty(Request.Params["ProductId"])) { if (uint.TryParse(Request.Params["ProductId"].ToString(), out pid)) { List<ProductCombo> resultList = null; _combMgr = new ProductComboMgr(connectionString); resultList = _combMgr.groupNumQuery(new ProductCombo { Parent_Id = int.Parse(Request.Params["ProductId"]) }); json = JsonConvert.SerializeObject(resultList); } else { ParentId = Request.Params["ProductId"]; List<ProductComboTemp> resultList = null; int writer_id = Convert.ToInt32(vendorModel.vendor_id); _combTempMgr = new ProductComboTempMgr(connectionString); ProductComboTemp query = new ProductComboTemp { Writer_Id = writer_id, Parent_Id = ParentId }; resultList = _combTempMgr.groupNumQueryByVendor(query); json = JsonConvert.SerializeObject(resultList); } } } 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); } return json; }
public HttpResponseBase comboPriceTempDelete() { resultStr = "{success:false}"; try { Caller _caller = (Session["caller"] as Caller); _combTempMgr = new ProductComboTempMgr(connectionString); ProductComboTemp delete = new ProductComboTemp { Writer_Id = _caller.user_id, Combo_Type = COMBO_TYPE }; //複製商品時 if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) { delete.Parent_Id = Request.Form["OldProductId"]; } _combTempMgr.comboPriceDelete(delete); resultStr = "{success:true}"; } 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); } Response.Clear(); Response.Write(resultStr); Response.End(); return this.Response; }
public string TempMoveCombo(ProductComboTemp query) {//edit jialei 20140917 加判斷writerId StringBuilder stb = new StringBuilder("insert into product_combo(`parent_id`,`child_id`,`s_must_buy`,`g_must_buy`,`pile_id`,`buy_limit`) "); stb.Append("select {0} as parent_id,child_id,s_must_buy,g_must_buy,pile_id,buy_limit from product_combo_temp where 1=1 "); if (query.Writer_Id != 0) { stb.AppendFormat(" and writer_id = {0}", query.Writer_Id); } stb.AppendFormat(" and parent_id='{0}';", query.Parent_Id); return stb.ToString(); }