public void updataFromsinfoDV(T_StyleCodeInfo dvsytleinfo, string guid) { T_StyleCodeInfoDAL StyleCodeInfodal = new T_StyleCodeInfoDAL(); //int t = 0; //t = StyleCodeInfodal.GetCountByosmDocTreeID(dvsytleinfo.CustomStyleCode); //if (t == 0) //{ StyleCodeInfodal.updataFromsinfoDV(dvsytleinfo, guid); //} }
private void DoWork_CusUpdata(object sender, DoWorkEventArgs args) { BackgroundWorker worker = sender as BackgroundWorker; // T_StyleCodeInfo[] styleinfo = new T_StyleCodeInfo(); T_StyleCodeInfo styleinfo = new T_StyleCodeInfo(); //using (TransactionScope ts = new TransactionScope()) //{ for (int i = 0; i < StyleCodeInfodataGridView.RowCount; i++) { // this.Invoke((EventHandler)(delegate // { //写入语句 //SQLBALLCOPY styleinfo.osmDocTreeID = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["osmDocTreeID"].Value); styleinfo.DocTreeID = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["DocTreeID"].Value); if (StyleCodeInfodataGridView.Rows[i].Cells["DeliverDate"].Value != null) { styleinfo.DeliverDate = Convert.ToDateTime(StyleCodeInfodataGridView.Rows[i].Cells["DeliverDate"].Value); } styleinfo.doccode = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["doccode"].Value); styleinfo.OrderDate = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["OrderDate"].Value); styleinfo.SessionType = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["SessionType"].Value); styleinfo.CCount = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["CCount"].Value); styleinfo.TotalCount = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["TotalCount"].Value); styleinfo.ExportPrice = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["ExportPrice"].Value); styleinfo.MonetaryUnit = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["MonetaryUnit"].Value); styleinfo.MonetaryUnitname = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["MonetaryUnitname"].Value); styleinfo.FactoryID = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["FactoryID"].Value); styleinfo.FactoryName = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["FactoryName"].Value); styleinfo.WarehouseID = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["WarehouseID"].Value); styleinfo.Warehouse = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["Warehouse"].Value); styleinfo.CustomStyleCode = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["CustomStyleCode"].Value); styleinfo.CutNo = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["CutNo"].Value); styleinfo.CustomID = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["CustomID"].Value); styleinfo.CustomName = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["CustomName"].Value); styleinfo.CustomBuyer = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["CustomBuyer"].Value); styleinfo.CustomBuyName = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["CustomBuyName"].Value); styleinfo.StyleID = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["StyleID"].Value); styleinfo.Code = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["Code"].Value); styleinfo.Name = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["Name"].Value); styleinfo.SingleTurn = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["SingleTurn"].Value); styleinfo.CustomPO = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["CustomPO"].Value); styleinfo.ManufactureOrder = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["ManufactureOrder"].Value); styleinfo.StyleNumber = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["StyleNumber"].Value); styleinfo.ColorID = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["ColorID"].Value); styleinfo.ColorName = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["ColorName"].Value); styleinfo.Editionhandle = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["Editionhandle"].Value); styleinfo.ModelNo = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["ModelNo"].Value); styleinfo.CuttingNo = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["CuttingNo"].Value); styleinfo.RBcode = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["RBcode"].Value); styleinfo.RBcolor = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["RBcolor"].Value); styleinfo.MDcode = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["MDcode"].Value); styleinfo.MDcolor = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["MDcolor"].Value); styleinfo.ddlcode = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["ddlcode"].Value); styleinfo.ddwcode = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["ddwcode"].Value); styleinfo.ddqcode = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["ddqcode"].Value); styleinfo.ddhcode = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["ddhcode"].Value); styleinfo.ddscode = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["ddscode"].Value); styleinfo.aocode = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["aocode"].Value); styleinfo.towcode = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["towcode"].Value); if (StyleCodeInfodataGridView.Rows[i].Cells["ShipMentDate"].Value != null) { styleinfo.ShipMentDate = Convert.ToDateTime(StyleCodeInfodataGridView.Rows[i].Cells["ShipMentDate"].Value); } styleinfo.ExportArea = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["ExportArea"].Value); styleinfo.AimArea = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["AimArea"].Value); styleinfo.ShipType = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["ShipType"].Value); styleinfo.ShipTypeName = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["ShipTypeName"].Value); styleinfo.Memo = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["Memo"].Value); styleinfo.CustomClothBrand = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["CustomClothBrand"].Value); styleinfo.logocode = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["logocode"].Value); styleinfo.logoname = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["logoname"].Value); styleinfo.OrderDocType = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["OrderDocType"].Value); styleinfo.OrderDocTypeName = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["OrderDocTypeName"].Value); styleinfo.DesignTypeID = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["DesignTypeID"].Value); styleinfo.DesignTypeName = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["DesignTypeName"].Value); styleinfo.GoodsType = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["GoodsType"].Value); styleinfo.GoodsTypeName = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["GoodsTypeName"].Value); styleinfo.ID = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["ID"].Value); styleinfo.StyleNo = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["StyleNo"].Value); styleinfo.PriceItem = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["PriceItem"].Value); styleinfo.PriceItemName = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["PriceItemName"].Value); styleinfo.BalanceType = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["BalanceType"].Value); styleinfo.BalanceTypeName = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["BalanceTypeName"].Value); styleinfo.CountryName = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["CountryName"].Value); styleinfo.CountryNum = Convert.ToString(StyleCodeInfodataGridView.Rows[i].Cells["CountryNum"].Value); // SetTextMessage((i + 1) * 100 / StyleCodeInfodataGridView.RowCount); // using (TransactionScope ts = new TransactionScope())//分布式事务 有错误 // { T_StyleCodeInfoBLL stylecodeinfobll = new T_StyleCodeInfoBLL(); // Guid guid = Guid.NewGuid(); string guidstr = stylecodeinfobll.GetCountByosmDocTreeID(styleinfo.CustomStyleCode); if (guidstr.Length <= 0)//保存前检查是否已有记录 { Guid guid = Guid.NewGuid(); stylecodeinfobll.updataFromDV(styleinfo, guid); //写订单明细 //写sizerun string DocTreeID; string osmDocTreeID; DocTreeID = this.StyleCodeInfodataGridView["DocTreeID", i].Value.ToString(); //第1列为ID 取值去查SIZERUN osmDocTreeID = this.StyleCodeInfodataGridView["osmDocTreeID", i].Value.ToString(); //第0列为ID 取值去查SIZERUN stylecodeinfobll.updataFromSize(Convert.ToString(guid), osmDocTreeID); // ts.Complete(); } else { // Guid guid = styleinfo.; stylecodeinfobll.updataFromsinfoDV(styleinfo, guidstr); //写订单明细 //写sizerun string DocTreeID; string osmDocTreeID; DocTreeID = this.StyleCodeInfodataGridView["DocTreeID", i].Value.ToString(); //第1列为ID 取值去查SIZERUN osmDocTreeID = this.StyleCodeInfodataGridView["osmDocTreeID", i].Value.ToString(); //第0列为ID 取值去查SIZERUN stylecodeinfobll.updataFromSize(guidstr, osmDocTreeID); // ts.Complete(); } // } if (worker.CancellationPending) { args.Cancel = true; break; } else { worker.ReportProgress(i * 100 / StyleCodeInfodataGridView.RowCount); Thread.Sleep(0); } //} //if (!args.Cancel) //没有取消 写入库 //{ // ts.Complete(); //} // })); // Thread.Sleep(100);//显示出来 } }