/// <summary>
    /// 显示销售订单信息
    /// </summary>
    private void ShowInfo()
    {
        OtherOutInBillBB otherOutInBill = new OtherOutInBillBB();
        OtherOutInDetailBB otherOutInDetailBill = new OtherOutInDetailBB();

        try
        {
            string id = Request.Params["id"];
            vOtherOutInBillData otherOutInBIllData = otherOutInBill.GetVModel(Convert.ToInt32(id));
            DataSet ds = new DataSet();

            //this.saleBillNo.Text = saleBillModel.saleBillNo;
            //this.saleBillDt.Text = Convert.ToDateTime(saleBillModel.saleBillDt).ToString("yyyy-MM-dd");
            //this.custNo.Text = saleBillModel.custNo;
            //this.custNm.Text = saleBillModel.custNm;
            //this.saleEmpNo.Text = saleBillModel.saleEmpNo;
           // this.saleBillType.Text = saleBillModel.saleBillType;
            this.mark.Text = otherOutInBIllData.Mark;

            //根据提货单号、销售订单号、采购合同号,查找销售订单明细
            ds = otherOutInDetailBill.GetVList("SAPDocEntry = '"+otherOutInBIllData.SAPDocEntry+"'");

            if (ds != null && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
            {
                this.grid.DataSource = ds;
                this.grid.DataBind();
            }
        }
        finally
        {
            otherOutInBill.Dispose();
            otherOutInDetailBill.Dispose();
        }
    }
    private void BindSaleBiil()
    {
        OtherOutInBillBB otherOutInBill = new OtherOutInBillBB();
        OtherOutInDetailBB otherOutInDetailBill = new OtherOutInDetailBB();

        try
        {

            string id = Request.Params["id"];
            vOtherOutInBillData otherOutInBIllData = otherOutInBill.GetVModel(Convert.ToInt32(id));
            string SAPDocEntry = otherOutInBIllData.SAPDocEntry;
            DataSet ds = new DataSet();
            ds = otherOutInDetailBill.GetVList("SAPDocEntry = " + SAPDocEntry + " and BoxNumber>0");
            if (ds != null && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
            {
                DtResult = ds.Tables[0];
                this.gridSaleBill.DataSource = ds;
                this.gridSaleBill.DataBind();
            }
        }
        finally
        {
            otherOutInBill.Dispose();
            otherOutInDetailBill.Dispose();
        }
    }
    protected void btnPlan_click(object sender, EventArgs e)
    {
        //首先要查看是否有选中的物料 如果没有选中物料 提示 并且返回
        //Response.Write(this.gridSaleBill.Rows.Count.ToString());
        string ids = "";
        foreach (GridViewRow gvrow in this.gridSaleBill.Rows)
        {
            CheckBox chkId = (CheckBox)gvrow.FindControl("chkId");

            if (chkId.Checked == true)
            {
                string id = this.gridSaleBill.DataKeys[gvrow.RowIndex].Values["id"].ToString();
                ids += id + ",";//使用逗号将数据进行处理
            }

        }
        if (ids == "")
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"没有选中任何销售物料\");", true);
            return;
        }
        else
        {

            DtResultNew.Rows.Clear();//将所有的行删除掉 用来解决数据不断重复往上加的问题
            string rowFilterString = "";
            string[] idChoose = ids.Split(',');//将id取出来
            for (int i = 0; i < idChoose.Length - 1; i++)
            {
                rowFilterString += "id = " + idChoose[i] + " or ";
            }

            DtResult.DefaultView.RowFilter = rowFilterString.Remove(rowFilterString.Length - 3, 2);
            DtResultCondtion = DtResult.DefaultView.ToTable();
        }
        //首先是遍历全部的数据
        //生成相应的CpickOutPlan
        //显示出来
        UStockBB stockBB = new UStockBB();
        LMaterialRelationBB materialRelationBB = new LMaterialRelationBB();
        OtherOutInDetailBB otherOutInDetailBB = new OtherOutInDetailBB();
        LMaterialBB materialBB = new LMaterialBB();
        DataSet dsStock = new DataSet();

        DataRow[] drsStock = null;

        foreach (DataRow drStockUpDetail in DtResultCondtion.Rows)
        {
            int needCount = Convert.ToInt32(drStockUpDetail["Number"]);
            string strLineNum = drStockUpDetail["lineNumber"].ToString();//行号
            string strDocEntry = drStockUpDetail["SAPdocEntry"].ToString();//销售订单ID
            string strMaterialNo = drStockUpDetail["MaterialNo"].ToString();
            string U_PCNo = drStockUpDetail["U_PCNo"].ToString();//增加采购合同号

            if (string.IsNullOrEmpty(U_PCNo))
            {
                //找到仓库内的同种物料所在的库位以及数量
                //首先是判断同一个库位下的信息是否能够满足所有的需求
                //不带采购合同号
                dsStock = stockBB.GetVListByGroupOtherWithOutFinanceBillNo("stock.financeBillSortNo='02' and stock.isOutStocking=0 and stock.wareLocatorNo<>''");
                if (dsStock.Tables[0].Rows.Count > 0)
                {
                    drsStock = dsStock.Tables[0].Select("materialno='" + strMaterialNo
                        + "' and num>=" + needCount.ToString());
                }
            }
            else
            {
                //带采购合同号
                dsStock = stockBB.GetVListByGroupOtherWithFinanceBillNo("stock.financeBillSortNo='02' and stock.isOutStocking=0 and stock.wareLocatorNo<>''");
                if (dsStock.Tables[0].Rows.Count > 0)
                {
                    drsStock = dsStock.Tables[0].Select("materialno='" + strMaterialNo
                       + "' and num>=" + needCount.ToString() + " and financeBillNo='" + U_PCNo + "'");
                }
            }

            if (drsStock.Length == 0)
            {
                if (string.IsNullOrEmpty(U_PCNo))
                {
                    dsStock = stockBB.GetVListByGroupOtherWithOutFinanceBillNo("stock.financeBillSortNo='02' and stock.isOutStocking=0 and stock.wareLocatorNo<>''");
                    if (dsStock.Tables[0].Rows.Count > 0)
                        drsStock = dsStock.Tables[0].Select("materialno='" + strMaterialNo + "' and num>0");
                }
                else
                {
                    dsStock = stockBB.GetVListByGroupOtherWithFinanceBillNo("stock.financeBillSortNo='02' and stock.isOutStocking=0 and stock.wareLocatorNo<>''");
                    if (dsStock.Tables[0].Rows.Count > 0)
                        drsStock = dsStock.Tables[0].Select("materialno='" + strMaterialNo
                        + "' and num>0 and financeBillNo='" + U_PCNo + "'");
                }
            }
            while (needCount > 0)
            {
                #region 原物料拣货

                //2015-08-24修改 在此处增加采购合同号的判断

                if (string.IsNullOrEmpty(U_PCNo))
                {
                    //找到仓库内的同种物料所在的库位以及数量
                    //首先是判断同一个库位下的信息是否能够满足所有的需求
                    //不带采购合同号

                    if (dsStock.Tables[0].Rows.Count > 0)
                    {
                        drsStock = dsStock.Tables[0].Select("materialno='" + strMaterialNo
                            + "' and num>=" + needCount.ToString());
                    }
                }
                else
                {
                    //带采购合同号

                    if (dsStock.Tables[0].Rows.Count > 0)
                    {
                        drsStock = dsStock.Tables[0].Select("materialno='" + strMaterialNo
                           + "' and num>=" + needCount.ToString() + " and financeBillNo='" + U_PCNo + "'");
                    }
                }

                if (drsStock.Length == 0)
                {
                    if (string.IsNullOrEmpty(U_PCNo))
                    {

                        if (dsStock.Tables[0].Rows.Count > 0)
                            drsStock = dsStock.Tables[0].Select("materialno='" + strMaterialNo + "' and num>0");
                    }
                    else
                    {

                        if (dsStock.Tables[0].Rows.Count > 0)
                            drsStock = dsStock.Tables[0].Select("materialno='" + strMaterialNo
                            + "' and num>0 and financeBillNo='" + U_PCNo + "'");
                    }
                }

                if (drsStock.Length > 0)
                {
                    //当前库位所拥有该物料的数量
                    int haveCount = Convert.ToInt32(drsStock[0]["num"]);

                    //如果当前库位的物料数量大于备货单所需数量,就保存当前库位
                    DataRow drnew = this.DtResultNew.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"] = "1";
                    drnew["wareNo"] = drsStock[0]["wareNo"];
                    drnew["wareLocatorNo"] = drsStock[0]["wareLocatorNo"];
                    drnew["palletNo"] = drsStock[0]["palletNo"];
                    drnew["stockUpMaterialNo"] = strMaterialNo;//备货物料编号
                    drnew["materialNo"] = drsStock[0]["materialNo"];//实际拣货物料编号
                    drnew["instantState"] = "01";
                    drnew["financeBillNo"] = U_PCNo;
                    drnew["docEntry"] = strDocEntry;//销售订单ID
                    drnew["lineNum"] = strLineNum;//行号
                    drnew["isDel"] = false;
                    this.DtResultNew.Rows.Add(drnew);
                    drStockUpDetail["number"] = needCount;//重新赋值拣货数量
                }
                else
                {
                    needCount = 0;
                    // break;
                }

                #endregion 原物料拣货
            }
        }

        OtherOutInBillBB otherOutInBill = new OtherOutInBillBB();
        OtherOutInDetailBB otherOutInDetailBill = new OtherOutInDetailBB();
        string id2 = Request.Params["id"];
        vOtherOutInBillData otherOutInBIllData = otherOutInBill.GetVModel(Convert.ToInt32(id2));
        string SAPDocEntry = otherOutInBIllData.SAPDocEntry;
        string strInfo = "";
        foreach (DataRow otherOutInBillRow in DtResultCondtion.Rows)
        {
            int planNum = 0;
            int factNum = 0;
            DataRow[] myDataRowArray = null;
            if (!string.IsNullOrEmpty(otherOutInBillRow["U_PCNo"].ToString()))
            {
                myDataRowArray = DtResultCondtion.Select("materialNo='"
                    + otherOutInBillRow["materialNo"].ToString() + "' and U_PCNo = '" + otherOutInBillRow["U_PCNo"] + "'");
            }
            else
            {
                myDataRowArray = DtResultCondtion.Select("materialNo='"
                       + otherOutInBillRow["materialNo"].ToString() + "'");
            }
            foreach (DataRow row in myDataRowArray)
            {
                planNum += Convert.ToInt32(row["hadNum"]);
            }
            if (!string.IsNullOrEmpty(otherOutInBillRow["U_PCNo"].ToString()))
            {
                myDataRowArray = this.DtResultNew.Select("materialNo=stockupmaterialNo and materialNo='"
                   + otherOutInBillRow["materialNo"].ToString() + "'and financeBillNo = '" + otherOutInBillRow["U_PCNo"] + "'");
            }
            else
            {
                myDataRowArray = this.DtResultNew.Select("materialNo=stockupmaterialNo and materialNo='"
                   + otherOutInBillRow["materialNo"].ToString() + "'");
            }
            foreach (DataRow row in myDataRowArray)
            {
                factNum += Convert.ToInt32(row["num"]);
            }

            if (planNum != factNum)
            {
                strInfo += "物料【" + otherOutInBillRow["materialNo"].ToString() + "】,计划拣货【"
                    + planNum.ToString() + "】件,实际拣货【" + factNum.ToString() + "】件;";
                btnSubmit.Enabled = false;
            }
        }
        if (strInfo != "")
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"当前未完成拣货,不允许保存!提示信息:" + strInfo + "\");", true);
            btnSubmit.Enabled = false;
        }
        BindGridPickOutPlan();
        //}
    }