//new PreOrderService().ManualAllocationJson(new ManualAllocationRequest() //{ PodRequest = pod, ID = Convert.ToInt64(ID), CustomerId = CustomerId, Creator = base.UserInfo.Name, Criterion = Criterion }); public override void CustomerDefinedSettledTransData(ref string message) { if (TransDataType == "PreOrder") { #region if (WareHouseID == 0) { message = "用户没有分配仓库!!"; return; } WarehouseInfo warehouse = ApplicationConfigHelper.GetWarehouseList().Where(m => m.ID == WareHouseID).FirstOrDefault();//customerid获取仓库 IEnumerable <WMS_Customer> CustomerList = ApplicationConfigHelper.GetAllCustomerByID(CustomerID); WMS_UnitAndSpecifications_Config wmsunit = ApplicationConfigHelper.GetWMS_UnitAndSpecifications_Config(ProjectID, CustomerID, warehouse.ID).ToArray()[0]; DataSet dsResualt = new DataSet(); DataTable dtpo = new DataTable(); dtpo.TableName = "预出库单主信息$"; DataTable dtpodetail = new DataTable(); dtpodetail.TableName = "预出库单明细信息$"; DataTable dtNike = Transdata.Tables[0]; //List<ProductSearch> searprolistfs = new List<ProductSearch>(); //for (int i = 0; i < dtNike.Rows.Count; i++) //{ // ProductSearch psfs = new ProductSearch(); // psfs.Str10 = dtNike.Rows[i]["Style Color"].ToString(); // psfs.Str9 = dtNike.Rows[i]["Size"].ToString(); // psfs.Str8 = "01"; // searprolistfs.Add(psfs); //} //IEnumerable<ProductSearch> productListfs = ApplicationConfigHelper.GetSearchProduct(CustomerID, searprolistfs, "Acticle"); dtpo.Columns.Add("外部单号"); dtpo.Columns.Add("预出库单类型"); dtpo.Columns.Add("仓库名称"); dtpo.Columns.Add("订单日期"); dtpo.Columns.Add("省"); dtpo.Columns.Add("市"); dtpo.Columns.Add("联系人"); dtpo.Columns.Add("快递公司"); dtpo.Columns.Add("备注"); dtpo.Columns.Add("自定义字段2"); dtpo.Columns.Add("自定义字段3"); dtpo.Columns.Add("自定义字段4"); dtpo.Columns.Add("地址"); dtpo.Columns.Add("联系方式"); dtpo.Columns.Add("自定义字段5"); dtpo.Columns.Add("自定义字段6"); dtpo.Columns.Add("自定义字段7"); dtpodetail.Columns.Add("外部单号"); dtpodetail.Columns.Add("仓库"); dtpodetail.Columns.Add("SKU"); dtpodetail.Columns.Add("UPC"); dtpodetail.Columns.Add("产品等级"); dtpodetail.Columns.Add("产品名称"); dtpodetail.Columns.Add("批次号"); dtpodetail.Columns.Add("托号"); dtpodetail.Columns.Add("备注"); dtpodetail.Columns.Add("期望数量"); dtpodetail.Columns.Add("自定义字段4"); dtpodetail.Columns.Add("自定义字段5"); dtpodetail.Columns.Add("自定义字段6"); dtpodetail.Columns.Add("自定义字段7"); dtpodetail.Columns.Add("单位"); dtpodetail.Columns.Add("规格"); for (int i = 0; i < dtNike.Rows.Count; i++) { if (dtpo.Select("外部单号='" + dtNike.Rows[i]["出库订单号"].ToString() + "'").Count() <= 0) { DataRow dr = dtpo.NewRow(); dr["外部单号"] = dtNike.Rows[i]["出库订单号"].ToString(); switch (dtNike.Rows[i]["订单类别"].ToString()) { case "2": dr["预出库单类型"] = "门店调拨出库"; break; case "6": dr["预出库单类型"] = "退仓出货"; break; default: dr["预出库单类型"] = dtNike.Rows[i]["订单类别"].ToString(); break; } //dr["预出库单类型"] = dtNike.Rows[i]["订单类别"].ToString() == "2" ? "门店调拨出库" : "退仓出货";//1大仓退货 2门店调拨 dr["仓库名称"] = warehouse.WarehouseName; dr["市"] = ""; dr["省"] = ""; dr["联系人"] = ""; dr["订单日期"] = dtNike.Rows[i]["订单日期"].ToString(); dr["备注"] = ""; dr["自定义字段2"] = dtNike.Rows[i]["门店代码"].ToString(); dr["自定义字段3"] = dtNike.Rows[i]["预计发货日期"].ToString(); dr["自定义字段4"] = dtNike.Rows[i]["客户要求到货日期"].ToString(); dr["地址"] = ""; dr["自定义字段5"] = dtNike.Rows[i]["箱号"].ToString(); dr["联系方式"] = ""; dr["自定义字段6"] = ""; dr["自定义字段7"] = ""; dtpo.Rows.Add(dr); } DataRow drdetail = dtpodetail.NewRow(); drdetail["外部单号"] = dtNike.Rows[i]["出库订单号"].ToString(); drdetail["仓库"] = warehouse.WarehouseName; drdetail["SKU"] = dtNike.Rows[i]["SKU"].ToString(); drdetail["UPC"] = ""; try { drdetail["产品等级"] = dtNike.Rows[i]["产品等级"].ToString(); } catch { drdetail["产品等级"] = "A品"; } drdetail["产品名称"] = dtNike.Rows[i]["SKU"].ToString(); drdetail["批次号"] = ""; drdetail["托号"] = ""; drdetail["规格"] = ""; drdetail["备注"] = ""; drdetail["期望数量"] = dtNike.Rows[i]["数量"].ToString(); drdetail["自定义字段4"] = dtNike.Rows[i]["箱号"].ToString(); drdetail["自定义字段5"] = dtNike.Rows[i]["Article"].ToString(); drdetail["自定义字段6"] = dtNike.Rows[i]["Size"].ToString(); drdetail["自定义字段7"] = dtNike.Rows[i]["物品类型"].ToString(); drdetail["单位"] = wmsunit.Unit; dtpodetail.Rows.Add(drdetail); } dsResualt.Tables.Add(dtpo); dsResualt.Tables.Add(dtpodetail); this.AfterData = dsResualt; #endregion } else if (TransDataType == "Asn") { #region 矩阵导入 DataTable dtNew = new DataTable(); DataRow rowNew = dtNew.NewRow(); DataColumn dc = null; //dc = dtNew.Columns.Add("ID", Type.GetType("System.Int32")); //dc.AutoIncrement = true;//自动增加 //dc.AutoIncrementSeed = 1;//起始为1 //dc.AutoIncrementStep = 1;//步长为1 //dc.AllowDBNull = false;// dc = dtNew.Columns.Add("类型", Type.GetType("System.String")); dc = dtNew.Columns.Add("行号", Type.GetType("System.String")); dc = dtNew.Columns.Add("单号", Type.GetType("System.String")); dc = dtNew.Columns.Add("日期", Type.GetType("System.DateTime")); dc = dtNew.Columns.Add("sold", Type.GetType("System.String")); dc = dtNew.Columns.Add("ship", Type.GetType("System.String")); dc = dtNew.Columns.Add("客户", Type.GetType("System.String")); dc = dtNew.Columns.Add("Article", Type.GetType("System.String")); dc = dtNew.Columns.Add("SKU", Type.GetType("System.String")); dc = dtNew.Columns.Add("BoxQty", Type.GetType("System.Int32")); dc = dtNew.Columns.Add("BoxNumber", Type.GetType("System.String")); dc = dtNew.Columns.Add("收货人", Type.GetType("System.String")); dc = dtNew.Columns.Add("地址", Type.GetType("System.String")); dc = dtNew.Columns.Add("联系方式", Type.GetType("System.String")); dc = dtNew.Columns.Add("邮编", Type.GetType("System.String")); if (!string.IsNullOrEmpty(Transdata.Tables[0].Rows[0].ToString().Trim()) && Transdata.Tables[0].Rows[0][3].ToString().Trim() == "Z001") { #region NIKE装箱单 List <ProductSearch> searprolistfs = new List <ProductSearch>(); for (int i = 11; i < Transdata.Tables[0].Rows.Count; i++) { ProductSearch psfs = new ProductSearch(); if (!string.IsNullOrEmpty(Transdata.Tables[0].Rows[i]["UPC"].ToString().Trim())) { psfs.SKU = Transdata.Tables[0].Rows[i]["UPC"].ToString().Trim(); //psfs.Str9 = dtNike.Rows[i]["Size"].ToString(); //psfs.Str8 = "01"; if (!searprolistfs.Exists(a => a.SKU == psfs.SKU)) { searprolistfs.Add(psfs); } } } IEnumerable <ProductSearch> productListfs = ApplicationConfigHelper.GetSearchProductYXDR(CustomerID, searprolistfs, "SKU"); for (int j = 0; j < Transdata.Tables[0].Rows.Count; j++) { DataRow rowValue = Transdata.Tables[0].Rows[j]; if (string.IsNullOrEmpty(rowValue[0].ToString().Trim())) { continue; } #region 处理数据 rowNew["类型"] = rowValue["OrderType"].ToString().Trim();//NIKE rowNew["行号"] = ""; rowNew["单号"] = rowValue["ExternOrderKey"].ToString().Trim(); rowNew["日期"] = System.DateTime.Now; rowNew["sold"] = ""; rowNew["ship"] = ""; rowNew["客户"] = "HADDA"; rowNew["Article"] = rowValue["Style"].ToString().Trim(); rowNew["SKU"] = rowValue["UPC"].ToString().Trim(); rowNew["收货人"] = ""; rowNew["地址"] = ""; rowNew["联系方式"] = ""; rowNew["邮编"] = ""; rowNew["BoxQty"] = rowValue["QtyShipped"].ToString().Trim(); rowNew["BoxNumber"] = rowValue["LabelNo"].ToString().Trim(); dtNew.Rows.Add(rowNew.ItemArray); #endregion } #region 转换 if (ApplicationConfigHelper.GetWarehouseListByCustomer(CustomerID).Where(p => p.ID == WareHouseID).ToArray().Count() <= 0) { message = "用户没有分配仓库!!"; return; } WarehouseInfo warehouse = ApplicationConfigHelper.GetWarehouseListByCustomer(CustomerID).Where(p => p.ID == WareHouseID).ToArray()[0];// IEnumerable <WMS_Customer> CustomerList = ApplicationConfigHelper.GetAllCustomerByID(CustomerID); WMS_UnitAndSpecifications_Config wmsunit = ApplicationConfigHelper.GetWMS_UnitAndSpecifications_Config(ProjectID, CustomerID, warehouse.ID).ToArray()[0]; DataSet dsResualt = new DataSet(); DataTable dtasn = new DataTable(); dtasn.TableName = "预入库单主信息$"; DataTable dtasndetail = new DataTable(); dtasndetail.TableName = "预入库单明细信息$"; DataTable dtNike = dtNew;// dtasn.Columns.Add("外部入库单号"); dtasn.Columns.Add("预入库单类型"); dtasn.Columns.Add("预入库日期"); dtasn.Columns.Add("仓库名称"); dtasn.Columns.Add("备注"); dtasn.Columns.Add("客户"); dtasndetail.Columns.Add("外部入库单号"); dtasndetail.Columns.Add("SKU"); dtasndetail.Columns.Add("UPC"); dtasndetail.Columns.Add("预收数量"); dtasndetail.Columns.Add("单位"); dtasndetail.Columns.Add("规格"); dtasndetail.Columns.Add("批次号"); dtasndetail.Columns.Add("托号"); for (int i = 0; i < dtNike.Rows.Count; i++) { if (dtNike.Rows[i]["单号"].ToString().Trim() != "" || dtNike.Rows[i]["SKU"].ToString().Trim() != "") { if (dtasn.Select("外部入库单号='" + dtNike.Rows[i]["单号"].ToString().Trim() + "'").Count() <= 0) { DataRow dr = dtasn.NewRow(); dr["外部入库单号"] = dtNike.Rows[i]["单号"].ToString().Trim(); dr["预入库单类型"] = dtNike.Rows[i]["类型"].ToString().Trim() == "Z001" ? "门店调拨入库" : dtNike.Rows[i][0].ToString().Trim();//入库暂时只有一种类型NIKE入库 dr["预入库日期"] = dtNike.Rows[i]["日期"].ToString().Trim(); dr["仓库名称"] = warehouse.WarehouseName; dr["备注"] = ""; dr["客户"] = dtNike.Rows[i]["客户"].ToString().Trim(); dtasn.Rows.Add(dr); } DataRow drdetail = dtasndetail.NewRow(); drdetail["外部入库单号"] = dtNike.Rows[i]["单号"].ToString().Trim(); drdetail["SKU"] = dtNike.Rows[i]["SKU"].ToString().Trim(); drdetail["UPC"] = ""; drdetail["预收数量"] = dtNike.Rows[i]["BoxQty"].ToString().Trim(); drdetail["单位"] = ""; drdetail["规格"] = ""; drdetail["批次号"] = ""; drdetail["托号"] = dtNike.Rows[i]["BoxNumber"].ToString().Trim(); dtasndetail.Rows.Add(drdetail); } } dsResualt.Tables.Add(dtasn); dsResualt.Tables.Add(dtasndetail); this.AfterData = dsResualt; #endregion #endregion } else { #region 普通装箱单 for (int r = 11; r < Transdata.Tables[0].Rows.Count; r++) { if (!string.IsNullOrEmpty(Transdata.Tables[0].Rows[r][0].ToString())) { for (int c = 1; c < 6; c++) { if (string.IsNullOrEmpty(Transdata.Tables[0].Rows[r][c].ToString())) { message = (r + 2) + "行" + (c + 1) + "列有空值!"; return; } } } } List <ProductSearch> searprolistfs = new List <ProductSearch>(); for (int i = 11; i < Transdata.Tables[0].Rows.Count; i++) { ProductSearch psfs = new ProductSearch(); if (!string.IsNullOrEmpty(Transdata.Tables[0].Rows[i][0].ToString().Trim())) { psfs.Str10 = Transdata.Tables[0].Rows[i][0].ToString().Trim(); //psfs.Str9 = dtNike.Rows[i]["Size"].ToString(); //psfs.Str8 = "01"; if (!searprolistfs.Exists(a => a.Str10 == psfs.Str10)) { searprolistfs.Add(psfs); } } } IEnumerable <ProductSearch> productListfs = ApplicationConfigHelper.GetSearchProductYXDR(CustomerID, searprolistfs, "Acticle"); for (int j = 11; j < Transdata.Tables[0].Rows.Count; j++) { DataRow rowValue = Transdata.Tables[0].Rows[j]; if (string.IsNullOrEmpty(rowValue[0].ToString().Trim())) { continue; } #region 处理数据 if (rowValue[0].ToString().Trim().Length >= 3) { string receiptnumber = Transdata.Tables[0].Rows[1][2].ToString().Trim() + "-"; string receipttype = Transdata.Tables[0].Rows[1][1].ToString().Trim(); string Article = rowValue[0].ToString().Trim(); string Color = rowValue[5].ToString().Trim(); int boxNumberStart = Int32.Parse(rowValue[1].ToString().Trim()); int boxNumberEnd = Int32.Parse(rowValue[3].ToString().Trim()); int boxCount = Int32.Parse(rowValue[4].ToString().Trim()); //if ( dtNew.Select("Article='"+Article+"'").Count()<=0 ) //{ // rowNew["单号"]=ordernumber + rowValue[0].ToString().Trim().Substring(rowValue[0].ToString().Trim().Length-1,rowValue[0].ToString().Trim().Length-4); //} rowNew["类型"] = receipttype; rowNew["行号"] = ""; rowNew["单号"] = receiptnumber + rowValue[0].ToString().Trim().Substring(rowValue[0].ToString().Trim().Length - 3, 3); rowNew["日期"] = System.DateTime.Now; rowNew["sold"] = ""; rowNew["ship"] = ""; rowNew["客户"] = "HADDA"; rowNew["Article"] = "Article"; rowNew["收货人"] = ""; rowNew["地址"] = ""; rowNew["联系方式"] = ""; rowNew["邮编"] = ""; //string Size = rowValue[0].ToString().Trim().Substring(rowValue[0].ToString().Trim().Length - 3, 3); for (int jc = 6; jc <= 16; jc++) { if (!string.IsNullOrEmpty(rowValue[jc].ToString().Trim())) { string size = Transdata.Tables[0].Rows[9][jc].ToString().Trim(); if (productListfs.Where(a => a.Str10 == Article & a.Str9 == size & a.Str8 == Color).OrderByDescending(a => a.Str10).Select(a => a.SKU).Count() <= 0) { message = "款号" + Article + " 尺码" + size + " 颜色" + Color + " 不存在!!"; } string SKU = productListfs.Where(a => a.Str10 == Article & a.Str9 == size & a.Str8 == Color).OrderByDescending(a => a.Str10).Select(a => a.SKU).FirstOrDefault().ToString(); rowNew["SKU"] = SKU; if (boxCount == 1) { rowNew["BoxQty"] = Int32.Parse(rowValue[jc].ToString().Trim()); rowNew["BoxNumber"] = boxNumberStart.ToString(); dtNew.Rows.Add(rowNew.ItemArray); } else { for (int i = boxNumberStart; i <= boxNumberEnd; i++) { rowNew["BoxQty"] = Int32.Parse(rowValue[jc].ToString().Trim()); rowNew["BoxNumber"] = i.ToString(); dtNew.Rows.Add(rowNew.ItemArray); } } } } } else { message = "行" + j + ",款号长度不足或款号有误!!"; return; } #endregion } #endregion #region 转换 if (ApplicationConfigHelper.GetWarehouseListByCustomer(CustomerID).Where(p => p.ID == WareHouseID).ToArray().Count() <= 0) { message = "用户没有分配仓库!!"; return; } WarehouseInfo warehouse = ApplicationConfigHelper.GetWarehouseListByCustomer(CustomerID).Where(p => p.ID == WareHouseID).ToArray()[0];// IEnumerable <WMS_Customer> CustomerList = ApplicationConfigHelper.GetAllCustomerByID(CustomerID); WMS_UnitAndSpecifications_Config wmsunit = ApplicationConfigHelper.GetWMS_UnitAndSpecifications_Config(ProjectID, CustomerID, warehouse.ID).ToArray()[0]; DataSet dsResualt = new DataSet(); DataTable dtasn = new DataTable(); dtasn.TableName = "预入库单主信息$"; DataTable dtasndetail = new DataTable(); dtasndetail.TableName = "预入库单明细信息$"; DataTable dtNike = dtNew;// dtasn.Columns.Add("外部入库单号"); dtasn.Columns.Add("预入库单类型"); dtasn.Columns.Add("预入库日期"); dtasn.Columns.Add("仓库名称"); dtasn.Columns.Add("备注"); dtasn.Columns.Add("客户"); dtasndetail.Columns.Add("外部入库单号"); dtasndetail.Columns.Add("SKU"); dtasndetail.Columns.Add("UPC"); dtasndetail.Columns.Add("预收数量"); dtasndetail.Columns.Add("单位"); dtasndetail.Columns.Add("规格"); dtasndetail.Columns.Add("批次号"); dtasndetail.Columns.Add("托号"); for (int i = 0; i < dtNike.Rows.Count; i++) { if (dtNike.Rows[i]["单号"].ToString().Trim() != "" || dtNike.Rows[i]["SKU"].ToString().Trim() != "") { if (dtasn.Select("外部入库单号='" + dtNike.Rows[i][2].ToString().Trim() + "'").Count() <= 0) { DataRow dr = dtasn.NewRow(); dr["外部入库单号"] = dtNike.Rows[i][2].ToString().Trim(); dr["预入库单类型"] = dtNike.Rows[i][0].ToString().Trim() == "1" ? "大仓补货入库" : dtNike.Rows[i][0].ToString().Trim();//入库暂时只有一种类型 dr["预入库日期"] = dtNike.Rows[i][3].ToString().Trim(); dr["仓库名称"] = warehouse.WarehouseName; dr["备注"] = ""; dr["客户"] = dtNike.Rows[i][6].ToString().Trim(); dtasn.Rows.Add(dr); } DataRow drdetail = dtasndetail.NewRow(); drdetail["外部入库单号"] = dtNike.Rows[i][2].ToString().Trim(); drdetail["SKU"] = dtNike.Rows[i][8].ToString().Trim(); drdetail["UPC"] = ""; drdetail["预收数量"] = dtNike.Rows[i][9].ToString().Trim(); drdetail["单位"] = ""; drdetail["规格"] = ""; drdetail["批次号"] = ""; drdetail["托号"] = dtNike.Rows[i][10].ToString().Trim(); dtasndetail.Rows.Add(drdetail); } } dsResualt.Tables.Add(dtasn); dsResualt.Tables.Add(dtasndetail); this.AfterData = dsResualt; #endregion } #endregion } else { this.AfterData = Transdata; } }
//new PreOrderService().ManualAllocationJson(new ManualAllocationRequest() //{ PodRequest = pod, ID = Convert.ToInt64(ID), CustomerId = CustomerId, Creator = base.UserInfo.Name, Criterion = Criterion }); public override void CustomerDefinedSettledTransData(ref string message) { if (TransDataType == "PreOrder") { List <ProductSearch> productListS = new List <ProductSearch>(); IEnumerable <ProductSearch> productList; if (WareHouseID == 0) { message = "用户没有分配仓库!!"; return; } WarehouseInfo warehouse = ApplicationConfigHelper.GetWarehouseList().Where(m => m.ID == WareHouseID).FirstOrDefault();//customerid获取仓库 IEnumerable <WMS_Customer> CustomerList = ApplicationConfigHelper.GetAllCustomerByID(CustomerID); WMS_UnitAndSpecifications_Config wmsunit = ApplicationConfigHelper.GetWMS_UnitAndSpecifications_Config(ProjectID, CustomerID, warehouse.ID).ToArray()[0]; DataSet dsResualt = new DataSet(); DataTable dtpo = new DataTable(); dtpo.TableName = "预出库单主信息$"; DataTable dtpodetail = new DataTable(); dtpodetail.TableName = "预出库单明细信息$"; DataTable dtNike = Transdata.Tables[0]; dtpo.Columns.Add("外部单号"); dtpo.Columns.Add("预出库单类型"); dtpo.Columns.Add("仓库名称"); dtpo.Columns.Add("订单日期"); dtpo.Columns.Add("省"); dtpo.Columns.Add("市"); dtpo.Columns.Add("联系人"); dtpo.Columns.Add("快递公司"); dtpo.Columns.Add("备注"); dtpo.Columns.Add("自定义字段2"); dtpo.Columns.Add("自定义字段3"); dtpo.Columns.Add("自定义字段4"); dtpo.Columns.Add("地址"); dtpo.Columns.Add("联系方式"); dtpo.Columns.Add("自定义字段5"); dtpo.Columns.Add("自定义字段6"); dtpo.Columns.Add("自定义字段7"); dtpo.Columns.Add("自定义字段12"); dtpodetail.Columns.Add("外部单号"); dtpodetail.Columns.Add("仓库"); dtpodetail.Columns.Add("SKU"); dtpodetail.Columns.Add("UPC"); dtpodetail.Columns.Add("产品名称"); dtpodetail.Columns.Add("产品等级"); dtpodetail.Columns.Add("批次号"); dtpodetail.Columns.Add("托号"); dtpodetail.Columns.Add("备注"); dtpodetail.Columns.Add("期望数量"); dtpodetail.Columns.Add("自定义字段4"); dtpodetail.Columns.Add("自定义字段5"); dtpodetail.Columns.Add("自定义字段6"); dtpodetail.Columns.Add("自定义字段7"); dtpodetail.Columns.Add("单位"); dtpodetail.Columns.Add("规格"); for (int i = 0; i < dtNike.Rows.Count; i++) { if (dtpo.Select("外部单号='" + dtNike.Rows[i]["订单号"].ToString() + "'").Count() <= 0) { DataRow dr = dtpo.NewRow(); dr["外部单号"] = dtNike.Rows[i]["订单号"].ToString(); dr["预出库单类型"] = dtNike.Rows[i]["订单类型"].ToString(); dr["仓库名称"] = warehouse.WarehouseName; dr["市"] = ""; dr["省"] = ""; dr["联系人"] = ""; dr["订单日期"] = dtNike.Rows[i]["日期"].ToString(); dr["备注"] = dtNike.Rows[i]["备注1"].ToString(); dr["自定义字段2"] = dtNike.Rows[i]["备注2"].ToString(); dr["自定义字段3"] = dtNike.Rows[i]["备注3"].ToString(); dr["自定义字段4"] = dtNike.Rows[i]["客户代码"].ToString(); //客户代码不存在 if (CustomerList.Where(m => m.StorerKey == dtNike.Rows[i]["客户代码"].ToString()).ToArray().Length <= 0) { message = dtNike.Rows[i]["客户代码"].ToString() + "客户代码不存在!"; return; } dr["地址"] = CustomerList.Where(m => m.StorerKey == dtNike.Rows[i]["客户代码"].ToString()).ToArray().Length > 0 ? CustomerList.Where(m => m.StorerKey == dtNike.Rows[i]["客户代码"].ToString()).ToArray()[0].AddressLine1 : ""; dr["自定义字段5"] = CustomerList.Where(m => m.StorerKey == dtNike.Rows[i]["客户代码"].ToString()).ToArray().Length > 0 ? CustomerList.Where(m => m.StorerKey == dtNike.Rows[i]["客户代码"].ToString()).ToArray()[0].Company : ""; dr["联系方式"] = CustomerList.Where(m => m.StorerKey == dtNike.Rows[i]["客户代码"].ToString()).ToArray().Length > 0 ? CustomerList.Where(m => m.StorerKey == dtNike.Rows[i]["客户代码"].ToString()).ToArray()[0].PhoneNum1 : ""; dr["自定义字段6"] = dtNike.Rows[i]["备注4"].ToString(); dr["自定义字段7"] = dtNike.Rows[i]["备注5"].ToString(); if (dtNike.Rows[i]["订单类型"].ToString().Equals("退仓出货")) { string querykey = "R" + System.DateTime.Now.Year.ToString().Substring(3, 1).ToString() + System.DateTime.Now.ToString("MMdd"); string Carrerkey = ApplicationConfigHelper.GetQueryDetail("pro_wms_getCarrierKey_select", querykey).ToString(); if (Carrerkey == "") { Carrerkey = "R" + System.DateTime.Now.Year.ToString().Substring(3, 1).ToString() + System.DateTime.Now.ToString("MMdd") + "01"; } else { Carrerkey = "R" + (Convert.ToInt32(Carrerkey.Substring(1, Carrerkey.Length - 1)) + 1).ToString(); } dr["自定义字段12"] = Carrerkey; } else { dr["自定义字段12"] = ""; } dtpo.Rows.Add(dr); } DataRow drdetail = dtpodetail.NewRow(); drdetail["外部单号"] = dtNike.Rows[i]["订单号"].ToString(); drdetail["仓库"] = warehouse.WarehouseName; drdetail["SKU"] = dtNike.Rows[i]["存货代码"].ToString(); ProductSearch ps = new ProductSearch(); //存货代码格式不正确 //for (int j = 0; j < drdetail["SKU"].ToString().Split('-').Length; j++) //{ // if (drdetail["SKU"].ToString().Split('-')[j].Equals("")) // { // message = drdetail["SKU"].ToString() + "存货代码格式不正确!"; // return; // } //} if (drdetail["SKU"].ToString().Split('-').Length < 3) { message = drdetail["SKU"].ToString() + "存货代码格式不正确!"; return; } try { ps.Str10 = drdetail["SKU"].ToString().Split('-')[0] + "-" + drdetail["SKU"].ToString().Split('-')[1]; ps.Str8 = drdetail["SKU"].ToString().Substring(drdetail["SKU"].ToString().Length - 2, 2); ps.Str9 = drdetail["SKU"].ToString().Substring(ps.Str10.Length + 1, drdetail["SKU"].ToString().Length - (ps.Str10.Length + 4)); } catch { message = drdetail["SKU"].ToString() + "存货代码格式不正确!"; return; } //if (drdetail["SKU"].ToString().Split('-').Length <= 4) //{ // ps.Str9 = drdetail["SKU"].ToString().Split('-')[2]; // ps.Str8 = drdetail["SKU"].ToString().Split('-')[3]; //} //else if (drdetail["SKU"].ToString().Split('-').Length == 5) //{ // ps.Str9 = drdetail["SKU"].ToString().Split('-')[2] + "-" + drdetail["SKU"].ToString().Split('-')[3]; // ps.Str8 = drdetail["SKU"].ToString().Split('-')[4]; //} //else if (drdetail["SKU"].ToString().Split('-').Length == 6) //{ // ps.Str9 = drdetail["SKU"].ToString().Split('-')[2] + "-" + drdetail["SKU"].ToString().Split('-')[3] + drdetail["SKU"].ToString().Split('-')[4]; // ps.Str8 = drdetail["SKU"].ToString().Split('-')[5]; //} //获得SKU集合 productListS.Add(ps); drdetail["UPC"] = ""; try { drdetail["产品等级"] = dtNike.Rows[i]["产品等级"].ToString(); } catch { drdetail["产品等级"] = "A品"; } drdetail["批次号"] = ""; drdetail["托号"] = ""; drdetail["规格"] = ""; drdetail["备注"] = ""; drdetail["期望数量"] = dtNike.Rows[i]["数量"].ToString(); drdetail["自定义字段4"] = dtNike.Rows[i]["单位"].ToString(); drdetail["自定义字段5"] = dtNike.Rows[i]["存货名称及规格型号"].ToString(); drdetail["自定义字段6"] = dtNike.Rows[i]["存货代码"].ToString(); drdetail["自定义字段7"] = dtNike.Rows[i]["BU"].ToString(); drdetail["单位"] = wmsunit.Unit; dtpodetail.Rows.Add(drdetail); } productList = ApplicationConfigHelper.GetSearchProduct(CustomerID, productListS, "Acticle"); for (int i = 0; i < dtpodetail.Rows.Count; i++) { string SKU = dtpodetail.Rows[i]["SKU"].ToString(); int skulength = SKU.Split('-').Length; string str10 = SKU.Split('-')[0] + "-" + SKU.Split('-')[1]; //string str8 = SKU.Split('-')[skulength - 1]; //string str9 = ""; string str8 = SKU.Substring(SKU.Length - 2, 2); string str9 = SKU.ToString().Substring(str10.Length + 1, SKU.Length - (str10.Length + 4)); //for (int m = 2; m < skulength - 1; m++) //{ // str9 += SKU.Split('-')[m]+"-"; //} //str9 = str9.Substring(0,str9.Length - 1); //存货代码不存在 if (productList.Where(c => c.Str10 == str10 && c.Str8 == str8 && c.Str9 == str9).Select(m => m.SKU).ToArray().Length <= 0) { message = dtpodetail.Rows[i]["SKU"].ToString() + "存货代码不存在!"; return; } //Article不存在 if (productList.Where(c => c.Str10 == str10 && c.Str8 == str8 && c.Str9 == str9).Select(m => m.LongMaterial).ToArray().Length <= 0) { message = str10 + "不存在!"; return; } dtpodetail.Rows[i]["SKU"] = productList.Where(c => c.Str10 == str10 && c.Str8 == str8 && c.Str9 == str9).Select(m => m.SKU).FirstOrDefault(); dtpodetail.Rows[i]["产品名称"] = productList.Where(c => c.SKU == dtpodetail.Rows[i]["SKU"]).ToArray().Length > 0 ? productList.Where(c => c.SKU == dtpodetail.Rows[i]["SKU"]).ToArray()[0].LongMaterial.ToString() : ""; } dsResualt.Tables.Add(dtpo); dsResualt.Tables.Add(dtpodetail); this.AfterData = dsResualt; } else if (TransDataType == "Receiving") { DataTable dt = Transdata.Tables[0].Copy(); if (!dt.Columns.Contains("生产日期")) { dt.Columns.Add("生产日期"); } if (!dt.Columns.Contains("UPC")) { dt.Columns.Add("UPC"); } if (!dt.Columns.Contains("箱内总数")) { dt.Columns.Add("箱内总数"); } for (int i = 0; i < dt.Rows.Count; i++) { try { Convert.ToDateTime(dt.Rows[i]["生产日期"].ToString()); } catch { dt.Rows[i]["生产日期"] = System.DateTime.Now.ToString(); } } DataSet ds = new DataSet(); ds.Tables.Add(dt); this.AfterData = ds; } else { this.AfterData = Transdata; } }
public override void CustomerDefinedSettledTransData(ref string message) { if (TransDataType == "PreOrder") { if (Transdata.Tables[0].Columns.Contains("订单类型")) { if (Transdata.Tables[0].Rows[0]["订单类型"].ToString() == "退仓出货") { #region 退仓出货 不拆单 List <ProductSearch> productListS = new List <ProductSearch>(); IEnumerable <ProductSearch> productList; if (WareHouseID == 0) { message = "用户没有分配仓库!!"; return; } WarehouseInfo warehouse = ApplicationConfigHelper.GetWarehouseList().Where(m => m.ID == WareHouseID).FirstOrDefault();//customerid获取仓库 IEnumerable <WMS_Customer> CustomerList = ApplicationConfigHelper.GetAllCustomerByID(CustomerID); WMS_UnitAndSpecifications_Config wmsunit = ApplicationConfigHelper.GetWMS_UnitAndSpecifications_Config(ProjectID, CustomerID, warehouse.ID).ToArray()[0]; DataSet dsResualt = new DataSet(); DataTable dtpo = new DataTable(); dtpo.TableName = "预出库单主信息$"; DataTable dtpodetail = new DataTable(); dtpodetail.TableName = "预出库单明细信息$"; DataTable dtNike = Transdata.Tables[0]; dtpo.Columns.Add("外部单号"); dtpo.Columns.Add("预出库单类型"); dtpo.Columns.Add("仓库名称"); dtpo.Columns.Add("订单日期"); dtpo.Columns.Add("省"); dtpo.Columns.Add("市"); dtpo.Columns.Add("联系人"); dtpo.Columns.Add("快递公司"); dtpo.Columns.Add("备注"); dtpo.Columns.Add("自定义字段2"); dtpo.Columns.Add("自定义字段3"); dtpo.Columns.Add("自定义字段4"); dtpo.Columns.Add("地址"); dtpo.Columns.Add("联系方式"); dtpo.Columns.Add("自定义字段5"); dtpo.Columns.Add("自定义字段6"); dtpo.Columns.Add("自定义字段7"); dtpo.Columns.Add("自定义字段12"); dtpodetail.Columns.Add("外部单号"); dtpodetail.Columns.Add("仓库"); dtpodetail.Columns.Add("SKU"); dtpodetail.Columns.Add("UPC"); dtpodetail.Columns.Add("产品名称"); dtpodetail.Columns.Add("产品等级"); dtpodetail.Columns.Add("批次号"); dtpodetail.Columns.Add("托号"); dtpodetail.Columns.Add("备注"); dtpodetail.Columns.Add("期望数量"); dtpodetail.Columns.Add("自定义字段4"); dtpodetail.Columns.Add("自定义字段5"); dtpodetail.Columns.Add("自定义字段6"); dtpodetail.Columns.Add("自定义字段7"); dtpodetail.Columns.Add("单位"); dtpodetail.Columns.Add("规格"); for (int i = 0; i < dtNike.Rows.Count; i++) { if (dtpo.Select("外部单号='" + dtNike.Rows[i]["订单号"].ToString() + "'").Count() <= 0) { DataRow dr = dtpo.NewRow(); dr["外部单号"] = dtNike.Rows[i]["订单号"].ToString(); dr["预出库单类型"] = dtNike.Rows[i]["订单类型"].ToString(); dr["仓库名称"] = warehouse.WarehouseName; dr["市"] = ""; dr["省"] = ""; dr["联系人"] = ""; dr["订单日期"] = dtNike.Rows[i]["日期"].ToString(); dr["备注"] = dtNike.Rows[i]["备注1"].ToString(); dr["自定义字段2"] = dtNike.Rows[i]["备注2"].ToString(); dr["自定义字段3"] = dtNike.Rows[i]["备注3"].ToString(); dr["自定义字段4"] = dtNike.Rows[i]["客户代码"].ToString(); //客户代码不存在 if (CustomerList.Where(m => m.StorerKey == dtNike.Rows[i]["客户代码"].ToString()).ToArray().Length <= 0) { message = "第【" + (i + 2) + "】行," + "【客户代码】列的客户代码格式不对或 " + dtNike.Rows[i]["客户代码"].ToString() + "客户代码不存在!"; return; } dr["地址"] = CustomerList.Where(m => m.StorerKey == dtNike.Rows[i]["客户代码"].ToString()).ToArray().Length > 0 ? CustomerList.Where(m => m.StorerKey == dtNike.Rows[i]["客户代码"].ToString()).ToArray()[0].AddressLine1 : ""; dr["自定义字段5"] = CustomerList.Where(m => m.StorerKey == dtNike.Rows[i]["客户代码"].ToString()).ToArray().Length > 0 ? CustomerList.Where(m => m.StorerKey == dtNike.Rows[i]["客户代码"].ToString()).ToArray()[0].Company : ""; dr["联系方式"] = CustomerList.Where(m => m.StorerKey == dtNike.Rows[i]["客户代码"].ToString()).ToArray().Length > 0 ? CustomerList.Where(m => m.StorerKey == dtNike.Rows[i]["客户代码"].ToString()).ToArray()[0].PhoneNum1 : ""; dr["自定义字段6"] = dtNike.Rows[i]["备注4"].ToString(); dr["自定义字段7"] = dtNike.Rows[i]["备注5"].ToString(); if (dtNike.Rows[i]["订单类型"].ToString().Equals("退仓出货")) { string querykey = "R" + System.DateTime.Now.Year.ToString().Substring(3, 1).ToString() + System.DateTime.Now.ToString("MMdd"); string Carrerkey = ApplicationConfigHelper.GetQueryDetail("pro_wms_getCarrierKey_select", querykey).ToString(); if (Carrerkey == "") { Carrerkey = "R" + System.DateTime.Now.Year.ToString().Substring(3, 1).ToString() + System.DateTime.Now.ToString("MMdd") + "01"; } else { Carrerkey = "R" + (Convert.ToInt32(Carrerkey.Substring(1, Carrerkey.Length - 1)) + 1).ToString(); } dr["自定义字段12"] = Carrerkey; } else { dr["自定义字段12"] = ""; } dtpo.Rows.Add(dr); } DataRow drdetail = dtpodetail.NewRow(); drdetail["外部单号"] = dtNike.Rows[i]["订单号"].ToString(); drdetail["仓库"] = warehouse.WarehouseName; drdetail["SKU"] = dtNike.Rows[i]["存货代码"].ToString(); ProductSearch ps = new ProductSearch(); if (drdetail["SKU"].ToString().Split('-').Length < 3) { message = drdetail["SKU"].ToString() + "存货代码格式不正确!"; return; } try { ps.Str10 = drdetail["SKU"].ToString().Split('-')[0] + "-" + drdetail["SKU"].ToString().Split('-')[1]; ps.Str8 = drdetail["SKU"].ToString().Substring(drdetail["SKU"].ToString().Length - 2, 2); ps.Str9 = drdetail["SKU"].ToString().Substring(ps.Str10.Length + 1, drdetail["SKU"].ToString().Length - (ps.Str10.Length + 4)); } catch { message = drdetail["SKU"].ToString() + "存货代码格式不正确!"; return; } //获得SKU集合 productListS.Add(ps); drdetail["UPC"] = ""; try { drdetail["产品等级"] = dtNike.Rows[i]["产品等级"].ToString(); } catch { drdetail["产品等级"] = "A品"; } if (dtNike.Columns.Contains("批次号")) { drdetail["批次号"] = dtNike.Rows[i]["批次号"].ToString(); } else { drdetail["批次号"] = ""; } drdetail["托号"] = ""; drdetail["规格"] = ""; drdetail["备注"] = ""; drdetail["期望数量"] = dtNike.Rows[i]["数量"].ToString(); drdetail["自定义字段4"] = dtNike.Rows[i]["单位"].ToString(); drdetail["自定义字段5"] = dtNike.Rows[i]["存货名称及规格型号"].ToString(); drdetail["自定义字段6"] = dtNike.Rows[i]["存货代码"].ToString(); drdetail["自定义字段7"] = dtNike.Rows[i]["BU"].ToString(); drdetail["单位"] = wmsunit.Unit; dtpodetail.Rows.Add(drdetail); } productList = ApplicationConfigHelper.GetSearchProduct(CustomerID, productListS, "Acticle"); for (int i = 0; i < dtpodetail.Rows.Count; i++) { string SKU = dtpodetail.Rows[i]["SKU"].ToString(); int skulength = SKU.Split('-').Length; string str10 = SKU.Split('-')[0] + "-" + SKU.Split('-')[1]; string str8 = SKU.Substring(SKU.Length - 2, 2); string str9 = SKU.ToString().Substring(str10.Length + 1, SKU.Length - (str10.Length + 4)); //存货代码不存在 if (productList.Where(c => c.Str10 == str10 && c.Str8 == str8 && c.Str9 == str9).Select(m => m.SKU).ToArray().Length <= 0) { message = "第【" + (i + 2) + "】行," + "【SKU】列的存货代码格式不对或 " + dtpodetail.Rows[i]["SKU"].ToString() + "存货代码不存在!"; return; } //Article不存在 if (productList.Where(c => c.Str10 == str10 && c.Str8 == str8 && c.Str9 == str9).Select(m => m.LongMaterial).ToArray().Length <= 0) { message = str10 + "不存在!"; return; } dtpodetail.Rows[i]["SKU"] = productList.Where(c => c.Str10 == str10.Trim().ToUpper() && c.Str8 == str8 && c.Str9 == str9.Trim().ToUpper()).Select(m => m.SKU).FirstOrDefault(); dtpodetail.Rows[i]["产品名称"] = productList.Where(c => c.SKU == dtpodetail.Rows[i]["SKU"]).ToArray().Length > 0 ? productList.Where(c => c.SKU == dtpodetail.Rows[i]["SKU"]).ToArray()[0].LongMaterial.ToString() : ""; } dsResualt.Tables.Add(dtpo); dsResualt.Tables.Add(dtpodetail); this.AfterData = dsResualt; #endregion } else if (Transdata.Tables[0].Rows[0]["订单类型"].ToString() == "CRW退货") { #region CRW退货 不拆单 if (ApplicationConfigHelper.GetWarehouseListByCustomer(CustomerID).Where(p => p.ID == WareHouseID).ToArray().Count() <= 0) { message = "用户没有分配仓库!!"; return; } WarehouseInfo warehouse = ApplicationConfigHelper.GetWarehouseListByCustomer(CustomerID).Where(p => p.ID == WareHouseID).ToArray()[0];//Bob IEnumerable <WMS_Customer> CustomerList = ApplicationConfigHelper.GetAllCustomerByID(CustomerID); WMS_UnitAndSpecifications_Config wmsunit = ApplicationConfigHelper.GetWMS_UnitAndSpecifications_Config(ProjectID, CustomerID, warehouse.ID).ToArray()[0]; DataSet dsResualt = new DataSet(); DataTable dtpo = new DataTable(); dtpo.TableName = "预出库单主信息$"; DataTable dtpodetail = new DataTable(); dtpodetail.TableName = "预出库单明细信息$"; DataTable dtNike = Transdata.Tables[0]; List <ProductSearch> searprolistfs = new List <ProductSearch>(); for (int i = 0; i < dtNike.Rows.Count; i++) { ProductSearch psfs = new ProductSearch(); //客户代码不存在 if (dtNike.Rows[i]["Style Color"].ToString().Equals("") || dtNike.Rows[i]["Style Color"].ToString().Length == 0) { message = "第【" + (i + 2) + "】行," + "【Style Color】列" + "有空值或格式不正确!"; return; } if (dtNike.Rows[i]["Size"].ToString().Equals("") || dtNike.Rows[i]["Style Color"].ToString().Length == 0) { message = "第【" + (i + 2) + "】行," + "【Size】列" + "有空值或格式不正确!"; return; } psfs.Str10 = dtNike.Rows[i]["Style Color"].ToString(); psfs.Str9 = dtNike.Rows[i]["Size"].ToString(); psfs.Str8 = "01"; searprolistfs.Add(psfs); } IEnumerable <ProductSearch> productListfs = ApplicationConfigHelper.GetSearchProduct(CustomerID, searprolistfs, "Acticle"); //先验证article存不存在再继续 for (int i = 0; i < dtNike.Rows.Count; i++) { if (productListfs.Where(m => m.Str10 == dtNike.Rows[i]["Style Color"].ToString()).ToArray().Length <= 0) { message = "第【" + (i + 2) + "】行," + "【Style Color】列的Article格式不对或Article " + dtNike.Rows[i]["Style Color"].ToString() + " 在系统中不存在!"; return; } else { if (productListfs.Where(m => m.Str10 == dtNike.Rows[i]["Style Color"].ToString() && m.Str9 == dtNike.Rows[i]["Size"].ToString()).ToArray().Length <= 0) { message = "第【" + (i + 2) + "】行," + "【Size】列的尺寸格式不对或 " + dtNike.Rows[i]["Style Color"].ToString() + "对应的尺寸" + dtNike.Rows[i]["Size"].ToString() + " 在系统中不存在!"; return; } } } dtpo.Columns.Add("外部单号"); dtpo.Columns.Add("预出库单类型"); dtpo.Columns.Add("仓库名称"); dtpo.Columns.Add("订单日期"); dtpo.Columns.Add("省"); dtpo.Columns.Add("市"); dtpo.Columns.Add("联系人"); dtpo.Columns.Add("快递公司"); dtpo.Columns.Add("备注"); dtpo.Columns.Add("自定义字段2"); dtpo.Columns.Add("自定义字段3"); dtpo.Columns.Add("自定义字段4"); dtpo.Columns.Add("地址"); dtpo.Columns.Add("联系方式"); dtpo.Columns.Add("自定义字段5"); dtpo.Columns.Add("自定义字段6"); dtpo.Columns.Add("自定义字段7"); dtpo.Columns.Add("自定义字段8"); dtpodetail.Columns.Add("外部单号"); dtpodetail.Columns.Add("仓库"); dtpodetail.Columns.Add("SKU"); dtpodetail.Columns.Add("UPC"); dtpodetail.Columns.Add("产品等级"); dtpodetail.Columns.Add("产品名称"); dtpodetail.Columns.Add("批次号"); dtpodetail.Columns.Add("托号"); dtpodetail.Columns.Add("备注"); dtpodetail.Columns.Add("期望数量"); dtpodetail.Columns.Add("自定义字段4"); dtpodetail.Columns.Add("自定义字段5"); dtpodetail.Columns.Add("自定义字段6"); dtpodetail.Columns.Add("自定义字段7"); dtpodetail.Columns.Add("单位"); dtpodetail.Columns.Add("规格"); //判断是否是殊门店配置 IEnumerable <WMSConfig> wmslist = null;//NFS分单配置 string userdef3 = ""; if (CustomerList.Where(m => m.StorerKey == dtNike.Rows[0]["Store Code"].ToString()).Count() > 0) { userdef3 = CustomerList.Where(m => m.StorerKey == dtNike.Rows[0]["Store Code"].ToString()).FirstOrDefault().UserDef3; } else { message = "第【1】行," + "【Store Code】列的门店代码格式不对或门店代码 " + dtNike.Rows[0][0].ToString() + "在系统中不存在!"; return; } try { wmslist = ApplicationConfigHelper.GetWMS_Config(userdef3); } catch (Exception) { } //特殊门店 if (wmslist != null && wmslist.Count() > 0) { for (int i = 0; i < dtNike.Rows.Count; i++) { string division = "", gender = ""; division = productListfs.Where(m => m.Str10 == dtNike.Rows[i]["Style Color"].ToString()).ToArray()[0].Division; gender = productListfs.Where(m => m.Str10 == dtNike.Rows[i]["Style Color"].ToString()).ToArray()[0].GenderAge; if (division == "FTW" && gender == "YA") { } string exterNo = DateTime.Parse(dtNike.Rows[i]["Store CRD"].ToString()).ToString("yyyyMMdd") + '-' + dtNike.Rows[0]["Store Code"].ToString() + wmslist.Where(m => m.Str1 == gender && m.Str2 == division).FirstOrDefault().Code;//年月日+门店代码+code //if (dtpo.Select("外部单号='" + DateTime.Parse(dtNike.Rows[i]["Store CRD"].ToString()).ToString("yyyyMMdd") + dtNike.Rows[i]["Store Code"].ToString() + wmslist.Where(m => m.Str1 == gender && m.Str2 == division).FirstOrDefault().Code + "'").Count() <= 0) if (dtpo.Select("外部单号='" + exterNo + "'").Count() <= 0) { DataRow dr = dtpo.NewRow(); if (productListfs.Where(m => m.Str10 == dtNike.Rows[i]["Style Color"].ToString()).ToArray().Length <= 0) { message = "第【" + (i + 2) + "】行," + "【Style Color】列的Article格式不对或Article " + dtNike.Rows[i]["Style Color"].ToString() + "在系统中不存在!"; return; } dr["外部单号"] = DateTime.Parse(dtNike.Rows[i]["Store CRD"].ToString()).ToString("yyyyMMdd") + '-' + dtNike.Rows[0]["Store Code"].ToString() + wmslist.Where(m => m.Str1 == gender && m.Str2 == division).FirstOrDefault().Code;//年月日+门店代码+code dr["预出库单类型"] = "门店调拨出库"; dr["仓库名称"] = warehouse.WarehouseName; dr["市"] = ""; dr["省"] = ""; dr["联系人"] = ""; dr["订单日期"] = DateTime.Now.ToString(); dr["备注"] = ""; dr["自定义字段2"] = dtNike.Rows[i]["Contract Code"].ToString(); dr["自定义字段3"] = productListfs.Where(m => m.Str10 == dtNike.Rows[i]["Style Color"].ToString()).ToArray().Length > 0 ? productListfs.Where(m => m.Str10 == dtNike.Rows[i]["Style Color"].ToString()).ToArray()[0].Division.ToString() : ""; if (CustomerList.Where(m => m.StorerKey == dtNike.Rows[i]["Store Code"].ToString()).ToArray().Length <= 0) { message = "第【" + (i + 2) + "】行," + "【Store Code】列的门店代码格式不对或门店代码 " + dtNike.Rows[i]["Store Code"].ToString() + "在系统中不存在!";//dtNike.Rows[i]["Store Code"].ToString() + "不存在!"; return; } if (dtNike.Columns.Contains("LF")) { dr["自定义字段8"] = dtNike.Rows[i]["LF"].ToString(); } dr["自定义字段4"] = dtNike.Rows[i]["Store Code"].ToString(); dr["地址"] = CustomerList.Where(m => m.StorerKey == dtNike.Rows[i]["Store Code"].ToString()).ToArray().Length > 0 ? CustomerList.Where(m => m.StorerKey == dtNike.Rows[i]["Store Code"].ToString()).ToArray()[0].AddressLine1 : ""; dr["自定义字段5"] = CustomerList.Where(m => m.StorerKey == dtNike.Rows[i]["Store Code"].ToString()).ToArray().Length > 0 ? CustomerList.Where(m => m.StorerKey == dtNike.Rows[i]["Store Code"].ToString()).ToArray()[0].Company.ToString() : ""; dr["联系方式"] = ""; dr["自定义字段6"] = productListfs.Where(m => m.Str10 == dtNike.Rows[i]["Style Color"].ToString()).ToArray().Length > 0 ? productListfs.Where(m => m.Str10 == dtNike.Rows[i]["Style Color"].ToString()).ToArray()[0].GenderAge.ToString() : ""; dr["自定义字段7"] = dtNike.Rows[i]["Store CRD"].ToString(); dtpo.Rows.Add(dr); } DataRow drdetail = dtpodetail.NewRow(); drdetail["外部单号"] = DateTime.Parse(dtNike.Rows[i]["Store CRD"].ToString()).ToString("yyyyMMdd") + '-' + dtNike.Rows[0]["Store Code"].ToString() + wmslist.Where(m => m.Str1 == gender && m.Str2 == division).FirstOrDefault().Code;//年月日+门店代码+code drdetail["仓库"] = warehouse.WarehouseName; drdetail["SKU"] = productListfs.Where(m => m.Str10 == dtNike.Rows[i]["Style Color"].ToString().Trim().ToUpper() && m.Str9 == dtNike.Rows[i]["Size"].ToString().Trim().ToUpper() && m.Str8 == "01").ToArray().Length > 0 ? productListfs.Where(m => m.Str10 == dtNike.Rows[i]["Style Color"].ToString().Trim().ToUpper() && m.Str9 == dtNike.Rows[i]["Size"].ToString().Trim().ToUpper() && m.Str8 == "01").ToArray()[0].SKU : ""; drdetail["UPC"] = ""; try { drdetail["产品等级"] = dtNike.Rows[i]["产品等级"].ToString(); } catch { drdetail["产品等级"] = "A品"; } drdetail["产品名称"] = productListfs.Where(m => m.Str10 == dtNike.Rows[i]["Style Color"].ToString()).ToArray().Length > 0 ? productListfs.Where(m => m.Str10 == dtNike.Rows[i]["Style Color"].ToString()).ToArray()[0].LongMaterial.ToString() : "";//产品名称 if (dtNike.Columns.Contains("批次号")) { drdetail["批次号"] = dtNike.Rows[i]["批次号"].ToString(); } else { drdetail["批次号"] = ""; } drdetail["托号"] = ""; drdetail["规格"] = ""; drdetail["备注"] = ""; drdetail["期望数量"] = dtNike.Rows[i]["Sugg# Rep Qty"].ToString(); drdetail["自定义字段4"] = ""; drdetail["自定义字段5"] = ""; drdetail["自定义字段6"] = dtNike.Rows[i]["Style Color"].ToString() + "-" + dtNike.Rows[i]["Size"].ToString(); drdetail["自定义字段7"] = productListfs.Where(m => m.Str10 == dtNike.Rows[i]["Style Color"].ToString()).ToArray().Length > 0 ? productListfs.Where(m => m.Str10 == dtNike.Rows[i]["Style Color"].ToString()).ToArray()[0].Division.ToString() : "";//BU drdetail["单位"] = wmsunit.Unit; dtpodetail.Rows.Add(drdetail); } } else { //string time = DateTime.Now.ToString("HHmmssfff"); //dtNike.DefaultView.Sort = "Store CRD ASC,BU ASC,Store Code ASC,Style Color ASC"; //dtNike = dtNike.DefaultView.ToTable(); for (int i = 0; i < dtNike.Rows.Count; i++) { //if (dtpo.Select("外部单号='" + DateTime.Parse(dtNike.Rows[i]["Store CRD"].ToString()).ToString("yyyyMMdd") + productListfs.Where(m => m.Str10 == dtNike.Rows[i]["Style Color"].ToString()).ToArray()[0].Division.Substring(0, 1).ToString() + '-' + dtNike.Rows[i]["Store Code"] + productListfs.Where(m => m.Str10 == dtNike.Rows[i]["Style Color"].ToString()).ToArray()[0].GenderAge.Substring(0, 1).ToString() + "'").Count() <= 0) //不拆单 if (dtpo.Select("外部单号='" + DateTime.Parse(dtNike.Rows[i]["Store CRD"].ToString()).ToString("yyyyMMdd") + '-' + dtNike.Rows[i]["Store Code"] + "'").Count() <= 0) { //time = DateTime.Now.ToString("HHmmssfff"); DataRow dr = dtpo.NewRow(); if (productListfs.Where(m => m.Str10 == dtNike.Rows[i]["Style Color"].ToString()).ToArray().Length <= 0) { message = "第【" + (i + 2) + "】行," + "【Style Color】列的Article格式不对或Article " + dtNike.Rows[i]["Style Color"].ToString() + "在系统中不存在!"; return; } //dr["外部单号"] = DateTime.Parse(dtNike.Rows[i]["Store CRD"].ToString()).ToString("yyyyMMdd") + productListfs.Where(m => m.Str10 == dtNike.Rows[i]["Style Color"].ToString()).ToArray()[0].Division.Substring(0, 1).ToString() + '-' + dtNike.Rows[i]["Store Code"] + productListfs.Where(m => m.Str10 == dtNike.Rows[i]["Style Color"].ToString()).ToArray()[0].GenderAge.Substring(0, 1).ToString(); //不拆单 dr["外部单号"] = DateTime.Parse(dtNike.Rows[i]["Store CRD"].ToString()).ToString("yyyyMMdd") + '-' + dtNike.Rows[i]["Store Code"].ToString(); dr["预出库单类型"] = "门店调拨出库"; dr["仓库名称"] = warehouse.WarehouseName; dr["市"] = ""; dr["省"] = ""; dr["联系人"] = ""; dr["订单日期"] = DateTime.Now.ToString(); dr["备注"] = ""; dr["自定义字段2"] = dtNike.Rows[i]["Contract Code"].ToString(); dr["自定义字段3"] = productListfs.Where(m => m.Str10 == dtNike.Rows[i]["Style Color"].ToString()).ToArray().Length > 0 ? productListfs.Where(m => m.Str10 == dtNike.Rows[i]["Style Color"].ToString()).ToArray()[0].Division.ToString() : ""; if (CustomerList.Where(m => m.StorerKey == dtNike.Rows[i]["Store Code"].ToString()).ToArray().Length <= 0) { message = "第【" + (i + 2) + "】行," + "【Store Code】列的门店代码格式不对或门店代码 " + dtNike.Rows[i]["Store Code"].ToString() + "在系统中不存在!";//dtNike.Rows[i]["Store Code"].ToString() + "不存在!"; return; } if (dtNike.Columns.Contains("LF")) { dr["自定义字段8"] = dtNike.Rows[i]["LF"].ToString(); } dr["自定义字段4"] = dtNike.Rows[i]["Store Code"].ToString(); dr["地址"] = CustomerList.Where(m => m.StorerKey == dtNike.Rows[i]["Store Code"].ToString()).ToArray().Length > 0 ? CustomerList.Where(m => m.StorerKey == dtNike.Rows[i]["Store Code"].ToString()).ToArray()[0].AddressLine1 : ""; dr["自定义字段5"] = CustomerList.Where(m => m.StorerKey == dtNike.Rows[i]["Store Code"].ToString()).ToArray().Length > 0 ? CustomerList.Where(m => m.StorerKey == dtNike.Rows[i]["Store Code"].ToString()).ToArray()[0].Company.ToString() : ""; dr["联系方式"] = ""; dr["自定义字段6"] = productListfs.Where(m => m.Str10 == dtNike.Rows[i]["Style Color"].ToString()).ToArray().Length > 0 ? productListfs.Where(m => m.Str10 == dtNike.Rows[i]["Style Color"].ToString()).ToArray()[0].GenderAge.ToString() : ""; dr["自定义字段7"] = dtNike.Rows[i]["Store CRD"].ToString(); dtpo.Rows.Add(dr); } DataRow drdetail = dtpodetail.NewRow(); //drdetail["外部单号"] = DateTime.Parse(dtNike.Rows[i]["Store CRD"].ToString()).ToString("yyyyMMdd") + productListfs.Where(m => m.Str10 == dtNike.Rows[i]["Style Color"].ToString()).ToArray()[0].Division.Substring(0, 1).ToString() + '-' + dtNike.Rows[i]["Store Code"] + productListfs.Where(m => m.Str10 == dtNike.Rows[i]["Style Color"].ToString()).ToArray()[0].GenderAge.Substring(0, 1).ToString(); //不拆单 drdetail["外部单号"] = DateTime.Parse(dtNike.Rows[i]["Store CRD"].ToString()).ToString("yyyyMMdd") + '-' + dtNike.Rows[i]["Store Code"].ToString().ToString(); drdetail["仓库"] = warehouse.WarehouseName; drdetail["SKU"] = productListfs.Where(m => m.Str10 == dtNike.Rows[i]["Style Color"].ToString().Trim().ToUpper() && m.Str9 == dtNike.Rows[i]["Size"].ToString().Trim().ToUpper() && m.Str8 == "01").ToArray().Length > 0 ? productListfs.Where(m => m.Str10 == dtNike.Rows[i]["Style Color"].ToString().Trim().ToUpper() && m.Str9 == dtNike.Rows[i]["Size"].ToString().Trim().ToUpper() && m.Str8 == "01").ToArray()[0].SKU : ""; drdetail["UPC"] = ""; try { drdetail["产品等级"] = dtNike.Rows[i]["产品等级"].ToString(); } catch { drdetail["产品等级"] = "A品"; } drdetail["产品名称"] = productListfs.Where(m => m.Str10 == dtNike.Rows[i]["Style Color"].ToString()).ToArray().Length > 0 ? productListfs.Where(m => m.Str10 == dtNike.Rows[i]["Style Color"].ToString()).ToArray()[0].LongMaterial.ToString() : "";//产品名称 if (dtNike.Columns.Contains("批次号")) { drdetail["批次号"] = dtNike.Rows[i]["批次号"].ToString(); } else { drdetail["批次号"] = ""; } drdetail["托号"] = ""; drdetail["规格"] = ""; drdetail["备注"] = ""; drdetail["期望数量"] = dtNike.Rows[i]["Sugg# Rep Qty"].ToString(); drdetail["自定义字段4"] = ""; drdetail["自定义字段5"] = ""; drdetail["自定义字段6"] = dtNike.Rows[i]["Style Color"].ToString() + "-" + dtNike.Rows[i]["Size"].ToString(); drdetail["自定义字段7"] = productListfs.Where(m => m.Str10 == dtNike.Rows[i]["Style Color"].ToString()).ToArray().Length > 0 ? productListfs.Where(m => m.Str10 == dtNike.Rows[i]["Style Color"].ToString()).ToArray()[0].Division.ToString() : "";//BU drdetail["单位"] = wmsunit.Unit; dtpodetail.Rows.Add(drdetail); } } //datatable 外部单号升序排序,并依次添加序号 //ModifyForDataTable MFD = new ModifyForDataTable(); //dtpo = MFD.AddSerialNumberForNFS(dtpo); //dtpodetail = MFD.AddSerialNumberForNFS(dtpodetail); dsResualt.Tables.Add(dtpo); dsResualt.Tables.Add(dtpodetail); //datatable 外部单号升序排序,并依次添加序号 ModifyForDataTable MFD = new ModifyForDataTable(); dsResualt = MFD.AddSerialNumberForNFS(dsResualt); this.AfterData = dsResualt; #endregion } } else { #region 正常出货 拆单 if (ApplicationConfigHelper.GetWarehouseListByCustomer(CustomerID).Where(p => p.ID == WareHouseID).ToArray().Count() <= 0) { message = "用户没有分配仓库!!"; return; } WarehouseInfo warehouse = ApplicationConfigHelper.GetWarehouseListByCustomer(CustomerID).Where(p => p.ID == WareHouseID).ToArray()[0]; IEnumerable <ProjectCustomer> Customer = ApplicationConfigHelper.GetProjectCustomers(ProjectID).ToArray(); IEnumerable <WMS_UnitAndSpecifications_Config> wmsunit = ApplicationConfigHelper.GetWMS_UnitAndSpecifications_Config(ProjectID, CustomerID, warehouse.ID).ToArray(); #region 产品等级列表 IEnumerable <WMSConfig> ProductLevelList = null; try { ProductLevelList = ApplicationConfigHelper.GetWMS_Config("ProductLevel_" + Customer.Select(s => s.Name).FirstOrDefault().ToString()).ToArray(); } catch (Exception) { ProductLevelList = ApplicationConfigHelper.GetWMS_Config("ProductLevel").ToArray(); } #endregion #region 预出库单类型列表 IEnumerable <WMSConfig> ordertypes = null; try { ordertypes = ApplicationConfigHelper.GetWMS_Config("OrderType_" + Customer.Select(s => s.Name).FirstOrDefault().ToString()).ToArray(); } catch (Exception) { ordertypes = ApplicationConfigHelper.GetWMS_Config("OrderType").ToArray(); } #endregion DataSet dsResualt = new DataSet(); DataTable dtpo = new DataTable(); dtpo.TableName = "预出库单主信息$"; DataTable dtpodetail = new DataTable(); dtpodetail.TableName = "预出库单明细信息$"; DataTable dtNike = Transdata.Tables[0]; List <ProductSearch> searprolistfs = new List <ProductSearch>(); for (int i = 0; i < dtNike.Rows.Count; i++) { ProductSearch psfs = new ProductSearch(); #region 验证物料 验证包装单位 验证产品等级 验证预出库单类型 数量是否为空 if (dtNike.Rows[i]["物料"].ToString().Equals("") || dtNike.Rows[i]["物料"].ToString().Length == 0) { message = "第【" + (i + 1) + "】行," + "【物料】列" + "有空值或格式不正确!"; return; } if (dtNike.Rows[i]["包装单位"].ToString().Equals("") || dtNike.Rows[i]["包装单位"].ToString().Length == 0) { message = "第【" + (i + 1) + "】行," + "【包装单位】列" + "有空值或格式不正确!"; return; } if (dtNike.Columns.Contains("产品等级")) { if (dtNike.Rows[i]["产品等级"].ToString().Equals("") || dtNike.Rows[i]["产品等级"].ToString().Length == 0) { message = "第【" + (i + 1) + "】行," + "【产品等级】列" + "有空值或格式不正确!"; return; } } if (dtNike.Columns.Contains("预出库单类型")) { if (dtNike.Rows[i]["预出库单类型"].ToString().Equals("") || dtNike.Rows[i]["预出库单类型"].ToString().Length == 0) { message = "第【" + (i + 1) + "】行," + "【预出库单类型】列" + "有空值或格式不正确!"; return; } } if (dtNike.Rows[i]["出货数量"].ToString().Equals("") || dtNike.Rows[i]["出货数量"].ToString().Length == 0) { message = "第【" + (i + 1) + "】行," + "【出货数量】列" + "有空值或格式不正确!"; return; } #endregion psfs.SKU = dtNike.Rows[i]["物料"].ToString(); searprolistfs.Add(psfs); } IEnumerable <ProductSearch> productListfs = ApplicationConfigHelper.GetSearchProduct(CustomerID, searprolistfs, "SKU"); for (int i = 0; i < dtNike.Rows.Count; i++) { #region 验证物料 验证单位 验证产品等级 验证出库单类型 if (productListfs.Where(m => m.SKU == dtNike.Rows[i]["物料"].ToString()).ToArray().Length <= 0) { message = "第【" + (i + 1) + "】行," + "【物料】列的格式不对或 " + dtNike.Rows[i]["物料"].ToString() + " 在系统中不存在!"; return; } if (wmsunit.Where(m => m.Unit == dtNike.Rows[i]["包装单位"].ToString()).ToArray().Length <= 0) { message = "第【" + (i + 1) + "】行," + "【包装单位】列的格式不对或 " + dtNike.Rows[i]["包装单位"].ToString() + " 在系统中不存在!"; return; } if (dtNike.Columns.Contains("产品等级")) { if (ProductLevelList.Where(m => m.Name == dtNike.Rows[i]["产品等级"].ToString()).ToArray().Length <= 0) { message = "第【" + (i + 1) + "】行," + "【产品等级】列的格式不对或 " + dtNike.Rows[i]["产品等级"].ToString() + " 在系统中不存在!"; return; } } if (dtNike.Columns.Contains("预出库单类型")) { if (ordertypes.Where(m => m.Name == dtNike.Rows[i]["预出库单类型"].ToString()).ToArray().Length <= 0) { message = "第【" + (i + 1) + "】行," + "【预出库单类型】列的格式不对或 " + dtNike.Rows[i]["预出库单类型"].ToString() + " 在系统中不存在!"; return; } } #endregion } #region dtpo.Columns.Add("外部单号"); dtpo.Columns.Add("预出库单类型"); dtpo.Columns.Add("仓库名称"); dtpo.Columns.Add("订单日期"); dtpo.Columns.Add("省"); dtpo.Columns.Add("市"); dtpo.Columns.Add("地址"); dtpo.Columns.Add("联系人"); dtpo.Columns.Add("联系方式"); dtpo.Columns.Add("快递公司"); dtpo.Columns.Add("备注"); dtpo.Columns.Add("自定义字段4"); dtpo.Columns.Add("自定义字段5"); #endregion #region dtpodetail.Columns.Add("外部单号"); dtpodetail.Columns.Add("仓库"); dtpodetail.Columns.Add("SKU"); dtpodetail.Columns.Add("UPC"); dtpodetail.Columns.Add("产品等级"); dtpodetail.Columns.Add("产品名称"); dtpodetail.Columns.Add("批次号"); dtpodetail.Columns.Add("托号"); dtpodetail.Columns.Add("单位"); dtpodetail.Columns.Add("规格"); dtpodetail.Columns.Add("备注"); dtpodetail.Columns.Add("期望数量"); #endregion for (int i = 0; i < dtNike.Rows.Count; i++) { if (dtpo.Select("外部单号='" + dtNike.Rows[i]["运单号"].ToString() + "'").Count() <= 0) { #region DataRow dr = dtpo.NewRow(); dr["外部单号"] = dtNike.Rows[i]["运单号"].ToString(); try { dr["预出库单类型"] = dtNike.Rows[i]["预出库单类型"].ToString(); } catch { dr["预出库单类型"] = "市内配送出库"; } dr["仓库名称"] = warehouse.WarehouseName; dr["订单日期"] = DateTime.Now.ToString(); dr["省"] = ""; dr["市"] = dtNike.Rows[i]["市"].ToString(); dr["地址"] = dtNike.Rows[i]["客户地址"].ToString(); dr["联系人"] = dtNike.Rows[i]["联系人"].ToString(); dr["联系方式"] = dtNike.Rows[i]["电话"].ToString(); dr["快递公司"] = dtNike.Rows[i]["承运商"].ToString(); dr["备注"] = ""; dr["自定义字段4"] = dtNike.Rows[i]["客户编号"].ToString(); dr["自定义字段5"] = dtNike.Rows[i]["客户名称"].ToString(); dtpo.Rows.Add(dr); #endregion } #region DataRow drdetail = dtpodetail.NewRow(); drdetail["外部单号"] = dtNike.Rows[i]["运单号"].ToString(); drdetail["仓库"] = warehouse.WarehouseName; drdetail["SKU"] = dtNike.Rows[i]["物料"].ToString().Trim().ToUpper(); drdetail["UPC"] = ""; try { drdetail["产品等级"] = dtNike.Rows[i]["产品等级"].ToString(); } catch { drdetail["产品等级"] = "A品"; } drdetail["产品名称"] = dtNike.Rows[i]["物料描述"].ToString(); drdetail["批次号"] = DateTime.Now.ToString("yyyyMMdd"); drdetail["托号"] = ""; drdetail["单位"] = dtNike.Rows[i]["包装单位"].ToString(); drdetail["规格"] = ""; drdetail["备注"] = dtNike.Rows[i]["发货备注"].ToString(); drdetail["期望数量"] = dtNike.Rows[i]["出货数量"].ToString(); dtpodetail.Rows.Add(drdetail); #endregion } dsResualt.Tables.Add(dtpo); dsResualt.Tables.Add(dtpodetail); //datatable 外部单号升序排序,并依次添加序号 //ModifyForDataTable MFD = new ModifyForDataTable(); //dsResualt = MFD.AddSerialNumberForNFS(dsResualt); this.AfterData = dsResualt; #endregion } } else if (TransDataType == "Receiving") { #region 架 DataTable dt = Transdata.Tables[0].Copy(); if (!dt.Columns.Contains("生产日期")) { dt.Columns.Add("生产日期"); } if (!dt.Columns.Contains("UPC")) { dt.Columns.Add("UPC"); } if (!dt.Columns.Contains("箱内总数")) { dt.Columns.Add("箱内总数"); } for (int i = 0; i < dt.Rows.Count; i++) { try { Convert.ToDateTime(dt.Rows[i]["生产日期"].ToString()); } catch { dt.Rows[i]["生产日期"] = System.DateTime.Now.ToString(); } } DataSet ds = new DataSet(); ds.Tables.Add(dt); this.AfterData = ds; #endregion } else { this.AfterData = Transdata; } }
public override void CustomerDefinedSettledTransData(ref string message) { if (TransDataType == "PreOrder") { if (ApplicationConfigHelper.GetWarehouseListByCustomer(CustomerID).Where(p => p.ID == WareHouseID).ToArray().Count() <= 0) { message = "用户没有分配仓库!!"; return; } //正常出货 拆单 WarehouseInfo warehouse = ApplicationConfigHelper.GetWarehouseListByCustomer(CustomerID).Where(p => p.ID == WareHouseID).ToArray()[0]; IEnumerable <WMS_Customer> CustomerList = ApplicationConfigHelper.GetAllCustomerByID(CustomerID); WMS_UnitAndSpecifications_Config wmsunit = ApplicationConfigHelper.GetWMS_UnitAndSpecifications_Config(ProjectID, CustomerID, warehouse.ID).ToArray()[0]; DataSet dsResualt = new DataSet(); DataTable dtpo = new DataTable(); DataTable dtpodetail = new DataTable(); dtpo.TableName = "预出库单主信息$"; dtpodetail.TableName = "预出库单明细信息$"; DataTable dtpodetailCount = Transdata.Tables[0]; //获取第一张表 DataTable dtpoloadkey = Transdata.Tables[1]; //获取第二张表 #region 验证空值 List <ProductSearch> searprolistfs = new List <ProductSearch>(); string aa = ""; string bb = ""; string Size = ""; string Article = ""; for (int i = 0; i < dtpodetailCount.Rows.Count; i++) { ProductSearch psfs = new ProductSearch(); if (dtpodetailCount.Rows[i]["Sku"].ToString().Equals("") || dtpodetailCount.Rows[i]["Sku"].ToString().Length == 0) { message = "第【" + (i + 2) + "】行," + "【Sku】列" + "有空值或格式不正确(应为文本格式)!"; return; } aa = dtpodetailCount.Rows[i]["sku"].ToString(); bb = aa.Substring(6, 3); Size = aa.Substring(9); aa = aa.Substring(0, 6); psfs.Str10 = aa + "-" + bb; psfs.Str9 = Size; psfs.Str8 = "01"; searprolistfs.Add(psfs); } #endregion #region 获得SKU集合 IEnumerable <ProductSearch> productListfs; productListfs = ApplicationConfigHelper.GetSearchProduct(CustomerID, searprolistfs, "Acticle"); #endregion #region 先验证article存不存在再继续 for (int i = 0; i < dtpodetailCount.Rows.Count; i++) { aa = dtpodetailCount.Rows[i]["sku"].ToString(); bb = aa.Substring(6, 3); Size = aa.Substring(9); aa = aa.Substring(0, 6); Article = aa + '-' + bb; if (productListfs.Where(m => m.Str10 == Article).ToArray().Length <= 0) { message = "第【" + (i + 2) + "】行," + "【sku】列的Article格式不对或Article " + dtpodetailCount.Rows[i]["sku"].ToString() + " 在系统中不存在!"; return; } else { if (productListfs.Where(m => m.Str10 == Article && m.Str9 == Size).ToArray().Length <= 0) { message = "第【" + (i + 2) + "】行," + "【sku】列的尺寸格式不对或 " + dtpodetailCount.Rows[i]["sku"].ToString() + "对应的尺寸" + dtpodetailCount.Rows[i]["sku"].ToString() + " 在系统中不存在!"; return; } } //判断是否为单仓订单 if (dtpoloadkey.Select("Loadkey='" + dtpodetailCount.Rows[i]["LOAD KEY"].ToString() + "'").Count() <= 0) { dtpodetailCount.Rows[i]["LF出库单号行号"] = "否"; } else { dtpodetailCount.Rows[i]["LF出库单号行号"] = "是"; } //判断 Division Code if (dtpodetailCount.Rows[i]["Division Code"].ToString() == "10") { dtpodetailCount.Rows[i]["Division Code"] = "APP"; } else if (dtpodetailCount.Rows[i]["Division Code"].ToString() == "20" || dtpodetailCount.Rows[i]["Division Code"].ToString() == "40") { dtpodetailCount.Rows[i]["Division Code"] = "FTW"; } else { dtpodetailCount.Rows[i]["Division Code"] = "EQP"; } } #endregion #region 建列 dtpo.Columns.Add("外部单号"); dtpo.Columns.Add("预出库单类型"); dtpo.Columns.Add("仓库名称"); dtpo.Columns.Add("订单日期"); dtpo.Columns.Add("省"); dtpo.Columns.Add("市"); //城市 dtpo.Columns.Add("联系人"); dtpo.Columns.Add("快递公司"); dtpo.Columns.Add("备注"); dtpo.Columns.Add("自定义字段2"); //运输时效 dtpo.Columns.Add("自定义字段3"); //Division Code dtpo.Columns.Add("自定义字段4"); //NFS店铺编码 dtpo.Columns.Add("地址"); //地址1+地址2+地址3+地址4 dtpo.Columns.Add("联系方式"); dtpo.Columns.Add("自定义字段5"); //公司名 dtpo.Columns.Add("自定义字段6"); dtpo.Columns.Add("自定义字段7"); //计划发货时间 dtpo.Columns.Add("自定义字段8"); //VAS Code dtpo.Columns.Add("自定义字段9"); //LOAD KEY dtpo.Columns.Add("自定义字段10"); //Nike PO dtpo.Columns.Add("自定义字段11"); //PACK SLIP NO dtpo.Columns.Add("自定义字段12"); //LF出库单号行号 (是否单仓) dtpo.Columns.Add("自定义字段13"); //BU dtpo.Columns.Add("自定义字段14"); //RP LI dtpo.Columns.Add("自定义字段15"); //CRD dtpo.Columns.Add("自定义字段16"); //预计卸货时间 dtpodetail.Columns.Add("外部单号"); dtpodetail.Columns.Add("仓库"); dtpodetail.Columns.Add("SKU"); //Sku dtpodetail.Columns.Add("UPC"); //UPC dtpodetail.Columns.Add("产品等级"); dtpodetail.Columns.Add("产品名称"); dtpodetail.Columns.Add("批次号"); dtpodetail.Columns.Add("托号"); dtpodetail.Columns.Add("备注"); dtpodetail.Columns.Add("期望数量"); //数量 dtpodetail.Columns.Add("自定义字段2"); dtpodetail.Columns.Add("自定义字段3"); dtpodetail.Columns.Add("自定义字段4"); //Sku dtpodetail.Columns.Add("自定义字段5"); //VAS dtpodetail.Columns.Add("自定义字段6"); //Article dtpodetail.Columns.Add("自定义字段7"); //Division Code BU dtpodetail.Columns.Add("自定义字段8"); //LF出库单号 dtpodetail.Columns.Add("自定义字段9"); ////NIke单据编码 dtpodetail.Columns.Add("单位"); dtpodetail.Columns.Add("规格"); #endregion #region 拆单 收货日期+BU+门店代码+Loadkey 计划发货时间+Loadkey+运输方式 for (int i = 0; i < dtpodetailCount.Rows.Count; i++) { aa = dtpodetailCount.Rows[i]["sku"].ToString(); bb = aa.Substring(6, 3); Size = aa.Substring(9); aa = aa.Substring(0, 6); Article = aa + '-' + bb; //生成外部单号 //string exterNo = dtpodetailCount.Rows[i]["Division Code"].ToString().Substring(0, 1) + '-' //+ dtpodetailCount.Rows[i]["NFS店铺编码"].ToString() + '-' + dtpodetailCount.Rows[i]["LOAD KEY"].ToString(); string exterNo = dtpodetailCount.Rows[i]["计划发货时间"].ToString().Replace("-", "") + '-' + dtpodetailCount.Rows[i]["LOAD KEY"].ToString() + '-' + dtpodetailCount.Rows[i]["运输方式"].ToString(); //判断外部单号是否存在 if (dtpo.Select("外部单号='" + exterNo + "'").Count() <= 0) { DataRow dr = dtpo.NewRow(); if (productListfs.Where(m => m.Str10 == Article).ToArray().Length <= 0) { message = "第【" + (i + 2) + "】行," + "【sku】列的Article格式不对或Article " + dtpodetailCount.Rows[i]["sku"].ToString() + "在系统中不存在!"; return; } dr["外部单号"] = exterNo; dr["预出库单类型"] = dtpodetailCount.Rows[i]["订单类型"].ToString();//正常出库AB,残次出库C dr["仓库名称"] = warehouse.WarehouseName; dr["市"] = dtpodetailCount.Rows[i]["城市"].ToString(); dr["省"] = ""; dr["联系人"] = ""; dr["订单日期"] = DateTime.Now.ToString(); dr["备注"] = ""; dr["自定义字段2"] = dtpodetailCount.Rows[i]["运输时效"].ToString(); dr["自定义字段3"] = dtpodetailCount.Rows[i]["运输方式"].ToString(); //if (CustomerList.Where(m => m.StorerKey == dtpodetailCount.Rows[i]["NFS店铺编码"].ToString()).ToArray().Length <= 0) //{ // message = "第【" + (i + 2) + "】行," + "【NFS店铺编码】列的店铺编码格式不对或店铺编码 " + dtpodetailCount.Rows[i]["NFS店铺编码"].ToString() + "在系统中不存在!";//dtNike.Rows[i]["Store Code"].ToString() + "不存在!"; // return; //} dr["自定义字段4"] = dtpodetailCount.Rows[i]["NFS店铺编码"].ToString(); dr["地址"] = dtpodetailCount.Rows[i]["地址3"].ToString() + '&' + dtpodetailCount.Rows[i]["地址4"].ToString() + '&' + dtpodetailCount.Rows[i]["地址2"].ToString() + '&' + dtpodetailCount.Rows[i]["地址1"].ToString(); dr["自定义字段5"] = dtpodetailCount.Rows[i]["公司名"].ToString(); dr["联系方式"] = ""; dr["自定义字段6"] = productListfs.Where(m => m.Str10 == Article).ToArray().Length > 0 ? productListfs.Where(m => m.Str10 == Article).ToArray()[0].GenderAge.ToString() : ""; dr["自定义字段7"] = dtpodetailCount.Rows[i]["计划发货时间"].ToString(); dr["自定义字段8"] = dtpodetailCount.Rows[i]["VAS Code"].ToString(); dr["自定义字段9"] = dtpodetailCount.Rows[i]["LOAD KEY"].ToString(); dr["自定义字段10"] = dtpodetailCount.Rows[i]["Nike PO"].ToString(); dr["自定义字段11"] = dtpodetailCount.Rows[i]["PACK SLIP NO"].ToString(); dr["自定义字段12"] = dtpodetailCount.Rows[i]["LF出库单号行号"].ToString(); dr["自定义字段13"] = dtpodetailCount.Rows[i]["Division Code"].ToString();//BU //判断 Nike PO 长度是否大于9 if (dtpodetailCount.Rows[i]["Nike PO"].ToString().Length >= 9) { if (dtpodetailCount.Rows[i]["Nike PO"].ToString().Substring(8, 1).Equals("L")) { //1.S列的第9位为L时,显示为LI,为S时,为RP。 dr["自定义字段14"] = "LI"; //LI } else if (dtpodetailCount.Rows[i]["Nike PO"].ToString().Substring(8, 1).Equals("S")) { dr["自定义字段14"] = "RP";//RP } else {// 2.当非L或S时,用T列判断,RP为RP,LI为LI,NIKECN为空值。 if (dtpodetailCount.Rows[i]["VAS Code"].ToString().Equals("NIKECN")) { dr["自定义字段14"] = ""; } else { dr["自定义字段14"] = dtpodetailCount.Rows[i]["VAS Code"].ToString();//RP为RP,LI为LI } } } else { // 2.当非L或S时,用T列判断,RP为RP,LI为LI,NIKECN为空值。 if (dtpodetailCount.Rows[i]["VAS Code"].ToString().Equals("NIKECN")) { dr["自定义字段14"] = ""; } else { dr["自定义字段14"] = dtpodetailCount.Rows[i]["VAS Code"].ToString(); //RP为RP,LI为LI } } //string.Format("{0:d}", dt) //dr["自定义字段15"] = string.Format("{0:d}", DateTime.Parse(dtpodetailCount.Rows[i]["计划发货时间"].ToString()) // .AddDays(int.Parse(dtpodetailCount.Rows[i]["运输时效"].ToString()))); dr["自定义字段15"] = (DateTime.Parse(dtpodetailCount.Rows[i]["计划发货时间"].ToString()) .AddDays(int.Parse(dtpodetailCount.Rows[i]["运输时效"].ToString()))).ToString("yyyy-MM-dd"); try { DateTime time = DateTime.Parse(dtpodetailCount.Rows[i]["Nike PO"].ToString().Substring(0, 8).Insert(4, "-").Insert(7, "-")); if (DateTime.Parse(dtpodetailCount.Rows[i]["计划发货时间"].ToString()) .AddDays(int.Parse(dtpodetailCount.Rows[i]["运输时效"].ToString())) >= DateTime.Parse(dtpodetailCount.Rows[i]["Nike PO"].ToString().Substring(0, 8).Insert(4, "-").Insert(7, "-")) ) { //1.当H + I》S时,不显示CRD 2.当H + I < S时,显示CRD为S列前8位 运输时效 Nike PO dr["自定义字段15"] = ""; //CRD } else { dr["自定义字段15"] = dtpodetailCount.Rows[i]["Nike PO"].ToString().Substring(0, 8).Insert(4, "-").Insert(7, "-"); } } catch (Exception e) { } //预计卸货时间 dr["自定义字段16"] = (DateTime.Parse(dtpodetailCount.Rows[i]["计划发货时间"].ToString()) .AddDays(int.Parse(dtpodetailCount.Rows[i]["运输时效"].ToString()))).ToString("yyyy-MM-dd"); try { DateTime time = DateTime.Parse(dtpodetailCount.Rows[i]["Nike PO"].ToString().Substring(0, 8).Insert(4, "-").Insert(7, "-")); dr["自定义字段16"] = dtpodetailCount.Rows[i]["Nike PO"].ToString().Substring(0, 8).Insert(4, "-").Insert(7, "-"); } catch (Exception) { } dtpo.Rows.Add(dr); } DataRow drdetail = dtpodetail.NewRow(); drdetail["外部单号"] = exterNo; drdetail["仓库"] = warehouse.WarehouseName; drdetail["SKU"] = productListfs.Where(m => m.Str10 == Article.Trim().ToUpper() && m.Str9 == Size.Trim().ToUpper() && m.Str8 == "01").ToArray().Length > 0 ? productListfs.Where(m => m.Str10 == Article.Trim().ToUpper() && m.Str9 == Size.Trim().ToUpper() && m.Str8 == "01").ToArray()[0].SKU : ""; drdetail["UPC"] = ""; if (dtpodetailCount.Rows[i]["订单类型"].ToString() == "正常出库") { drdetail["产品等级"] = "A品"; } else { drdetail["产品等级"] = "C品"; } drdetail["产品名称"] = productListfs.Where(m => m.Str10 == Article).ToArray().Length > 0 ? productListfs.Where(m => m.Str10 == Article).ToArray()[0].LongMaterial.ToString() : "";//产品名称 drdetail["批次号"] = ""; drdetail["托号"] = ""; drdetail["规格"] = ""; drdetail["备注"] = ""; drdetail["期望数量"] = dtpodetailCount.Rows[i]["数量"].ToString(); drdetail["自定义字段2"] = productListfs.Where(m => m.Str10 == Article.Trim().ToUpper() && m.Str9 == Size.Trim().ToUpper() && m.Str8 == "01").ToArray()[0].Price; //价格 drdetail["自定义字段3"] = productListfs.Where(m => m.Str10 == Article.Trim().ToUpper() && m.Str9 == Size.Trim().ToUpper() && m.Str8 == "01").ToArray()[0].SafeLock; //安全扣 drdetail["自定义字段4"] = productListfs.Where(m => m.Str10 == Article.Trim().ToUpper() && m.Str9 == Size.Trim().ToUpper() && m.Str8 == "01").ToArray()[0].Hanger; //衣架 drdetail["自定义字段5"] = dtpodetailCount.Rows[i]["VAS"].ToString(); drdetail["自定义字段6"] = Article + '-' + Size; drdetail["自定义字段7"] = dtpodetailCount.Rows[i]["Division Code"];//BU drdetail["自定义字段8"] = dtpodetailCount.Rows[i]["LF出库单号"].ToString(); drdetail["自定义字段9"] = dtpodetailCount.Rows[i]["NIke单据编码"].ToString(); drdetail["单位"] = wmsunit.Unit; dtpodetail.Rows.Add(drdetail); } #endregion dsResualt.Tables.Add(dtpo); dsResualt.Tables.Add(dtpodetail); //ModifyForDataTable MFD = new ModifyForDataTable(); //dsResualt = MFD.AddSerialNumberForNFS(dsResualt); this.AfterData = dsResualt; } else if (TransDataType == "Receiving") { #region 架 DataTable dt = Transdata.Tables[0].Copy(); foreach (DataRow item in dt.Rows) { if (!item["托号"].ToString().Equals("")) { message = "托号列不能有值,请清除后再导入!"; return; } } if (!dt.Columns.Contains("生产日期")) { dt.Columns.Add("生产日期"); } if (!dt.Columns.Contains("UPC")) { dt.Columns.Add("UPC"); } if (!dt.Columns.Contains("箱内总数")) { dt.Columns.Add("箱内总数"); } for (int i = 0; i < dt.Rows.Count; i++) { try { Convert.ToDateTime(dt.Rows[i]["生产日期"].ToString()); } catch { dt.Rows[i]["生产日期"] = System.DateTime.Now.ToString(); } } DataSet ds = new DataSet(); ds.Tables.Add(dt); this.AfterData = ds; #endregion } else if (TransDataType == "Asn") { try { if (ApplicationConfigHelper.GetWarehouseListByCustomer(CustomerID).Where(p => p.ID == WareHouseID).ToArray().Count() <= 0) { message = "用户没有分配仓库!!"; return; } //Asn WarehouseInfo warehouse = ApplicationConfigHelper.GetWarehouseListByCustomer(CustomerID).Where(p => p.ID == WareHouseID).ToArray()[0]; IEnumerable <WMS_Customer> CustomerList = ApplicationConfigHelper.GetAllCustomerByID(CustomerID); WMS_UnitAndSpecifications_Config wmsunit = ApplicationConfigHelper.GetWMS_UnitAndSpecifications_Config(ProjectID, CustomerID, warehouse.ID).ToArray()[0]; DataTable dtpodetailCount = Transdata.Tables[0]; //获取第1张表 DataTable dtpoloadkey = Transdata.Tables[1]; //获取第2张表 #region 验证空值 List <ProductSearch> searprolistfs = new List <ProductSearch>(); for (int i = 0; i < dtpoloadkey.Rows.Count; i++) { ProductSearch psfs = new ProductSearch(); if (dtpoloadkey.Rows[i]["SKU"].ToString().Equals("") || dtpoloadkey.Rows[i]["SKU"].ToString().Length == 0) { message = "第【" + (i + 2) + "】行," + "【SKU】列" + "有空值或格式不正确(应为文本格式)!"; return; } if (dtpoloadkey.Rows[i]["UPC"].ToString().Equals("") || dtpoloadkey.Rows[i]["UPC"].ToString().Length == 0) { message = "第【" + (i + 2) + "】行," + "【UPC】列" + "有空值或格式不正确(应为文本格式)!"; return; } psfs.Str10 = dtpoloadkey.Rows[i]["SKU"].ToString(); psfs.Str9 = dtpoloadkey.Rows[i]["UPC"].ToString(); psfs.Str8 = "01"; searprolistfs.Add(psfs); } #endregion #region 获得SKU集合 IEnumerable <ProductSearch> productListfs; productListfs = ApplicationConfigHelper.GetSearchProduct(CustomerID, searprolistfs, "Acticle"); #endregion //退货仓填写默认门店代码 for (int i = 0; i < dtpodetailCount.Rows.Count; i++) { dtpodetailCount.Rows[i]["门店代码"] = "QQQQQQ"; } for (int i = 0; i < dtpoloadkey.Rows.Count; i++) { string Article = dtpoloadkey.Rows[i]["SKU"].ToString(); string Sz = dtpoloadkey.Rows[i]["UPC"].ToString(); try { dtpoloadkey.Rows[i]["SKU"] = productListfs.Where(m => m.Str10 == Article && m.Str9 == Sz && m.Str8 == "01").ToArray()[0].SKU.ToString(); dtpoloadkey.Rows[i]["UPC"] = DBNull.Value; } catch (Exception e) { message = "第" + (i + 1) + "行Article【" + Article + "】,Sz【" + Sz + "】在系统中不存在!"; return; } } this.AfterData = Transdata; } catch (Exception e) { throw; } } else { this.AfterData = Transdata; } }
public override void CustomerDefinedSettledTransData(ref string message) { if (this.TransDataType == "PreOrder") { List <ProductSearch> productListS = new List <ProductSearch>();//产品 IEnumerable <ProductSearch> productList; if (WareHouseID == 0) { message = "用户没有分配仓库!!"; return; } WarehouseInfo warehouse = ApplicationConfigHelper.GetWarehouseList().Where(m => m.ID == WareHouseID).FirstOrDefault();//customerid获取仓库 IEnumerable <WMS_Customer> CustomerList = ApplicationConfigHelper.GetAllCustomerByID(CustomerID); WMS_UnitAndSpecifications_Config wmsunit = ApplicationConfigHelper.GetWMS_UnitAndSpecifications_Config(ProjectID, CustomerID, warehouse.ID).ToArray()[0]; DataSet dsResualt = new DataSet(); DataTable dtpo = new DataTable(); DataTable dtpodetail = new DataTable(); dtpo.TableName = "预出库单主信息$"; dtpodetail.TableName = "预出库单明细信息$"; DataTable dtYXDRBJ = Transdata.Tables[0];//获取转换之后的excel数据 //主表 dtpo.Columns.Add("外部单号"); dtpo.Columns.Add("预出库单类型"); dtpo.Columns.Add("仓库名称"); dtpo.Columns.Add("订单日期"); dtpo.Columns.Add("收货公司"); dtpo.Columns.Add("省"); dtpo.Columns.Add("市"); dtpo.Columns.Add("联系人"); dtpo.Columns.Add("备注"); dtpo.Columns.Add("地址"); dtpo.Columns.Add("联系方式"); dtpo.Columns.Add("自定义字段4"); dtpo.Columns.Add("自定义字段2"); dtpo.Columns.Add("自定义字段3"); //子表 dtpodetail.Columns.Add("外部单号"); dtpodetail.Columns.Add("仓库"); dtpodetail.Columns.Add("SKU"); dtpodetail.Columns.Add("UPC"); dtpodetail.Columns.Add("产品名称"); dtpodetail.Columns.Add("产品等级"); dtpodetail.Columns.Add("批次号"); dtpodetail.Columns.Add("托号"); dtpodetail.Columns.Add("备注"); dtpodetail.Columns.Add("期望数量"); dtpodetail.Columns.Add("单位"); dtpodetail.Columns.Add("规格"); dtpodetail.Columns.Add("自定义字段4"); dtpodetail.Columns.Add("自定义字段5"); dtpodetail.Columns.Add("自定义字段6"); for (int i = 0; i < dtYXDRBJ.Rows.Count; i++) { if (dtpo.Select("外部单号='" + dtYXDRBJ.Rows[i]["订单号"].ToString() + "'").Count() <= 0)//判断excel中是否有相同的外部单号 { DataRow dr = dtpo.NewRow(); dr["外部单号"] = dtYXDRBJ.Rows[i]["订单号"].ToString(); dr["预出库单类型"] = dtYXDRBJ.Rows[i]["订单类型"].ToString(); dr["仓库名称"] = warehouse.WarehouseName; dr["市"] = CustomerList.Where(m => m.StorerKey == dtYXDRBJ.Rows[i]["货主"].ToString()).ToArray().Length > 0 ? CustomerList.Where(m => m.StorerKey == dtYXDRBJ.Rows[i]["货主"].ToString()).ToArray()[0].City : ""; dr["省"] = ""; dr["联系人"] = CustomerList.Where(m => m.StorerKey == dtYXDRBJ.Rows[i]["货主"].ToString()).ToArray().Length > 0 ? CustomerList.Where(m => m.StorerKey == dtYXDRBJ.Rows[i]["货主"].ToString()).ToArray()[0].Contact1 : ""; dr["订单日期"] = dtYXDRBJ.Rows[i]["订单日期"].ToString(); dr["备注"] = dtYXDRBJ.Rows[i]["备注1"].ToString(); dr["自定义字段4"] = dtYXDRBJ.Rows[i]["货主"].ToString(); dr["自定义字段2"] = dtYXDRBJ.Rows[i]["备注2"].ToString(); dr["自定义字段3"] = dtYXDRBJ.Rows[i]["备注3"].ToString(); if (CustomerList.Where(a => a.StorerKey == dtYXDRBJ.Rows[i]["货主"].ToString()).ToArray().Length <= 0) { message = dtYXDRBJ.Rows[i]["货主"].ToString() + "货主不存在!!"; return; } dr["地址"] = CustomerList.Where(m => m.StorerKey == dtYXDRBJ.Rows[i]["货主"].ToString()).ToArray().Length > 0 ? CustomerList.Where(m => m.StorerKey == dtYXDRBJ.Rows[i]["货主"].ToString()).ToArray()[0].AddressLine1 : ""; //地址从wms_customer获取 dr["联系方式"] = CustomerList.Where(m => m.StorerKey == dtYXDRBJ.Rows[i]["货主"].ToString()).ToArray().Length > 0 ? CustomerList.Where(m => m.StorerKey == dtYXDRBJ.Rows[i]["货主"].ToString()).ToArray()[0].PhoneNum1 : ""; //联系方式从wms_customer获取 dr["收货公司"] = CustomerList.Where(m => m.StorerKey == dtYXDRBJ.Rows[i]["货主"].ToString()).ToArray().Length > 0 ? CustomerList.Where(m => m.StorerKey == dtYXDRBJ.Rows[i]["货主"].ToString()).ToArray()[0].Company : ""; //门店的名称从wms_customer获取 dtpo.Rows.Add(dr);//主表添加一行 } DataRow drdetail = dtpodetail.NewRow(); drdetail["外部单号"] = dtYXDRBJ.Rows[i]["订单号"].ToString(); drdetail["仓库"] = warehouse.WarehouseName; ProductSearch ps = new ProductSearch(); ps.Str10 = dtYXDRBJ.Rows[i]["存货Article"].ToString(); ps.Str9 = dtYXDRBJ.Rows[i]["存货Size"].ToString(); productListS.Add(ps);//先获取Article+size集合,然后一起校验sku drdetail["UPC"] = ""; try { drdetail["产品等级"] = dtYXDRBJ.Rows[i]["产品等级"].ToString(); } catch { drdetail["产品等级"] = "A品"; } drdetail["批次号"] = ""; drdetail["托号"] = ""; drdetail["规格"] = ""; drdetail["备注"] = ""; drdetail["期望数量"] = dtYXDRBJ.Rows[i]["数量"].ToString(); drdetail["自定义字段4"] = dtYXDRBJ.Rows[i]["备注4"].ToString(); drdetail["自定义字段5"] = dtYXDRBJ.Rows[i]["备注5"].ToString(); drdetail["自定义字段6"] = dtYXDRBJ.Rows[i]["备注6"].ToString(); drdetail["单位"] = dtYXDRBJ.Rows[i]["单位"].ToString(); dtpodetail.Rows.Add(drdetail); } productList = ApplicationConfigHelper.GetSearchProductYXDR(CustomerID, productListS, "ArticleSize"); for (int i = 0; i < dtpodetail.Rows.Count; i++) { if (productList.ToArray().Length <= 0) { message = "excel中的Article+Size未匹配到任何SKU,请检查excel数据!"; return; } string sku = productList.Where(p => p.Str10 == productListS[i].Str10 && p.Str9 == productListS[i].Str9).ToArray().Length > 0 ? productList.Where(p => p.Str10 == productListS[i].Str10 && p.Str9 == productListS[i].Str9).ToArray()[0].SKU : ""; if (string.IsNullOrEmpty(sku)) { int x = i + 1; message = "excel中第" + x + "行的Article=" + productListS[i].Str10 + "和Size=" + productListS[i].Str9 + "未匹配到SKU"; return; } dtpodetail.Rows[i]["SKU"] = sku; dtpodetail.Rows[i]["产品名称"] = productList.Where(p => p.Str10 == productListS[i].Str10 && p.Str9 == productListS[i].Str9).ToArray().Length > 0 ? productList.Where(p => p.Str10 == productListS[i].Str10 && p.Str9 == productListS[i].Str9).ToArray()[0].GoodsName : ""; } //验证同一外部单号是否存在相同的SKU //var dd = from t in dtpodetail.AsEnumerable() // group t by new { t1 = t.Field<string>("外部单号"), t2 = t.Field<string>("SKU") } into m // select new // { // 外部单号 = m.Select(p => p.Field<string>("外部单号")).First(), // SKU = m.Select(p => p.Field<string>("SKU")).First(), // count = m.Count(), // }; //var dr1 = dd.Where(c => c.count > 1); //if (dr1.Count() > 0) //{ // foreach (var item in dr1) // { // message += "<p><font color='#FF0000'>外部单号" + item.外部单号 + "中的SKU" + item.SKU + "存在重复值!" + "</font></p>"; // return; // } //} dsResualt.Tables.Add(dtpo); dsResualt.Tables.Add(dtpodetail); this.AfterData = dsResualt; } else if (TransDataType == "Asn")//入库单 { if (ApplicationConfigHelper.GetWarehouseListByCustomer(CustomerID).Where(p => p.ID == WareHouseID).ToArray().Count() <= 0) { message = "用户没有分配仓库!!"; return; } List <ProductSearch> productListS = new List <ProductSearch>();//产品 IEnumerable <ProductSearch> productList; WarehouseInfo warehouse = ApplicationConfigHelper.GetWarehouseListByCustomer(CustomerID).Where(p => p.ID == WareHouseID).ToArray()[0]; //查询仓库 IEnumerable <WMS_Customer> CustomerList = ApplicationConfigHelper.GetAllCustomerByID(CustomerID); //查询wms_customer WMS_UnitAndSpecifications_Config wmsunit = ApplicationConfigHelper.GetWMS_UnitAndSpecifications_Config(ProjectID, CustomerID, warehouse.ID).ToArray()[0]; //查询单位等信息 DataSet dsresult = new DataSet(); DataTable dtas = new DataTable(); DataTable dtasdetail = new DataTable(); DataTable dtYXDRBJas = Transdata.Tables[0]; dtas.TableName = "预入库单主信息$"; dtasdetail.TableName = "预入库单明细信息$"; //主表 dtas.Columns.Add("外部入库单号"); dtas.Columns.Add("预入库单类型"); dtas.Columns.Add("预入库日期"); dtas.Columns.Add("仓库名称"); dtas.Columns.Add("客户"); dtas.Columns.Add("备注"); dtas.Columns.Add("自定义字段1"); dtas.Columns.Add("自定义字段2"); dtas.Columns.Add("自定义字段3"); //子表 dtasdetail.Columns.Add("外部入库单号"); dtasdetail.Columns.Add("仓库"); dtasdetail.Columns.Add("SKU"); dtasdetail.Columns.Add("产品名称"); dtasdetail.Columns.Add("UPC"); dtasdetail.Columns.Add("规格"); dtasdetail.Columns.Add("预收数量"); dtasdetail.Columns.Add("单位"); dtasdetail.Columns.Add("产品等级"); dtasdetail.Columns.Add("箱号"); dtasdetail.Columns.Add("备注"); dtasdetail.Columns.Add("自定义字段4"); dtasdetail.Columns.Add("自定义字段5"); dtasdetail.Columns.Add("自定义字段6"); for (int i = 0; i < dtYXDRBJas.Rows.Count; i++) { if (dtas.Select("外部入库单号='" + dtYXDRBJas.Rows[i]["订单号"].ToString() + "'").Count() <= 0) { DataRow dr = dtas.NewRow(); dr["外部入库单号"] = dtYXDRBJas.Rows[i]["订单号"].ToString(); dr["预入库单类型"] = dtYXDRBJas.Rows[i]["预入库单类型"].ToString(); dr["预入库日期"] = dtYXDRBJas.Rows[i]["预入库日期"].ToString(); dr["仓库名称"] = warehouse.WarehouseName; dr["客户"] = dtYXDRBJas.Rows[i]["客户"].ToString(); dr["备注"] = dtYXDRBJas.Rows[i]["备注1"].ToString(); dr["自定义字段1"] = dtYXDRBJas.Rows[i]["备注1"].ToString(); dr["自定义字段2"] = dtYXDRBJas.Rows[i]["备注2"].ToString(); dr["自定义字段3"] = dtYXDRBJas.Rows[i]["备注3"].ToString(); dtas.Rows.Add(dr); } //子表 DataRow drdetail = dtasdetail.NewRow(); drdetail["外部入库单号"] = dtYXDRBJas.Rows[i]["订单号"].ToString(); drdetail["仓库"] = warehouse.WarehouseName; ProductSearch ps = new ProductSearch(); ps.SKU = dtYXDRBJas.Rows[i]["SKU"].ToString(); productListS.Add(ps); drdetail["UPC"] = ""; drdetail["规格"] = ""; drdetail["预收数量"] = dtYXDRBJas.Rows[i]["预收数量"].ToString(); drdetail["箱号"] = dtYXDRBJas.Rows[i]["箱号"].ToString(); drdetail["单位"] = dtYXDRBJas.Rows[i]["单位"].ToString(); try { drdetail["产品等级"] = dtYXDRBJas.Rows[i]["产品等级"].ToString(); } catch (Exception) { drdetail["产品等级"] = "A品";//默认A } drdetail["备注"] = dtYXDRBJas.Rows[i]["备注4"].ToString(); drdetail["自定义字段4"] = dtYXDRBJas.Rows[i]["备注4"].ToString(); drdetail["自定义字段5"] = dtYXDRBJas.Rows[i]["备注5"].ToString(); drdetail["自定义字段6"] = dtYXDRBJas.Rows[i]["备注6"].ToString(); dtasdetail.Rows.Add(drdetail); } productList = ApplicationConfigHelper.GetSearchProductYXDR(CustomerID, productListS, "SKU"); for (int i = 0; i < dtYXDRBJas.Rows.Count; i++) { if (productList.ToArray().Length <= 0) { message = "excel中的SKU在系统中不存在,请检查excel数据!"; return; } string sku = productList.Where(p => p.SKU == productListS[i].SKU).ToArray().Length > 0 ? productList.Where(p => p.SKU == productListS[i].SKU).ToArray()[0].SKU : ""; if (string.IsNullOrEmpty(sku)) { message = "excel中的SKU=" + dtYXDRBJas.Rows[i]["SKU"].ToString() + "在系统中不存在,请检查数据!"; return; } dtasdetail.Rows[i]["SKU"] = sku; dtasdetail.Rows[i]["产品名称"] = productList.Where(p => p.SKU == sku).Select(p => p.GoodsName).FirstOrDefault(); } //验证同一外部单号是否存在相同的SKU //var dd = from t in dtasdetail.AsEnumerable() // group t by new { t1 = t.Field<string>("外部入库单号"), t2 = t.Field<string>("SKU") } into m // select new // { // 外部单号 = m.Select(p => p.Field<string>("外部入库单号")).First(), // SKU = m.Select(p => p.Field<string>("SKU")).First(), // count = m.Count(), // }; //var dr1 = dd.Where(c => c.count > 1); //if (dr1.Count() > 0) //{ // foreach (var item in dr1) // { // message += "<p><font color='#FF0000'>外部入库单号" + item.外部单号 + "中的SKU" + item.SKU + "存在重复值!" + "</font></p>"; // return; // } //} dsresult.Tables.Add(dtas); dsresult.Tables.Add(dtasdetail); this.AfterData = dsresult; } else if (TransDataType == "Receiving")//上架单 { DataTable dt = new DataTable(); dt = this.Transdata.Tables[0].Copy(); if (!dt.Columns.Contains("生产日期")) { dt.Columns.Add("生产日期"); } if (!dt.Columns.Contains("UPC")) { dt.Columns.Add("UPC"); } if (!dt.Columns.Contains("箱内总数")) { dt.Columns.Add("箱内总数"); } for (int i = 0; i < dt.Rows.Count; i++) { try { Convert.ToDateTime(dt.Rows[i]["生产日期"].ToString()); } catch { dt.Rows[i]["生产日期"] = System.DateTime.Now.ToString(); } } DataSet ds = new DataSet(); ds.Tables.Add(dt); this.AfterData = ds; } else { this.AfterData = Transdata; } }