public string TempMoveCategory(ProductCategorySetTemp proCategorySetTemp) { StringBuilder stb = new StringBuilder("insert into product_category_set(product_id,category_id,brand_id) select {0} as product_id,"); stb.AppendFormat("category_id,brand_id from product_category_set_temp where writer_id = {0} and combo_type = {1}", proCategorySetTemp.Writer_Id, proCategorySetTemp.Combo_Type); stb.AppendFormat(" and product_id='{0}'", proCategorySetTemp.Product_Id); return stb.ToString(); }
public string SaveFromCategorySet(ProductCategorySetTemp proCategorySetTemp) { StringBuilder strSql = new StringBuilder("insert into product_category_set_temp select "); strSql.AppendFormat("{0} as writer_id,product_id,category_id,brand_id,{1} as combo_type from product_category_set ", proCategorySetTemp.Writer_Id, proCategorySetTemp.Combo_Type); strSql.AppendFormat("where product_id='{0}'", proCategorySetTemp.Product_Id); return strSql.ToString(); }
public string TempDelete(ProductCategorySetTemp proCategorySetTemp) { StringBuilder strSql = new StringBuilder("set sql_safe_updates = 0; delete from product_category_set_temp "); strSql.AppendFormat("where writer_id = {0} and combo_type = {1}", proCategorySetTemp.Writer_Id, proCategorySetTemp.Combo_Type); strSql.AppendFormat(" and product_id='{0}';set sql_safe_updates = 1;", proCategorySetTemp.Product_Id); return strSql.ToString(); }
public List<ProductCategorySetTemp> Query(ProductCategorySetTemp queryTemp) { StringBuilder strSql = new StringBuilder("select writer_id,category_id from product_category_set_temp "); strSql.AppendFormat("where writer_id = {0} and combo_type = {1} ", queryTemp.Writer_Id, queryTemp.Combo_Type); strSql.AppendFormat(" and product_id='{0}'", queryTemp.Product_Id); return _access.getDataTableForObj<ProductCategorySetTemp>(strSql.ToString()); }
public string TempDeleteByVendor(ProductCategorySetTemp proCategorySetTemp) { StringBuilder strSql = new StringBuilder(); try { strSql.Append("set sql_safe_updates = 0; delete from product_category_set_temp "); strSql.AppendFormat(" where writer_id={0} ", proCategorySetTemp.Writer_Id); strSql.AppendFormat(" and combo_type={0}", proCategorySetTemp.Combo_Type); if (!string.IsNullOrEmpty(proCategorySetTemp.Product_Id) && proCategorySetTemp.Product_Id != "0") { strSql.AppendFormat(" and product_id='{0}';set sql_safe_updates = 1;", proCategorySetTemp.Product_Id); } else { strSql.AppendFormat(" and product_id='{0}';set sql_safe_updates = 1;", proCategorySetTemp.Product_Id); } return strSql.ToString(); } catch (Exception ex) { throw new Exception("ProductCategorySetTempDao-->TempDeleteByVendor-->" + ex.Message + strSql.ToString(), ex); } }
public string TempDelete(ProductCategorySetTemp proCategorySetTemp) { try { return _cateSetDao.TempDelete(proCategorySetTemp); } catch (Exception ex) { throw new Exception("ProductCategorySetTempMgr-->TempDelete-->" + ex.Message, ex); } }
public List<ProductCategorySetTemp> Query(ProductCategorySetTemp queryTemp) { try { return _cateSetDao.Query(queryTemp); } catch (Exception ex) { throw new Exception("ProductCategorySetTempMgr-->Query-->" + ex.Message, ex); } }
public int Delete(ProductCategorySetTemp delTemp,string deStr="0") { StringBuilder strSql = new StringBuilder("set sql_safe_updates = 0; delete from product_category_set_temp "); strSql.AppendFormat("where writer_id = {0} and combo_type = {1}", delTemp.Writer_Id, delTemp.Combo_Type); strSql.AppendFormat(" and product_id='{0}'", delTemp.Product_Id ); if (deStr != "0") { strSql.AppendFormat(" AND category_id in ({0})", deStr); } strSql.Append("; set sql_safe_updates = 1;"); return _access.execCommand(strSql.ToString()); }
public bool Delete(ProductCategorySetTemp delTemp,string deStr="") { try { if (deStr == "") return true; return _cateSetDao.Delete(delTemp, deStr) <= 0 ? false : true; } catch (Exception ex) { throw new Exception("ProductCategorySetTempMgr-->Delete-->" + ex.Message, ex); } }
public HttpResponseBase tempCategoryAdd() { BLL.gigade.Model.Vendor vendorModel = (BLL.gigade.Model.Vendor)Session["vendor"]; int writd_Id = (int)vendorModel.vendor_id; string resultStr = "{success:true}"; string tempStr = Request.Params["result"]; string cate_id = Request.Params["cate_id"]; List<ProductCategorySetTemp> saveTempList = new List<ProductCategorySetTemp>(); try { JavaScriptSerializer js = new JavaScriptSerializer(); List<ProductCategorySetCustomTemp> cateCustomList = js.Deserialize<List<ProductCategorySetCustomTemp>>(tempStr); if (string.IsNullOrEmpty(tempStr)) { cateCustomList = new List<ProductCategorySetCustomTemp>(); } string vendor_pId = string.Empty; if (!string.IsNullOrEmpty(Request.Params["ProductId"])) { vendor_pId = Request.Params["ProductId"]; //if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) //{ // vendor_pId = Request.Form["OldProductId"]; //} _categoryTempSetMgr = new ProductCategorySetTempMgr(connectionString); _productTempMgr = new ProductTempMgr(connectionString); if (string.IsNullOrEmpty(tempStr)) { bool result = _categoryTempSetMgr.DeleteByVendor(new ProductCategorySetTemp { Writer_Id = writd_Id, Combo_Type = COMBO_TYPE, Product_Id = vendor_pId }); } else { ProductCategorySetTemp saveTemp; ProductTemp query = new ProductTemp { Writer_Id = writd_Id, Combo_Type = COMBO_TYPE, Product_Id = vendor_pId }; ProductTemp proTemp = _productTempMgr.GetVendorProTemp(query); foreach (ProductCategorySetCustomTemp item in cateCustomList) { saveTemp = new ProductCategorySetTemp(); saveTemp.Writer_Id = writd_Id; saveTemp.Product_Id = vendor_pId; saveTemp.Category_Id = item.Category_Id; saveTemp.Brand_Id = proTemp.Brand_Id; saveTemp.Combo_Type = COMBO_TYPE; saveTempList.Add(saveTemp); } if (!_categoryTempSetMgr.SaveByVendor(saveTempList)) { resultStr = "{success:false}"; } } if (!_productTempMgr.CategoryInfoUpdateByVendor(new ProductTemp { Writer_Id = writd_Id, Cate_Id = cate_id, Combo_Type = COMBO_TYPE, Product_Id = vendor_pId })) { resultStr = "{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); resultStr = "{success:false}"; } this.Response.Clear(); this.Response.Write(resultStr); this.Response.End(); return this.Response; }
public int Save(ProductCategorySetTemp saveTemp) { StringBuilder stb = new StringBuilder("insert into product_category_set_temp (`writer_id`,`product_id`,`category_id`,`brand_id`,`combo_type`) "); stb.AppendFormat(" values ({0},{1},{2},{3},{4})", saveTemp.Writer_Id, saveTemp.Product_Id, saveTemp.Category_Id, saveTemp.Brand_Id, saveTemp.Combo_Type); return _access.execCommand(stb.ToString()); }
public string VendorSaveFromCategorySet(ProductCategorySetTemp proCategorySetTemp, string old_product_Id) { StringBuilder strSql = new StringBuilder("insert into product_category_set_temp select "); strSql.AppendFormat("{0} as writer_id,'{1}' as product_id,category_id,brand_id,{2} as combo_type ", proCategorySetTemp.Writer_Id, proCategorySetTemp.Product_Id, proCategorySetTemp.Combo_Type); uint productid = 0; if (uint.TryParse(old_product_Id, out productid)) { strSql.AppendFormat(" from product_category_set where product_id={0}", productid); } else { strSql.AppendFormat(" from product_category_set_temp where product_id='{0}'", old_product_Id); } return strSql.ToString(); }
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 List<ProductCategorySetTemp> QueryByVendor(ProductCategorySetTemp queryTemp) { //edit jialei 20140912 用於商品管理供應商申請審核 StringBuilder strSql = new StringBuilder(); try { strSql.Append("select writer_id,category_id from product_category_set_temp where 1=1 "); if (queryTemp.Writer_Id != 0) { strSql.AppendFormat(" and writer_id = {0} ", queryTemp.Writer_Id); } if (!string.IsNullOrEmpty(queryTemp.Product_Id)) { strSql.AppendFormat(" and product_id='{0}'", queryTemp.Product_Id); } if (queryTemp.Combo_Type!=0) { strSql.AppendFormat(" and combo_type = {0}", queryTemp.Combo_Type); } strSql.AppendFormat(";set sql_safe_updates = 1; ", queryTemp.Combo_Type); return _access.getDataTableForObj<ProductCategorySetTemp>(strSql.ToString()); } catch (Exception ex) { throw new Exception("ProductCategorySetTempDao-->QueryByVendor-->" + ex.Message + strSql.ToString(), ex); } }
public HttpResponseBase GetCatagory(string id = "true") { List<ProductCategory> categoryList = new List<ProductCategory>(); List<ProductCategoryCustom> cateList = new List<ProductCategoryCustom>(); string resultStr = ""; BLL.gigade.Model.Vendor vendorModel = (BLL.gigade.Model.Vendor)Session["vendor"]; try { _procateMgr = new ProductCategoryMgr(connectionString); categoryList = _procateMgr.QueryAll(new ProductCategory { }); cateList = getCate(categoryList, "5"); List<ProductCategorySetTemp> TempresultList = new List<ProductCategorySetTemp>(); List<ProductCategorySet> resultList = new List<ProductCategorySet>(); ProductCategorySetTemp query = new ProductCategorySetTemp(); if (!string.IsNullOrEmpty(Request.Params["ProductId"])) { uint product_id = 0; if (uint.TryParse(Request.Params["ProductId"], out product_id)) //正式表數據 { _categorySetMgr = new ProductCategorySetMgr(connectionString); resultList = _categorySetMgr.Query(new ProductCategorySet { Product_Id = uint.Parse(Request.Params["ProductId"]) }); TempresultList = null; } else { resultList = null; query.Product_Id = Request.Params["ProductId"]; _productTempMgr = new ProductTempMgr(connectionString); ProductTemp productT = _productTempMgr.GetProTempByVendor(new ProductTemp { Product_Id = Request.Params["ProductId"] }).FirstOrDefault(); if (productT != null) { query.Combo_Type = productT.Combo_Type; } else { query.Combo_Type = COMBO_TYPE; } query.Writer_Id = (int)vendorModel.vendor_id; _categoryTempSetMgr = new ProductCategorySetTempMgr(connectionString); TempresultList = (from c in _categoryTempSetMgr.QueryByVendor(query) select new { Id = c.Id, Product_Id = c.Product_Id, Category_Id = c.Category_Id, Brand_Id = c.Brand_Id }).ToList().ConvertAll<ProductCategorySetTemp>(m => new ProductCategorySetTemp { Id = m.Id, Product_Id = m.Product_Id, Category_Id = m.Category_Id, Brand_Id = m.Brand_Id }); } } //調試resultlist是否為空 GetCategoryList(categoryList, ref cateList, TempresultList, resultList); List<ProductCategoryCustom> cateListResult = new List<ProductCategoryCustom>(); cateListResult = getCate(categoryList, "0"); cateListResult[0].children = getCate(categoryList, cateListResult[0].id.ToString()); int cateLen = cateListResult[0].children.Count; int i = 0; while (cateLen > 0) { if (cateListResult[0].children[i].id == "5") { i++; } else { cateListResult[0].children.Remove(cateListResult[0].children[i]); } cateLen--; } cateListResult[0].children[0].children = cateList; resultStr = JsonConvert.SerializeObject(cateListResult); resultStr = resultStr.Replace("Checked", "checked"); } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); } this.Response.Clear(); this.Response.Write(resultStr); this.Response.End(); return this.Response; }
public HttpResponseBase 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 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 } }
public bool DeleteByVendor(ProductCategorySetTemp delTemp) { try { return _cateSetDao.DeleteByVendor(delTemp) <= 0 ? false : true; } catch (Exception ex) { throw new Exception("ProductCategorySetTempMgr-->DeleteByVendor-->" + ex.Message, ex); } }
/// <summary> /// 管理員核可供應商建立的商品時將商品類別信息由臨時表移動到正式表 /// </summary> /// <param name="proCategorySetTemp">臨時表中的數據對象</param> /// <returns>此操作的sql語句</returns> public string Vendor_TempMoveCategory(ProductCategorySetTemp proCategorySetTemp) { try { return _cateSetDao.Vendor_TempMoveCategory(proCategorySetTemp); } catch (Exception ex) { throw new Exception("ProductCategorySetTempMgr-->Vendor_TempMoveCategory-->" + ex.Message, ex); } }
public string VendorSaveFromCategorySet(ProductCategorySetTemp proCategorySetTemp,string old_product_Id) { try { return _cateSetDao.VendorSaveFromCategorySet(proCategorySetTemp, old_product_Id); } catch (Exception ex) { throw new Exception("ProductCategorySetTempMgr-->VendorSaveFromCategorySet-->" + ex.Message, ex); } }
public string SaveFromCategorySet(ProductCategorySetTemp proCategorySetTemp) { try { return _cateSetDao.SaveFromCategorySet(proCategorySetTemp); } catch (Exception ex) { throw new Exception("ProductCategorySetTempMgr-->SaveFromCategorySet-->" + ex.Message, ex); } }
public int DeleteByVendor(ProductCategorySetTemp delTemp) { StringBuilder strSql = new StringBuilder(); try { strSql.Append("set sql_safe_updates = 0; delete from product_category_set_temp "); strSql.AppendFormat("where writer_id = {0} and combo_type = {1}", delTemp.Writer_Id, delTemp.Combo_Type); strSql.AppendFormat(" and product_id='{0}';set sql_safe_updates = 1;", delTemp.Product_Id); return _access.execCommand(strSql.ToString()); } catch (Exception ex) { throw new Exception("ProductCategorySetTempDao-->DeleteByVendor-->" + ex.Message + strSql.ToString(), 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 SaveByVendor(ProductCategorySetTemp saveTemp) { StringBuilder strSql = new StringBuilder(); try { strSql.Append("insert into product_category_set_temp (`writer_id`,`product_id`,`category_id`,`brand_id`,`combo_type`) "); strSql.AppendFormat(" values ({0},'{1}',{2},{3},{4})", saveTemp.Writer_Id, saveTemp.Product_Id, saveTemp.Category_Id, saveTemp.Brand_Id, saveTemp.Combo_Type); return _access.execCommand(strSql.ToString()); } catch (Exception ex) { throw new Exception("ProductCategorySetTempDao-->SaveByVendor-->" + ex.Message + strSql.ToString(), ex); } }
public HttpResponseBase GetCatagory() { List<ProductCategory> categoryList = new List<ProductCategory>(); List<ProductCategoryCustom> cateList = new List<ProductCategoryCustom>(); int categoryType = 2; //用來區別查詢所有節點還是查詢新館的節點 //edit by wwei0216w 2014/12/25 //從後臺獲取查詢所有節點還是查詢新館的節點 categoryType = Request["categoryType"] == null ? 2 : Convert.ToInt32(Request["categoryType"]); string resultStr = ""; try { _procateMgr = new ProductCategoryMgr(connectionString); categoryList = _procateMgr.QueryAll(new ProductCategory { }); cateList = getCate(categoryList, 0); List<ProductCategorySet> resultList = new List<ProductCategorySet>(); if (!string.IsNullOrEmpty(Request.Params["ProductId"])) { _categorySetMgr = new ProductCategorySetMgr(connectionString); resultList = _categorySetMgr.Query(new ProductCategorySet { Product_Id = uint.Parse(Request.Params["ProductId"]) }); } else { Caller _caller = (Session["caller"] as Caller); ProductCategorySetTemp query = new ProductCategorySetTemp { Writer_Id = _caller.user_id, Combo_Type = COMBO_TYPE }; _categoryTempSetMgr = new ProductCategorySetTempMgr(connectionString); if (!string.IsNullOrEmpty(Request.Params["OldProductId"]))//edit by xiaohui 2014/09/24 { query.Product_Id = Request.Params["OldProductId"]; } resultList = (from c in _categoryTempSetMgr.Query(query) select new { Id = c.Id, Product_Id = c.Product_Id, Category_Id = c.Category_Id, Brand_Id = c.Brand_Id }).ToList().ConvertAll<ProductCategorySet>(m => new ProductCategorySet() { Id = m.Id, Product_Id = uint.Parse(m.Product_Id), Category_Id = m.Category_Id, Brand_Id = m.Brand_Id }); } GetCategoryList(categoryList, ref cateList, resultList); switch (categoryType) { case 0: resultStr = JsonConvert.SerializeObject(cateList); break; case 1: //等於754 cateList.FindAll(m => m.id == "2")[0].children.RemoveAll(m => m.id != "754");//移除新館節點 resultStr = JsonConvert.SerializeObject(cateList); break; case 2: cateList.FindAll(m => m.id == "2")[0].children.RemoveAll(m => m.id == "754");//移除新館節點 resultStr = JsonConvert.SerializeObject(cateList); break; } resultStr = resultStr.Replace("Checked", "checked"); } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); } this.Response.Clear(); this.Response.Write(resultStr); this.Response.End(); return this.Response; }
public HttpResponseBase GetCatagory() { List<ProductCategory> categoryList = new List<ProductCategory>(); List<ProductCategoryCustom> cateList = new List<ProductCategoryCustom>(); string resultStr = ""; try { _procateMgr = new ProductCategoryMgr(connectionString); categoryList = _procateMgr.QueryAll(new ProductCategory { }); cateList = getCate(categoryList, "5"); List<ProductCategorySetTemp> TempresultList = new List<ProductCategorySetTemp>(); List<ProductCategorySet> resultList = new List<ProductCategorySet>(); string Ven_product_id = string.Empty; if (!string.IsNullOrEmpty(Request.Params["ProductId"])) { Ven_product_id = Request.Params["ProductId"]; } //if (!string.IsNullOrEmpty(Request.Form["OldProductId"])) //{ // Ven_product_id = Request.Form["OldProductId"]; //} BLL.gigade.Model.Vendor vendorModel = (BLL.gigade.Model.Vendor)Session["vendor"]; int writd_Id = Convert.ToInt32(vendorModel.vendor_id); ProductCategorySetTemp query = new ProductCategorySetTemp { Writer_Id = writd_Id, Combo_Type = COMBO_TYPE, Product_Id = Ven_product_id }; _categoryTempSetMgr = new ProductCategorySetTempMgr(connectionString); TempresultList = (from c in _categoryTempSetMgr.QueryByVendor(query) select new { Id = c.Id, Product_Id = c.Product_Id, Category_Id = c.Category_Id, Brand_Id = c.Brand_Id }).ToList().ConvertAll<ProductCategorySetTemp>(m => new ProductCategorySetTemp() { Id = m.Id, Product_Id = m.Product_Id, Category_Id = m.Category_Id, Brand_Id = m.Brand_Id }); GetCategoryList(categoryList, ref cateList, TempresultList, resultList); List<ProductCategoryCustom> cateListResult = new List<ProductCategoryCustom>(); cateListResult = getCate(categoryList, "0"); cateListResult[0].children = getCate(categoryList, cateListResult[0].id.ToString()); int cateLen = cateListResult[0].children.Count; int i = 0; while (cateLen > 0) { if (cateListResult[0].children[i].id.ToString() == "5") { i++; } else { cateListResult[0].children.Remove(cateListResult[0].children[i]); } cateLen--; } cateListResult[0].children[0].children = cateList; resultStr = JsonConvert.SerializeObject(cateListResult); resultStr = resultStr.Replace("Checked", "checked"); } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); } this.Response.Clear(); this.Response.Write(resultStr); this.Response.End(); return this.Response; }