/// <summary> /// 自动生成拣货计划 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnPlan_click(object sender, EventArgs e) { UStockBB stockBB = new UStockBB(); CStockUpBillBB stockUpBillBB = new CStockUpBillBB(); CStockUpDetailBB stockUpDetailBB = new CStockUpDetailBB(); LMaterialRelationBB materialRelationBB = new LMaterialRelationBB(); CSaleDetailBB saleDetailBB = new CSaleDetailBB(); LMaterialBB materialBB = new LMaterialBB(); try { CStockUpBillData stockUpBillModel = new CStockUpBillData(); DataSet dsStock = new DataSet(); DataSet dsStockUpDetail = new DataSet(); DataRow[] drsStock = null; string strInfo = ""; stockUpBillModel = stockUpBillBB.GetModel(this.IdValue);//销售备货单实例 #region 生成按单的拣货信息 //如果是按单,则直接查找按单采购物料 //dsStock = stockBB.GetVListByGroup("(saleBillNo in ('" + stockUpBillModel.saleBillNos.Replace(",", "','") // + "') or substring(financeBillNo,1,charindex('-',financeBillNo)) like '%" // + this.hidCustNo.Value + "%') and isOutStocking=0 and wareLocatorNo<>''"); //如果是按单,则直接查找按单采购物料 dsStock = stockBB.GetVListByGroup_ByFinanceBillNo("(stock.saleBillNo in ('" + stockUpBillModel.saleBillNos.Replace(",", "','") + "') or '," + stockUpBillModel.financeBillNos + ",' like '%,'+stock.financeBillNo+',%') and stock.financeBillSortNo='01' and stock.isOutStocking=0 and stock.wareLocatorNo<>''"); //获取定向的备货单明细 dsStockUpDetail = stockUpDetailBB.GetMaterielVList("stockUpBillNo='" + stockUpBillModel.stockUpBillNo + "' and financeBillSort='按单'");//and isnull(financeBillNo,'')<>'' if (dsStock.Tables[0].Rows.Count > 0) { foreach (DataRow drStockUpDetail in dsStockUpDetail.Tables[0].Rows) { //备货单明细合计出来的某种物料总数量 int needCount = Convert.ToInt32(drStockUpDetail["num"]); string strMaterialNo = drStockUpDetail["materialno"].ToString();//物料号 string strFinanceBillNo = drStockUpDetail["financeBillNo"].ToString(); //string strFinanceBillSort = drStockUpDetail["financeBillSort"].ToString(); string strFinanceBillSort = "按单"; string strDocEntry = drStockUpDetail["docEntry"].ToString();//销售订单ID string strSaleBillNo = drStockUpDetail["saleBillNo"].ToString();//销售订单号 string strLineNum = drStockUpDetail["lineNum"].ToString();//行号 string strAbsEntry = drStockUpDetail["absEntry"].ToString();//提货单编号 #region 按单的需原物料拣货 while (needCount > 0) { //根据先进先出,尽量使用同一托盘原则 //找到仓库内的同种物料所在的库位以及数量 //首先查找不少于此需要物料数量的库位 drsStock = dsStock.Tables[0].Select("financeBillNo='" + strFinanceBillNo + "' and materialNo='" + strMaterialNo + "' and num>=" + needCount.ToString()); if (drsStock.Length == 0) { drsStock = dsStock.Tables[0].Select("financeBillNo='" + strFinanceBillNo + "' and materialNo='" + strMaterialNo + "' and num>0"); } if (drsStock.Length > 0) { //当前库位所拥有该物料的数量 int haveCount = Convert.ToInt32(drsStock[0]["num"]); //如果当前库位的物料数量大于备货单所需数量,就保存当前库位 DataRow drnew = this.DtResult.NewRow(); drnew["rowId"] = Guid.NewGuid().ToString(); drnew["id"] = 0; if (haveCount >= needCount) { drnew["num"] = needCount; } else { drnew["num"] = haveCount; } drsStock[0]["num"] = Convert.ToInt32(drsStock[0]["num"]) - Convert.ToInt32(drnew["num"]);//库存数量减去已备货数量 needCount = needCount - Convert.ToInt32(drnew["num"]); drnew["stockUpBillNo"] = stockUpBillModel.stockUpBillNo; drnew["palletIndex"] = drStockUpDetail["palletIndex"].ToString(); drnew["wareNo"] = drsStock[0]["wareNo"]; drnew["wareLocatorNo"] = drsStock[0]["wareLocatorNo"]; drnew["palletNo"] = drsStock[0]["palletNo"]; drnew["stockUpMaterialNo"] = strMaterialNo;//备货物料编号 drnew["materialNo"] = drsStock[0]["materialNo"];//实际拣货物料编号 drnew["wareNm"] = drsStock[0]["wareNm"]; drnew["wareLocatorNm"] = drsStock[0]["wareLocatorNm"]; drnew["materialDesc"] = drsStock[0]["materialDesc"]; drnew["financeBillNo"] = strFinanceBillNo;//采购合同号 drnew["financeBillSort"] = strFinanceBillSort;//采购合同类型 drnew["saleBillNo"] = strSaleBillNo;//销售订单号 drnew["docEntry"] = strDocEntry;//销售订单ID drnew["lineNum"] = strLineNum;//行号 drnew["absEntry"] = strAbsEntry;//提货单号 drnew["instantState"] = "01"; drnew["isDel"] = false; this.DtResult.Rows.Add(drnew); drStockUpDetail["num"] = needCount;//重新赋值拣货数量 } else { needCount = 0; } } #endregion 按单的需原物料拣货 } } #endregion 生成按单的拣货信息 #region 销售订单没有按单采购 //备货需要逐个库位查找 dsStock = stockBB.GetVListByGroup("stock.financeBillSortNo='02' and stock.isOutStocking=0 and stock.wareLocatorNo<>''"); //获取备货的备货单明细 dsStockUpDetail = stockUpDetailBB.GetMaterielVList("stockUpBillNo='" + stockUpBillModel.stockUpBillNo + "' and financeBillSort='备货'");//根据采购合同类型,不根据采购合同号判断 and (isnull(financeBillNo,'')='' if (dsStock.Tables[0].Rows.Count > 0) { foreach (DataRow drStockUpDetail in dsStockUpDetail.Tables[0].Rows) { //备货单明细合计出来的某种物料总数量 int needCount = Convert.ToInt32(drStockUpDetail["num"]); string strMaterialNo = drStockUpDetail["materialno"].ToString();//物料号 string strFinanceBillNo = ""; string strFinanceBillSort = "备货"; string strSaleBillNo = drStockUpDetail["saleBillNo"].ToString();//销售订单号 string strLineNum = drStockUpDetail["lineNum"].ToString();//行号 string strAbsEntry = drStockUpDetail["absEntry"].ToString();//提货单编号 string strDocEntry = drStockUpDetail["docEntry"].ToString();//销售订单ID while (needCount > 0) { #region 原物料拣货 //找到仓库内的同种物料所在的库位以及数量 drsStock = dsStock.Tables[0].Select("materialno='" + strMaterialNo + "' and num>=" + needCount.ToString()); if (drsStock.Length == 0) { drsStock = dsStock.Tables[0].Select("materialno='" + strMaterialNo + "' and num>0"); } if (drsStock.Length > 0) { //当前库位所拥有该物料的数量 int haveCount = Convert.ToInt32(drsStock[0]["num"]); //如果当前库位的物料数量大于备货单所需数量,就保存当前库位 DataRow drnew = this.DtResult.NewRow(); drnew["rowId"] = Guid.NewGuid().ToString(); drnew["id"] = 0; if (haveCount >= needCount) { drnew["num"] = needCount; } else { drnew["num"] = haveCount; } drsStock[0]["num"] = Convert.ToInt32(drsStock[0]["num"]) - Convert.ToInt32(drnew["num"]);//库存数量减去已备货数量 needCount = needCount - Convert.ToInt32(drnew["num"]); drnew["stockUpBillNo"] = stockUpBillModel.stockUpBillNo; drnew["palletIndex"] = drStockUpDetail["palletIndex"].ToString(); drnew["wareNo"] = drsStock[0]["wareNo"]; drnew["wareLocatorNo"] = drsStock[0]["wareLocatorNo"]; drnew["palletNo"] = drsStock[0]["palletNo"]; drnew["stockUpMaterialNo"] = strMaterialNo;//备货物料编号 drnew["materialNo"] = drsStock[0]["materialNo"];//实际拣货物料编号 drnew["wareNm"] = drsStock[0]["wareNm"]; drnew["wareLocatorNm"] = drsStock[0]["wareLocatorNm"]; drnew["materialDesc"] = drsStock[0]["materialDesc"]; drnew["instantState"] = "01"; drnew["financeBillNo"] = strFinanceBillNo;//采购合同号 drnew["financeBillSort"] = strFinanceBillSort;//采购合同类型 drnew["saleBillNo"] = strSaleBillNo;//销售订单号 drnew["docEntry"] = strDocEntry;//销售订单ID drnew["lineNum"] = strLineNum;//行号 drnew["absEntry"] = strAbsEntry;//提货单号 drnew["isDel"] = false; this.DtResult.Rows.Add(drnew); drStockUpDetail["num"] = needCount;//重新赋值拣货数量 } else { break; } #endregion 原物料拣货 } #region 根据物料对应关系拣货 while (needCount > 0) { //需要根据物料对应关系拣其他物料 DataTable dtConvertMaterial = new DataTable(); dtConvertMaterial = materialRelationBB.GetList("oldMaterialNo='" + strMaterialNo + "'").Tables[0]; if (dtConvertMaterial.Rows.Count == 0) { break; } foreach (DataRow row in dtConvertMaterial.Rows) { //找到仓库内的有对应关系物料所在的库位以及数量 drsStock = dsStock.Tables[0].Select("materialno='" + row["newMaterialNo"].ToString() + "' and num>=" + needCount.ToString()); if (drsStock.Length == 0) { drsStock = dsStock.Tables[0].Select("materialno='" + row["newMaterialNo"].ToString() + "' and num>0"); } if (drsStock.Length > 0) { //当前库位所拥有该物料的数量 int haveCount = Convert.ToInt32(drsStock[0]["num"]); //如果当前库位的物料数量大于备货单所需数量,就保存当前库位 DataRow drnew = this.DtResult.NewRow(); drnew["rowId"] = Guid.NewGuid().ToString(); drnew["id"] = 0; if (haveCount >= needCount) { drnew["num"] = needCount; } else { drnew["num"] = haveCount; } drsStock[0]["num"] = Convert.ToInt32(drsStock[0]["num"]) - Convert.ToInt32(drnew["num"]);//库存数量减去已备货数量 needCount = needCount - Convert.ToInt32(drnew["num"]); drnew["stockUpBillNo"] = stockUpBillModel.stockUpBillNo; drnew["palletIndex"] = drStockUpDetail["palletIndex"].ToString(); drnew["wareNo"] = drsStock[0]["wareNo"]; drnew["wareLocatorNo"] = drsStock[0]["wareLocatorNo"]; drnew["palletNo"] = drsStock[0]["palletNo"]; drnew["stockUpMaterialNo"] = strMaterialNo;//备货物料编号 drnew["materialNo"] = drsStock[0]["materialNo"];//实际拣货物料编号 drnew["wareNm"] = drsStock[0]["wareNm"]; drnew["wareLocatorNm"] = drsStock[0]["wareLocatorNm"]; drnew["materialDesc"] = drsStock[0]["materialDesc"]; drnew["instantState"] = "01"; drnew["financeBillNo"] = strFinanceBillNo;//采购合同号 drnew["financeBillSort"] = strFinanceBillSort;//采购合同类型 drnew["saleBillNo"] = strSaleBillNo;//销售订单号 drnew["docEntry"] = strDocEntry;//销售订单ID drnew["lineNum"] = strLineNum;//行号 drnew["absEntry"] = strAbsEntry;//提货单号 drnew["isDel"] = false; this.DtResult.Rows.Add(drnew); drStockUpDetail["num"] = needCount;//重新赋值拣货数量 } else { needCount = 0; break; } } } #endregion 根据物料对应关系拣货 } } #endregion 销售订单没有按单采购 #region 判断是否完全拣货 DataSet dsStockUpDetail_Temp = stockUpDetailBB.GetMaterielVList("stockUpBillNo='" + stockUpBillModel.stockUpBillNo + "'"); foreach (DataRow rowStockUpDetail in dsStockUpDetail_Temp.Tables[0].Rows) { int planNum = 0, factNum = 0; DataRow[] myDataRowArray = null; string strNewMaterialNo = ""; DataTable dtConvertMaterial = new DataTable(); //计算计划备货数量 myDataRowArray = dsStockUpDetail_Temp.Tables[0].Select("materialNo='" + rowStockUpDetail["materialNo"].ToString() + "'"); foreach (DataRow row in myDataRowArray) { planNum += Convert.ToInt32(row["num"]); } //计算原物料可拣货数量 //20140725 update //myDataRowArray = this.DtResult.Select("isDel=0 and materialNo='" // + rowStockUpDetail["materialNo"].ToString() + "'"); myDataRowArray = this.DtResult.Select("isDel=0 and materialNo=stockupmaterialNo and materialNo='" + rowStockUpDetail["materialNo"].ToString() + "'"); foreach (DataRow row in myDataRowArray) { factNum += Convert.ToInt32(row["num"]); } // 20140807 add if (planNum != factNum) { //获取转换物料的拣货数量 dtConvertMaterial = materialRelationBB.GetList("oldMaterialNo='" + rowStockUpDetail["materialNo"].ToString() + "'").Tables[0]; if (dtConvertMaterial.Rows.Count > 0) { // 20140725 update //strNewMaterialNo = dtConvertMaterial.Rows[0]["newMaterialNo"].ToString(); //myDataRowArray = this.DtResult.Select("isDel=0 and materialNo='" + strNewMaterialNo + "'"); strNewMaterialNo = dtConvertMaterial.Rows[0]["oldMaterialNo"].ToString(); myDataRowArray = this.DtResult.Select("isDel=0 and stockupmaterialNo='" + strNewMaterialNo + "' and materialNo<>stockupmaterialNo "); foreach (DataRow row in myDataRowArray) { factNum += Convert.ToInt32(row["num"]); } } } //判断是否完成拣货 if (planNum != factNum) { strInfo += "物料【" + rowStockUpDetail["materialNo"].ToString() + "】,计划拣货【" + planNum.ToString() + "】件,实际拣货【" + factNum.ToString() + "】件;"; } } if (strInfo != "") { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"当前未完成拣货,不允许保存!提示信息:" + strInfo + "\");", true); } #endregion 判断是否完全拣货 this.BindGridPickOutPlan();//绑定拣货计划列表 } catch (Exception ex) { this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true); return; } finally { stockBB.Dispose(); stockUpBillBB.Dispose(); stockUpDetailBB.Dispose(); materialRelationBB.Dispose(); saleDetailBB.Dispose(); materialBB.Dispose(); } }
/// <summary> /// 手工保存拣货计划 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSaveDetail_Click(object sender, EventArgs e) { LWareLocatorBB wareLocatorBB = new LWareLocatorBB(); LMaterialBB materialBB = new LMaterialBB(); UStockBB stockBB = new UStockBB(); SCommBB commBB = new SCommBB(); CStockUpDetailBB stockUpDetailBB = new CStockUpDetailBB(); LMaterialRelationBB materialRelationBB = new LMaterialRelationBB(); try { #region 验证数据是否填写完整 string strErrorInfo = "", strWareNo = "", strWareNm = "", strWareLocatorNm = "", strMaterialDesc = "", strWhere = ""; //strStockUpMaterialNo = "", strPalletIndex = "" DataTable dtWareLocator = new DataTable(); DataTable dtMaterial = new DataTable(); DataTable dtStock = new DataTable(); DataTable dtStockUpDetail = new DataTable(); DataRow[] myDataRowArray = null; bool isRightMaterial = false; int planNum = 0, factNum = 0; #region 校验填写库位 if (this.txtWareLocarorNo.Value.Trim() == "") { strErrorInfo = "请首先填写库位!"; this.txtWareLocarorNo.Focus(); this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "showFloatDetail();alert('" + strErrorInfo + "');", true); return; } dtWareLocator = wareLocatorBB.GetVList("wareLocatorNo='" + this.txtWareLocarorNo.Value.Trim() + "'").Tables[0]; if (dtWareLocator.Rows.Count == 0) { strErrorInfo = "请首先填写正确库位!"; this.txtWareLocarorNo.Focus(); this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "showFloatDetail();alert('" + strErrorInfo + "');", true); return; } strWareNo = dtWareLocator.Rows[0]["wareNo"].ToString();//库区编码 strWareNm = dtWareLocator.Rows[0]["wareNm"].ToString();//库区名称 strWareLocatorNm = dtWareLocator.Rows[0]["wareLocatorNm"].ToString();//库位名称 if (strWareNo != "GLHJ01" && strWareNo != "GLHJ02" && this.txtPalletNo.Value.Trim() == "") { strErrorInfo = "请首先填写托盘号!"; this.txtPalletNo.Focus(); this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "showFloatDetail();alert('" + strErrorInfo + "');", true); return; } #endregion 校验填写库位 #region 校验填写物料 if (this.txtMaterialNo.Value.Trim() == "") { strErrorInfo = "请首先填写物料编号!"; this.txtMaterialNo.Focus(); this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "showFloatDetail();alert('" + strErrorInfo + "');", true); return; } dtMaterial = materialBB.GetVList("materialNo='" + this.txtMaterialNo.Value.Trim() + "'").Tables[0]; if (dtMaterial.Rows.Count == 0) { strErrorInfo = "请首先填写正确物料!"; this.txtMaterialNo.Focus(); this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "showFloatDetail();alert('" + strErrorInfo + "');", true); return; } strMaterialDesc = dtMaterial.Rows[0]["materialNm_CH"].ToString();//物料描述 //strStockUpMaterialNo = this.txtMaterialNo.Value.Trim().ToUpper();//计划备货物料 #endregion 校验填写物料 #region 校验填写数量 if (this.tbNum.Text.Trim() == "") { strErrorInfo = "请首先填写数量!"; this.tbNum.Focus(); this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "showFloatDetail();alert('" + strErrorInfo + "');", true); return; } if (!CommFunction.IsInt(this.tbNum.Text.Trim())) { strErrorInfo = "数量格式错误!"; this.tbNum.Focus(); this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "showFloatDetail();alert('" + strErrorInfo + "');", true); return; } if (Convert.ToInt32(this.tbNum.Text.Trim()) <= 0) { strErrorInfo = "数量必须大于0!"; this.tbNum.Focus(); this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "showFloatDetail();alert('" + strErrorInfo + "');", true); return; } //校验拣货数量是否超出计划备货数量 strWhere = "stockUpBillNo='" + this.stockUpBillNo.Text.Trim() + "' and palletIndex='" + this.PalletIndex + "' and materialNo='" + this.StockUpMaterialNo + "'"; if (this.txtFinanceBillNo.Value.Trim() != "") { strWhere += " and financeBillNo='" + this.txtFinanceBillNo.Value.Trim() + "'"; } if (this.SaleBillNo != "" && this.SaleBillNo != "0") { strWhere += " and saleBillNo='" + this.SaleBillNo + "'"; } if (this.LineNum != "" && this.LineNum != "0") { strWhere += " and lineNum='" + this.LineNum + "'"; } if (this.AbsEntry != "" && this.AbsEntry != "0") { strWhere += " and absEntry='" + this.AbsEntry + "'"; } dtStockUpDetail = stockUpDetailBB.GetList(strWhere).Tables[0]; foreach (DataRow row in dtStockUpDetail.Rows) { planNum += Convert.ToInt32(dtStockUpDetail.Rows[0]["num"]);//计算计划备货数量 } //计算实际备货数量 strWhere = "isDel=0 and stockUpBillNo='" + this.stockUpBillNo.Text.Trim() + "' and palletIndex='" + this.PalletIndex + "' and stockUpMaterialNo='" + this.StockUpMaterialNo + "'"; if (this.txtFinanceBillNo.Value.Trim() != "") { strWhere += " and financeBillNo='" + this.txtFinanceBillNo.Value.Trim() + "'"; } if (this.SaleBillNo != "" && this.SaleBillNo != "0") { strWhere += " and saleBillNo='" + this.SaleBillNo + "'"; } if (this.LineNum != "" && this.LineNum != "0") { strWhere += " and lineNum='" + this.LineNum + "'"; } if (this.AbsEntry != "" && this.AbsEntry != "0") { strWhere += " and absEntry='" + this.AbsEntry + "'"; } myDataRowArray = this.DtResult.Select(strWhere); foreach (DataRow row in myDataRowArray) { factNum += Convert.ToInt32(row["num"]); } if (factNum + Convert.ToInt32(this.tbNum.Text.Trim()) > planNum) { if (this.SaleBillNo != "" && this.SaleBillNo != "0") { strErrorInfo = "托盘【" + this.PalletIndex + "】的提货单【" + this.AbsEntry + "】销售订单【" + this.SaleBillNo + "】行号【" + this.LineNum + "】物料【" + this.StockUpMaterialNo + "】计划备货【" + planNum.ToString() + "】,已经备货【" + factNum + "】,填写数量超出还需要备货数量!"; } else { strErrorInfo = "托盘【" + this.PalletIndex + "】的物料【" + this.StockUpMaterialNo + "】计划备货【" + planNum.ToString() + "】,已经备货【" + factNum + "】,填写数量超出还需要备货数量!"; } this.tbNum.Focus(); this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "showFloatDetail();alert('" + strErrorInfo + "');", true); return; } #endregion 校验填写数量 #region 判断是否重复拣货 strWhere = "isDel=0 and palletIndex='" + this.PalletIndex + "' and wareLocatorNo='" + this.txtWareLocarorNo.Value.Trim() + "' and materialNo='" + this.txtMaterialNo.Value.Trim() + "'"; if (this.txtFinanceBillNo.Value.Trim() != "") { strWhere += " and financeBillNo='" + this.txtFinanceBillNo.Value.Trim() + "'"; } if (this.SaleBillNo != "" && this.SaleBillNo != "0") { strWhere += " and saleBillNo='" + this.SaleBillNo + "'"; } if (this.LineNum != "" && this.LineNum != "0") { strWhere += " and lineNum='" + this.LineNum + "'"; } if (this.AbsEntry != "" && this.AbsEntry != "0") { strWhere += " and absEntry='" + this.AbsEntry + "'"; } myDataRowArray = this.DtResult.Select(strWhere); if (myDataRowArray.Length > 0) { if (this.txtFinanceBillNo.Value.Trim() == "") { if (this.SaleBillNo != "" && this.SaleBillNo != "0") { strErrorInfo = "托盘【" + this.PalletIndex + "】的提货单【" + this.AbsEntry + "】销售订单【" + this.SaleBillNo + "】行号【" + this.LineNum + "】已经从库位【" + this.txtWareLocarorNo.Value.Trim() + "】中拣出物料【" + this.txtMaterialNo.Value.Trim() + "】,请首先删除原有记录,再添加新记录!"; } else { strErrorInfo = "托盘【" + this.PalletIndex + "】已经从库位【" + this.txtWareLocarorNo.Value.Trim() + "】中拣出物料【" + this.txtMaterialNo.Value.Trim() + "】,请首先删除原有记录,再添加新记录!"; } } else { if (this.SaleBillNo != "" && this.SaleBillNo != "0") { strErrorInfo = "托盘【" + this.PalletIndex + "】的提货单【" + this.AbsEntry + "】销售订单【" + this.SaleBillNo + "】行号【" + this.LineNum + "】已经从库位【" + this.txtWareLocarorNo.Value.Trim() + "】中拣出采购合同【" + this.txtFinanceBillNo.Value.Trim() + "】的物料【" + this.txtMaterialNo.Value.Trim() + "】,请首先删除原有记录,再添加新记录!"; } else { strErrorInfo = "托盘【" + this.PalletIndex + "】已经从库位【" + this.txtWareLocarorNo.Value.Trim() + "】中拣出采购合同【" + this.txtFinanceBillNo.Value.Trim() + "】的物料【" + this.txtMaterialNo.Value.Trim() + "】,请首先删除原有记录,再添加新记录!"; } } this.txtMaterialNo.Focus(); this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "showFloatDetail();alert('" + strErrorInfo + "');", true); return; } #endregion 判断是否重复拣货 #region 根据库位、物料、采购合同号,判断是否有货 strWhere = "wareLocatorNo='" + this.txtWareLocarorNo.Value.Trim() + "' and materialNo='" + this.txtMaterialNo.Value.Trim() + "'"; if (this.txtFinanceBillNo.Value.Trim() != "") { strWhere += " and financeBillNo='" + this.txtFinanceBillNo.Value.Trim() + "'"; } dtStock = stockBB.GetVList(strWhere).Tables[0]; if (dtStock.Rows.Count == 0) { if (this.txtFinanceBillNo.Value.Trim() == "") { strErrorInfo = "库位【" + this.txtWareLocarorNo.Value.Trim() + "】中不存在物料【" + this.txtMaterialNo.Value.Trim() + "】!"; } else { strErrorInfo = "库位【" + this.txtWareLocarorNo.Value.Trim() + "】中不存在采购合同【" + this.txtFinanceBillNo.Value.Trim() + "】的物料【" + this.txtMaterialNo.Value.Trim() + "】!"; } this.txtMaterialNo.Focus(); this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "showFloatDetail();alert('" + strErrorInfo + "');", true); return; } #endregion 根据库位、物料、采购合同号,判断是否有货 #region 校验物料是否是需要拣出的物料 if (this.StockUpMaterialNo == this.txtMaterialNo.Value.Trim()) { isRightMaterial = true; } else { DataTable dtConvertMaterial = new DataTable(); dtConvertMaterial = materialRelationBB.GetList("newMaterialNo='" + this.txtMaterialNo.Value.Trim() + "'").Tables[0]; if (dtConvertMaterial.Rows.Count > 0) { foreach (DataRow row in dtConvertMaterial.Rows) { if (this.StockUpMaterialNo == row["oldMaterialNo"].ToString()) { isRightMaterial = true; break; } } } } if (isRightMaterial == false) { strErrorInfo = "当前物料不在备货计划内!"; this.txtMaterialNo.Focus(); this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "showFloatDetail();alert('" + strErrorInfo + "');", true); return; } #endregion 校验物料是否是需要拣出的物料 #endregion 验证数据是否填写完整 DataRow myDataRow = this.DtResult.NewRow(); myDataRow["rowId"] = Guid.NewGuid().ToString(); myDataRow["id"] = 0; myDataRow["num"] = this.tbNum.Text.Trim(); myDataRow["stockUpBillNo"] = ""; myDataRow["palletIndex"] = this.PalletIndex;//托盘序号 myDataRow["wareNo"] = strWareNo; myDataRow["wareLocatorNo"] = this.txtWareLocarorNo.Value.Trim().ToUpper(); myDataRow["palletNo"] = this.txtPalletNo.Value.Trim(); myDataRow["stockUpMaterialNo"] = this.StockUpMaterialNo;//计划备货物料 myDataRow["materialNo"] = this.txtMaterialNo.Value.Trim();//实际拣货物料 myDataRow["wareNm"] = strWareNm; myDataRow["wareLocatorNm"] = strWareLocatorNm; myDataRow["materialDesc"] = strMaterialDesc; myDataRow["instantState"] = "01"; myDataRow["financeBillNo"] = this.txtFinanceBillNo.Value.Trim().ToUpper();//采购合同号 myDataRow["financeBillSort"] = this.txtFinanceBillNo.Value.Trim() == "" ? "备货" : "按单";//采购合同类型 myDataRow["saleBillNo"] = this.SaleBillNo;//销售订单号 myDataRow["docEntry"] = this.DocEntry;//销售订单ID myDataRow["lineNum"] = this.LineNum;//销售订单行号 myDataRow["absEntry"] = this.AbsEntry;//提货单号 myDataRow["isDel"] = false; this.DtResult.Rows.Add(myDataRow); this.BindGridPickOutPlan();//绑定拣货明细列表 } finally { wareLocatorBB.Dispose(); materialBB.Dispose(); stockBB.Dispose(); commBB.Dispose(); stockUpDetailBB.Dispose(); materialRelationBB.Dispose(); } }
/// <summary> /// 保存或保存并提交公用方法 /// </summary> /// <param name="isSubmit"></param> protected void SubmitArrangeBill(bool isSubmit) { //要保存之前判断状态是否被改变 CStockUpBillBB stockUpBillBB = new CStockUpBillBB(); string stockUpState = stockUpBillBB.GetVList("stockUpBillNo = '" + stockUpBillNo.Text.Trim() + "'").Tables[0].Rows[0]["instantState"].ToString(); stockUpBillNo.Dispose(); if (stockUpState != StockUpinstantState) { this.ClientScript.RegisterStartupScript(this.GetType(), "alert12", "alert(\"拣货单已经被别人生成\");", true); return; } using (CPickOutPlanBC planBC = new CPickOutPlanBC()) { CStockUpDetailBB stockUpDetailBB = new CStockUpDetailBB(); LMaterialRelationBB materialRelationBB = new LMaterialRelationBB(); try { #region 判断是否完全拣货 DataSet dsStockUpDetail_Temp = stockUpDetailBB.GetMaterielVList("stockUpBillNo='" + this.stockUpBillNo.Text.Trim() + "'"); foreach (DataRow rowStockUpDetail in dsStockUpDetail_Temp.Tables[0].Rows) { int planNum = 0, factNum = 0; DataRow[] myDataRowArray = null; string strNewMaterialNo = ""; DataTable dtConvertMaterial = new DataTable(); //计算计划备货数量 myDataRowArray = dsStockUpDetail_Temp.Tables[0].Select("materialNo='" + rowStockUpDetail["materialNo"].ToString() + "'"); foreach (DataRow row in myDataRowArray) { planNum += Convert.ToInt32(row["num"]); } //计算原物料可拣货数量 //7月25号修改 //解决拣货单下发不下去的问题 //myDataRowArray = this.DtResult.Select("isDel=0 and materialNo='" // + rowStockUpDetail["materialNo"].ToString() + "'"); myDataRowArray = this.DtResult.Select("isDel=0 and materialNo=stockupmaterialNo and materialNo='" + rowStockUpDetail["materialNo"].ToString() + "'"); foreach (DataRow row in myDataRowArray) { factNum += Convert.ToInt32(row["num"]); } //获取转换物料的拣货数量 //20140807 add if (planNum != factNum) { dtConvertMaterial = materialRelationBB.GetList("oldMaterialNo='" + rowStockUpDetail["materialNo"].ToString() + "'").Tables[0]; if (dtConvertMaterial.Rows.Count > 0) { //7月25号修改 //解决拣货单下发不下去的问题 //strNewMaterialNo = dtConvertMaterial.Rows[0]["newMaterialNo"].ToString(); //myDataRowArray = this.DtResult.Select("isDel=0 and materialNo='" + strNewMaterialNo + "'"); strNewMaterialNo = dtConvertMaterial.Rows[0]["oldMaterialNo"].ToString(); myDataRowArray = this.DtResult.Select("isDel=0 and stockupmaterialNo='" + strNewMaterialNo + "' and materialNo<>stockupmaterialNo"); foreach (DataRow row in myDataRowArray) { factNum += Convert.ToInt32(row["num"]); } } } if (planNum != factNum) { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"当前未完成拣货,不允许保存!\");", true); return; } } #endregion 判断是否完全拣货 planBC.EmpID = this.currentUser.empId; planBC.SavePickOutPlanBill(this.DtResult, this.stockUpBillNo.Text.Trim(), isSubmit); this.DtResult = null; this.InitDtPickOutPlan(); if (isSubmit)//保存并提交 { this.ClientScript.RegisterStartupScript(this.GetType(), "alert12", "alert(\"拣货单维护成功!\");window.location='" + Request.Params["backurl"] + "';", true); } else//保存 { this.ClientScript.RegisterStartupScript(this.GetType(), "alert12", "alert(\"拣货单维护成功!\");", true); } } catch (Exception ex) { this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true); return; } finally { stockUpDetailBB.Dispose(); materialRelationBB.Dispose(); } } }
/// <summary> /// 显示销售备货单信息 /// </summary> private void ShowStockUpBillInfo() { CStockUpBillBB stockUpBillBB = new CStockUpBillBB(); CStockUpDetailBB stockUpDetailBB = new CStockUpDetailBB(); CSaleDetailBB saleDetailBB = new CSaleDetailBB(); try { vCStockUpBillData stockUpBillModel = stockUpBillBB.GetVModel(this.IdValue); string strSaleBillNos = "", strAbsEntrys = "", strLineNums = "", strWhere = "1=1"; DataSet ds = new DataSet(); this.stockUpBillNo.Text = stockUpBillModel.stockUpBillNo; this.shippingMarkNo.Text = stockUpBillModel.shippingMarkNo; this.hidCustNo.Value = stockUpBillModel.custNo;//客户编号 this.lblCustNm.Text = stockUpBillModel.custNm; this.invoiceNo.Text = stockUpBillModel.invoiceNo; this.empNm.Text = stockUpBillModel.stockUpEmpNm; this.mark.Text = stockUpBillModel.mark; this.outBillDate.Text = Convert.ToDateTime(stockUpBillModel.outStockDt).ToString("yyyy-MM-dd"); strSaleBillNos = "'" + stockUpBillModel.saleBillNos.Replace(",", "','") + "'";//销售订单编号组合 strAbsEntrys = "'" + stockUpBillModel.absEntrys.Replace(",", "','") + "'";//提货单编号组合 strLineNums = "'" + stockUpBillModel.lineNums.Replace(",", "','") + "'";//行号组合 //绑定销售订单明细列表 string[] saleBillNoArray = strSaleBillNos.Split(','); string[] absEntryArray = strAbsEntrys.Split(','); string[] lineNumArray = strLineNums.Split(','); strWhere += " and ("; for (int i = 0; i < saleBillNoArray.Length; i++) { if (i == 0) { strWhere += " (absEntry=" + absEntryArray[i] + " and saleBillNo=" + saleBillNoArray[i] + " and lineNum=" + lineNumArray[i] + ")"; } else { strWhere += " or (absEntry=" + absEntryArray[i] + " and saleBillNo=" + saleBillNoArray[i] + " and lineNum=" + lineNumArray[i] + ")"; } } strWhere += ")"; ds = saleDetailBB.GetVList(strWhere); this.gridSaleBill.DataSource = ds; this.gridSaleBill.DataBind(); //绑定备货单明细列表 ds = stockUpDetailBB.GetVList("stockUpBillNo='" + stockUpBillModel.stockUpBillNo + "'"); this.gridStockUpDetail.DataSource = ds; this.gridStockUpDetail.DataBind(); } finally { stockUpBillBB.Dispose(); stockUpDetailBB.Dispose(); saleDetailBB.Dispose(); } }
public bool ChangeStaus(string StatusCode, string PalletNO) { CStockUpDetailBB bb = new CStockUpDetailBB(); return bb.ModifyRecord(StatusCode, PalletNO); }
protected void gridStockUpDetail_RowUpdating(object sender, GridViewUpdateEventArgs e) { string id = gridStockUpDetail.DataKeys[e.RowIndex].Values["id"].ToString(); using (CStockUpDetailBB stockUpBillBB = new CStockUpDetailBB()) { CStockUpDetailData model = stockUpBillBB.GetModel(Convert.ToInt32(id)); model.printNum = Convert.ToDouble(((TextBox)(gridStockUpDetail.Rows[e.RowIndex].Cells[17].Controls[0])).Text.ToString().Trim()); stockUpBillBB.ModifyRecord(model); } gridStockUpDetail.EditIndex = -1; this.ShowStockUpBillInfo(); }
public string GetStockUpNewPalletNo(string strStockUpBillNo, int palletIndex) { CStockUpDetailBB stockUpDetailBB = new CStockUpDetailBB(); try { DataTable dt = new DataTable(); dt = stockUpDetailBB.GetList("stockUpBillNo='" + strStockUpBillNo + "' and palletIndex=" + palletIndex.ToString()).Tables[0]; foreach (DataRow row in dt.Rows) { if (row["palletNo"] != DBNull.Value) { return row["palletNo"].ToString(); } } return ""; } finally { stockUpDetailBB.Dispose(); } }
public void UpdateStockUpDetailPrintNum(int stockUpDetailId, double num) { CStockUpDetailBB stockUpDetailBB = new CStockUpDetailBB(); try { CStockUpDetailData stockUpDetailModel = new CStockUpDetailData(); stockUpDetailModel = stockUpDetailBB.GetModel(stockUpDetailId); stockUpDetailModel.printNum = stockUpDetailModel.printNum + num; stockUpDetailBB.ModifyRecord(stockUpDetailModel); } finally { stockUpDetailBB.Dispose(); } }
public DataTable GetStockUpDetailByWhere(string strWhere) { CStockUpDetailBB stockUpDetailBB = new CStockUpDetailBB(); try { DataTable dt = new DataTable(); dt = stockUpDetailBB.GetVList(strWhere).Tables[0]; return dt; } finally { stockUpDetailBB.Dispose(); } }
public DataTable GetStockUpDetailById(int id) { CStockUpDetailBB stockUpDetailBB = new CStockUpDetailBB(); try { DataTable dt = new DataTable(); dt = stockUpDetailBB.GetVList("id=" + id.ToString()).Tables[0]; return dt; } finally { stockUpDetailBB.Dispose(); } }
public DataTable GetOutStockPalletList(string strStockUpBillNo, string strStockUpDetailIDs) { CPickOutPlanBB pickOutPlanBB = new CPickOutPlanBB(); UStockBB stockBB = new UStockBB(); CStockUpDetailBB stockUpDetailBB = new CStockUpDetailBB(); try { DataTable dtPickOutPlan = new DataTable(); DataTable dtPallet = new DataTable(); DataTable dtStock = new DataTable(); DataColumn myDataColumn = null; DataRow myDataRow = null; dtPallet.TableName = "dtPallet"; //生成托盘条码号表托盘条码号列 myDataColumn = new DataColumn(); myDataColumn.DataType = System.Type.GetType("System.String"); myDataColumn.ColumnName = "palletNo"; dtPallet.Columns.Add(myDataColumn); foreach (string strStockUpDetialId in strStockUpDetailIDs.Split(',')) { CStockUpDetailData stockUpDetailModel = new CStockUpDetailData(); stockUpDetailModel = stockUpDetailBB.GetModel(Convert.ToInt32(strStockUpDetialId)); //获取拣货计划 dtPickOutPlan = pickOutPlanBB.GetList("stockUpBillNo='" + strStockUpBillNo + "' and palletIndex='" + stockUpDetailModel.palletIndex.ToString() + "' and stockUpMaterialNo='" + stockUpDetailModel.materialNo + "' and docEntry='" + stockUpDetailModel.DocEntry.ToString() + "' and absEntry='" + stockUpDetailModel.absEntry.ToString() + "' and lineNum='" + stockUpDetailModel.lineNum.ToString() + "' and isnull(palletNo,'')<>''").Tables[0]; foreach (DataRow rowPickOutPlan in dtPickOutPlan.Rows) { string strPalletNo = rowPickOutPlan["palletNo"].ToString();//托盘条码号 //库存中原物料 dtStock = stockBB.GetList("palletNo='" + strPalletNo + "' and not exists(select 1 from dbo.BForkliftTask as t where t.palletNo='" + strPalletNo + "' and t.isDeal=0)").Tables[0]; //库存中有托盘 if (dtStock.Rows.Count > 0) { //新增一条托盘记录 if (dtPallet.Select("palletNo='" + strPalletNo + "'").Length == 0) { myDataRow = dtPallet.NewRow(); myDataRow["palletNo"] = strPalletNo; dtPallet.Rows.Add(myDataRow); } } } } ////获取拣货计划 //dtPickOutPlan = pickOutPlanBB.GetList("stockUpBillNo='" + strStockUpBillNo + "' and isnull(palletNo,'')<>''").Tables[0]; ////合计备货单明细物料剩余数量 //strSql.Append(@"select materialNo,sum(num-factNum) as leavingNum "); //strSql.Append(@"from dbo.vCStockUpDetail as stockUpDetail "); //strSql.Append(@"where id in (" + strStockUpDetailIDs + ") "); //strSql.Append(@"group by materialNo "); //dtStockUpDetail = commBB.Query(strSql.ToString()).Tables[0]; ////获取拣货托盘 //foreach (DataRow row in dtStockUpDetail.Rows) //{ // string strMaterialNo = "", strConvertMaterialNo = ""; // int leavingNum = 0; // strMaterialNo = row["materialNo"].ToString();//物料编号 // leavingNum = Convert.ToInt32(row["leavingNum"]);//剩余拣货数量 // myDataRowArray = dtPickOutPlan.Select("materialNo='" + strMaterialNo + "'"); // //根据物料转换关系查找 // if (myDataRowArray.Length == 0) // { // DataTable dtMaterialRelation = new DataTable(); // dtMaterialRelation = materialRelationBB.GetList("oldMaterialNo='" + strMaterialNo + "'").Tables[0]; // if (dtMaterialRelation.Rows.Count > 0) // { // strConvertMaterialNo = dtMaterialRelation.Rows[0]["newMaterialNo"].ToString();//转换物料号 // myDataRowArray = dtPickOutPlan.Select("materialNo='" + strConvertMaterialNo + "'"); // } // } // foreach (DataRow rowPickOutPlan in myDataRowArray) // { // if (leavingNum > 0) // { // string strPalletNo = ""; // strPalletNo = rowPickOutPlan["palletNo"].ToString();//托盘条码号 // //库存中原物料 // dtStock = stockBB.GetList("palletNo='" + strPalletNo // + "' and materialNo='" + strMaterialNo // + "' and not exists(select 1 from dbo.BForkliftTask as t where t.palletNo=dbo.UStock.palletNo and t.isDeal=0)").Tables[0]; // //库存中转换物料 // if (dtStock.Rows.Count == 0) // { // dtStock = stockBB.GetList("palletNo='" + strPalletNo // + "' and materialNo='" + strConvertMaterialNo // + "' and not exists(select 1 from dbo.BForkliftTask as t where t.palletNo=dbo.UStock.palletNo and t.isDeal=0)").Tables[0]; // } // foreach (DataRow rowStock in dtStock.Rows) // { // //新增一条托盘记录 // if (dtPallet.Select("palletNo='" + strPalletNo + "'").Length == 0) // { // myDataRow = dtPallet.NewRow(); // myDataRow["palletNo"] = strPalletNo; // dtPallet.Rows.Add(myDataRow); // } // if (Convert.ToInt32(rowStock["num"]) > leavingNum) // { // leavingNum = 0; // break; // } // else // { // leavingNum -= Convert.ToInt32(rowStock["num"]); // } // } // } // } //} return dtPallet; } finally { pickOutPlanBB.Dispose(); stockBB.Dispose(); stockUpDetailBB.Dispose(); } }
/// <summary> /// 初始化备货单明细数据源 /// </summary> private void InitDtResult() { if (this.DtResult == null) { CStockUpDetailBB stockUpDetailBB = new CStockUpDetailBB(); try { string strWhere = "stockUpBillNo=@stockUpBillNo"; SqlParameter[] param = new SqlParameter[] { new SqlParameter("@stockUpBillNo", this.StockBillNo) }; DataSet ds = stockUpDetailBB.GetVList(strWhere, param); if (ds != null && ds.Tables.Count > 0) { this.DtResult = ds.Tables[0]; this.DtResult.Columns.Add(new DataColumn("rowId", typeof(string))); this.DtResult.Columns.Add(new DataColumn("isdel", typeof(string))); this.DtResult.Columns.Add(new DataColumn("ischeck", typeof(string))); this.DtResult.Columns.Add(new DataColumn("hideAmount", typeof(string))); this.DtResult.Columns["palletIndex"].DataType = Type.GetType("System.Int32"); foreach (DataRow dr in this.DtResult.Rows) { dr["rowId"] = Guid.NewGuid().ToString(); dr["isdel"] = "0"; dr["ischeck"] = "false"; #region 记录合计行 if (dr["num"] != null && dr["num"] != DBNull.Value) { //初始化时保存amount的原始值 dr["hideAmount"] = dr["num"].ToString() == "" ? "0" : dr["num"].ToString(); } else { dr["hideAmount"] = "0"; } #endregion } } } catch (Exception ex) { this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",4);", true); return; } finally { stockUpDetailBB.Dispose(); } } }
/// <summary> /// 提交SAP /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnCommit_Click(object sender, EventArgs e) { CSaleDetailBB saleDetailBB = new CSaleDetailBB(); DMWJEXECUTE services = new DMWJEXECUTE(); IList<string> messList = new List<string>(); IList<string> datalist = new List<string>(); messList.Clear(); try { bool isChecked = false; //获取选中的数据Id foreach (GridViewRow gvrow in this.grid.Rows) { CheckBox chkId = (CheckBox)gvrow.FindControl("chkId"); if (chkId.Checked == true) { string strMaterialNo = "", strInvoiceNo = "", palletNO = "", custNo = "", custNm = "", outdata = ""; ; int docEntry = 0, lineNum = 0; double num = 0; bool isSapOutstock = true; CSaleDetailData saleDetailModel = new CSaleDetailData(); docEntry = Convert.ToInt32(this.grid.DataKeys[gvrow.RowIndex]["docEntry"].ToString()); lineNum = Convert.ToInt32(this.grid.DataKeys[gvrow.RowIndex]["lineNum"].ToString()); strMaterialNo = this.grid.DataKeys[gvrow.RowIndex]["materialNo"].ToString(); num = Convert.ToDouble(this.grid.DataKeys[gvrow.RowIndex]["num"]); strInvoiceNo = this.grid.DataKeys[gvrow.RowIndex]["invoiceNo"].ToString(); palletNO = this.grid.DataKeys[gvrow.RowIndex]["palletNo"].ToString(); // palletNO = "1"; custNo = this.grid.DataKeys[gvrow.RowIndex]["custNo"].ToString(); custNm = this.grid.DataKeys[gvrow.RowIndex]["custNm"].ToString(); outdata = this.grid.DataKeys[gvrow.RowIndex]["outStockDt"].ToString(); string suid = this.grid.DataKeys[gvrow.RowIndex]["suid"].ToString(); //获取销售单明细实例 saleDetailModel = saleDetailBB.GetModel(Convert.ToInt32(chkId.ValidationGroup)); if (Convert.ToBoolean(saleDetailModel.isSapOutStock) == false) { isSapOutstock = false; } if (isSapOutstock == true) { this.BindGrid(); this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"当前到货单下的物料已经提交SAP入库!\");", true); return; } string mess = docEntry + ";" + lineNum + ";" + strMaterialNo + ";" + num +";" + strInvoiceNo+";"+Convert.ToString(Convert.ToInt32(chkId.ValidationGroup))+";"+palletNO+";"+custNo+";"+custNm+";"+outdata+";"+suid; messList.Add(mess); datalist.Add(mess); //if (datalist.Count == 0) //{ // datalist.Add(docEntry.ToString() + lineNum.ToString()); //} //else //{ // int m = 0; // for (int i = 0; i < datalist.Count; i++) // { // if (docEntry.ToString() + lineNum.ToString() == datalist[i].ToString().ToString()) // { // m = 1; // break; // } // } // if (m == 0) // { // datalist.Add(docEntry.ToString() + lineNum.ToString()); // } //} // strResult = services.SAPOutStock(Convert.ToInt32(chkId.ValidationGroup), docEntry, lineNum, strMaterialNo, num, strInvoiceNo, palletNO); //if (strResult.Split('&')[0] == "1") //{ // isChecked = true; //} //else if (strResult.Split('&')[0] == "0") //{ // this.BindGrid(); // this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"" + strResult.Split('&')[1] + "\");", true); // return; //} } } if (messList.Count > 0) { try { IList<string> newMessList = new List<string>(); for (int j = 0; j < datalist.Count; j++) { int num =0; for(int i=0;i<messList.Count;i++) { if ((datalist[j].Split(';')[0].ToString() + datalist[j].Split(';')[1].ToString() + datalist[j].Split(';')[2].ToString() ) == (messList[i].Split(';')[0].ToString() + messList[i].Split(';')[1].ToString() + messList[i].Split(';')[2].ToString() )) { num=num+Convert.ToInt32(messList[i].Split(';')[3].ToString()); //num =Convert.ToInt32(messList[i].Split(';')[3].ToString()); //datalist[i].Split(';')[3] =Convert.ToString(Convert.ToInt32(datalist[i].Split(';')[3].ToString())+Convert.ToInt32(messList[i].Split(';')[3].ToString())); } } string compare =datalist[j].Split(';')[0].ToString() + ";" + datalist[j].Split(';')[1].ToString() + ";" + datalist[j].Split(';')[2].ToString() + ";" + num + ";" + datalist[j].Split(';')[4].ToString() + ";" + datalist[j].Split(';')[5].ToString() + ";" + datalist[j].Split(';')[6].ToString() + ";" + datalist[j].Split(';')[7].ToString() + ";" + datalist[j].Split(';')[8].ToString() + ";" + datalist[j].Split(';')[9].ToString(); //datalist[j].Split(';')[3] =Convert.ToString(num); if (newMessList.Count == 0) { newMessList.Add(compare); } else { int nn = 0; for (int m = 0; m < newMessList.Count; m++) { if ((newMessList[m].Split(';')[0].ToString() + newMessList[m].Split(';')[1].ToString() + newMessList[m].Split(';')[2].ToString()) == (compare.Split(';')[0].ToString() + compare.Split(';')[1].ToString() + compare.Split(';')[2].ToString())) { nn = 1; break; } } if (nn == 0) { newMessList.Add(compare); } } } SapOnlineService.SapOnlineService sapService = new SapOnlineService.SapOnlineService(); SapOnlineService.DLN1New[] list = new SapOnlineService.DLN1New[newMessList.Count]; for (int i = 0; i < newMessList.Count; i++) { SapOnlineService.DLN1New por1 = new SapOnlineService.DLN1New(); por1.DocEntry = Convert.ToInt32(newMessList[i].Split(';')[0].ToString()); por1.LineNum = Convert.ToInt32(newMessList[i].Split(';')[1].ToString()); por1.ItemCode = newMessList[i].Split(';')[2].ToString(); por1.Quantity = Convert.ToInt32(newMessList[i].Split(';')[3].ToString()); list[i] = por1; } string strResult = sapService.AddODLN(newMessList[0].Split(';')[7].ToString(), newMessList[0].Split(';')[8].ToString(), Convert.ToDateTime(newMessList[0].Split(';')[9].ToString()), "由WMS同步", Convert.ToDateTime(newMessList[0].Split(';')[9].ToString()), "由WMS同步", newMessList[0].Split(';')[4].ToString(), list); if (strResult.Split('&')[0] == "1") { for (int i = 0; i < datalist.Count; i++) { CSaleDetailData saleDetailModel = new CSaleDetailData(); saleDetailModel = saleDetailBB.GetModel(Convert.ToInt32(datalist[i].Split(';')[5])); //首先要进行判断在CstockUpdetail当中是否所有的数据都已经是‘06’状态,新增06状态用于表示SAP出库已近完成 //首先是将状态从05改为06,然后再进行别的处理 CStockUpDetailBB bb = new CStockUpDetailBB(); bb.ModifyRecord1("06", datalist[i].Split(';')[10]); //bb.ModifyRecord("06", datalist[i].Split(';')[6]);//首先将05的状态改成06 然后 if (bb.GetStatus(Convert.ToInt32(datalist[i].Split(';')[5]))) { saleDetailModel.isSapOutStock = true;//是否已提交SAP出库 saleDetailBB.ModifyRecord(saleDetailModel); } } isChecked = true; } else if (strResult.Split('&')[0] == "0") { this.BindGrid(); this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"" + strResult.Split('&')[1] + "\");", true); return; } if (isChecked) { this.BindGrid(); this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"SAP出库成功!\");", true); } // this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"" + datalist[j].ToString() + "\");", true); //SapOnlineService.SapOnlineService sapService = new SapOnlineService.SapOnlineService(); //SapOnlineService.DLN1New[] list = new SapOnlineService.DLN1New[messList.Count]; //IList<string> newMessList = new List<string>(); //for (int i = 0; i < messList.Count; i++) //{ // if (Convert.ToDateTime(messList[i].Split(';')[9].ToString()).ToString("yyyy-MM-dd") == datalist[j].ToString()) // { // newMessList.Add(messList[i]); // } //} //SapOnlineService.SapOnlineService sapService = new SapOnlineService.SapOnlineService(); //SapOnlineService.DLN1New[] list = new SapOnlineService.DLN1New[newMessList.Count]; //for (int i = 0; i < newMessList.Count; i++) //{ // SapOnlineService.DLN1New por1 = new SapOnlineService.DLN1New(); // por1.DocEntry = Convert.ToInt32(newMessList[i].Split(';')[0].ToString()); // por1.LineNum = Convert.ToInt32(newMessList[i].Split(';')[1].ToString()); // por1.ItemCode = newMessList[i].Split(';')[2].ToString(); // por1.Quantity = Convert.ToInt32(newMessList[i].Split(';')[3].ToString()); // list[i] = por1; //} //string strResult = sapService.AddODLN(newMessList[0].Split(';')[7].ToString(), newMessList[0].Split(';')[8].ToString(), Convert.ToDateTime(newMessList[0].Split(';')[9].ToString()), "由WMS同步", Convert.ToDateTime(newMessList[0].Split(';')[9].ToString()), "由WMS同步", newMessList[0].Split(';')[4].ToString(), list); //if (strResult.Split('&')[0] == "1") //{ // for (int i = 0; i < newMessList.Count; i++) // { // CSaleDetailData saleDetailModel = new CSaleDetailData(); // saleDetailModel = saleDetailBB.GetModel(Convert.ToInt32(newMessList[i].Split(';')[5])); // //首先要进行判断在CstockUpdetail当中是否所有的数据都已经是‘06’状态,新增06状态用于表示SAP出库已近完成 // //首先是将状态从05改为06,然后再进行别的处理 // CStockUpDetailBB bb = new CStockUpDetailBB(); // bb.ModifyRecord("06", newMessList[i].Split(';')[6]);//首先将05的状态改成06 然后 // if (bb.GetStatus(Convert.ToInt32(newMessList[i].Split(';')[5]))) // { // saleDetailModel.isSapOutStock = true;//是否已提交SAP出库 // saleDetailBB.ModifyRecord(saleDetailModel); // } // } // isChecked = true; // } // //else if (strResult.Split('&')[0] == "0") // //{ // // isChecked = false; // // this.BindGrid(); // // this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"日期是" + newMessList[0].Split(';')[9].ToString() + "的数据没有同步成功,SAP返回:"+strResult+"\");", true); // // return; // //} //} //if (isChecked) //{ // this.BindGrid(); // this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"SAP出库成功!\");", true); //} } catch { } } else if (messList.Count == 0) { this.BindGrid(); this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"对不起你没有选择数据!\");", true); } //if(messList.Count>0) //{ // SapOnlineService.SapOnlineService sapService = new SapOnlineService.SapOnlineService(); // SapOnlineService.DLN1New[] list = new SapOnlineService.DLN1New[messList.Count]; // for (int i = 0; i < messList.Count; i++) // { // SapOnlineService.DLN1New por1 = new SapOnlineService.DLN1New(); // por1.DocEntry = Convert.ToInt32(messList[i].Split(';')[0].ToString()); // por1.LineNum = Convert.ToInt32(messList[i].Split(';')[1].ToString()); // por1.ItemCode = messList[i].Split(';')[2].ToString(); // por1.Quantity = Convert.ToInt32(messList[i].Split(';')[3].ToString()); // list[i] = por1; // } // string strResult = sapService.AddODLN(messList[0].Split(';')[7].ToString(), messList[0].Split(';')[8].ToString(), Convert.ToDateTime(messList[0].Split(';')[9].ToString()), "由WMS同步", Convert.ToDateTime(messList[0].Split(';')[9].ToString()), "由WMS同步", messList[0].Split(';')[4].ToString(), list); // // string strResult = sapService.AddODLN(Convert.ToInt32(messList[0].Split(';')[0].ToString()), System.DateTime.Today, "从仓库系统生成", messList[0].Split(';')[4].ToString(), list); // // string strResult = services.SAPOutStock(Convert.ToInt32(chkId.ValidationGroup), docEntry, lineNum, strMaterialNo, num, strInvoiceNo, palletNO); // if (strResult.Split('&')[0] == "1") // { // for (int i = 0; i < messList.Count; i++) // { // CSaleDetailData saleDetailModel = new CSaleDetailData(); // saleDetailModel = saleDetailBB.GetModel(Convert.ToInt32(messList[i].Split(';')[5])); // //首先要进行判断在CstockUpdetail当中是否所有的数据都已经是‘06’状态,新增06状态用于表示SAP出库已近完成 // //首先是将状态从05改为06,然后再进行别的处理 // CStockUpDetailBB bb = new CStockUpDetailBB(); // bb.ModifyRecord("06", messList[i].Split(';')[6]);//首先将05的状态改成06 然后 // if (bb.GetStatus(Convert.ToInt32(messList[i].Split(';')[5]))) // { // saleDetailModel.isSapOutStock = true;//是否已提交SAP出库 // saleDetailBB.ModifyRecord(saleDetailModel); // } // } // isChecked = true; // } // else if (strResult.Split('&')[0] == "0") // { // this.BindGrid(); // this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"" + strResult.Split('&')[1] + "\");", true); // return; // } // if (isChecked) // { // this.BindGrid(); // this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"SAP出库成功!\");", true); // } //} //else if (messList.Count == 0) //{ // this.BindGrid(); // this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"对不起你没有选择数据!\");", true); //} } finally { saleDetailBB.Dispose(); services.Dispose(); } }