/// <summary>
    /// 绑定Grid
    /// </summary>
    protected void BindGrid()
    {
        LMaterialBB materialBB = new LMaterialBB();
        DataSet ds = new DataSet();

        try
        {
            string strWhere = this.StrWhere;

            //物料编码
            if (this.tbMaterialNo.Text.Trim() != "")
            {
                strWhere += " and materialNo like '%" + this.tbMaterialNo.Text.Trim().Replace("'", "''") + "%'";
            }

            //物料名称
            if (this.tbMaterialNm.Text.Trim() != "")
            {
                strWhere += " and materialDesc like '%" + this.tbMaterialNm.Text.Trim().Replace("'", "''") + "%'";
            }

            //货位分类
            if (this.ddlWareSort.SelectedValue != "")
            {
                strWhere += " and wareSortNo='" + this.ddlWareSort.SelectedValue + "'";
            }

            ds = materialBB.GetVList(strWhere);
            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
        {
            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>
    protected void BindMateriel()
    {
        string strWhere = "1=1";
        DataSet ds = new DataSet();
        LMaterialBB materialBB = new LMaterialBB();

        //物料
        if (this.txtC.Text.Trim() != "")
        {
            strWhere += " and (materialNo like '%" + this.txtC.Text.Replace("'", "''")
                + "%' or materialDesc like '%" + this.txtC.Text.Replace("'", "''") + "%')";
        }
        ds = materialBB.GetVList(strWhere);
        this.grvMateriel.DataSource = ds.Tables[0];
        this.grvMateriel.DataBind();

        //赋值记录条数、页面总数
        this.Label3.Text = ds.Tables[0].Rows.Count.ToString();
        this.Label2.Text = this.grvMateriel.PageCount.ToString();
        this.currPage.Text = (this.grvMateriel.PageIndex + 1).ToString();
    }
Exemple #4
0
    /// <summary>
    /// 绑定Grid
    /// </summary>
    protected void BindGrid()
    {
        LMaterialBB bOMBB = new LMaterialBB();
        DataSet ds = new DataSet();

        try
        {
            string wherestr = " 1=1 ";
            if (!string.IsNullOrEmpty(txtMaterialnm.Text))
            {
                wherestr += "  and  materialDesc='%" + txtMaterialnm.Text.Replace("'", "''") + "%'";
            }
            if (!string.IsNullOrEmpty(txtMaterialno.Text))
            {
                wherestr += "  and  materialno like '%" + txtMaterialno.Text.Replace("'", "''") + "%'";
            }

            ds = bOMBB.GetVList(wherestr);
            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
        {
            bOMBB.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();
        LMaterialRelationBB materialRelationBB = new LMaterialRelationBB();

        try
        {

            string strErrorInfo = "", strWareNo = "", strWareNm = "",
            strWareLocatorNm = "", strMaterialDesc = "";

            DataTable dtWareLocator = new DataTable();
            DataTable dtMaterial = new DataTable();
            DataTable dtStock = new DataTable();
            DataTable dtStockUpDetail = new DataTable();

            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;
            }

            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();//计划备货物料

            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;
            }

            DataRow drnew = this.DtResultNew.NewRow();

            drnew["rowId"] = Guid.NewGuid().ToString();
            drnew["id"] = 0;
            drnew["num"] = this.tbNum.Text.Trim();
            drnew["palletIndex"] = "1";
            drnew["wareNo"] = strWareNo;
            drnew["wareLocatorNo"] = this.txtWareLocarorNo.Value.Trim().ToUpper();
            drnew["palletNo"] = this.txtPalletNo.Value.Trim();
            drnew["stockUpMaterialNo"] = this.StockUpMaterialNo;//计划备货物料
            drnew["materialNo"] = this.txtMaterialNo.Value.Trim();//实际拣货物料
            //drnew["materialDesc"] = strMaterialDesc;
            drnew["instantState"] = "01";
            drnew["financeBillNo"] = this.txtFinanceBillNo.Value.Trim().ToUpper();//采购合同号
            //drnew["financeBillSort"] = this.txtFinanceBillNo.Value.Trim() == "" ? "备货" : "按单";//采购合同类型
            drnew["saleBillNo"] = this.SaleBillNo;//销售订单号
            drnew["docEntry"] = this.DocEntry;//销售订单ID
            drnew["lineNum"] = this.LineNum;//销售订单行号

            drnew["isDel"] = false;

            //去除判断属性 直接进行数据的保存 将校验数据去除

            this.DtResultNew.Rows.Add(drnew);

            this.BindGridPickOutPlan();//绑定拣货明细列表
            this.btnSubmit.Enabled = true;
        }
        finally
        {
            wareLocatorBB.Dispose();
            materialBB.Dispose();
            stockBB.Dispose();
            commBB.Dispose();

            materialRelationBB.Dispose();
        }
    }