private static void ReadRCPFile(List <string> dataList, string filename, SpareEntities db) { Console.WriteLine(@"接收采购订单收货数据开始"); var partList = new List <TA_PART>(); var billList = new List <TB_BILL>(); var MIList = new List <TB_IN>(); for (int i = 0; i < dataList.Count; i++) { string strErr = "采购订单收货文件 " + filename + " 第 " + i + " 行 \t"; string data = dataList[i]; var cols = data.Split(';'); if (cols.Length != 11) { Console.WriteLine(strErr + @" 格式错误" + Environment.NewLine + "\t\t\t\t" + data); continue; } //添加TB_BILL表数据 var bill = new TB_BILL(); var BillNum = ""; var SourceBillNum = cols[0]; if (billList.FirstOrDefault(p => p.SourceBillNum == SourceBillNum) == null) { bill.BillNum = BillNum; bill.BillTime = DateTime.Now; bill.BillType = (int)BillType.MaterialIn; bill.OperName = GlobalVar.OperName; bill.SourceBillNum = SourceBillNum; billList.Add(bill); } //添加TB_IN表记录 var MI = new TB_IN() { BillNum = BillNum, PoBillNum = SourceBillNum, PoLineNum = Convert.ToInt32(cols[1]), PartCode = cols[3], Batch = GetBatch(), ToLocCode = _defaultLoc, Qty = Convert.ToInt32(cols[4]), UnitPrice = Convert.ToDecimal(cols[5]), ProduceDate = DateTime.Now }; MIList.Add(MI); } BillHandler.AddMaterialIn(db, billList, MIList); Console.WriteLine(@"接收采购订单收货数据完成"); }
private ServiceState AddBill(BillType billType, DataSet ds) { ServiceState state = ServiceState.NoError; DataTable dt = new DataTable(); switch (billType) { case BillType.MaterialIn: dt = ds.Tables[0]; var bill = ConvertHelper.DataTableToEntity <TB_BILL>(dt); dt = ds.Tables[1]; var details = ConvertHelper.DataTableToList <TB_MATERIAL_IN>(dt); state = BillHandler.AddMaterialIn(bill, details); break; } return(state); }