/// <summary> /// 刪除臨時表 /// </summary> /// <returns></returns> public bool DeleteTemp(int writerId, int combo_type, string product_Id) { try { ArrayList sqls = new ArrayList(); sqls.Add(Delete(new ProductTemp { Writer_Id = writerId, Combo_Type = combo_type, Product_Id = product_Id.ToString() })); //edit by xiangwang0413w 2015/03/11 ICourseProductTempImplMgr _courProdTempMgr = new CourseProductTempMgr(""); _courProdTempMgr.DeleteSql(new CourseProductTemp { Writer_Id = writerId , Product_Id = uint.Parse(product_Id)}); ProductItemTempMgr proItemTempMgr = new ProductItemTempMgr(""); sqls.Add(proItemTempMgr.DeleteSql(new ProductItemTemp { Writer_Id = writerId, Product_Id = product_Id })); //edit by xiangwang0413w 2015/03/11 ICourseDetailItemTempImplMgr _courDetaItemTempMgr = new CourseDetailItemTempMgr(""); sqls.Add(_courDetaItemTempMgr.DeleteSql(writerId)); //add by xiangwang0413w 2014/11/06 ProductDeliverySetTempMgr proDelSetTempMgr = new ProductDeliverySetTempMgr(""); sqls.Add(proDelSetTempMgr.Delete(new ProductDeliverySetTemp { Writer_Id = writerId,Combo_Type = combo_type, Product_id = int.Parse(product_Id) })); ProductNoticeSetTempMgr proNoticeSetTempMgr = new ProductNoticeSetTempMgr(""); sqls.Add(proNoticeSetTempMgr.Delete(new ProductNoticeSetTemp { Writer_Id = writerId, Combo_Type = combo_type, product_id = product_Id })); ProductTagSetTempMgr proTagSetTempMgr = new ProductTagSetTempMgr(""); sqls.Add(proTagSetTempMgr.Delete(new ProductTagSetTemp { Writer_Id = writerId, Combo_Type = combo_type, product_id = product_Id })); ProductSpecTempMgr proSpecTempMgr = new ProductSpecTempMgr(""); sqls.Add(proSpecTempMgr.TempDelete(new ProductSpecTemp { Writer_Id = writerId, product_id = product_Id })); ProductPictureTempImplMgr proPicTempMgr = new ProductPictureTempImplMgr(""); sqls.Add(proPicTempMgr.Delete(new ProductPictureTemp { writer_Id = writerId, combo_type = combo_type, product_id = product_Id },1)); //刪除說明圖 sqls.Add(proPicTempMgr.Delete(new ProductPictureTemp { writer_Id = writerId, combo_type = combo_type, product_id = product_Id },2)); //刪除APP圖 ProductCategorySetTempMgr proCateSetTempMgr = new ProductCategorySetTempMgr(""); sqls.Add(proCateSetTempMgr.TempDelete(new ProductCategorySetTemp { Writer_Id = writerId, Combo_Type = combo_type, Product_Id = product_Id })); ItemPriceTempMgr itemPriceMgr = new ItemPriceTempMgr(""); sqls.Add(itemPriceMgr.Delete(product_Id, combo_type, writerId)); PriceMasterTempMgr priceMasterTempMgr = new PriceMasterTempMgr(""); sqls.Add(priceMasterTempMgr.Delete(new PriceMasterTemp { writer_Id = writerId, product_id = product_Id, combo_type = combo_type })); ProductComboTempMgr proComboTempMgr = new ProductComboTempMgr(""); sqls.Add(proComboTempMgr.TempDelete(new ProductComboTemp { Writer_Id = writerId, Parent_Id = product_Id })); //add by dongya 2015/08/25 14:03 根據writeid和productId刪除商品推薦屬性臨時表中信息 複製的邏輯:首先是刪除臨時表中的數據,然後把數據插入到臨時表; RecommendedProductAttributeMgr rmendeAttribute =new RecommendedProductAttributeMgr(""); sqls.Add(rmendeAttribute.TempDelete(writerId,Convert.ToInt32(product_Id),combo_type)); MySqlDao mySqlDao = new MySqlDao(connStr); return mySqlDao.ExcuteSqls(sqls); } catch (Exception ex) { throw new Exception("ProductTempMg.DeleteTemp-->" + ex.Message, ex); } }
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 } }