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

        try
        {
            string strWhere = " 1=1 ";

            if (this.txtNo.Text.Trim() != "")
            {
                strWhere += " and materialNo like '%" + this.txtNo.Text.Replace("'", "''") + "%' ";
            }

            if (this.txtNm.Text.Trim() != "")
            {
                strWhere += " and materialDesc like '%" + this.txtNm.Text.Replace("'", "''") + "%' ";
            }

            ds = materialBB.GetList(strWhere);
            this.grvMateriel.DataSource = ds.Tables[0];
            this.grvMateriel.DataBind();
        }
        finally
        {
            materialBB.Dispose();
        }
    }
    protected void BindGrid()
    {
        using (LMaterialBB bb = new LMaterialBB())
        {
            string strwhere = " 1=1 ";
            if (!string.IsNullOrEmpty(txtMaterialno.Text))
            {
                strwhere += "  and materialNo like '%" + txtMaterialno.Text + "%'";
            }

            if (!string.IsNullOrEmpty(txtMaterialnm.Text))
            {
                strwhere += "  and materialDesc like '%" + txtMaterialnm.Text + "%'";
            }
            DataSet ds = bb.GetList(strwhere);
            grid.DataSource = ds;
            grid.DataBind();
        }
    }
    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;
    }
    public DataTable GetMaterial(string strMaterialNo)
    {
        LMaterialBB materialBB = new LMaterialBB();

        try
        {
            DataTable dt = new DataTable();

            dt = materialBB.GetList("materialNo='" + strMaterialNo + "'").Tables[0];
            return dt;
        }
        finally
        {
            materialBB.Dispose();
        }
    }