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

        try
        {
            string strWhere = this.StrWhere;

            //限制库位没有占用
            strWhere += "  and not exists(select 1 from dbo.UStock where dbo.UStock.wareLocatorNo=dbo.vLWareLocator.wareLocatorNo)";

            if (this.ddlWare.SelectedValue != "")
            {
                strWhere += " and wareNo='" + this.ddlWare.SelectedValue + "'";
            }

            ds = lWareBB.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
        {
            lWareBB.Dispose();
        }
    }
    /// <summary>
    /// 绑定Grid
    /// </summary>
    protected void BindGrid()
    {
        LWareLocatorBB wareLocatorBB = new LWareLocatorBB();
        DataSet ds = new DataSet();

        try
        {
            string strWhere = this.StrWhere;

            //库位编码
            if (this.tbWareLocatorNo.Text.Trim() != "")
            {
                strWhere += " and wareLocatorNo like '%" + this.tbWareLocatorNo.Text.Trim().Replace("'", "''") + "%'";
            }

            //库位名称
            if (this.tbWareLocatorNm.Text.Trim() != "")
            {
                strWhere += " and wareLocatorNm like '%" + this.tbWareLocatorNm.Text.Trim().Replace("'", "''") + "%'";
            }

            //所属库区
            if (this.ddlWare.SelectedValue != "")
            {
                strWhere += " and wareNo='" + this.ddlWare.SelectedValue + "'";
            }

            ds = wareLocatorBB.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
        {
            wareLocatorBB.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="cb"></param>
    private void BindWareLocator(DropDownList ddlWareLocator)
    {
        LWareLocatorBB wareLocatorBB = new LWareLocatorBB();

        try
        {
            DataTable dt = new DataTable();

            dt = wareLocatorBB.GetList(" wareNo='GZT' and isnull(downWareLocatorNo,'')<>''").Tables[0];

            ddlWareLocator.DataTextField = "wareLocatorNm";
            ddlWareLocator.DataValueField = "wareLocatorNo";
            ddlWareLocator.DataSource = dt;
            ddlWareLocator.DataBind();
            ddlWareLocator.Items.Insert(0, new ListItem("-请选择-", ""));
        }
        finally
        {
            wareLocatorBB.Dispose();
        }
    }
    /// <summary>
    /// 解除库位锁定
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnUnLock_Click(object sender, EventArgs e)
    {
        LWareLocatorBB wareLocatorBB = new LWareLocatorBB();

        try
        {
            //获取选中的数据Id
            foreach (GridViewRow gvrow in this.grid.Rows)
            {
                CheckBox chkId = (CheckBox)gvrow.FindControl("chkId");
                if (chkId.Checked == true)
                {
                    int id = int.Parse(chkId.ValidationGroup);
                    LWareLocatorData wareLocatorModel = new LWareLocatorData();

                    wareLocatorModel = wareLocatorBB.GetModel(id);
                    wareLocatorModel.isUsing = false;
                    wareLocatorModel.updtDt = System.DateTime.Now.ToString();
                    wareLocatorModel.updtEmpId = this.currentUser.empId;
                    wareLocatorBB.ModifyRecord(wareLocatorModel);
                }
            }
        }
        catch (Exception ex)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
            return;
        }
        finally
        {
            wareLocatorBB.Dispose();
        }
    }
Exemple #6
0
    /// <summary>
    /// 绑定库位
    /// </summary>
    public void BindWareLocatorByWareType(DropDownList ddlWareLocator, string strWareType)
    {
        using (LWareLocatorBB wareLocatorBB = new LWareLocatorBB())
        {
            DataSet ds = new DataSet();
            ds = wareLocatorBB.GetVList("isDel=0 and wareType='" + strWareType + "'");

            ddlWareLocator.DataTextField = "wareLocatorNm";
            ddlWareLocator.DataValueField = "wareLocatorNo";
            ddlWareLocator.DataSource = ds.Tables[0];
            ddlWareLocator.DataBind();
            ddlWareLocator.Items.Insert(0, new ListItem("-请选择-", ""));
        }
    }
    /// <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();
        }
    }
    public DataTable GetWareLocatorInfoById(string strWareLocatorNo)
    {
        LWareLocatorBB wareLocatorBB = new LWareLocatorBB();

        try
        {
            DataTable dt = new DataTable();

            dt = wareLocatorBB.GetVList("id='" + strWareLocatorNo + "'").Tables[0];
            return dt;
        }
        finally
        {
            wareLocatorBB.Dispose();
        }
    }
    public bool IsWareLocatorUsing(string strWareLocatorNo)
    {
        LWareLocatorBB wareLocatorBB = new LWareLocatorBB();
        LWareBB wareBB = new LWareBB();

        try
        {
            DataTable dtWare = new DataTable();
            DataTable dtWareLocator = new DataTable();

            dtWare = wareBB.GetList("wareNo='" + strWareLocatorNo + "'").Tables[0];//获取库区
            dtWareLocator = wareLocatorBB.GetVList("wareLocatorNo='" + strWareLocatorNo + "'").Tables[0];//获取库位

            //如果扫描的为库区,返回true
            if (dtWare.Rows.Count > 0)
            {
                return false;
            }

            //判断库位是否正在使用
            if (dtWareLocator.Rows.Count == 0)
            {
                return true;
            }
            else if (dtWareLocator.Rows[0]["wareType"].ToString() == "07"
                || dtWareLocator.Rows[0]["isUsing"] == DBNull.Value
                || Convert.ToBoolean(dtWareLocator.Rows[0]["isUsing"]) == false)
            {
                return false;
            }
            else
            {
                return true;
            }
        }
        finally
        {
            wareLocatorBB.Dispose();
            wareBB.Dispose();
        }
    }
    public DataTable GetWareLocator(string strWareNo, string strWhere)
    {
        using (LWareLocatorBB wareLocatorBB = new LWareLocatorBB())
        {
            DataSet ds = new DataSet();
            ds = wareLocatorBB.GetVList("isDel=0 and wareNo='" + strWareNo + "'" + strWhere);

            return ds.Tables[0];
        }
    }
    public DataTable GetWareLocatorByWareType(string strWareType)
    {
        LWareLocatorBB wareLocatorBB = new LWareLocatorBB();

        try
        {
            DataTable dt = new DataTable();

            dt = wareLocatorBB.GetVList("wareType='" + strWareType + "' and isDel=0").Tables[0];
            return dt;
        }
        finally
        {
            wareLocatorBB.Dispose();
        }
    }
    public string GetSuggestWareLocator_ForkliftTask(int forkliftTaskId)
    {
        string strSuggestWareLocator = "";
        BForkliftTaskBB forkliftTaskBB = new BForkliftTaskBB();
        LWareLocatorBB wareLocatorBB = new LWareLocatorBB();
        SCommBB commBB = new SCommBB();
        LWareLocatorRelationBB wareLocatorRelation = new LWareLocatorRelationBB();

        try
        {
            vBForkliftTaskData vForkliftTaskModel = new vBForkliftTaskData();
            BForkliftTaskData forkliftTaskModel = new BForkliftTaskData();
            DataTable dtWareLocator = new DataTable();

            //获取叉车任务实例
            forkliftTaskModel = forkliftTaskBB.GetModel(forkliftTaskId);
            vForkliftTaskModel = forkliftTaskBB.GetVModel(forkliftTaskId);

            if (forkliftTaskModel.taskType == "01" || forkliftTaskModel.taskType == "04"
                || forkliftTaskModel.taskType == "10")
            {
                #region 01 从排托区到质检区、04 从理货区返回质检区、10 从收货区到质检区

                //获取没有使用的质检区的所有库位
                //2015-08-04 修改增加相应的对应关系 与表LwareLocator之间产生关系
                if (!string.IsNullOrEmpty(forkliftTaskModel.nextLocatorNo))//已有目的库位
                {
                    strSuggestWareLocator = vForkliftTaskModel.nextWareNo
                        + "," + vForkliftTaskModel.nextWareNm
                        + "," + vForkliftTaskModel.nextLocatorNo
                        + "," + vForkliftTaskModel.nextWareLocatorNm;
                }
                else//没有目的库位
                {
                    //只有原来的库区是在收货区的时候 才进行处理
                    //if (vForkliftTaskModel.preWareNo == "SHQ")
                    //{
                    //    //首先是查找出所有的可以进行入库的库位
                    //    DataTable dtNew = new DataTable();
                    //    if (vForkliftTaskModel.preLocatorNo.Contains("SH"))
                    //        dtNew = wareLocatorRelation.GetList("wareLocatorStartPrefix = 'SH' and isdel = 0").Tables[0];
                    //    else
                    //        dtNew = wareLocatorRelation.GetList("wareLocatorStartPrefix = 'S' and isdel = 0").Tables[0];
                    //    for (int i = 0; i < dtNew.Rows.Count; i++)
                    //    {
                    //      //2015-08-04 数据库实现后发现只能通过程序来进行实现
                    //        dtWareLocator = wareLocatorBB.GetVList("wareType='01' and isUsing=0 and isDel=0 and wareLocatorNo like '" + dtNew.Rows[i]["wareLocatorEndPrefix"] + "%'").Tables[0];
                    //        if(dtWareLocator.Rows.Count>0)
                    //        {
                    //            break;//如果大于0的话则进行退出操作
                    //        }

                    //    }
                    //       // dtWareLocator = wareLocatorBB.GetVList("wareType='01' and isUsing=0 and isDel=0").Tables[0];
                    //}
                    //else
                    //{
                    //首先要通过叉车能够获取获取托盘上此时有的信息
                    string palletNO = vForkliftTaskModel.palletNo;
                    DataTable dtPallet = GetBoxByPalletNo(palletNO);
                    string checkMaterial = "";
                    if (dtPallet != null)
                    {
                        if (dtPallet.Rows.Count > 0 && dtPallet.Rows[0]["materialNO"] != "")
                        {
                            checkMaterial = dtPallet.Rows[0]["materialNO"].ToString();
                        }

                    }

                    //dtWareLocator = wareLocatorBB.GetVList("wareType='01' and isUsing=0 and isDel=0").Tables[0];
                    dtWareLocator = wareLocatorBB.GetVListJoey(checkMaterial).Tables[0];
                    //}
                    if (dtWareLocator.Rows.Count > 0)
                    {
                        //获取推荐库位信息
                        strSuggestWareLocator = dtWareLocator.Rows[0]["wareNo"].ToString()
                            + "," + dtWareLocator.Rows[0]["wareNm"].ToString()
                            + "," + dtWareLocator.Rows[0]["wareLocatorNo"].ToString()
                            + "," + dtWareLocator.Rows[0]["wareLocatorNm"].ToString();

                        //更改叉车任务的目的库位信息
                        forkliftTaskModel.nextWareNo = dtWareLocator.Rows[0]["wareNo"].ToString();//目的库区
                        forkliftTaskModel.nextLocatorNo = dtWareLocator.Rows[0]["wareLocatorNo"].ToString();//目的库位

                        forkliftTaskBB.ModifyRecord(forkliftTaskModel);

                        //更改目的库位的使用状态
                        commBB.ExecuteSql("update dbo.LWareLocator set isUsing=1 where wareLocatorNo='"
                            + dtWareLocator.Rows[0]["wareLocatorNo"].ToString() + "'");
                    }
                }

                #endregion 01 从排托区到质检区、04 从理货区返回质检区、10 从收货区到质检区
            }
            else if (forkliftTaskModel.taskType == "08" || forkliftTaskModel.taskType == "02"
                || forkliftTaskModel.taskType == "03" || forkliftTaskModel.taskType == "05"
                || forkliftTaskModel.taskType == "06" || forkliftTaskModel.taskType == "11"
                || forkliftTaskModel.taskType == "12")
            {
                #region 08 从收货区到收货排托区,02 从质检区到理货区,03 从理货区到正式库区,05 从正式库区到拣货区,06 从拣货区返回正式库区,11 从质检区到正式区,12 托盘移库

                strSuggestWareLocator = vForkliftTaskModel.nextWareNo
                    + "," + vForkliftTaskModel.nextWareNm
                    + "," + vForkliftTaskModel.nextLocatorNo
                    + "," + vForkliftTaskModel.nextWareLocatorNm;

                #endregion 08 从收货区到收货排托区,02 从质检区到理货区,03 从理货区到正式库区,05 从正式库区到拣货区,06 从拣货区返回正式库区,11 从质检区到正式区,12 托盘移库
            }
            else if (forkliftTaskModel.taskType == "07")
            {
                #region 07 拣货区发货

                strSuggestWareLocator = ",发货区,,发货区";

                #endregion 07 拣货区发货
            }
            else if (forkliftTaskModel.taskType == "09")
            {
                #region 09 从收货排托区返回收货区

                if (!string.IsNullOrEmpty(forkliftTaskModel.nextLocatorNo))//已有目的库位
                {
                    strSuggestWareLocator = vForkliftTaskModel.nextWareNo
                        + "," + vForkliftTaskModel.nextWareNm
                        + "," + vForkliftTaskModel.nextLocatorNo
                        + "," + vForkliftTaskModel.nextWareLocatorNm;
                }
                else
                {
                    //获取收货区的所有库位
                    dtWareLocator = wareLocatorBB.GetVList("wareType='05' and isUsing=0").Tables[0];

                    if (dtWareLocator.Rows.Count > 0)
                    {
                        strSuggestWareLocator = dtWareLocator.Rows[0]["wareNo"].ToString()
                            + "," + dtWareLocator.Rows[0]["wareNm"].ToString()
                            + "," + dtWareLocator.Rows[0]["wareLocatorNo"].ToString()
                            + "," + dtWareLocator.Rows[0]["wareLocatorNm"].ToString();

                        //更改叉车任务的目的库位信息
                        forkliftTaskModel.nextWareNo = dtWareLocator.Rows[0]["wareNo"].ToString();//目的库区
                        forkliftTaskModel.nextLocatorNo = dtWareLocator.Rows[0]["wareLocatorNo"].ToString();//目的库位

                        forkliftTaskBB.ModifyRecord(forkliftTaskModel);

                        //更改目的库位的使用状态
                        commBB.ExecuteSql("update dbo.LWareLocator set isUsing=1 where wareLocatorNo='"
                            + dtWareLocator.Rows[0]["wareLocatorNo"].ToString() + "'");
                    }
                }

                #endregion 09 从收货排托区返回收货区
            }
            else if (forkliftTaskModel.taskType == "13" || forkliftTaskModel.taskType == "30")
            {
                #region 13 从理货区到异常区

                //获取没有使用的异常区的所有库位
                //if (!string.IsNullOrEmpty(forkliftTaskModel.nextLocatorNo))//已有目的库位
                //{
                //    strSuggestWareLocator = vForkliftTaskModel.nextWareNo
                //    + "," + vForkliftTaskModel.nextWareNm
                //    + "," + vForkliftTaskModel.nextLocatorNo
                //    + "," + vForkliftTaskModel.nextWareLocatorNm;
                //}
                //else
                //{
                //}

                //dtWareLocator = wareLocatorBB.GetVList("wareType='09' and isUsing=0 and isDel=0").Tables[0];
                dtWareLocator = wareLocatorBB.GetVList("wareType='09' and isDel=0").Tables[0];//临时不限制是否正在使用
                if (dtWareLocator.Rows.Count > 0)
                {
                    //获取推荐库位信息
                    strSuggestWareLocator = dtWareLocator.Rows[0]["wareNo"].ToString()
                        + "," + dtWareLocator.Rows[0]["wareNm"].ToString()
                        + "," + dtWareLocator.Rows[0]["wareLocatorNo"].ToString()
                        + "," + dtWareLocator.Rows[0]["wareLocatorNm"].ToString();

                    //更改叉车任务的目的库位信息
                    forkliftTaskModel.nextWareNo = dtWareLocator.Rows[0]["wareNo"].ToString();//目的库区
                    forkliftTaskModel.nextLocatorNo = dtWareLocator.Rows[0]["wareLocatorNo"].ToString();//目的库位
                    forkliftTaskBB.ModifyRecord(forkliftTaskModel);

                    ////更改目的库位的使用状态
                    //commBB.ExecuteSql("update dbo.LWareLocator set isUsing=1 where wareLocatorNo='"
                    //    + dtWareLocator.Rows[0]["wareLocatorNo"].ToString() + "'");
                }

                #endregion 13 从理货区到异常区
            }
            else if (forkliftTaskModel.taskType == "14")
            {
                #region 14 从拣货区到打托区

                if (!string.IsNullOrEmpty(forkliftTaskModel.nextLocatorNo))//已有目的库位
                {
                    strSuggestWareLocator = vForkliftTaskModel.nextWareNo
                        + "," + vForkliftTaskModel.nextWareNm
                        + "," + vForkliftTaskModel.nextLocatorNo
                        + "," + vForkliftTaskModel.nextWareLocatorNm;
                }
                else
                {
                    //获取打托区的所有库位
                    dtWareLocator = wareLocatorBB.GetVList("wareType='10' and isUsing=0 and isDel=0").Tables[0];

                    if (dtWareLocator.Rows.Count > 0)
                    {
                        strSuggestWareLocator = dtWareLocator.Rows[0]["wareNo"].ToString()
                            + "," + dtWareLocator.Rows[0]["wareNm"].ToString()
                            + "," + dtWareLocator.Rows[0]["wareLocatorNo"].ToString()
                            + "," + dtWareLocator.Rows[0]["wareLocatorNm"].ToString();

                        //更改叉车任务的目的库位信息
                        forkliftTaskModel.nextWareNo = dtWareLocator.Rows[0]["wareNo"].ToString();//目的库区
                        forkliftTaskModel.nextLocatorNo = dtWareLocator.Rows[0]["wareLocatorNo"].ToString();//目的库位

                        forkliftTaskBB.ModifyRecord(forkliftTaskModel);

                        //更改目的库位的使用状态
                        //日期 2014-07-22 将打托区占用取消掉 打托区当中可以有多个被占用
                        //commBB.ExecuteSql("update dbo.LWareLocator set isUsing=1 where wareLocatorNo='"
                        //    + dtWareLocator.Rows[0]["wareLocatorNo"].ToString() + "'");
                    }
                }

                #endregion 14 从拣货区到打托区
            }
            else if (forkliftTaskModel.taskType == "15")
            {
                #region 15 从打托区到发货区

                if (!string.IsNullOrEmpty(forkliftTaskModel.nextLocatorNo))//已有目的库位
                {
                    strSuggestWareLocator = vForkliftTaskModel.nextWareNo
                        + "," + vForkliftTaskModel.nextWareNm
                        + "," + vForkliftTaskModel.nextLocatorNo
                        + "," + vForkliftTaskModel.nextWareLocatorNm;
                }
                else
                {
                    //获取发货区的所有库位
                    dtWareLocator = wareLocatorBB.GetVList("wareType='08' and isUsing=0 and isDel=0").Tables[0];

                    if (dtWareLocator.Rows.Count > 0)
                    {
                        strSuggestWareLocator = dtWareLocator.Rows[0]["wareNo"].ToString()
                            + "," + dtWareLocator.Rows[0]["wareNm"].ToString()
                            + "," + dtWareLocator.Rows[0]["wareLocatorNo"].ToString()
                            + "," + dtWareLocator.Rows[0]["wareLocatorNm"].ToString();

                        //更改叉车任务的目的库位信息
                        forkliftTaskModel.nextWareNo = dtWareLocator.Rows[0]["wareNo"].ToString();//目的库区
                        forkliftTaskModel.nextLocatorNo = dtWareLocator.Rows[0]["wareLocatorNo"].ToString();//目的库位

                        forkliftTaskBB.ModifyRecord(forkliftTaskModel);

                        //更改目的库位的使用状态
                        commBB.ExecuteSql("update dbo.LWareLocator set isUsing=1 where wareLocatorNo='"
                            + dtWareLocator.Rows[0]["wareLocatorNo"].ToString() + "'");
                    }
                }

                #endregion 15 从打托区到发货区
            }
            else if (forkliftTaskModel.taskType == "20")
            {
                #region 20的时候 正式出库

                if (!string.IsNullOrEmpty(forkliftTaskModel.nextLocatorNo))//已有目的库位
                {
                    strSuggestWareLocator = vForkliftTaskModel.nextWareNo
                        + "," + vForkliftTaskModel.nextWareNm
                        + "," + vForkliftTaskModel.nextLocatorNo
                        + "," + vForkliftTaskModel.nextWareLocatorNm;
                }
                else
                {
                    //获取发货区的所有库位
                    dtWareLocator = wareLocatorBB.GetVList("wareType='11' and isUsing=0 and isDel=0").Tables[0];

                    if (dtWareLocator.Rows.Count > 0)
                    {
                        strSuggestWareLocator = dtWareLocator.Rows[0]["wareNo"].ToString()
                            + "," + dtWareLocator.Rows[0]["wareNm"].ToString()
                            + "," + dtWareLocator.Rows[0]["wareLocatorNo"].ToString()
                            + "," + dtWareLocator.Rows[0]["wareLocatorNm"].ToString();

                        //更改叉车任务的目的库位信息
                        forkliftTaskModel.nextWareNo = dtWareLocator.Rows[0]["wareNo"].ToString();//目的库区
                        forkliftTaskModel.nextLocatorNo = dtWareLocator.Rows[0]["wareLocatorNo"].ToString();//目的库位

                        forkliftTaskBB.ModifyRecord(forkliftTaskModel);

                        //更改目的库位的使用状态
                        //commBB.ExecuteSql("update dbo.LWareLocator set isUsing=1 where wareLocatorNo='"
                        //    + dtWareLocator.Rows[0]["wareLocatorNo"].ToString() + "'");
                    }
                }

                #endregion 20 正式库区发货

            }
            else if (forkliftTaskModel.taskType == "30")
            {
                //2015-08-07进行修改
                #region 退货区生成叉车任务获取相应的库位
                dtWareLocator = wareLocatorBB.GetVList("wareType='09' and isUsing=0 and isDel=0 and wareNO = 'YCQ'").Tables[0];
                if (dtWareLocator.Rows.Count > 0)
                {
                    strSuggestWareLocator = dtWareLocator.Rows[0]["wareNo"].ToString()
                        + "," + dtWareLocator.Rows[0]["wareNm"].ToString()
                        + "," + dtWareLocator.Rows[0]["wareLocatorNo"].ToString()
                        + "," + dtWareLocator.Rows[0]["wareLocatorNm"].ToString();
                    //更改叉车任务的目的库位信息
                    forkliftTaskModel.nextWareNo = dtWareLocator.Rows[0]["wareNo"].ToString();//目的库区
                    forkliftTaskModel.nextLocatorNo = dtWareLocator.Rows[0]["wareLocatorNo"].ToString();//目的库位
                    forkliftTaskBB.ModifyRecord(forkliftTaskModel);
                #endregion

                }
            }

        }
        finally
        {
            forkliftTaskBB.Dispose();
            wareLocatorBB.Dispose();
            commBB.Dispose();
        }

        return strSuggestWareLocator;
    }
    public string GetPalletWareInfo(string strPalletNo)
    {
        string strWareLocatorNo = "";
        BArrangeBillBoxBB arrangeBillBoxBB = new BArrangeBillBoxBB();
        LWareBB wareBB = new LWareBB();
        LWareLocatorBB wareLocatorBB = new LWareLocatorBB();
        LMaterialBB materialBB = new LMaterialBB();
        SCommBB commBB = new SCommBB();

        try
        {
            DataTable dtArrangeBillBox = new DataTable();
            DataTable dtWare = new DataTable();
            DataTable dtWareLocator = new DataTable();

            //获取托盘下的所有箱子
            dtArrangeBillBox = arrangeBillBoxBB.GetVList("palletNo='" + strPalletNo + "' and isnull(wareNo,'')<>''").Tables[0];
            if (dtArrangeBillBox.Rows.Count > 0)
            {
                string strFinanceBillSort = "", strFinanceBillNo = "";

                strFinanceBillSort = dtArrangeBillBox.Rows[0]["financeBillSort"].ToString();//采购合同类型
                strFinanceBillNo = dtArrangeBillBox.Rows[0]["financeBillNo"].ToString();//采购合同号
                if (strFinanceBillSort == "按单" || strFinanceBillNo.IndexOf("EB16") == -1)
                {
                    #region 按单

                    //按单的物料,放置在正式库的平面库区
                    dtWareLocator = wareLocatorBB.GetVList("wareSortNo='A' and wareType='03' and isUsing=0 and isDel=0").Tables[0];
                    if (dtWareLocator.Rows.Count > 0)
                    {
                        strWareLocatorNo = dtWareLocator.Rows[0]["wareNo"].ToString() + ","
                            + dtWareLocator.Rows[0]["wareLocatorNo"].ToString();//库位
                    }

                    #endregion 按单
                }
                else if (strFinanceBillSort == "备货" || strFinanceBillNo.IndexOf("EB16") != -1)
                {
                    #region 备货

                    string strMaterialNos = "", strUCodeNos = "", strWareSortNos = "B";
                    int materialNum = 1;
                    DataTable dtMaterial = new DataTable();

                    //判断当前托盘是否存在多个物料
                    strMaterialNos = dtArrangeBillBox.Rows[0]["materialNo"].ToString();//物料编号
                    strUCodeNos = dtArrangeBillBox.Rows[0]["U_CodeNo"].ToString();//物料U_CodeNo
                    foreach (DataRow row in dtArrangeBillBox.Rows)
                    {
                        if (strMaterialNos.IndexOf(row["materialNo"].ToString()) == -1)
                        {
                            materialNum++;
                            strMaterialNos += "," + row["materialNo"].ToString();//物料编号
                        }

                        if (strUCodeNos.IndexOf(row["U_CodeNo"].ToString()) == -1)
                        {
                            strUCodeNos += "," + row["U_CodeNo"].ToString();//物料U_CodeNo
                        }
                    }

                    if (materialNum == 1)//托盘上只有一种物料
                    {
                        dtMaterial = materialBB.GetList("materialNo='" + strMaterialNos + "'").Tables[0];//获取物料信息
                        strWareSortNos = dtMaterial.Rows[0]["wareSortNo"].ToString();//获取物料的货位分类
                    }
                    else
                    {
                        foreach (DataRow row in dtArrangeBillBox.Rows)
                        {
                            dtMaterial = materialBB.GetList("materialNo='" + row["materialNo"].ToString() + "'").Tables[0];//获取物料信息
                            if (dtMaterial.Rows[0]["wareSortNo"].ToString() != "B")//查找货位分类为非高位货架所有类别
                            {
                                if (strWareSortNos == "B")//如果当前类型为高位货架
                                {
                                    strWareSortNos = dtMaterial.Rows[0]["wareSortNo"].ToString();//货架分类赋新值
                                }
                                else
                                {
                                    if (strWareSortNos.IndexOf(dtMaterial.Rows[0]["wareSortNo"].ToString()) == -1)
                                    {
                                        strWareSortNos += "," + dtMaterial.Rows[0]["wareSortNo"].ToString();
                                    }
                                }
                            }
                        }
                    }

                    if (strWareSortNos == "D" || strWareSortNos == "E")//流利货架摆放不分库位,推荐到库区即可
                    {
                        //获取推荐库区信息
                        dtWare = wareBB.GetVList("wareSortNo='" + strWareSortNos + "' and wareType='03' and isDel=0").Tables[0];
                        if (dtWare.Rows.Count > 0)
                        {
                            strWareLocatorNo = dtWare.Rows[0]["wareNo"].ToString() + ",";//库区
                        }
                    }
                    else//其他货架,推荐到库位
                    {
                        //获取推荐库位信息
                        dtWareLocator = commBB.Query("exec Proc_GetSuggestWareLocator '" + strWareSortNos.Trim(',')
                            + "','" + strUCodeNos.Trim(',') + "','" + strMaterialNos.Trim(',') + "'").Tables[0];
                        if (dtWareLocator.Rows.Count > 0)
                        {
                            strWareLocatorNo = dtWareLocator.Rows[0]["wareNo"].ToString() + ","
                                + dtWareLocator.Rows[0]["wareLocatorNo"].ToString();//库位
                        }
                    }

                    #endregion 备货
                }
            }
        }
        finally
        {
            arrangeBillBoxBB.Dispose();
            wareBB.Dispose();
            wareLocatorBB.Dispose();
            materialBB.Dispose();
            commBB.Dispose();
        }

        return strWareLocatorNo;
    }
    /// <summary>
    /// 数据保存
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string strInfo = "";

        if (!this.ValidateData(out strInfo))
        {
            strInfo = strInfo.Replace("\"", "'").Replace("\n", "");
            this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + strInfo + "');", true);
            return;
        }

        LWareLocatorData model = new LWareLocatorData();
        LWareLocatorBB wareLocatorBB = new LWareLocatorBB();

        try
        {
            if (this.State == "1")
            {
                this.SetModel(ref model);
                model.isrtDt = DateTime.Now.ToString();
                model.isrtEmpId = this.currentUser.empId;
                this.IdValue = wareLocatorBB.AddRecord(model);
            }
            else if (this.State == "2")
            {
                model = wareLocatorBB.GetModel(this.IdValue);
                this.SetModel(ref model);
                model.updtDt = DateTime.Now.ToString();
                model.updtEmpId = this.currentUser.empId;
                wareLocatorBB.ModifyRecord(model);
            }
        }
        catch (Exception ex)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
            return;
        }
        finally
        {
            wareLocatorBB.Dispose();
        }

        if (Request.Params["backurl"] != null && Request.Params["backurl"].Trim() != "")
        {
            Response.Redirect(Request.Params["backurl"], true);
        }
    }
    /// <summary>
    /// 验证页面信息
    /// </summary>
    /// <param name="strErrorInfo">错误提示信息</param>
    /// <returns></returns>
    private bool ValidateData(out string strErrorInfo)
    {
        LWareLocatorBB wareLocatorBB = new LWareLocatorBB();

        try
        {
            strErrorInfo = "";
            DataSet ds = new DataSet();

            if (this.tbWareLocatorNo.Text.Trim() == "")
            {
                strErrorInfo = "请首先填写库位编码!";
                this.tbWareLocatorNo.Focus();
                return false;
            }

            //判断库区编码是否重复
            ds = wareLocatorBB.GetList("wareNo='" + this.tbWareLocatorNo.Text.Trim().Replace("'", "''") + "' and id<>" + this.IdValue.ToString());
            if (ds.Tables[0].Rows.Count > 0)
            {
                strErrorInfo = "库位编码重复!";
                this.tbWareLocatorNo.Focus();
                return false;
            }

            if (this.tbWareLocatorNm.Text.Trim() == "")
            {
                strErrorInfo = "请首先填写库位名称!";
                this.tbWareLocatorNm.Focus();
                return false;
            }

            if (this.ddlWare.SelectedValue == "")
            {
                strErrorInfo = "请首先选择库区!";
                this.ddlWare.Focus();
                return false;
            }

            if (this.tbMaxBoxNum.Text.Trim() != "" && !CommFunction.IsInt(this.tbMaxBoxNum.Text.Trim()))
            {
                strErrorInfo = "最多放置箱数不是正确的数字类型!";
                this.tbMaxBoxNum.Focus();
                return false;
            }

            return true;
        }
        finally
        {
            wareLocatorBB.Dispose();
        }
    }
    /// <summary>
    /// 展示数据
    /// </summary>
    /// <param name="id">记录Id</param>
    private void ShowInfo(int id)
    {
        LWareLocatorBB wareLocatorBB = new LWareLocatorBB();
        vLWareLocatorData model = new vLWareLocatorData();
        try
        {
            model = wareLocatorBB.GetVModel(id);
            this.tbWareLocatorNo.Text = model.wareLocatorNo;
            this.tbWareLocatorNm.Text = model.wareLocatorNm;
            this.ddlWare.SelectedValue = model.wareNo;
            this.ddlIsBoard.SelectedValue = model.isBoard.ToString();

            if (model.maxBoxNum != 0)
            {
                this.tbMaxBoxNum.Text = model.maxBoxNum.ToString();
            }

            this.ddlDownWareLocator.SelectedValue = model.downWareLocatorNo;
            this.ddlReturnWareLocator.SelectedValue = model.returnWareLocatorNo;
            this.hidMaterialNo.Value = model.materialNo;
            this.textMaterialDesc.Value = model.materialDesc;
        }
        finally
        {
            wareLocatorBB.Dispose();
        }
    }