/// <summary> /// 绑定Grid /// </summary> protected void BindGrid() { CStockUpBillBB stockUpBillBB = new CStockUpBillBB(); DataSet ds = new DataSet(); try { string strs = this.StrWhere; if (!string.IsNullOrEmpty(txtCustNo.Text)) { strs += " and (custNo like '%" + txtCustNo.Text.Trim().Replace("'", "''") + "%' or custNm like '%" + txtCustNo.Text.Trim().Replace("'", "''") + "%')"; } if (!string.IsNullOrEmpty(txtInvoke.Text)) { strs += " and invoiceNo='" + txtInvoke.Text.Trim().Replace("'", "''") + "'"; } if (!string.IsNullOrEmpty(txtShippingmark.Text)) { strs += " and shippingMarkNo='" + txtShippingmark.Text.Trim().Replace("'", "''") + "'"; } if (!string.IsNullOrEmpty(txtStockUpBill.Text)) { strs += " and stockUpBillNo='" + txtStockUpBill.Text.Trim().Replace("'", "''") + "'"; } if (!string.IsNullOrEmpty(ddlState.SelectedValue)) { strs += " and instantState='" + ddlState.SelectedValue + "'"; } ds = stockUpBillBB.GetVList(strs); this.grid.DataSource = ds.Tables[0]; this.grid.DataBind(); //赋值记录条数、页面总数 this.Label3.Text = ds.Tables[0].Rows.Count.ToString(); this.Label2.Text = this.grid.PageCount.ToString(); this.currPage.Text = (this.grid.PageIndex + 1).ToString(); } finally { stockUpBillBB.Dispose(); } }
/// <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> 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(); } }
/// <summary> /// 绑定Grid /// </summary> protected void BindGrid() { CStockUpBillBB stockUpBillBB = new CStockUpBillBB(); DataSet ds = new DataSet(); try { string strs = this.StrWhere; //限制备货单的所有托盘都在发货区 strs += @" and not exists( select 1 from ( select distinct stockUpDetail.stockUpBillNo,arrangeBillBox.wareType from dbo.vBArrangeBillBox as arrangeBillBox inner join dbo.CStockUpDetail as stockUpDetail on stockUpDetail.palletNo=arrangeBillBox.palletNo where stockUpDetail.instantState='03' ) as main where main.wareType<>'08' and main.stockUpBillNo=a.stockUpBillNo)"; //备货单编号 if (!string.IsNullOrEmpty(txtStockUpBill.Text)) { strs += " and a.stockUpBillNo like '%" + txtStockUpBill.Text.Trim().Replace("'", "''") + "%'"; } //客户编号 if (!string.IsNullOrEmpty(txtCustNo.Text)) { strs += " and custNo='" + txtCustNo.Text.Trim().Replace("'", "''") + "'"; } //发票号 if (!string.IsNullOrEmpty(txtInvoke.Text)) { strs += " and invoiceNo='" + txtInvoke.Text.Trim().Replace("'", "''") + "'"; } //唛头 if (!string.IsNullOrEmpty(txtShippingmark.Text)) { strs += " and shippingMarkNo='" + txtShippingmark.Text.Trim().Replace("'", "''") + "'"; } ds = stockUpBillBB.GetVListInFHQ(strs); this.grid.DataSource = ds.Tables[0]; this.grid.DataBind(); //赋值记录条数、页面总数 this.Label3.Text = ds.Tables[0].Rows.Count.ToString(); this.Label2.Text = this.grid.PageCount.ToString(); this.currPage.Text = (this.grid.PageIndex + 1).ToString(); } finally { stockUpBillBB.Dispose(); } }
public void UpdateStockUpBiillStaus(string stockUpNo) { CStockUpBillBB bb = new CStockUpBillBB(); try { bb.ModifyRecord(stockUpNo); } finally { bb.Dispose(); } }
/// <summary> /// 显示备货单信息 /// </summary> private void ShowInfo() { CStockUpBillBB stockUpBillBB = new CStockUpBillBB(); LCustBB custBB = new LCustBB(); CSaleDetailBB saleDetailBB = new CSaleDetailBB(); try { string strCustNo = Request.QueryString["custNo"]; string strSaleBillNos = Request.QueryString["saleBillNos"];//销售订单号 string strAbsEntrys = Request.QueryString["absEntrys"];//提货单号 string strFinanceBillNos = Request.QueryString["financeBillNos"];//采购合同号组合 string strLineNums = Request.QueryString["lineNums"];//行号组合 string strWhere = "1=1"; DataSet ds = new DataSet(); if (Request.Params["id"] != null && Request.Params["id"] != "") { this.IdValue = Convert.ToInt32(Request.Params["id"]); vCStockUpBillData stockUpBillModel = stockUpBillBB.GetVModel(this.IdValue); this.StockBillNo = stockUpBillModel.stockUpBillNo; this.stockUpBillNo.Text = stockUpBillModel.stockUpBillNo; this.shippingMarkNo.Text = stockUpBillModel.shippingMarkNo; this.lblCustNm.Text = stockUpBillModel.custNm; this.invoiceNo.Text = stockUpBillModel.invoiceNo; this.txtstockEmpNm.Text = stockUpBillModel.stockUpEmpNm; this.empId.Value = stockUpBillModel.stockUpEmpId.ToString(); strSaleBillNos = "'" + stockUpBillModel.saleBillNos.Replace(",", "','") + "'";//销售订单编号组合 strAbsEntrys = "'" + stockUpBillModel.absEntrys.Replace(",", "','") + "'";//提货单编号组合 strLineNums = "'" + stockUpBillModel.lineNums.Replace(",", "','") + "'";//行号组合 if (stockUpBillModel.financeBillNos != "")//采购合同号组合 { strFinanceBillNos = "'" + stockUpBillModel.financeBillNos.Replace(",", "','") + "'"; } this.mark.Text = stockUpBillModel.mark; this.outStockDt.Text = Convert.ToDateTime(stockUpBillModel.outStockDt).ToString("yyyy-MM-dd"); } else { if (strCustNo == null || strCustNo == "") { return; } DataSet dsCust = custBB.GetList(" custNo ='" + strCustNo.Trim() + "'"); if (dsCust != null && dsCust.Tables[0] != null && dsCust.Tables[0].Rows.Count > 0) { this.stockUpBillNo.Text = stockUpBillBB.GetCurrentInBillNoByStockUpBillNo(); this.StockBillNo = this.stockUpBillNo.Text; this.CustomNo = strCustNo; this.shippingMarkNo.Text = dsCust.Tables[0].Rows[0]["shippingMark"].ToString(); this.lblCustNm.Text = dsCust.Tables[0].Rows[0]["custNm"].ToString(); } } //绑定销售订单明细列表 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); //ds = saleDetailBB.GetVList(" saleBillNo in (" + strSaleBillNos // + ") and absEntry in (" + strAbsEntrys + ") and lineNum in (" + strLineNums + ")"); this.DtSaleList = ds.Tables[0]; } finally { stockUpBillBB.Dispose(); custBB.Dispose(); saleDetailBB.Dispose(); } }
/// <summary> /// 删除备货单明细 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void gridStockUpDetail_RowDeleting(object sender, GridViewDeleteEventArgs e) { CStockUpBillBB stockUpBillBB = new CStockUpBillBB(); try { CStockUpBillData stockUpBillModel = new CStockUpBillData(); string Id = this.gridStockUpDetail.DataKeys[e.RowIndex].Values["id"].ToString();//ID string rowid = this.gridStockUpDetail.DataKeys[e.RowIndex].Values["rowId"].ToString();//GUID string materialNo = this.gridStockUpDetail.DataKeys[e.RowIndex].Values["materialNo"].ToString();//物料编号 DataRow[] myDataRowArray_Result = null; //根据rowid查找备货明细 myDataRowArray_Result = this.DtResult.Select("rowid='" + rowid + "'"); if (myDataRowArray_Result.Length > 0) { //更改删除标志 myDataRowArray_Result[0]["isdel"] = "1";//删除 myDataRowArray_Result[0]["num"] = 0; //判断备货单是否已经提交 stockUpBillModel = stockUpBillBB.GetModel(this.IdValue); if (stockUpBillModel != null && stockUpBillModel.instantState != "01") { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('已提交数据无法删除!');", true); return; } } } catch (Exception ex) { this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true); return; } finally { this.BindGridStockUpDetail();//绑定备货单明细列表 this.SaveStencilDetailViewState();//保存备货信息 this.BindGridSaleBill();//显示销售订单明细列表 stockUpBillBB.Dispose(); } }
/// <summary> /// 保存或提交备货单公共方法 /// </summary> /// <param name="isSubmit"></param> protected void SubmitArrangeBill(bool isSubmit) { CStockUpBillBC stockUpBillBC = new CStockUpBillBC(); CStockUpBillBB stockUpBillBB = new CStockUpBillBB(); try { this.SaveStencilDetailViewState();//保存备货信息 this.BindGridStockUpDetail();//绑定备货单明细列表 this.BindGridSaleBill();//显示销售订单明细列表 if (this.ValidateArrangeDetail()) { CStockUpBillData data = stockUpBillBB.GetModel(this.StockBillNo); if (data == null) { #region 未生成备货单 data = new CStockUpBillData(); data.id = 0; data.stockUpBillNo = this.StockBillNo; data.invoiceNo = this.invoiceNo.Text; data.stockUpEmpId = Convert.ToInt32(this.empId.Value == "" ? "0" : this.empId.Value); data.mark = this.mark.Text; data.custNo = this.CustomNo; data.outStockDt = this.outStockDt.Text; data.saleBillNos = this.lbSaleBillNos.Text; data.lineNums = Request.QueryString["lineNums"]; data.absEntrys = Request.QueryString["absEntrys"]; data.financeBillNos = Request.QueryString["financeBillNos"]; data.shippingMarkNo = this.shippingMarkNo.Text; data.isrtDt = DateTime.Now.ToString(); data.isrtEmpId = this.currentUser.empId; if (isSubmit) { data.instantState = "02"; data.updtDt = DateTime.Now.ToString(); data.updtEmpId = this.currentUser.empId; data.commitDt = DateTime.Now.ToString(); data.commitEmpId = this.currentUser.empId; } else { data.instantState = "01"; data.updtDt = DateTime.Now.ToString(); data.updtEmpId = this.currentUser.empId; } #endregion 未生成备货单 } else { #region 已生成备货单 if (data.instantState != "01") { this.ClientScript.RegisterStartupScript(this.GetType(), "alert9", "alert(\"当前备货单已经提交,不允许继续修改备货单信息!\");", true); return; } data.invoiceNo = this.invoiceNo.Text; data.stockUpEmpId = Convert.ToInt32(this.empId.Value == "" ? "0" : this.empId.Value); data.mark = this.mark.Text; data.custNo = this.CustomNo; data.outStockDt = this.outStockDt.Text; data.shippingMarkNo = this.shippingMarkNo.Text; data.updtDt = DateTime.Now.ToString(); data.updtEmpId = this.currentUser.empId; if (isSubmit) { data.instantState = "02"; data.updtDt = DateTime.Now.ToString(); data.updtEmpId = this.currentUser.empId; data.commitDt = DateTime.Now.ToString(); data.commitEmpId = this.currentUser.empId; } else { data.instantState = "01"; data.updtDt = DateTime.Now.ToString(); data.updtEmpId = this.currentUser.empId; } #endregion 已生成备货单 } if (stockUpBillBC.SaveBArrangeBill(data, this.DtResult, isSubmit)) { this.DtResult = null; this.InitDtResult();//初始化备货单明细数据源 this.BindGridStockUpDetail();//绑定备货单明细列表 this.BindGridSaleBill();//绑定销售订单明细列表 if (isSubmit)//提交 { this.ClientScript.RegisterStartupScript(this.GetType(), "alert12", "alert(\"备货单维护成功!\");window.location='" + Request.Params["backurl"] + "';", true); } else//保存 { this.BindGridStockUpDetail();//绑定备货单明细列表 this.BindGridSaleBill();//绑定销售订单明细列表 this.ClientScript.RegisterStartupScript(this.GetType(), "alert12", "alert(\"备货单维护成功!\");", 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 { stockUpBillBB.Dispose(); stockUpBillBC.Dispose(); } }