/// <summary> /// 星创销售订单导入 /// </summary> /// <param name="dt"></param> private bool InsertSaleBill_XC(DataTable dt) { DataTable tmpdt = FilterData(dt, "数量 > 0"); //CustomDesktopAlert.H2(tmpdt.Rows.Count.ToString()); if (tmpdt.Rows.Count > 0) { Huali.EDI2.DAL.SEOutStock dSale = new EDI2.DAL.SEOutStock(); int interId = dSale.GetMaxFInterID(); string billNo = dSale.GetMaxFBillNo(); string sourceBillNo = tmpdt.Rows[0]["订单号"].ToString(); //已经翻译到名店编号列 int custId = int.Parse(tmpdt.Rows[0]["购货单位代码"].ToString()); int storeId = int.Parse(tmpdt.Rows[0]["门店代码"].ToString()); string productName = tmpdt.Rows[0]["收货方部门"].ToString(); //string explanation = string.Format("补货 {0}", productName); string explanation = string.Format("{0}", productName); int empId = dSale.GetEmpIDByStoreID(storeId); Huali.EDI2.Models.SEOutStock mSale = BuildSaleModel(interId, billNo, storeId, explanation, sourceBillNo, custId, 20302, null, 15322, empId); try { if (dSale.InsertBill(mSale) == true) { //CustomDesktopAlert.H2("写主表成功!"); //写子表 int succ = 0; for (int i = 0; i < tmpdt.Rows.Count; i++) { Huali.EDI2.DAL.SEOutStockEntry dSaleEnrty = new EDI2.DAL.SEOutStockEntry(); int itemId = int.Parse(tmpdt.Rows[i]["SKU"].ToString()); int entryId = i + 1; int stockId = int.Parse(tmpdt.Rows[i]["仓库"].ToString()); int qty = int.Parse(tmpdt.Rows[i]["数量"].ToString()); //int cxType = int.Parse(tmpdt.Rows[i]["促销类别"].ToString()); Huali.EDI2.DAL.T_ICItem dicitem = new EDI2.DAL.T_ICItem(); //decimal price = dicitem.GetSalePriceByFItemID(itemId); decimal price = 0; int unitid = dicitem.GetUnitIDByitemID(itemId); Huali.EDI2.Models.SEOutStockEntry mSaleEntry = BuildSaleEntryModel(interId, entryId, itemId, stockId, qty, price, 0, 0, 0, 0, 0, 0, 40384, 40470, unitid); if (dSaleEnrty.InsertBillEntry(mSaleEntry)) { succ += 1; } } if (succ == tmpdt.Rows.Count) { CustomDesktopAlert.H2("单据号 " + billNo + " :" + succ + " 条记录导入成功!</h2>"); return(true); } else { CustomDesktopAlert.H2(billNo + "写子表失败!"); return(false); } } else { CustomDesktopAlert.H2("写主数据表失败"); return(false); } } catch (Exception ex) { MessageBox.Show(ex.Message); return(false); } } else { CustomDesktopAlert.H2("没有可用的数据!"); return(false); } }
/// <summary> /// 将一张订单的数据写入数据库 /// </summary> /// <param name="dt">一张订单的数据</param> private bool InsertSaleBill_RL(DataTable dt) { Huali.EDI2.DAL.SEOutStock dSale = new EDI2.DAL.SEOutStock(); int interId = dSale.GetMaxFInterID(); string billNo = dSale.GetMaxFBillNo(); string sourceBillNo = dt.Rows[0]["订单号"].ToString(); //已经翻译到名店编号列 int custId = int.Parse(dt.Rows[0]["客户编号"].ToString()); int storeId = int.Parse(dt.Rows[0]["门店编号"].ToString()); string productName = dt.Rows[0]["补货产品名称"].ToString(); string explanation = string.Format("免费品 {0} 2+1+1", productName); int empId = dSale.GetEmpIDByStoreID(storeId); Huali.EDI2.Models.SEOutStock mSale = BuildSaleModel(interId, billNo, storeId, explanation, sourceBillNo, custId, 20303, 40394, 15326, empId); try { if (dSale.InsertBill(mSale) == true) { //CustomDesktopAlert.H2("写主表成功!"); //写子表 int succ = 0; for (int i = 0; i < dt.Rows.Count; i++) { Huali.EDI2.DAL.SEOutStockEntry dSaleEnrty = new EDI2.DAL.SEOutStockEntry(); int itemId = int.Parse(dt.Rows[i]["补货产品编号"].ToString()); int entryId = i + 1; int stockId = 526;//CSW int qty = int.Parse(dt.Rows[i]["补货数量"].ToString()); Huali.EDI2.DAL.T_ICItem dicitem = new EDI2.DAL.T_ICItem(); decimal price = dicitem.GetSalePriceByFItemID(itemId); //Huali.EDI2.Models.SEOutStockEntry mSaleEntry = BuildSaleEntryModel(interId, entryId, itemId, stockId, qty, price, 0, 0, qty, qty, 0, 0,40311,40635, 255); Huali.EDI2.Models.SEOutStockEntry mSaleEntry = BuildSaleEntryModel(interId, entryId, itemId, stockId, qty, price, 0, 0, 0, 0, 0, 0, 40311, 40635, 255); if (dSaleEnrty.InsertBillEntry(mSaleEntry)) { succ += 1; } } if (succ == dt.Rows.Count) { CustomDesktopAlert.H2("单据号 " + billNo + " :" + succ + " 条记录导入成功!"); return(true); } else { CustomDesktopAlert.H2(billNo + "写子表失败!"); return(false); } } else { CustomDesktopAlert.H2("写主数据表失败"); return(false); } } catch (Exception ex) { MessageBox.Show(ex.Message); return(false); } }