public bool VendorCopyProduct(int writerId, int combo_type, string old_product_Id, ref string product_id, string product_Ipfrom) { int Vendor_rid = 0; try { List<ProductTemp> copynumber = _pTempDao.GetProTempByVendor(new ProductTemp { Writer_Id = writerId, Combo_Type = combo_type, Create_Channel = 2, Temp_Status = 13 }); if (copynumber.Count != 0) { foreach (var item in copynumber) { DeleteVendorProductTemp(writerId, combo_type, item.Product_Id); } } ArrayList sqls = new ArrayList(); Vendor_rid = VendorSaveFromPro(new ProductTemp { Writer_Id = writerId, Combo_Type = combo_type, Product_Id = old_product_Id, Product_Ipfrom = product_Ipfrom, Product_Createdate = uint.Parse(Common.CommonFunction.GetPHPTime(DateTime.Now.ToString()).ToString()) }); product_id = "T" + Vendor_rid; ProductNoticeSetTempMgr proNoticeSetTempMgr = new ProductNoticeSetTempMgr(""); sqls.Add(proNoticeSetTempMgr.VendorSaveFromProNotice(new ProductNoticeSetTemp { Writer_Id = writerId, Combo_Type = combo_type, product_id = product_id }, old_product_Id)); ProductTagSetTempMgr proTagSetTempMgr = new ProductTagSetTempMgr(""); sqls.Add(proTagSetTempMgr.VendorSaveFromTag(new ProductTagSetTemp { Writer_Id = writerId, Combo_Type = combo_type, product_id = product_id }, old_product_Id)); ProductPictureTempImplMgr proPicTempMgr = new ProductPictureTempImplMgr(""); sqls.Add(proPicTempMgr.VendorSaveFromProPicture(new ProductPictureTemp { writer_Id = writerId, combo_type = combo_type, product_id = product_id }, old_product_Id)); ProductCategorySetTempMgr proCateSetTempMgr = new ProductCategorySetTempMgr(""); sqls.Add(proCateSetTempMgr.VendorSaveFromCategorySet(new ProductCategorySetTemp { Writer_Id = writerId, Combo_Type = combo_type, Product_Id = product_id }, old_product_Id)); PriceMasterTempMgr priceMasterTempMgr = new PriceMasterTempMgr(""); ArrayList specs = new ArrayList(); if (combo_type == 1)//單一商品 { sqls.Add(priceMasterTempMgr.VendorSaveFromPriceMaster(new PriceMasterTemp { writer_Id = writerId, product_id = product_id, combo_type = combo_type }, old_product_Id)); ProductItemTempMgr proItemTempMgr = new ProductItemTempMgr(""); sqls.Add(proItemTempMgr.VendorSaveFromProItem(new ProductItemTemp { Writer_Id = writerId, Product_Id = product_id }, old_product_Id)); //因為複製的是臨時表所以換成productspectemp ProductSpecTempMgr ProSpecTemp = new ProductSpecTempMgr(connStr); //查詢出要複製的商品裡面的規格是否為空 List<ProductSpecTemp> proSpecs = ProSpecTemp.VendorQuery(new ProductSpecTemp { product_id = old_product_Id }); //ProductSpecMgr proSpecMgr = new ProductSpecMgr(connStr); if (proSpecs != null) { ProductSpecTempMgr proSpecTempMgr = new ProductSpecTempMgr(connStr); StringBuilder str; foreach (var item in proSpecs) { str = new StringBuilder(); str.Append(proSpecTempMgr.VendorSaveFromSpec(new ProductSpecTemp { Writer_Id = writerId, product_id = product_id, spec_id = item.spec_id }, old_product_Id)); str.Append(proItemTempMgr.VendorUpdateCopySpecId(new ProductItemTemp { Writer_Id = writerId, Product_Id = product_id, Spec_Id_1 = item.spec_id, Spec_Id_2 = item.spec_id })); specs.Add(str.ToString()); } } return _pTempDao.VendorCopyProduct(sqls, specs, null, null, null); } else { PriceMasterMgr priceMasterMgr = new PriceMasterMgr(""); string selMaster = priceMasterMgr.VendorSelectChild(new PriceMasterTemp { product_id = old_product_Id }); string moveMaster = priceMasterTempMgr.VendorSaveFromPriceMaster(new PriceMasterTemp { combo_type = combo_type, product_id = product_id, writer_Id = writerId }, old_product_Id); ItemPriceTempMgr itemPriceTempMgr = new ItemPriceTempMgr(""); string movePrice = itemPriceTempMgr.SaveFromItemPriceByMasterId(); ProductComboTempMgr proComboTempMgr = new ProductComboTempMgr(""); sqls.Add(proComboTempMgr.VendorSaveFromCombo(new ProductComboTemp { Writer_Id = writerId, Parent_Id = product_id }, old_product_Id)); return _pTempDao.VendorCopyProduct(sqls, specs, selMaster, moveMaster, movePrice); } } catch (Exception ex) { throw new Exception("ProductTempMgr.VendorCopyProduct-->" + ex.Message, ex); } }