/// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model">model</param>
        public bool ModifyRecord(CPickOutPlanData model)
        {
            bool ret = false;
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update CPickOutPlan set ");
            strSql.Append("stockUpBillNo=@stockUpBillNo,");
            strSql.Append("palletIndex=@palletIndex,");
            strSql.Append("wareNo=@wareNo,");
            strSql.Append("wareLocatorNo=@wareLocatorNo,");
            strSql.Append("palletNo=@palletNo,");
            strSql.Append("stockUpMaterialNo=@stockUpMaterialNo,");
            strSql.Append("materialNo=@materialNo,");
            strSql.Append("num=@num,");
            strSql.Append("pickOutEmpId=@pickOutEmpId,");
            strSql.Append("pickOutDt=@pickOutDt,");
            strSql.Append("instantState=@instantState,");
            strSql.Append("financeBillNo=@financeBillNo,");
            strSql.Append("financeBillSort=@financeBillSort,");
            strSql.Append("isSAPOutStock=@isSAPOutStock,");
            strSql.Append("isSapInStock=@isSapInStock,");
            strSql.Append("isrtEmpId=@isrtEmpId,");
            strSql.Append("isrtDt=@isrtDt,");
            strSql.Append("saleBillNo=@saleBillNo,");
            strSql.Append("absEntry=@absEntry,");
            strSql.Append("lineNum=@lineNum,");
            strSql.Append("DocEntry=@DocEntry");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int),
                    new SqlParameter("@stockUpBillNo", SqlDbType.VarChar,20),
                    new SqlParameter("@palletIndex", SqlDbType.Int),
                    new SqlParameter("@wareNo", SqlDbType.VarChar,20),
                    new SqlParameter("@wareLocatorNo", SqlDbType.VarChar,20),
                    new SqlParameter("@palletNo", SqlDbType.VarChar,20),
                    new SqlParameter("@stockUpMaterialNo", SqlDbType.VarChar,20),
                    new SqlParameter("@materialNo", SqlDbType.VarChar,20),
                    new SqlParameter("@num", SqlDbType.Float),
                    new SqlParameter("@pickOutEmpId", SqlDbType.Int),
                    new SqlParameter("@pickOutDt", SqlDbType.DateTime),
                    new SqlParameter("@instantState", SqlDbType.VarChar,10),
                    new SqlParameter("@financeBillNo", SqlDbType.VarChar,20),
                    new SqlParameter("@financeBillSort", SqlDbType.NVarChar,20),
                    new SqlParameter("@isSAPOutStock", SqlDbType.Bit),
                    new SqlParameter("@isSapInStock", SqlDbType.Bit),
                    new SqlParameter("@isrtEmpId", SqlDbType.Int),
                    new SqlParameter("@isrtDt", SqlDbType.DateTime),
                    new SqlParameter("@saleBillNo", SqlDbType.VarChar,20),
                    new SqlParameter("@absEntry", SqlDbType.Int),
                    new SqlParameter("@lineNum", SqlDbType.Int),
                    new SqlParameter("@DocEntry", SqlDbType.Int)
                };
            parameters[0].Value = model.id;
            parameters[1].Value = model.stockUpBillNo;
            parameters[2].Value = model.palletIndex;
            parameters[3].Value = model.wareNo;
            parameters[4].Value = model.wareLocatorNo;
            parameters[5].Value = model.palletNo;
            parameters[6].Value = model.stockUpMaterialNo;
            parameters[7].Value = model.materialNo;
            parameters[8].Value = model.num;
            parameters[9].Value = model.pickOutEmpId;
            parameters[10].Value = model.pickOutDt == string.Empty ? null : model.pickOutDt;
            parameters[11].Value = model.instantState;
            parameters[12].Value = model.financeBillNo;
            parameters[13].Value = model.financeBillSort;
            parameters[14].Value = model.isSAPOutStock;
            parameters[15].Value = model.isSapInStock;
            parameters[16].Value = model.isrtEmpId;
            parameters[17].Value = model.isrtDt == string.Empty ? null : model.isrtDt;
            parameters[18].Value = model.saleBillNo;
            parameters[19].Value = model.absEntry;
            parameters[20].Value = model.lineNum;
            parameters[21].Value = model.DocEntry;

            try
            {
                SqlHelper.ExecuteNonQuery(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);
                ret = true;

            }
            catch (Exception ex)
            {
                throw ex;
            }

            return ret;
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(CPickOutPlanData model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("set nocount on; ");
            strSql.Append("insert into CPickOutPlan(");
            strSql.Append(@"stockUpBillNo,palletIndex,wareNo,wareLocatorNo,palletNo,stockUpMaterialNo,materialNo,num,pickOutEmpId,pickOutDt,
                            instantState,financeBillNo,financeBillSort,isSAPOutStock,isSapInStock,isrtEmpId,isrtDt,saleBillNo,absEntry,lineNum,
                            DocEntry)");
            strSql.Append(" values (");
            strSql.Append(@"@stockUpBillNo,@palletIndex,@wareNo,@wareLocatorNo,@palletNo,@stockUpMaterialNo,@materialNo,@num,@pickOutEmpId,@pickOutDt,
                            @instantState,@financeBillNo,@financeBillSort,@isSAPOutStock,@isSapInStock,@isrtEmpId,@isrtDt,@saleBillNo,@absEntry,@lineNum,
                            @DocEntry)");
            strSql.Append("; select @@identity; set nocount off; ");
            SqlParameter[] parameters = {
                    new SqlParameter("@stockUpBillNo", SqlDbType.VarChar,20),
                    new SqlParameter("@palletIndex", SqlDbType.Int),
                    new SqlParameter("@wareNo", SqlDbType.VarChar,20),
                    new SqlParameter("@wareLocatorNo", SqlDbType.VarChar,20),
                    new SqlParameter("@palletNo", SqlDbType.VarChar,20),
                    new SqlParameter("@stockUpMaterialNo", SqlDbType.VarChar,20),
                    new SqlParameter("@materialNo", SqlDbType.VarChar,20),
                    new SqlParameter("@num", SqlDbType.Float),
                    new SqlParameter("@pickOutEmpId", SqlDbType.Int),
                    new SqlParameter("@pickOutDt", SqlDbType.DateTime),
                    new SqlParameter("@instantState", SqlDbType.VarChar,10),
                    new SqlParameter("@financeBillNo", SqlDbType.VarChar,20),
                    new SqlParameter("@financeBillSort", SqlDbType.NVarChar,20),
                    new SqlParameter("@isSAPOutStock", SqlDbType.Bit),
                    new SqlParameter("@isSapInStock", SqlDbType.Bit),
                    new SqlParameter("@isrtEmpId", SqlDbType.Int),
                    new SqlParameter("@isrtDt", SqlDbType.DateTime),
                    new SqlParameter("@saleBillNo", SqlDbType.VarChar,20),
                    new SqlParameter("@absEntry", SqlDbType.Int),
                    new SqlParameter("@lineNum", SqlDbType.Int),
                    new SqlParameter("@DocEntry", SqlDbType.Int)
                };
            parameters[0].Value = model.stockUpBillNo;
            parameters[1].Value = model.palletIndex;
            parameters[2].Value = model.wareNo;
            parameters[3].Value = model.wareLocatorNo;
            parameters[4].Value = model.palletNo;
            parameters[5].Value = model.stockUpMaterialNo;
            parameters[6].Value = model.materialNo;
            parameters[7].Value = model.num;
            parameters[8].Value = model.pickOutEmpId;
            parameters[9].Value = model.pickOutDt == string.Empty ? null : model.pickOutDt;
            parameters[10].Value = model.instantState;
            parameters[11].Value = model.financeBillNo;
            parameters[12].Value = model.financeBillSort;
            parameters[13].Value = model.isSAPOutStock;
            parameters[14].Value = model.isSapInStock;
            parameters[15].Value = model.isrtEmpId;
            parameters[16].Value = model.isrtDt == string.Empty ? null : model.isrtDt;
            parameters[17].Value = model.saleBillNo;
            parameters[18].Value = model.absEntry;
            parameters[19].Value = model.lineNum;
            parameters[20].Value = model.DocEntry;

            int id = 0;
            try
            {
                object ret = SqlHelper.ExecuteScalar(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);

                if (ret != null && ret != DBNull.Value)
                {
                    id = Convert.ToInt32(ret);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return id;
        }
 /// <summary>
 /// 更新一条数据
 /// </summary>
 /// <param name="model">model</param>
 public bool ModifyRecord(CPickOutPlanData model)
 {
     return this.pickOutPlanDB.ModifyRecord(model);
 }
        /// <summary>
        /// 得到一个model
        /// </summary>
        /// <param name="id">主键值</param>
        /// <returns>model</returns>
        public CPickOutPlanData GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(@"select id,stockUpBillNo,palletIndex,wareNo,wareLocatorNo,palletNo,stockUpMaterialNo,materialNo,num,pickOutEmpId,pickOutDt,
                            instantState,financeBillNo,financeBillSort,isSAPOutStock,isSapInStock,isrtEmpId,isrtDt,saleBillNo,absEntry,lineNum,
                            DocEntry from CPickOutPlan");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int)
                };
            parameters[0].Value = id;

            CPickOutPlanData model = new CPickOutPlanData();
            DataSet ds = SqlHelper.ExecuteDataset(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                DataRow row = ds.Tables[0].Rows[0];
                if (row["id"] != DBNull.Value)
                {
                    model.id = Convert.ToInt32(row["id"]);
                }
                if (row["stockUpBillNo"] != DBNull.Value)
                {
                    model.stockUpBillNo = Convert.ToString(row["stockUpBillNo"]);
                }
                if (row["palletIndex"] != DBNull.Value)
                {
                    model.palletIndex = Convert.ToInt32(row["palletIndex"]);
                }
                if (row["wareNo"] != DBNull.Value)
                {
                    model.wareNo = Convert.ToString(row["wareNo"]);
                }
                if (row["wareLocatorNo"] != DBNull.Value)
                {
                    model.wareLocatorNo = Convert.ToString(row["wareLocatorNo"]);
                }
                if (row["palletNo"] != DBNull.Value)
                {
                    model.palletNo = Convert.ToString(row["palletNo"]);
                }
                if (row["stockUpMaterialNo"] != DBNull.Value)
                {
                    model.stockUpMaterialNo = Convert.ToString(row["stockUpMaterialNo"]);
                }
                if (row["materialNo"] != DBNull.Value)
                {
                    model.materialNo = Convert.ToString(row["materialNo"]);
                }
                if (row["num"] != DBNull.Value)
                {
                    model.num = Convert.ToDouble(row["num"]);
                }
                if (row["pickOutEmpId"] != DBNull.Value)
                {
                    model.pickOutEmpId = Convert.ToInt32(row["pickOutEmpId"]);
                }
                if (row["pickOutDt"] != DBNull.Value)
                {
                    model.pickOutDt = Convert.ToString(row["pickOutDt"]);
                }
                if (row["instantState"] != DBNull.Value)
                {
                    model.instantState = Convert.ToString(row["instantState"]);
                }
                if (row["financeBillNo"] != DBNull.Value)
                {
                    model.financeBillNo = Convert.ToString(row["financeBillNo"]);
                }
                if (row["financeBillSort"] != DBNull.Value)
                {
                    model.financeBillSort = Convert.ToString(row["financeBillSort"]);
                }
                if (row["isSAPOutStock"] != DBNull.Value)
                {
                    model.isSAPOutStock = Convert.ToBoolean(row["isSAPOutStock"]);
                }
                if (row["isSapInStock"] != DBNull.Value)
                {
                    model.isSapInStock = Convert.ToBoolean(row["isSapInStock"]);
                }
                if (row["isrtEmpId"] != DBNull.Value)
                {
                    model.isrtEmpId = Convert.ToInt32(row["isrtEmpId"]);
                }
                if (row["isrtDt"] != DBNull.Value)
                {
                    model.isrtDt = Convert.ToString(row["isrtDt"]);
                }
                if (row["saleBillNo"] != DBNull.Value)
                {
                    model.saleBillNo = Convert.ToString(row["saleBillNo"]);
                }
                if (row["absEntry"] != DBNull.Value)
                {
                    model.absEntry = Convert.ToInt32(row["absEntry"]);
                }
                if (row["lineNum"] != DBNull.Value)
                {
                    model.lineNum = Convert.ToInt32(row["lineNum"]);
                }
                if (row["DocEntry"] != DBNull.Value)
                {
                    model.DocEntry = Convert.ToInt32(row["DocEntry"]);
                }
                return model;
            }
            else
            {
                return null;
            }
        }
    public void FinishPickOutPlan(int pickOutPlanId, int pickOutEmpId)
    {
        CPickOutPlanBB pickOutPlanBB = new CPickOutPlanBB();
        SCommBB commBB = new SCommBB();

        try
        {

            StringBuilder strSql = new StringBuilder();
            CPickOutPlanData pickOutPlanModel = new CPickOutPlanData();

            pickOutPlanModel = pickOutPlanBB.GetModel(pickOutPlanId);

            pickOutPlanModel.pickOutDt = System.DateTime.Now.ToString();//拣货时间
            pickOutPlanModel.pickOutEmpId = pickOutEmpId;//拣货人
            pickOutPlanModel.instantState = "03";//已完成

            pickOutPlanBB.ModifyRecord(pickOutPlanModel);

            ////解除库位的锁定
            //strSql.Append(@"update dbo.UStock set isOutStocking=0 where wareLocatorNo='" + pickOutPlanModel.wareLocatorNo
            //    + "' and materialNo='" + pickOutPlanModel.materialNo + "'and isOutStocking=1");
            //commBB.ExecuteSql(strSql.ToString());

            ////更改原箱的是否锁定状态
            //strSql = new StringBuilder();
            //strSql.Append("update dbo.BArrangeBillBox set isOutStocking=0 where wareLocatorNo='" + pickOutPlanModel.wareLocatorNo
            //    + "' and materialNo='" + pickOutPlanModel.materialNo + "' and isOutStocking=1");
            //commBB.ExecuteSql(strSql.ToString());
        }
        finally
        {
            pickOutPlanBB.Dispose();
            commBB.Dispose();
        }
    }
 /// <summary>
 /// 增加一条数据
 /// </summary>
 /// <param name="model">model</param>
 public int AddRecord(CPickOutPlanData model)
 {
     return this.pickOutPlanDB.AddRecord(model);
 }
        /// <summary>
        /// 保存备货计划
        /// </summary>
        /// <param name="dtPlan">备货计划数据源</param>
        /// <param name="strStockUpBillNo">备货单编号</param>
        /// <param name="issubmit">是否提交</param>
        /// <returns></returns>
        public bool SavePickOutPlanBill(DataTable dtPlan, string strStockUpBillNo, bool issubmit)
        {
            bool ret = false;
            UStockBB stockBB = new UStockBB(this.connection);
            SCommBB commBB = new SCommBB(this.connection);
            SqlTransaction trans = null;

            try
            {
                if (this.transaction == null)
                {
                    trans = this.connection.BeginTransaction("TranSave");
                    this.pickOutPlanBB.Transaction = trans;
                    stockBB.Transaction = trans;
                    commBB.Transaction = trans;
                }
                else
                {
                    this.pickOutPlanBB.Transaction = this.transaction;
                    stockBB.Transaction = this.transaction;
                    commBB.Transaction = this.transaction;
                }

                CPickOutPlanData pickOutPlanModel = new CPickOutPlanData();

                #region 逐条保存拣货计划

                //逐条保存拣货计划
                foreach (DataRow dr in dtPlan.Rows)
                {
                    string strWareLocatorNo = "", strFinanceBillNo = "", strMaterialNo = "", strWhere = "", strSql = "";
                    float num = 0;
                    DataTable dtStock = new DataTable();

                    strWareLocatorNo = dr["wareLocatorNo"].ToString();//库位
                    strFinanceBillNo = dr["financeBillNo"].ToString();//采购合同号
                    strMaterialNo = dr["materialNo"].ToString();//物料编号
                    num = Convert.ToSingle(dr["num"]);//数量

                    if (Convert.ToBoolean(dr["isDel"]) == true && Convert.ToInt32(dr["id"]) > 0)
                    {
                        //前期生成拣货计划,现在删除,处理逻辑:删除拣货计划,解除物料箱锁定

                        //删除拣货计划
                        pickOutPlanBB.DeleteRecord(Convert.ToInt32(dr["id"]));

                        #region 解除物料箱锁定

                        ////查询库存
                        //strWhere = "isOutStocking=1 and checkResult=1 and wareLocatorNo='" + strWareLocatorNo
                        //    + "' and materialNo='" + strMaterialNo + "' and num>0";

                        //if (strFinanceBillNo != "")
                        //{
                        //    strWhere += " and financeBillNo='" + strFinanceBillNo + "'";
                        //}

                        //dtStock = stockBB.GetVList(strWhere).Tables[0];

                        //foreach (DataRow row in dtStock.Rows)
                        //{
                        //    int stockId = 0;//库存ID
                        //    float stockNum = 0;//库存数量
                        //    string strBoxNo = "";//箱号

                        //    stockId = Convert.ToInt32(row["id"]);
                        //    stockNum = Convert.ToSingle(row["num"]);//库存数量
                        //    strBoxNo = row["boxNo"].ToString();

                        //    //更改库存锁定状态
                        //    strSql = "update dbo.UStock set isOutStocking=0 where id=" + stockId.ToString();
                        //    commBB.ExecuteSql(strSql);

                        //    //更改原箱库存锁定状态
                        //    strSql = "update dbo.BArrangeBillBox set isOutStocking=0 where boxNo='" + strBoxNo + "'";
                        //    commBB.ExecuteSql(strSql);

                        //    if (stockNum >= num)
                        //    {
                        //        break;
                        //    }
                        //    else
                        //    {
                        //        num = num - stockNum;
                        //    }
                        //}

                        #endregion 解除物料箱锁定
                    }
                    else if (Convert.ToBoolean(dr["isDel"]) == false && Convert.ToInt32(dr["id"]) == 0)
                    {
                        //前期没有生成拣货计划,现在生成,处理逻辑:添加拣货计划,更改物料箱锁定状态

                        #region 更改物料箱锁定状态

                        ////查询库存
                        //strWhere = "isOutStocking=0 and checkResult=1 and wareLocatorNo='" + strWareLocatorNo
                        //    + "' and materialNo='" + strMaterialNo + "' and num>0";

                        //if (strFinanceBillNo != "")
                        //{
                        //    strWhere += " and financeBillNo='" + strFinanceBillNo + "'";
                        //}

                        //dtStock = stockBB.GetVList(strWhere).Tables[0];

                        //foreach (DataRow row in dtStock.Rows)
                        //{
                        //    int stockId = 0;//库存ID
                        //    float stockNum = 0;//库存数量
                        //    string strBoxNo = "";//箱号

                        //    stockId = Convert.ToInt32(row["id"]);
                        //    stockNum = Convert.ToSingle(row["num"]);//库存数量
                        //    strBoxNo = row["boxNo"].ToString();

                        //    //更改库存锁定状态
                        //    strSql = "update dbo.UStock set isOutStocking=1 where id=" + stockId.ToString();
                        //    commBB.ExecuteSql(strSql);

                        //    //更改原箱库存锁定状态
                        //    strSql = "update dbo.BArrangeBillBox set isOutStocking=1 where boxNo='" + strBoxNo + "'";
                        //    commBB.ExecuteSql(strSql);

                        //    if (stockNum >= num)
                        //    {
                        //        break;
                        //    }
                        //    else
                        //    {
                        //        num = num - stockNum;
                        //    }
                        //}

                        #endregion 更改物料箱锁定状态
                    }

                    #region 保存拣货计划

                    if (Convert.ToInt32(dr["id"]) == 0 && Convert.ToBoolean(dr["isDel"]) == false)
                    {
                        pickOutPlanModel = new CPickOutPlanData();

                        pickOutPlanModel.stockUpBillNo = strStockUpBillNo;
                        pickOutPlanModel.palletIndex = Convert.ToInt32(dr["palletIndex"]);
                        pickOutPlanModel.wareNo = dr["wareNo"].ToString();
                        pickOutPlanModel.wareLocatorNo = dr["wareLocatorNo"].ToString();
                        pickOutPlanModel.palletNo = dr["palletNo"].ToString();
                        pickOutPlanModel.stockUpMaterialNo = dr["stockUpMaterialNo"].ToString();//备货物料
                        pickOutPlanModel.materialNo = dr["materialNo"].ToString();//实际拣货物料
                        pickOutPlanModel.num = Convert.ToInt32(dr["num"]);
                        pickOutPlanModel.financeBillNo = dr["financeBillNo"].ToString();//采购合同号
                        pickOutPlanModel.financeBillSort = dr["financeBillSort"].ToString();//采购合同类型
                        pickOutPlanModel.isrtDt = System.DateTime.Now.ToString();
                        pickOutPlanModel.isrtEmpId = this.empId;
                        pickOutPlanModel.saleBillNo =dr["saleBillNo"].ToString();//销售订单号
                        pickOutPlanModel.DocEntry = Convert.ToInt32(dr["docEntry"]);//销售订单ID
                        pickOutPlanModel.absEntry = Convert.ToInt32(dr["absEntry"]);//提货单号
                        pickOutPlanModel.lineNum = Convert.ToInt32(dr["lineNum"]);//销售订单行号

                        if (issubmit)
                        {
                            pickOutPlanModel.instantState = "02";
                        }
                        else
                        {
                            pickOutPlanModel.instantState = "01";
                        }

                        this.pickOutPlanBB.AddRecord(pickOutPlanModel);
                    }
                    else if (Convert.ToInt32(dr["id"]) > 0 && Convert.ToBoolean(dr["isDel"]) == false)
                    {
                        pickOutPlanModel = this.pickOutPlanBB.GetModel(Convert.ToInt32(dr["id"]));

                        if (issubmit)
                        {
                            pickOutPlanModel.instantState = "02";
                        }
                        else
                        {
                            pickOutPlanModel.instantState = "01";
                        }

                        this.pickOutPlanBB.ModifyRecord(pickOutPlanModel);
                    }

                    #endregion 保存拣货计划
                }

                #endregion 逐条保存拣货计划

                #region 修改备货单状态

                //修改备货单状态
                if (issubmit)
                {
                    commBB.ExecuteSql("update dbo.CStockUpBill set instantState='04' where stockUpBillNo='"
                        + strStockUpBillNo + "'");
                }
                else
                {
                    commBB.ExecuteSql("update dbo.CStockUpBill set instantState='03' where stockUpBillNo='"
                        + strStockUpBillNo + "'");
                }

                #endregion 修改备货单状态

                if (this.transaction == null) trans.Commit();
                ret = true;
            }
            catch
            {
                if (transaction == null) trans.Rollback("TranSave");
                throw new Exception("保存拣货单出错了!");
            }
            finally
            {
                stockBB.Dispose();
                commBB.Dispose();
            }

            return ret;
        }
        //*****************************************************************************
        //do it later      do it later      do it later
        //*****************************************************************************
        /// <summary>
        /// 保存拣货信息
        /// </summary>
        /// <param name="pickOutPlanId">拣货单明细ID</param>
        /// <returns></returns>
        public bool SavePickOutInfo(int pickOutPlanId)
        {
            bool ret = false;
            SqlTransaction trans = null;
            SCommBB commBB = new SCommBB(this.connection);

            try
            {
                if (this.transaction == null)
                {
                    trans = this.connection.BeginTransaction("TransSave");
                    this.pickOutPlanBB.Transaction = trans;
                    commBB.Transaction = trans;
                }
                else
                {
                    this.pickOutPlanBB.Transaction = this.transaction;
                    commBB.Transaction = this.transaction;
                }

                //保存拣货信息
                CPickOutPlanData pickOutPlanModel = new CPickOutPlanData();

                pickOutPlanModel = this.pickOutPlanBB.GetModel(pickOutPlanId);
                pickOutPlanModel.pickOutEmpId = this.empId;//拣货人
                pickOutPlanModel.pickOutDt = System.DateTime.Now.ToString();//拣货时间
                pickOutPlanModel.instantState = "03";//更改状态为“已拣货”

                this.pickOutPlanBB.ModifyRecord(pickOutPlanModel);

                if (this.transaction == null) trans.Commit();
                ret = true;
            }
            catch (Exception ex)
            {
                if (this.transaction == null) trans.Rollback("TransSave");
                throw ex;
            }
            finally
            {
                commBB.Dispose();
            }

            return ret;
        }
        /// <summary>
        /// 更新一条"销售拣货计划"信息
        /// </summary>
        /// <param name="model">model</param>
        public bool ModifyRecord(CPickOutPlanData model)
        {
            bool ret = false;
            SqlTransaction trans = null;
            try
            {
                if (this.transaction == null)
                {
                    trans = this.connection.BeginTransaction("TransModify");
                    this.pickOutPlanBB.Transaction = trans;
                    this.errorDiaryBB.Transaction = trans;
                    this.operatDiaryBB.Transaction = trans;
                }

                this.pickOutPlanBB.ModifyRecord(model);

                SOperatDiaryData operatDiaryData = new SOperatDiaryData();
                operatDiaryData.empId = this.empId;
                operatDiaryData.functionId = "";
                operatDiaryData.recordId = model.id.ToString();
                operatDiaryData.operateContent = "销售拣货计划修改一条id为“" + model.id.ToString() + "”的记录";
                this.operatDiaryBB.AddRecord(operatDiaryData);

                if (this.transaction == null) trans.Commit();
                ret = true;
            }
            catch (Exception ex)
            {
                if (this.transaction == null) trans.Rollback("TransModify");
                SErrorDiaryData errorDiaryData = new SErrorDiaryData();
                errorDiaryData.empId = this.empId;
                errorDiaryData.functionId = "";
                errorDiaryData.errorText = "销售拣货计划修改记录“" + model.id.ToString() + "”时报错:" + ex.Message;
                this.errorDiaryBB.AddRecord(errorDiaryData);
                throw ex;
            }
            finally
            {
            }
            return ret;
        }
        /// <summary>
        /// 增加一条"销售拣货计划"信息
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(CPickOutPlanData model)
        {
            int id = 0;
            SqlTransaction trans = null;
            try
            {
                if (this.transaction == null)
                {
                    trans = this.connection.BeginTransaction("TransAdd");
                    this.pickOutPlanBB.Transaction = trans;
                    this.errorDiaryBB.Transaction = trans;
                    this.operatDiaryBB.Transaction = trans;
                }

                id = this.pickOutPlanBB.AddRecord(model);

                SOperatDiaryData operatDiaryData = new SOperatDiaryData();
                operatDiaryData.empId = this.empId;
                operatDiaryData.functionId = "";
                operatDiaryData.recordId = id.ToString();
                operatDiaryData.operateContent = "销售拣货计划增加一条id为“" + id.ToString() + "”的记录";
                this.operatDiaryBB.AddRecord(operatDiaryData);

                if (this.transaction == null) trans.Commit();
            }
            catch (Exception ex)
            {
                if (this.transaction == null) trans.Rollback("TransAdd");
                SErrorDiaryData errorDiaryData = new SErrorDiaryData();
                errorDiaryData.empId = this.empId;
                errorDiaryData.functionId = "";
                errorDiaryData.errorText = "销售拣货计划增加记录时报错:" + ex.Message;
                this.errorDiaryBB.AddRecord(errorDiaryData);
                throw ex;
            }
            finally
            {
            }
            return id;
        }
Exemple #11
0
        /// <summary>
        /// 保存流利货架箱子拣货信息
        /// </summary>
        /// <param name="pickOutPlanID">拣货计划ID</param>
        /// <param name="strStockUpBillNo">备货单编号</param>
        /// <param name="palletIndex">备货单内托盘序号</param>
        /// <param name="strNewPalletNo">新托盘号</param>
        /// <param name="strOldBoxNo">原箱号</param>
        /// <param name="strNewBoxNo">新箱号</param>
        /// <param name="pickOutNum">拣货数量</param>
        /// <param name="strOperType">操作类型:01 流利货架拣货,02 拆托合托</param>
        /// <returns></returns>
        public bool SavePickOutInfo_DE(int pickOutPlanID, string strStockUpBillNo, int palletIndex, string strNewPalletNo,
            string strOldBoxNo, string strNewBoxNo, int pickOutNum, string strOperType)
        {
            bool ret = false;
            SqlTransaction trans = null;
            SCommBB commBB = new SCommBB(this.connection);
            BArrangeBillBoxBB arrangeBillBoxBB = new BArrangeBillBoxBB(this.connection);
            CDEPickOutBoxBB DEPickOutBoxBB = new CDEPickOutBoxBB(this.connection);
            LMaterialBB materialBB = new LMaterialBB();
            LWareBB wareBB = new LWareBB();
            UStockOutInDetailBB stockOutInDetailBB = new UStockOutInDetailBB(this.connection);
            CPickOutPlanBB pickOutPlanBB = new CPickOutPlanBB();

            try
            {
                if (this.transaction == null)
                {
                    trans = this.connection.BeginTransaction("TranSave");
                    this.stockBB.Transaction = trans;
                    commBB.Transaction = trans;
                    arrangeBillBoxBB.Transaction = trans;
                    DEPickOutBoxBB.Transaction = trans;
                    stockOutInDetailBB.Transaction = trans;
                }
                else
                {
                    this.stockBB.Transaction = this.transaction;
                    commBB.Transaction = this.transaction;
                    arrangeBillBoxBB.Transaction = this.transaction;
                    DEPickOutBoxBB.Transaction = this.transaction;
                    stockOutInDetailBB.Transaction = this.transaction;
                }

                DataTable dtArrangeBillBox = new DataTable();
                DataTable dtPallet = new DataTable();
                DataTable dtMaterial = new DataTable();
                DataTable dtStock = new DataTable();
                CDEPickOutBoxData DEPickOutBoxModel = new CDEPickOutBoxData();
                UStockOutInDetailData stockOutInDetailModel = new UStockOutInDetailData();
                UStockData stockModel = new UStockData();
                CPickOutPlanData pickOutPlanModel = new CPickOutPlanData();
                string strSql = "", strPreWareLocatorNo = "";
                int stockNum = 0;
                object obj = null;

                //获取箱信息
                dtArrangeBillBox = arrangeBillBoxBB.GetVList("boxNo='" + strOldBoxNo + "'").Tables[0];
                if (dtArrangeBillBox.Rows.Count == 0)
                {
                    return false;
                }

                //获取当前托盘上的库存明细
                obj = commBB.ExecuteScalar("select count(1) from dbo.UStock where palletNo='" + strNewPalletNo + "' and num>0");
                if (obj != null)
                {
                    stockNum = Convert.ToInt32(obj);
                }

                //扫描箱所在库位
                strPreWareLocatorNo = dtArrangeBillBox.Rows[0]["wareLocatorNo"].ToString();

                //获取托盘上的正式物料箱
                dtPallet = arrangeBillBoxBB.GetVList("palletNo='" + strNewPalletNo + "' and isnull(wareNo,'')<>''").Tables[0];

                //获取箱内物料信息
                dtMaterial = materialBB.GetList("materialNo='" + dtArrangeBillBox.Rows[0]["materialNo"].ToString() + "'").Tables[0];

                //获取拣货计划实例
                pickOutPlanModel = pickOutPlanBB.GetModel(pickOutPlanID);

                //增加出入库明细-原箱出库
                dtStock = stockBB.GetList("boxNo='" + strOldBoxNo + "'").Tables[0];
                if (dtStock.Rows.Count > 0)//原箱有库存
                {
                    //保存出入库明细数据-出库
                    stockOutInDetailModel = new UStockOutInDetailData();

                    stockOutInDetailModel.billNo = strStockUpBillNo;//单据编号
                    stockOutInDetailModel.outInType = "08";//拆托合托
                    stockOutInDetailModel.isOut = true;//是否出库
                    stockOutInDetailModel.stockDt = System.DateTime.Today.ToString();//库存日期
                    stockOutInDetailModel.dt = System.DateTime.Today.ToString();//操作日期
                    stockOutInDetailModel.wareNo = dtArrangeBillBox.Rows[0]["wareNo"].ToString();//仓库
                    stockOutInDetailModel.wareLocatorNo = dtArrangeBillBox.Rows[0]["wareLocatorNo"].ToString();//库位
                    stockOutInDetailModel.salverNo = dtArrangeBillBox.Rows[0]["palletNo"].ToString();//托盘号
                    stockOutInDetailModel.boxNo = strOldBoxNo;//箱号
                    stockOutInDetailModel.materialNo = dtArrangeBillBox.Rows[0]["materialNo"].ToString();//物料编号
                    stockOutInDetailModel.factMonomerNum = Convert.ToDouble(dtMaterial.Rows[0]["U_UintQty"]);//单体数量
                    stockOutInDetailModel.factPackNum = Convert.ToDouble(dtMaterial.Rows[0]["U_BoxQty"]);//整箱数量
                    stockOutInDetailModel.num = pickOutNum;//数量
                    stockOutInDetailModel.nextBoxNo = strNewBoxNo;//拆箱目的箱号
                    stockOutInDetailModel.isrtEmpId = this.empId;
                    stockOutInDetailModel.isrtDt = System.DateTime.Now.ToString();

                    stockOutInDetailBB.AddRecord(stockOutInDetailModel);
                }

                //更改正式库存信息
                commBB.ExecuteSql("update dbo.UStock set num=num-" + pickOutNum.ToString() + " where boxNo='" + strOldBoxNo + "'");

                #region 拣货信息赋值

                DEPickOutBoxModel = new CDEPickOutBoxData();

                DEPickOutBoxModel.boxNo = strNewBoxNo;//新箱号
                DEPickOutBoxModel.oldBoxNo = strOldBoxNo;//原箱号
                DEPickOutBoxModel.materialNo = dtArrangeBillBox.Rows[0]["materialNo"].ToString();//物料编号
                DEPickOutBoxModel.num = pickOutNum;//拣货数量
                DEPickOutBoxModel.palletNo = strNewPalletNo;//新托盘号
                DEPickOutBoxModel.region = "";//新区域
                DEPickOutBoxModel.oldPalletNo = dtArrangeBillBox.Rows[0]["palletNo"].ToString();//原托盘号
                DEPickOutBoxModel.oldRegion = dtArrangeBillBox.Rows[0]["region"].ToString();//原区域
                DEPickOutBoxModel.preWareNo = dtArrangeBillBox.Rows[0]["wareNo"].ToString();//原库区
                DEPickOutBoxModel.preWareLocatorNo = dtArrangeBillBox.Rows[0]["wareLocatorNo"].ToString(); //原库位
                DEPickOutBoxModel.stockUpBillNo = strStockUpBillNo;//备货单编号
                DEPickOutBoxModel.palletIndex = palletIndex;//托盘序号

                if (pickOutPlanModel != null)
                {
                    DEPickOutBoxModel.absEntry = pickOutPlanModel.absEntry;
                    DEPickOutBoxModel.saleBillNo = pickOutPlanModel.saleBillNo;
                    DEPickOutBoxModel.lineNum = pickOutPlanModel.lineNum;
                    DEPickOutBoxModel.DocEntry = pickOutPlanModel.DocEntry;
                }

                DEPickOutBoxModel.isrtEmpId = this.EmpID;//添加人
                DEPickOutBoxModel.isrtDt = System.DateTime.Now.ToString();//添加时间

                #endregion 拣货信息赋值

                //添加库存明细--高位货架上的托盘
                if ((dtPallet.Rows.Count > 0 && dtPallet.Rows[0]["wareType"].ToString() == "03"
                    && strOperType == "02" && dtPallet.Rows[0]["wareLocatorNo"].ToString() != ""
                    && dtPallet.Rows[0]["wareSortNo"].ToString() != "D"
                    && dtPallet.Rows[0]["wareSortNo"].ToString() != "E")
                    || (stockNum > 0 && DEPickOutBoxModel.oldPalletNo != ""))
                {
                    #region 放置托盘在正式库区

                    #region 保存拣货信息

                    DEPickOutBoxModel.wareNo = dtPallet.Rows[0]["wareNo"].ToString();//新库区
                    DEPickOutBoxModel.wareLocatorNo = dtPallet.Rows[0]["wareLocatorNo"].ToString();//新库位
                    DEPickOutBoxModel.isOutStock = true;//是否出库
                    DEPickOutBoxModel.updtDt = System.DateTime.Now.ToString();//更改时间
                    DEPickOutBoxModel.updtEmpId = this.EmpID;//更改人员

                    #endregion 保存拣货信息

                    #region 保存库存明细数据

                    dtStock = stockBB.GetList("boxNo='" + strNewBoxNo + "' and num>0").Tables[0];
                    if (dtStock.Rows.Count == 0)//没有库存
                    {
                        //增加库存明细
                        stockModel = new UStockData();

                        stockModel.wareNo = dtPallet.Rows[0]["wareNo"].ToString();//仓库
                        stockModel.wareLocatorNo = dtPallet.Rows[0]["wareLocatorNo"].ToString();//库位
                        stockModel.stockDt = System.DateTime.Today.ToString();//库存日期
                        stockModel.palletNo = strNewPalletNo;//托盘号
                        stockModel.materialNo = dtArrangeBillBox.Rows[0]["materialNo"].ToString();//物料编号
                        stockModel.boxNo = strNewBoxNo;//箱号
                        stockModel.factMonomerNum = Convert.ToDouble(dtMaterial.Rows[0]["U_UintQty"]);//单体数量
                        stockModel.factPackNum = Convert.ToDouble(dtMaterial.Rows[0]["U_BoxQty"]);//整箱数量
                        stockModel.num = pickOutNum;//数量
                        stockModel.isOutStocking = false;//是否正在出库
                        stockModel.stockMark = "拆托合托";

                        stockBB.AddRecord(stockModel);
                    }
                    else//已有库存
                    {
                        strSql = "update dbo.UStock set num=num+" + pickOutNum.ToString() + " where boxNo='" + strNewBoxNo + "'";
                        commBB.ExecuteSql(strSql);
                    }

                    //增加出入库明细-新箱入库
                    stockOutInDetailModel = new UStockOutInDetailData();

                    stockOutInDetailModel.billNo = strStockUpBillNo;//单据编号
                    stockOutInDetailModel.outInType = "08";//拆托合托
                    stockOutInDetailModel.isOut = false;//是否出库
                    stockOutInDetailModel.stockDt = System.DateTime.Today.ToString();//库存日期
                    stockOutInDetailModel.dt = System.DateTime.Today.ToString();//操作日期
                    stockOutInDetailModel.wareNo = dtPallet.Rows[0]["wareNo"].ToString();//仓库
                    stockOutInDetailModel.wareLocatorNo = dtPallet.Rows[0]["wareLocatorNo"].ToString();//库位
                    stockOutInDetailModel.salverNo = strNewPalletNo;//托盘号
                    stockOutInDetailModel.boxNo = strNewBoxNo;//箱号
                    stockOutInDetailModel.materialNo = dtArrangeBillBox.Rows[0]["materialNo"].ToString();//物料编号
                    stockOutInDetailModel.factMonomerNum = Convert.ToDouble(dtMaterial.Rows[0]["U_UintQty"]);//单体数量
                    stockOutInDetailModel.factPackNum = Convert.ToDouble(dtMaterial.Rows[0]["U_BoxQty"]);//整箱数量
                    stockOutInDetailModel.num = pickOutNum;//数量
                    stockOutInDetailModel.nextBoxNo = "";//拆箱目的箱号
                    stockOutInDetailModel.isrtEmpId = this.empId;
                    stockOutInDetailModel.isrtDt = System.DateTime.Now.ToString();

                    stockOutInDetailBB.AddRecord(stockOutInDetailModel);

                    #endregion 保存库存明细数据

                    //更改排托箱入库信息
                    commBB.ExecuteSql("update dbo.BArrangeBillBox set inStockDt=getDate(),inStockEmpId="
                        + this.EmpID.ToString() + ",inStockNum='" + stockOutInDetailModel.num.ToString()
                        + "',isOutStocking=0 where boxNo='" + stockOutInDetailModel.boxNo
                        + "' and isnull(wareNo,'')<>'' and inStockDt is null");

                    #endregion 放置托盘在正式库区
                }
                else
                {
                    #region 保存流利货架拣货或非正式库拆托组托信息或拆到空托盘

                    if (DEPickOutBoxModel.oldPalletNo != "")//非正式库拆托组托或拆到空托盘
                    {
                        if (dtPallet.Rows.Count > 0
                            && dtPallet.Rows[0]["wareNo"].ToString().IndexOf("GLHJ") == -1
                            && dtPallet.Rows[0]["wareLocatorNo"].ToString() != "")//新托盘上已有物料箱,将物料放到原有托盘
                        {
                            DEPickOutBoxModel.wareNo = dtPallet.Rows[0]["wareNo"].ToString();//新库区
                            DEPickOutBoxModel.wareLocatorNo = dtPallet.Rows[0]["wareLocatorNo"].ToString();//新库位
                        }
                        else
                        {
                            DEPickOutBoxModel.wareNo = dtArrangeBillBox.Rows[0]["wareNo"].ToString();//新库区
                            DEPickOutBoxModel.wareLocatorNo = "";//放到空托盘
                        }

                        //是否出库
                        if (DEPickOutBoxModel.wareLocatorNo != "")//非正式库拆托组托
                        {
                            DEPickOutBoxModel.isOutStock = true;//是否出库
                            DEPickOutBoxModel.updtDt = System.DateTime.Now.ToString();//更改时间
                            DEPickOutBoxModel.updtEmpId = this.EmpID;//更改人员
                        }
                        else
                        {
                            //拆到空托盘
                            DEPickOutBoxModel.isOutStock = false;
                        }
                    }
                    else//流利货架拣货
                    {
                        DEPickOutBoxModel.wareNo = dtArrangeBillBox.Rows[0]["wareNo"].ToString();//新库区
                        DEPickOutBoxModel.wareLocatorNo = dtArrangeBillBox.Rows[0]["wareLocatorNo"].ToString();//新库位
                        DEPickOutBoxModel.isOutStock = false;//是否出库
                    }

                    #endregion 保存流利货架拣货或非正式库拆托组托信息或拆到空托盘
                }

                //保存拣货信息
                DEPickOutBoxBB.AddRecord(DEPickOutBoxModel);

                //拣货处理逻辑更改为:根据实际需要数量进行拣货
                //处理情况分为:整箱拣货、拆箱拣货
                if (strNewBoxNo == strOldBoxNo)//整箱拣货
                {
                    if (DEPickOutBoxModel.oldPalletNo != ""
                        || dtArrangeBillBox.Rows[0]["wareNo"] == DBNull.Value
                        || dtArrangeBillBox.Rows[0]["wareNo"].ToString() == "")//非流利货架或已出库箱重新入库
                    {
                        //物料箱库位赋值
                        commBB.ExecuteSql("update dbo.BArrangeBillBox set oldPalletNo=palletNo,palletNo='"
                                + strNewPalletNo + "',region=oldRegion,oldRegion='',preWareNo=wareNo,preWareLocatorNo=wareLocatorNo,wareNo='"
                                + DEPickOutBoxModel.wareNo + "',wareLocatorNo='" + DEPickOutBoxModel.wareLocatorNo + "',stockUpBillNo='" + strStockUpBillNo
                                + "' where boxNo='" + strOldBoxNo + "'");
                    }
                    else
                    {
                        //流利货架,库位赋空值
                        commBB.ExecuteSql("update dbo.BArrangeBillBox set oldPalletNo=palletNo,palletNo='"
                                + strNewPalletNo + "',region=oldRegion,oldRegion='',preWareNo=wareNo,preWareLocatorNo=wareLocatorNo,wareNo='"
                                + DEPickOutBoxModel.wareNo + "',wareLocatorNo='',stockUpBillNo='" + strStockUpBillNo
                                + "' where boxNo='" + strOldBoxNo + "'");
                    }
                }

                //如果原箱剩余数量为0,清空原箱的托盘号、库区、库位
                dtArrangeBillBox = arrangeBillBoxBB.GetVList("boxNo='" + strOldBoxNo + "'").Tables[0];
                if (Convert.ToInt32(dtArrangeBillBox.Rows[0]["leavingNum"]) == 0)
                {
                    commBB.ExecuteSql(@"update dbo.BArrangeBillBox set oldPalletNo=palletNo,palletNo='',preWareNo=wareNo,preWareLocatorNo=wareLocatorNo,
                                            wareNo='',wareLocatorNo='',stockUpBillNo='" + strStockUpBillNo
                                        + "' where boxNo='" + strOldBoxNo + "'");
                }

                #region 新增新的排托箱

                DataTable dtArrangeBillBoxNew = new DataTable();

                dtArrangeBillBoxNew = arrangeBillBoxBB.GetList("boxNo='" + strNewBoxNo + "'").Tables[0];

                //新增新的排托箱
                if (dtArrangeBillBoxNew.Rows.Count == 0)
                {
                    BArrangeBillBoxData newArrangeBillBoxModel = new BArrangeBillBoxData();

                    newArrangeBillBoxModel.arriveBillNo = "";//到货单号
                    newArrangeBillBoxModel.financeBillNo = dtArrangeBillBox.Rows[0]["financeBillNo"].ToString();//采购订单号
                    newArrangeBillBoxModel.arrangeBillNo = "";//排托单号
                    newArrangeBillBoxModel.stockUpBillNo = strStockUpBillNo;//备货单编号
                    newArrangeBillBoxModel.boxNo = strNewBoxNo;//箱号
                    newArrangeBillBoxModel.oldBoxNo = strOldBoxNo;//原箱号
                    newArrangeBillBoxModel.materialNo = dtArrangeBillBox.Rows[0]["materialNo"].ToString();//物料编号
                    newArrangeBillBoxModel.factNum = 0;//数量,赋0值通过拣货清单计算实际数量
                    newArrangeBillBoxModel.palletNo = strNewPalletNo;//托盘号
                    newArrangeBillBoxModel.region = "";//区域
                    newArrangeBillBoxModel.oldPalletNo = dtArrangeBillBox.Rows[0]["palletNo"].ToString();//原托盘号
                    newArrangeBillBoxModel.oldRegion = dtArrangeBillBox.Rows[0]["region"].ToString();//原托内区域
                    newArrangeBillBoxModel.wareNo = dtArrangeBillBox.Rows[0]["wareNo"].ToString();//库区

                    if (DEPickOutBoxModel.oldPalletNo != "")//非流利货架
                    {
                        newArrangeBillBoxModel.wareLocatorNo = DEPickOutBoxModel.wareLocatorNo;//库位
                    }
                    else//流利货架
                    {
                        newArrangeBillBoxModel.wareLocatorNo = "";//库位
                    }

                    newArrangeBillBoxModel.preWareNo = dtArrangeBillBox.Rows[0]["wareNo"].ToString();//原库区
                    newArrangeBillBoxModel.preWareLocatorNo = dtArrangeBillBox.Rows[0]["wareLocatorNo"].ToString();//原库位
                    newArrangeBillBoxModel.isBoxArrange = true;//是否排托
                    newArrangeBillBoxModel.isPalletUsing = true;//托盘是否正在使用
                    newArrangeBillBoxModel.acceptEmpId = this.EmpID;//接收人
                    newArrangeBillBoxModel.acceptDt = System.DateTime.Now.ToString();//接收时间
                    newArrangeBillBoxModel.checkResult = Convert.ToBoolean(dtArrangeBillBox.Rows[0]["checkResult"]);//校验结果
                    newArrangeBillBoxModel.isOutStocking = false;//是否正在出库
                    newArrangeBillBoxModel.noPassReasonId = Convert.ToInt32(dtArrangeBillBox.Rows[0]["noPassReasonId"]);//不合格原因
                    newArrangeBillBoxModel.noPassMark = dtArrangeBillBox.Rows[0]["noPassMark"].ToString();//不合格备注

                    arrangeBillBoxBB.AddRecord(newArrangeBillBoxModel);
                }

                #endregion 新增新的排托箱

                //库存明细数量为0,删除信息
                strSql = "delete from dbo.UStock where num=0";
                commBB.ExecuteSql(strSql);

                //更改库存中原箱的是否锁定状态
                strSql = "update dbo.UStock set isOutStocking=0 where id in (select top 1 id from dbo.UStock where wareLocatorNo='" + strPreWareLocatorNo
                    + "' and materialNo='" + dtArrangeBillBox.Rows[0]["materialNo"].ToString() + "' and isOutStocking=1 order by id)";
                commBB.ExecuteSql(strSql);

                //更改原箱的是否锁定状态
                strSql = "update dbo.BArrangeBillBox set isOutStocking=0 where id in (select top 1 id from dbo.BArrangeBillBox where wareLocatorNo='" + strPreWareLocatorNo
                    + "' and materialNo='" + dtArrangeBillBox.Rows[0]["materialNo"].ToString() + "' and isOutStocking=1 order by id)";
                commBB.ExecuteSql(strSql);

                //释放库位,首先判断原托盘上是否有物料
                strSql = @"update dbo.LWareLocator set isUsing=0
                           where not exists(select 1 from dbo.BArrangeBillBox as t where t.wareLocatorNo=dbo.LWareLocator.wareLocatorNo)
                           and isUsing=1 and isDel=0
                           and wareLocatorNo='" + strPreWareLocatorNo + "'";
                commBB.ExecuteSql(strSql);

                if (this.transaction == null) trans.Commit();
                ret = true;
            }
            catch
            {
                if (transaction == null) trans.Rollback("TranSave");
                throw new Exception("保存信息失败!");
            }
            finally
            {
                commBB.Dispose();
                arrangeBillBoxBB.Dispose();
                DEPickOutBoxBB.Dispose();
                materialBB.Dispose();
                wareBB.Dispose();
                stockOutInDetailBB.Dispose();
                pickOutPlanBB.Dispose();
            }

            return ret;
        }