/// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="connection">数据连接</param>
 public BSendNotesListBC(SqlConnection connection)
 {
     this.connection = connection;
     this.sendNotesListBB = new BSendNotesListBB(this.connection);
     this.errorDiaryBB = new SErrorDiaryBB(this.connection);
     this.operatDiaryBB = new SOperatDiaryBB(this.connection);
     this.commBB = new SCommBB(this.connection);
 }
Esempio n. 2
0
 /// <summary>
 /// ���캯��
 /// </summary>
 /// <param name="connection">��������</param>
 public WRunListBC(SqlConnection connection)
 {
     this.connection = connection;
     this.runListBB = new WRunListBB(this.connection);
     this.errorDiaryBB = new SErrorDiaryBB(this.connection);
     this.operatDiaryBB = new SOperatDiaryBB(this.connection);
     this.commBB = new SCommBB(this.connection);
 }
Esempio n. 3
0
 /// <summary>
 /// ���캯��
 /// </summary>
 /// <param name="connection">��������</param>
 public MBusinessBC(SqlConnection connection)
 {
     this.connection = connection;
     this.businessBB = new MBusinessBB(this.connection);
     this.errorDiaryBB = new SErrorDiaryBB(this.connection);
     this.operatDiaryBB = new SOperatDiaryBB(this.connection);
     this.commBB = new SCommBB(this.connection);
 }
Esempio n. 4
0
 /// <summary>
 /// ���캯��
 /// </summary>
 public WRunListBC()
 {
     this.selfConn = true;
     this.connection = new SqlConnection(HS.Config.SqlDataObject.GetSqlConnectionString);
     this.connection.Open();
     this.runListBB = new WRunListBB(this.connection);
     this.errorDiaryBB = new SErrorDiaryBB(this.connection);
     this.operatDiaryBB = new SOperatDiaryBB(this.connection);
     this.commBB = new SCommBB(this.connection);
 }
Esempio n. 5
0
 /// <summary>
 /// ���캯��
 /// </summary>
 public MBusinessBC()
 {
     this.selfConn = true;
     this.connection = new SqlConnection(HS.Config.SqlDataObject.GetSqlConnectionString);
     this.connection.Open();
     this.businessBB = new MBusinessBB(this.connection);
     this.errorDiaryBB = new SErrorDiaryBB(this.connection);
     this.operatDiaryBB = new SOperatDiaryBB(this.connection);
     this.commBB = new SCommBB(this.connection);
 }
        //*****************************************************************************
        //do it later      do it later      do it later
        //*****************************************************************************
        /// <summary>
        /// 保存扫描箱体信息
        /// </summary>
        /// <param name="strArriveBillNo">到货单号</param>
        /// <param name="strFinanceBillNo">采购订单号</param>
        /// <param name="strPalletIndex">托盘序号</param>
        /// <param name="strRegion">托内区域</param>
        /// <param name="strBoxNo">箱号</param>
        /// <param name="strMaterialNo">物料号</param>
        /// <returns></returns>
        public bool SaveRecord(string strArriveBillNo, string strFinanceBillNo, string strPalletIndex, 
            string strRegion, string strBoxNo, string strMaterialNo)
        {
            bool ret = false;
            SqlTransaction trans = null;
            LWareLocatorBB wareLocatorBB = new LWareLocatorBB();
            BArrangeBillFactBB arrangeBillFactBB = new BArrangeBillFactBB();
            BArrangeBillBoxBB arrangeBillBoxBB = new BArrangeBillBoxBB(this.connection);
            SCommBB commBB = new SCommBB(this.connection);

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

                BArrangeBillFactDetailData arrangeBillFactDetailModel = new BArrangeBillFactDetailData();
                BArrangeBillBoxData arrangeBillBoxModel = new BArrangeBillBoxData();
                DataSet ds = new DataSet();
                DataTable dtWareLocator = new DataTable();
                string mainId = "0", strPalletNo = "";
                StringBuilder strSql = new StringBuilder();

                //获取排托实际信息
                ds = arrangeBillFactBB.GetList("arriveBillNo='" + strArriveBillNo + "' and financeBillNo='"
                    + strFinanceBillNo + "' and palletIndex='" + strPalletIndex + "'");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    mainId = ds.Tables[0].Rows[0]["id"].ToString();
                    strPalletNo = ds.Tables[0].Rows[0]["palletNo"].ToString();
                }

                //获取排托区下线库位信息
                strSql.Append(@"select wareLocator.wareNo,wareLocator.downWareLocatorNo as wareLocatorNo ");
                strSql.Append(@"from dbo.BArrangeBillBox as arriveBox ");
                strSql.Append(@"left join dbo.LWareLocator as wareLocator on wareLocator.wareLocatorNo=arriveBox.wareLocatorNo ");
                strSql.Append(@"where arriveBox.boxNo='" + strBoxNo + "'");

                dtWareLocator = commBB.Query(strSql.ToString()).Tables[0];

                //保存排托收货单明细信息
                arrangeBillFactDetailModel.mainId = mainId;//排托收货单ID
                arrangeBillFactDetailModel.boxNo = strBoxNo;//箱号
                arrangeBillFactDetailModel.region = strRegion;//区域
                arrangeBillFactDetailModel.isrtEmpId = this.empId;
                arrangeBillFactDetailModel.isrtDt = System.DateTime.Now.ToString();

                arrangeBillFactDetailBB.AddRecord(arrangeBillFactDetailModel);

                //更改扫描箱信息
                commBB.ExecuteSql("update dbo.BArrangeBillBox set arrangeBillNo='" + "PT" + strArriveBillNo
                    + "',preWareNo=wareNo,preWareLocatorNo=wareLocatorNo,oldPalletNo=palletNo,oldRegion=region,palletNo='" + strPalletNo
                    + "',region='" + strRegion + "',wareNo='" + dtWareLocator.Rows[0]["wareNo"].ToString()
                    + "',wareLocatorNo='" + dtWareLocator.Rows[0]["wareLocatorNo"].ToString()
                    + "',isrtEmpId='" + this.empId.ToString()
                    + "',isrtDt='" + System.DateTime.Now.ToString()
                    + "',isBoxArrange=1 where boxNo='" + strBoxNo + "'");

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

            return ret;
        }
        /// <summary>
        /// 删除扫描箱体信息
        /// </summary>
        /// <param name="strBoxNo"></param>
        /// <returns></returns>
        public bool DeleteRecord(string strBoxNo)
        {
            bool ret = false;
            SqlTransaction trans = null;
            SCommBB commBB = new SCommBB(this.connection);

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

                //删除排托收货明细
                commBB.ExecuteSql("delete from dbo.BArrangeBillFactDetail where boxNo='" + strBoxNo + "'");

                //更改箱体信息
                commBB.ExecuteSql("update from dbo.BArrangeBillBox wareNo=preWareNo,wareLocatorNo=preWareLocatorNo,isBoxArrange=0 where boxNo='" + strBoxNo + "'");

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

            return ret;
        }
        //*****************************************************************************
        //do it later      do it later      do it later
        //*****************************************************************************
        /// <summary>
        /// 保存排托收货单信息
        /// </summary>
        /// <param name="strArrangeBillNo">排托单号</param>
        /// <param name="strArriveBillNo">到货单号</param>
        /// <param name="strFinanceBillNos">采购订单编号组合</param>
        /// <param name="strPalletIndex">托盘序号</param>
        /// <param name="strPalletNo">托盘号</param>
        /// <param name="isrtEmpId">添加人</param>
        /// <param name="updtEmpId">修改人</param>
        /// <param name="strInstantState">状态:01 收货单,02 收货已完成</param>
        /// <returns></returns>
        public bool SaveRecord(string strArrangeBillNo, string strArriveBillNo,string strFinanceBillNos,
        string strPalletIndex, string strPalletNo, int isrtEmpId, int updtEmpId, string strInstantState)
        {
            bool ret = false;
            SqlTransaction trans = null;
            SCommBB commBB = new SCommBB(this.connection);
            BForkliftTaskBB forkliftTaskBB = new BForkliftTaskBB(this.connection);
            BArrangeBillBoxBB arrangeBillBoxBB = new BArrangeBillBoxBB(this.connection);

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

                DataSet ds = new DataSet();
                BArrangeBillFactData arrangeBillFactModel = new BArrangeBillFactData();

                #region 维护排托收货单信息

                foreach (string strFinanceBillNo in strFinanceBillNos.Split(','))
                {
                    //维护排托收货单信息
                    ds = arrangeBillFactBB.GetList("arrangeBillNo='" + strArrangeBillNo
                        + "' and palletIndex='" + strPalletIndex + "' and financeBillNo='" + strFinanceBillNo + "'");//添加物料编号
                    if (ds.Tables[0].Rows.Count == 0)
                    {
                        arrangeBillFactModel = new BArrangeBillFactData();

                        arrangeBillFactModel.arrangeBillNo = strArrangeBillNo;//排托单号
                        arrangeBillFactModel.arriveBillNo = strArriveBillNo;//到货单号
                        arrangeBillFactModel.financeBillNo = strFinanceBillNo;//采购订单号
                        arrangeBillFactModel.palletIndex = strPalletIndex;//托盘序号
                        arrangeBillFactModel.palletNo = strPalletNo;//托盘条码号
                        arrangeBillFactModel.isTally = false;//是否已理货
                        arrangeBillFactModel.isrtEmpId = isrtEmpId;//添加人
                        arrangeBillFactModel.isrtDt = System.DateTime.Now.ToString();//添加时间
                        arrangeBillFactModel.instantState = strInstantState;//状态

                        arrangeBillFactBB.AddRecord(arrangeBillFactModel);
                    }
                    else
                    {
                        arrangeBillFactModel = arrangeBillFactBB.GetModel(Convert.ToInt32(ds.Tables[0].Rows[0]["id"]));

                        if (strPalletNo != "")//如果托盘号不为空,更改托盘号
                        {
                            arrangeBillFactModel.palletNo = strPalletNo;//托盘条码号
                        }
                        else
                        {
                            strPalletNo = ds.Tables[0].Rows[0]["palletNo"].ToString();//获取托盘条码
                        }

                        arrangeBillFactModel.updtDt = System.DateTime.Now.ToString();//修改时间
                        arrangeBillFactModel.updtEmpId = updtEmpId;//修改人
                        arrangeBillFactModel.instantState = strInstantState;//状态

                        arrangeBillFactBB.ModifyRecord(arrangeBillFactModel);
                    }
                }

                #endregion 维护排托收货单信息

                #region 更改状态

                //更改状态
                if (strInstantState == "01")//排托中
                {
                    //更改排托单明细状态为“02 排托中”
                    commBB.ExecuteSql("update dbo.BArrangeBillDetail set instantState='02' where arriveBillNo='"
                        + strArriveBillNo + "' and palletIndex='" + strPalletIndex + "'");

                    //更改排托单状态为“03 排托中”
                    commBB.ExecuteSql("update dbo.BArrangeBill set instantState='03' where arriveBillNo='"
                        + strArriveBillNo + "'");

                    //更改到货单状态为“04 排托中”
                    commBB.ExecuteSql("update dbo.BArriveBill set instantState='04' where billNo='"
                        + strArriveBillNo + "'");
                }
                else if (strInstantState == "02")//排托已完成
                {
                    #region 更改单据状态

                    //更改排托单明细状态为“03 排托已完成”
                    commBB.ExecuteSql("update dbo.BArrangeBillDetail set instantState='03' where arriveBillNo='"
                        + strArriveBillNo + "' and palletIndex='" + strPalletIndex + "'");

                    //如果排托单明细全部排托已完成,更改排托单状态为“排托已完成”
                    commBB.ExecuteSql("update dbo.BArrangeBill set instantState='04' where arriveBillNo='" + strArriveBillNo
                        + "' and not exists (select 1 from dbo.BArrangeBillDetail where dbo.BArrangeBill.arriveBillNo=dbo.BArrangeBillDetail.arriveBillNo and isnull(dbo.BArrangeBillDetail.instantState,'')<>'03')");

                    //如果排托单明细全部排托已完成,更改到货单状态为“排托已完成”
                    commBB.ExecuteSql(@"update dbo.BArriveBill set instantState='05' where billNo='" + strArriveBillNo
                        + "' and not exists (select 1 from dbo.BArrangeBillDetail where dbo.BArriveBill.billNo=dbo.BArrangeBillDetail.arriveBillNo and isnull(dbo.BArrangeBillDetail.instantState,'')<>'03')");

                    #endregion 更改单据状态

                    #region 生成叉车任务

                    //首先判断当前托盘存在未执行的叉车任务
                    DataTable dtForkliftTask = new DataTable();

                    dtForkliftTask = forkliftTaskBB.GetList("palletNo='" + strPalletNo + "' and isDeal=0").Tables[0];
                    if (dtForkliftTask.Rows.Count == 0)
                    {
                        BForkliftTaskData forkliftTaskModel = new BForkliftTaskData();
                        DataSet dsArrangeBillBox = new DataSet();

                        dsArrangeBillBox = arrangeBillBoxBB.GetVList("arriveBillNo='" + strArriveBillNo
                            + "' and palletNo='" + strPalletNo + "' and isnull(wareNo,'')<>''");

                        if (dsArrangeBillBox.Tables[0].Rows.Count > 0)
                        {
                            forkliftTaskModel = new BForkliftTaskData();

                            forkliftTaskModel.taskType = "01";//任务类型为:从排托区到质检区
                            forkliftTaskModel.palletNo = strPalletNo;//托盘号
                            forkliftTaskModel.preWareNo = dsArrangeBillBox.Tables[0].Rows[0]["wareNo"].ToString();//源库区
                            forkliftTaskModel.preLocatorNo = dsArrangeBillBox.Tables[0].Rows[0]["wareLocatorNo"].ToString();//源库位
                            forkliftTaskModel.effectDt = System.DateTime.Now.ToString();//生效时间
                            forkliftTaskModel.isDeal = false;//是否处理
                            forkliftTaskModel.isrtDt = System.DateTime.Now.ToString();//添加时间
                            forkliftTaskModel.isrtEmpId = isrtEmpId;//添加人

                            forkliftTaskBB.AddRecord(forkliftTaskModel);
                        }
                    }

                    #endregion 生成叉车任务
                }

                #endregion 更改状态

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

            return ret;
        }
Esempio n. 9
0
        /// <summary>
        /// 保存叉车任务信息
        /// </summary>
        /// <param name="strPalletNo">托盘条码号</param>
        /// <param name="strNextWareNo">目的库区编码</param>
        /// <param name="strNextWareLocatorNo">目的库位编码</param>
        /// <param name="strTaskType">任务类型</param>
        /// <param name="isrtEmpId">添加人</param>
        /// <returns></returns>
        public bool SaveForkliftTaskWithTHD(string strPalletNo, string strNextWareNo, string strNextWareLocatorNo,
            string strTaskType, int isrtEmpId,string THD)
        {
            bool ret = false;
            SqlTransaction trans = null;
            SCommBB commBB = new SCommBB(this.connection);
            BArrangeBillBoxBB arrangeBillBoxBB = new BArrangeBillBoxBB(this.connection);

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

                DataSet dsArrangeBillBox = new DataSet();
                DataTable dtWareLocator = new DataTable();
                DataTable dtForkliftTask = new DataTable();
                BForkliftTaskData forkliftTaskModel = new BForkliftTaskData();
                StringBuilder strSql = new StringBuilder();

                //获取原托盘的未执行的叉车任务
                dtForkliftTask = forkliftTaskBB.GetList("palletNo='" + strPalletNo + "' and isDeal=0").Tables[0];
                if (dtForkliftTask.Rows.Count == 0)
                {
                    string strBoxNo = "";

                    //获取原托盘所在库位
                    dsArrangeBillBox = arrangeBillBoxBB.GetList("palletNo='" + strPalletNo + "' and isnull(wareNo,'')<>''");

                    #region 保存叉车任务

                    //保存叉车任务
                    forkliftTaskModel.taskType = strTaskType;//任务类型
                    forkliftTaskModel.palletNo = strPalletNo;//托盘条码号

                    strBoxNo = dsArrangeBillBox.Tables[0].Rows[dsArrangeBillBox.Tables[0].Rows.Count - 1]["boxNo"].ToString();
                    forkliftTaskModel.preWareNo = dsArrangeBillBox.Tables[0].Rows[dsArrangeBillBox.Tables[0].Rows.Count - 1]["wareNo"].ToString();//源库位编码
                    forkliftTaskModel.preLocatorNo = dsArrangeBillBox.Tables[0].Rows[dsArrangeBillBox.Tables[0].Rows.Count - 1]["wareLocatorNo"].ToString();//源库位编码

                    if (strTaskType == "04" || strTaskType == "06" || strTaskType == "09")//04 从理货区返回质检区,09 从平台返回收货区
                    {
                        //获取排托区返回库位信息
                        strSql.Append(@"select wareLocator.wareNo,wareLocator.returnWareLocatorNo as wareLocatorNo ");
                        strSql.Append(@"from dbo.BArrangeBillBox as arrangeBillBoxBox ");
                        strSql.Append(@"left join dbo.LWareLocator as wareLocator on wareLocator.wareLocatorNo=arrangeBillBoxBox.wareLocatorNo ");
                        strSql.Append(@"where arrangeBillBoxBox.boxNo='" + strBoxNo + "'");

                        dtWareLocator = commBB.Query(strSql.ToString()).Tables[0];
                        if (dtWareLocator.Rows.Count > 0
                            && dtWareLocator.Rows[0]["wareLocatorNo"] != DBNull.Value
                            && dtWareLocator.Rows[0]["wareLocatorNo"].ToString() != "")
                        {
                            //源库位信息
                            forkliftTaskModel.preWareNo = dtWareLocator.Rows[0]["wareNo"].ToString();//源库区编码
                            forkliftTaskModel.preLocatorNo = dtWareLocator.Rows[0]["wareLocatorNo"].ToString();//源库位编码
                        }
                    }
                    else if (strTaskType == "01" || strTaskType == "03")//01 从排托区到质检区,03 从理货区到正式库区
                    {
                        //获取排托区下线库位信息
                        strSql.Append(@"select wareLocator.wareNo,wareLocator.downWareLocatorNo as wareLocatorNo ");
                        strSql.Append(@"from dbo.BArrangeBillBox as arrangeBillBoxBox ");
                        strSql.Append(@"left join dbo.LWareLocator as wareLocator on wareLocator.wareLocatorNo=arrangeBillBoxBox.wareLocatorNo ");
                        strSql.Append(@"where arrangeBillBoxBox.boxNo='" + strBoxNo + "'");

                        dtWareLocator = commBB.Query(strSql.ToString()).Tables[0];
                        if (dtWareLocator.Rows.Count > 0
                            && dtWareLocator.Rows[0]["wareLocatorNo"] != DBNull.Value
                            && dtWareLocator.Rows[0]["wareLocatorNo"].ToString() != "")
                        {
                            //源库位信息
                            forkliftTaskModel.preWareNo = dtWareLocator.Rows[0]["wareNo"].ToString();//源库区编码
                            forkliftTaskModel.preLocatorNo = dtWareLocator.Rows[0]["wareLocatorNo"].ToString();//源库位编码
                        }
                    }
                    else if (strTaskType == "06")//06 从拣货区返回正式库区
                    {
                        DataTable dtForkliftTask_Last = new DataTable();
                        DataTable dtStockUpBill = new DataTable();

                        //获取叉车任务的上个库位
                        dtForkliftTask = commBB.Query("select top 1 * from dbo.BForkliftTask order by id desc").Tables[0];
                        if (dtForkliftTask.Rows.Count > 0)
                        {
                            //获取排托区返回库位信息
                            strSql.Append(@"select wareLocator.wareNo,wareLocator.returnWareLocatorNo as wareLocatorNo ");
                            strSql.Append(@" from dbo.LWareLocator as wareLocator where wareLocator.wareLocatorNo='" + dtForkliftTask.Rows[0]["nextLocatorNo"].ToString() + "' ");

                            dtWareLocator = commBB.Query(strSql.ToString()).Tables[0];
                            if (dtWareLocator.Rows.Count > 0
                                && dtWareLocator.Rows[0]["wareLocatorNo"] != DBNull.Value
                                && dtWareLocator.Rows[0]["wareLocatorNo"].ToString() != "")
                            {
                                //源库位信息
                                forkliftTaskModel.preWareNo = dtWareLocator.Rows[0]["wareNo"].ToString();//源库区编码
                                forkliftTaskModel.preLocatorNo = dtWareLocator.Rows[0]["wareLocatorNo"].ToString();//源库位编码
                            }
                        }
                        else if (strTaskType == "20")//暂定20 用来作为叉车出库
                        {
                            //叉车出库
                            //出库操作
                            strSql.Append(@"select wareLocator.wareNo,wareLocator.returnWareLocatorNo as wareLocatorNo ");
                            strSql.Append(@"from dbo.BArrangeBillBox as arrangeBillBoxBox ");
                            strSql.Append(@"left join dbo.LWareLocator as wareLocator on wareLocator.wareLocatorNo=arrangeBillBoxBox.wareLocatorNo ");
                            strSql.Append(@"where arrangeBillBoxBox.boxNo='" + strBoxNo + "'");

                            dtWareLocator = commBB.Query(strSql.ToString()).Tables[0];
                            if (dtWareLocator.Rows.Count > 0
                                && dtWareLocator.Rows[0]["wareLocatorNo"] != DBNull.Value
                                && dtWareLocator.Rows[0]["wareLocatorNo"].ToString() != "")
                            {
                                //源库位信息
                                forkliftTaskModel.preWareNo = dtWareLocator.Rows[0]["wareNo"].ToString();//源库区编码
                                forkliftTaskModel.preLocatorNo = dtWareLocator.Rows[0]["wareLocatorNo"].ToString();//源库位编码
                            }

                        }

                        //获取备货单号
                        dtStockUpBill = commBB.Query("select top 1 stockUpBillNo from dbo.BForkliftTask where palletNo='"
                            + strPalletNo + "' and taskType='05' order by id desc").Tables[0];

                        if (dtStockUpBill.Rows.Count > 0)
                        {
                            forkliftTaskModel.stockUpBillNo = dtStockUpBill.Rows[0]["stockUpBillNo"].ToString();
                        }
                    }

                    //2015-02-03增加退货单号 用来进行后期的查询
                    if (forkliftTaskModel.taskType == "30")
                    {
                        forkliftTaskModel.stockUpBillNo = THD;
                    }

                    //目的库区编码
                    if (strNextWareNo != "")
                    {
                        forkliftTaskModel.nextWareNo = strNextWareNo;
                    }

                    //目的库位编码
                    if (strNextWareLocatorNo != "")
                    {
                        forkliftTaskModel.nextLocatorNo = strNextWareLocatorNo;
                    }

                    forkliftTaskModel.effectDt = System.DateTime.Now.ToString();//生效时间
                    forkliftTaskModel.isDeal = false;//是否处理
                    forkliftTaskModel.isrtDt = System.DateTime.Now.ToString();//添加时间
                    forkliftTaskModel.isrtEmpId = isrtEmpId;//添加人

                    forkliftTaskBB.AddRecord(forkliftTaskModel);//添加叉车任务信息

                    #endregion 保存叉车任务

                    #region 更改辅助信息

                    //更新目的库区占用状态
                    if (strNextWareLocatorNo != "")
                    {
                        //更改库位的使用状态
                        commBB.ExecuteSql("update dbo.LWareLocator set isUsing=1 where wareLocatorNo='"
                            + strNextWareLocatorNo + "'");
                    }

                    if (strTaskType == "08" || strTaskType == "12")//从收货区到排托区、托盘移库
                    {
                        //更改到货箱的托盘使用状态(已使用)
                        commBB.ExecuteSql("update dbo.BArrangeBillBox set isPalletUsing=1 where palletNo='"
                            + strPalletNo + "' and isnull(wareNo,'')<>''");
                    }

                    #endregion 更改辅助信息
                }

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

            return ret;
        }
        /// <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.therOutInPickOutPlanBB.Transaction = trans;
                    stockBB.Transaction = trans;
                    commBB.Transaction = trans;
                }
                else
                {
                    this.therOutInPickOutPlanBB.Transaction = this.transaction;
                    stockBB.Transaction = this.transaction;
                    commBB.Transaction = this.transaction;
                }

                OtherOutInPickOutPlanData pickOutPlanModel = new OtherOutInPickOutPlanData();
                OtherOutInPickOutPlanBB stockUpBillNo = new OtherOutInPickOutPlanBB();
                string stockUpBillNOValue = stockUpBillNo.GetCurrentInBillNoByStockUpBillNoByQT();

                int SAPDocEntry = 0;
                #region 逐条保存拣货计划

                //逐条保存拣货计划
                foreach (DataRow dr in dtPlan.Rows)
                {
                    string strWareLocatorNo = "", strMaterialNo = "", strWhere = "", strSql = "";
                    float num = 0;
                    DataTable dtStock = new DataTable();
                    stockUpBillNo.DeleteRecord(int.Parse(dr["id"].ToString()));
                    strWareLocatorNo = dr["wareLocatorNo"].ToString();//库位
                    //strFinanceBillNo = dr["financeBillNo"].ToString();//采购合同号
                    strMaterialNo = dr["materialNo"].ToString();//物料编号
                    num = Convert.ToSingle(dr["num"]);//数量

                    pickOutPlanModel = new OtherOutInPickOutPlanData();

                    pickOutPlanModel.StockUpBillNO = stockUpBillNOValue;//获取其他备货单号
                    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
                    SAPDocEntry = pickOutPlanModel.DocEntry;
                    //pickOutPlanModel.absEntry = Convert.ToInt32(dr["absEntry"]);//提货单号
                    pickOutPlanModel.lineNum = Convert.ToInt32(dr["lineNum"]);//销售订单行号

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

                    this.therOutInPickOutPlanBB.AddRecord(pickOutPlanModel);
                    string command = "Update OtherOutInBill set StockUpbillNo = '" + stockUpBillNOValue + "',InstantState = '02' where SAPDocEntry = " + SAPDocEntry + "";
                    SQLHelperDM.ExecuteNonQuery(HS.Config.SqlDataObject.GetJoeyConnectionString, command);
                    ret = true;

                }
                stockUpBillNo.Dispose();

                #endregion 保存拣货计划
            }
            catch
            {

            }
            try
            {
                if (this.transaction == null) trans.Commit();

            }
            catch
            {
                ret = false;
            }

            finally
            {
                stockBB.Dispose();
                commBB.Dispose();
                therOutInPickOutPlanBB.Dispose();

            }

            return ret;
        }
Esempio n. 11
0
        /// <summary>
        /// 删除提货单
        /// </summary>
        /// <param name="absEntry">提货单ID</param>
        /// <returns></returns>
        public bool DeleteSaleBill(int absEntry)
        {
            bool ret = false;
            SCommBB commBB = new SCommBB(this.connection);
            CStockUpBillBB stockUpBillBB = new CStockUpBillBB(this.connection);
            CPickOutPlanBB pickOutPlanBB = new CPickOutPlanBB(this.connection);
            SqlTransaction trans = null;

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

                string strStockUpBillNo = "";
                DataTable dtStockUpBill = new DataTable();
                DataTable dtPickOutPlan = new DataTable();

                //删除销售订单
                commBB.ExecuteSql("delete from dbo.CSaleBill where absEntry=" + absEntry.ToString());

                //删除销售订单明细
                commBB.ExecuteSql("delete from dbo.CSaleDetail where absEntry=" + absEntry.ToString());

                //删除销售订单临时表
                //commBB.ExecuteSql("delete from dbo.CSaleBill_HangHao where absEntry=" + absEntry.ToString());

                //删除销售订单明细临时表
                //commBB.ExecuteSql("delete from dbo.CSaleDetail_HangHao where absEntry=" + absEntry.ToString());

                //获取备货单编号
                //dtStockUpBill = stockUpBillBB.GetList("absEntrys='" + absEntry.ToString() + "'").Tables[0];
                //if (dtStockUpBill.Rows.Count > 0)
                //{
                //    strStockUpBillNo = dtStockUpBill.Rows[0]["stockUpBillNo"].ToString();//备货单编号

                //    dtPickOutPlan = pickOutPlanBB.GetList("stockUpBillNo='" + strStockUpBillNo + "'").Tables[0];
                //    foreach (DataRow row in dtPickOutPlan.Rows)
                //    {
                //        commBB.ExecuteSql("update dbo.UStock set isOutStocking=0 where wareLocatorNo='" + row["wareLocatorNo"].ToString() + "'");
                //    }

                //    //删除备货单
                //    commBB.ExecuteSql("delete from dbo.CStockUpBill where stockUpBillNo='" + strStockUpBillNo + "'");

                //    //删除备货单明细
                //    commBB.ExecuteSql("delete from dbo.CStockUpDetail where stockUpBillNo='" + strStockUpBillNo + "'");

                //    //删除拣货计划
                //    commBB.ExecuteSql("delete from dbo.CPickOutPlan where stockUpBillNo='" + strStockUpBillNo + "'");
                //}

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

            return ret;
        }
Esempio n. 12
0
        /// <summary>
        /// 其他出入库 保存 
        /// 解决因为使用CpickoutPlan导致的保存不了DocEntry 从而导致拣货完成后 没有保存的时候 看到的数据有问题。
        /// </summary>
        /// <param name="pickOutPlanID"></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"></param>
        /// <returns></returns>
        public bool SaveOtherPickOutInfo_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);
            OtherOutInPickOutPlanBB pickOutPlanBB = new OtherOutInPickOutPlanBB();

            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();
                OtherOutInPickOutPlanData pickOutPlanModel = new OtherOutInPickOutPlanData();
                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 = 0;//此处暂时将提货单ID设为0
                    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;
        }
Esempio n. 13
0
        /// <summary>
        /// 托盘移库
        /// </summary>
        /// <param name="strPalletNo">托盘号</param>
        /// <param name="strNextWareNo">目的库区</param>
        /// <param name="strNextWareLocatorNo">目的库位</param>
        /// <returns></returns>
        public bool MovePallet(string strPalletNo, string strNextWareNo, string strNextWareLocatorNo)
        {
            bool ret = false;
            SqlTransaction trans = null;
            SCommBB commBB = new SCommBB(this.connection);
            LWareBB wareBB = new LWareBB();
            LWareLocatorBB wareLocatorBB = new LWareLocatorBB();
            BArrangeBillBoxBB arrangeBillBoxBB = new BArrangeBillBoxBB(this.connection);
            LMaterialBB materialBB = new LMaterialBB();
            CDEPickOutBoxBB DEPickOutBoxBB = new CDEPickOutBoxBB(this.connection);
            UStockOutInDetailBB stockOutInDetailBB = new UStockOutInDetailBB(this.connection);

            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 dtPreWare = new DataTable();
                DataTable dtNextWare = new DataTable();
                DataTable dtMaterial = new DataTable();
                DataTable dtStock = new DataTable();
                UStockOutInDetailData stockOutInDetailModel = new UStockOutInDetailData();
                int stockNum = 0;
                string strSql = "";
                object obj = null;

                //获取物料箱信息
                if (string.IsNullOrEmpty(strPalletNo))
                {
                    return false;
                }
                dtArrangeBillBox = arrangeBillBoxBB.GetVList("palletNo='" + strPalletNo
                    + "' and isnull(wareNo,'')<>''").Tables[0];

                if (dtArrangeBillBox.Rows.Count == 0)
                {
                    return false;
                }

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

                //获取源库区信息
                dtPreWare = wareBB.GetList("wareNo='" + dtArrangeBillBox.Rows[0]["wareNo"].ToString() + "'").Tables[0];

                //获取目的库区信息
                dtNextWare = wareBB.GetList("wareNo='" + strNextWareNo + "'").Tables[0];

                #region 移库处理

                #region 源库区、库位处理

                //释放源正式库位
                commBB.ExecuteSql("update dbo.LWareLocator set isUsing=0 where wareLocatorNo='"
                    + dtArrangeBillBox.Rows[0]["wareLocatorNo"].ToString() + "'");

                //增加出入库明细-原托盘出库
                foreach (DataRow row in dtArrangeBillBox.Rows)
                {
                    dtStock = stockBB.GetList("boxNo='" + row["boxNo"].ToString() + "'").Tables[0];
                    if (dtStock.Rows.Count > 0)
                    {
                        dtMaterial = materialBB.GetList("materialNo='" + row["materialNo"].ToString() + "'").Tables[0];

                        //保存出入库明细数据
                        stockOutInDetailModel = new UStockOutInDetailData();

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

                        stockOutInDetailBB.AddRecord(stockOutInDetailModel);
                    }
                }

                //删除库存明细
                commBB.ExecuteSql("delete from dbo.UStock where palletNo='" + strPalletNo + "'");

                #endregion 源库区、库位处理

                #region 更改箱子库位

                //修改拆托拣货箱信息
                strSql = @"update dbo.CDEPickOutBox set isOutStock=1,updtDt=getDate(),updtEmpId="
                    + this.EmpID.ToString() + " where palletNo='" + strPalletNo + "' and isOutStock=0";

                commBB.ExecuteSql(strSql);

                //更改排托箱库位信息
                if (strNextWareNo != "")//移到其他库位
                {
                    commBB.ExecuteSql("update dbo.BArrangeBillBox set preWareNo=wareNo,wareNo='" + strNextWareNo
                        + "',preWareLocatorNo=wareLocatorNo,wareLocatorNo='" + strNextWareLocatorNo
                        + "' where palletNo='" + strPalletNo + "' and isnull(wareNo,'')<>''");
                }
                else//移出库
                {
                    commBB.ExecuteSql("update dbo.BArrangeBillBox set oldPalletNo=palletNo,palletNo='',preWareNo=wareNo,wareNo='',preWareLocatorNo=wareLocatorNo,wareLocatorNo='',"
                        + "outStockDt=getDate(),outStockEmpId=" + this.EmpID.ToString()
                        + " where palletNo='" + strPalletNo + "' and isnull(wareNo,'')<>''");
                }

                #endregion 更改箱子库位

                #region 目的库区、库位处理

                if (strNextWareLocatorNo != "")
                {
                    //占用目的库位
                    commBB.ExecuteSql("update dbo.LWareLocator set isUsing=1 where wareLocatorNo='"
                        + strNextWareLocatorNo + "'");

                    //目的库位为正式库区、源库位为正式库区或有库存明细
                    if ((dtNextWare.Rows.Count > 0
                        && dtNextWare.Rows[0]["wareType"].ToString() == "03")
                        || dtPreWare.Rows[0]["wareType"].ToString() == "03" || stockNum > 0)
                    {
                        #region 移到正式库

                        UStockData stockModel = new UStockData();

                        //排托箱信息入正式库
                        for (int i = 0; i < dtArrangeBillBox.Rows.Count; i++)
                        {
                            dtMaterial = materialBB.GetList("materialNo='" + dtArrangeBillBox.Rows[i]["materialNo"].ToString() + "'").Tables[0];

                            //保存库存明细数据
                            stockModel = new UStockData();

                            stockModel.wareNo = strNextWareNo;//仓库
                            stockModel.wareLocatorNo = strNextWareLocatorNo;//库位
                            stockModel.stockDt = System.DateTime.Today.ToString();//库存日期
                            stockModel.palletNo = strPalletNo;//托盘号
                            stockModel.materialNo = dtArrangeBillBox.Rows[i]["materialNo"].ToString();//物料编号
                            stockModel.boxNo = dtArrangeBillBox.Rows[i]["boxNo"].ToString();//箱号
                            stockModel.factMonomerNum = Convert.ToDouble(dtArrangeBillBox.Rows[i]["U_UintQty"]);//单体数量
                            stockModel.factPackNum = Convert.ToDouble(dtArrangeBillBox.Rows[i]["U_BoxQty"]);//整箱数量
                            stockModel.num = Convert.ToDouble(dtArrangeBillBox.Rows[i]["leavingNum"])
                                + Convert.ToDouble(dtArrangeBillBox.Rows[0]["DEPickOutNum"]);//数量
                            stockModel.isOutStocking = false;//是否正在出库
                            stockModel.stockMark = "移库";
                            stockModel.isrtEmpId = this.empId;
                            stockModel.isrtDt = System.DateTime.Now.ToString();

                            stockBB.AddRecord(stockModel);

                            //保存出入库明细数据
                            stockOutInDetailModel = new UStockOutInDetailData();

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

                            stockOutInDetailBB.AddRecord(stockOutInDetailModel);

                            //更改排托箱入库信息
                            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 移到正式库
                    }
                }

                #endregion 目的库区、库位处理

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

                #endregion 移库处理

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

            return ret;
        }
Esempio n. 14
0
        /// <summary>
        /// 合箱处理
        /// </summary>
        /// <param name="strOldBoxNo">源箱号</param>
        /// <param name="strNewBoxNo">目的箱号</param>
        /// <param name="pickOutNum">合并数量</param>
        /// <returns></returns>
        public bool JoinBox(string strOldBoxNo, string strNewBoxNo, int pickOutNum)
        {
            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();
            UStockOutInDetailBB stockOutInDetailBB = new UStockOutInDetailBB(this.connection);

            try
            {
                if (this.transaction == null)
                {
                    trans = this.connection.BeginTransaction("TranJoinBox");
                    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 dtOldArrangeBillBox = new DataTable();
                DataTable dtNewArrangeBillBox = new DataTable();
                DataTable dtMaterial = new DataTable();
                DataTable dtStock = new DataTable();
                CDEPickOutBoxData DEPickOutBoxModel = new CDEPickOutBoxData();
                UStockOutInDetailData stockOutInDetailModel = new UStockOutInDetailData();
                UStockData stockModel = new UStockData();
                string strSql = "", strPreWareLocatorNo = "";

                //获取源箱信息
                dtOldArrangeBillBox = arrangeBillBoxBB.GetVList("boxNo='" + strOldBoxNo + "'").Tables[0];

                //获取新箱信息
                dtNewArrangeBillBox = arrangeBillBoxBB.GetVList("boxNo='" + strNewBoxNo + "'").Tables[0];

                //扫描箱所在库位
                if (dtOldArrangeBillBox.Rows.Count > 0)
                {
                    strPreWareLocatorNo = dtOldArrangeBillBox.Rows[0]["wareLocatorNo"].ToString();
                }

                #region 增加拣货信息赋值

                DEPickOutBoxModel = new CDEPickOutBoxData();

                DEPickOutBoxModel.boxNo = strNewBoxNo;//新箱号
                DEPickOutBoxModel.oldBoxNo = strOldBoxNo;//原箱号
                DEPickOutBoxModel.materialNo = dtNewArrangeBillBox.Rows[0]["materialNo"].ToString();//物料编号
                DEPickOutBoxModel.num = pickOutNum;//拣货数量
                DEPickOutBoxModel.palletNo = dtNewArrangeBillBox.Rows[0]["palletNo"].ToString();//新托盘号
                DEPickOutBoxModel.region = "";//新区域

                if (dtOldArrangeBillBox.Rows.Count > 0)
                {
                    DEPickOutBoxModel.oldPalletNo = dtOldArrangeBillBox.Rows[0]["palletNo"].ToString();//原托盘号
                    DEPickOutBoxModel.oldRegion = dtOldArrangeBillBox.Rows[0]["region"].ToString();//原区域
                    DEPickOutBoxModel.preWareNo = dtOldArrangeBillBox.Rows[0]["wareNo"].ToString();//原库区
                    DEPickOutBoxModel.preWareLocatorNo = dtOldArrangeBillBox.Rows[0]["wareLocatorNo"].ToString();//原库位
                }
                else
                {
                    DEPickOutBoxModel.oldPalletNo = "";//原托盘号
                    DEPickOutBoxModel.oldRegion = "";//原区域
                    DEPickOutBoxModel.preWareNo = "";//原库区
                    DEPickOutBoxModel.preWareLocatorNo = "";//原库位
                }

                DEPickOutBoxModel.stockUpBillNo = "";//备货单编号
                DEPickOutBoxModel.palletIndex = 0;//备货单内托盘序号
                DEPickOutBoxModel.isrtEmpId = this.EmpID;//添加人
                DEPickOutBoxModel.isrtDt = System.DateTime.Now.ToString();//添加时间
                DEPickOutBoxModel.wareNo = dtNewArrangeBillBox.Rows[0]["wareNo"].ToString();//新库区
                DEPickOutBoxModel.wareLocatorNo = dtNewArrangeBillBox.Rows[0]["wareLocatorNo"].ToString();//新库位
                DEPickOutBoxModel.isOutStock = true;//是否出库

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

                #endregion 增加拣货信息赋值

                #region 源箱处理

                if (strOldBoxNo.Trim() != "")//源箱号在系统中已存在
                {
                    //增加出入库明细-原箱出库
                    dtStock = stockBB.GetList("boxNo='" + strOldBoxNo + "'").Tables[0];
                    if (dtStock.Rows.Count > 0)//原箱有库存
                    {
                        //获取物料属性
                        dtMaterial = materialBB.GetList("materialNo='" + dtOldArrangeBillBox.Rows[0]["materialNo"].ToString() + "'").Tables[0];

                        //保存出入库明细数据-出库
                        stockOutInDetailModel = new UStockOutInDetailData();

                        stockOutInDetailModel.billNo = "";//单据编号
                        stockOutInDetailModel.outInType = "09";//合箱
                        stockOutInDetailModel.isOut = true;//是否出库
                        stockOutInDetailModel.stockDt = System.DateTime.Today.ToString();//库存日期
                        stockOutInDetailModel.dt = System.DateTime.Today.ToString();//操作日期
                        stockOutInDetailModel.wareNo = dtOldArrangeBillBox.Rows[0]["wareNo"].ToString();//仓库
                        stockOutInDetailModel.wareLocatorNo = dtOldArrangeBillBox.Rows[0]["wareLocatorNo"].ToString();//库位
                        stockOutInDetailModel.salverNo = dtOldArrangeBillBox.Rows[0]["palletNo"].ToString();//托盘号
                        stockOutInDetailModel.boxNo = strOldBoxNo;//箱号
                        stockOutInDetailModel.materialNo = dtOldArrangeBillBox.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 + "'");
                    }
                }

                #endregion 源箱处理

                #region 目的箱处理

                dtStock = stockBB.GetList("boxNo='" + strNewBoxNo + "'").Tables[0];
                if (dtStock.Rows.Count > 0)//新箱已有库存
                {
                    //获取物料属性
                    dtMaterial = materialBB.GetList("materialNo='" + dtNewArrangeBillBox.Rows[0]["materialNo"].ToString() + "'").Tables[0];

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

                    stockOutInDetailModel.billNo = "";//单据编号
                    stockOutInDetailModel.outInType = "09";//合箱
                    stockOutInDetailModel.isOut = false;//是否出库
                    stockOutInDetailModel.stockDt = System.DateTime.Today.ToString();//库存日期
                    stockOutInDetailModel.dt = System.DateTime.Today.ToString();//操作日期
                    stockOutInDetailModel.wareNo = dtNewArrangeBillBox.Rows[0]["wareNo"].ToString();//仓库
                    stockOutInDetailModel.wareLocatorNo = dtNewArrangeBillBox.Rows[0]["wareLocatorNo"].ToString();//库位
                    stockOutInDetailModel.salverNo = dtNewArrangeBillBox.Rows[0]["palletNo"].ToString(); ;//托盘号
                    stockOutInDetailModel.boxNo = strNewBoxNo;//箱号
                    stockOutInDetailModel.materialNo = dtNewArrangeBillBox.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);

                    //修改目的箱的库存数量
                    strSql = "update dbo.UStock set num=num+" + pickOutNum.ToString() + " where boxNo='" + strNewBoxNo + "'";
                    commBB.ExecuteSql(strSql);

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

                #endregion 目的箱处理

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

                //库存明细数量为0,删除信息
                strSql = "delete from dbo.UStock where num=0";
                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("TranJoinBox");
                throw new Exception("保存信息失败!");
            }
            finally
            {
                commBB.Dispose();
                arrangeBillBoxBB.Dispose();
                DEPickOutBoxBB.Dispose();
                materialBB.Dispose();
                stockOutInDetailBB.Dispose();
            }

            return ret;
        }
Esempio n. 15
0
        /// <summary>
        /// 流利货架入库
        /// </summary>
        /// <param name="strPalletNo">托盘条码号</param>
        /// <param name="strBoxNo">箱号</param>
        /// <param name="strWareNo">库区编码</param>
        /// <param name="strWareLocatorNo">库位编码</param>
        /// <returns></returns>
        public bool FluencyPalletInStock(string strPalletNo, string strBoxNo, string strWareNo, string strWareLocatorNo)
        {
            bool ret = false;
            SqlTransaction trans = null;
            BArrangeBillBoxBB arrangeBillBoxBB = new BArrangeBillBoxBB(this.connection);
            UStockOutInDetailBB stockOutInDetailBB = new UStockOutInDetailBB(this.connection);
            SCommBB commBB = new SCommBB(this.connection);
            LMaterialBB materialBB = new LMaterialBB();

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

                DataTable dtMaterial = new DataTable();
                DataTable dtArrangeBillBox = new DataTable();
                UStockData stockModel = new UStockData();
                UStockOutInDetailData stockOutInDetailModel = new UStockOutInDetailData();

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

                #region 保存库存明细数据

                //保存库存明细数据
                stockModel = new UStockData();

                stockModel.wareNo = strWareNo;//仓库
                stockModel.wareLocatorNo = strWareLocatorNo;//库位
                stockModel.stockDt = System.DateTime.Today.ToString();//库存日期
                stockModel.palletNo = "";//托盘号
                stockModel.materialNo = dtArrangeBillBox.Rows[0]["materialNo"].ToString();//物料编号
                stockModel.boxNo = strBoxNo;//箱号
                stockModel.factMonomerNum = Convert.ToDouble(dtMaterial.Rows[0]["U_UintQty"]);//单体数量
                stockModel.factPackNum = Convert.ToDouble(dtMaterial.Rows[0]["U_BoxQty"]);//整箱数量
                stockModel.num = Convert.ToDouble(dtArrangeBillBox.Rows[0]["leavingNum"])
                    + Convert.ToDouble(dtArrangeBillBox.Rows[0]["DEPickOutNum"]);//数量
                stockModel.isOutStocking = false;//是否正在出库
                stockModel.stockMark = "流利货架入库";
                stockModel.isrtDt = System.DateTime.Now.ToString();//操作时间
                stockModel.isrtEmpId = this.empId;//操作人员

                stockBB.AddRecord(stockModel);

                #endregion 保存库存明细数据

                #region 保存出入库明细数据

                //保存出入库明细数据
                stockOutInDetailModel = new UStockOutInDetailData();

                stockOutInDetailModel.billNo = dtArrangeBillBox.Rows[0]["arriveBillNo"].ToString();//单据编号
                stockOutInDetailModel.outInType = "05";//理货入库
                stockOutInDetailModel.isOut = false;//是否出库
                stockOutInDetailModel.stockDt = System.DateTime.Today.ToString();//库存日期
                stockOutInDetailModel.dt = System.DateTime.Today.ToString();//操作日期
                stockOutInDetailModel.wareNo = strWareNo;//仓库
                stockOutInDetailModel.wareLocatorNo = strWareLocatorNo;//库位
                stockOutInDetailModel.salverNo = "";//托盘号
                stockOutInDetailModel.boxNo = strBoxNo;//箱号
                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 = Convert.ToDouble(dtArrangeBillBox.Rows[0]["leavingNum"])
                    + Convert.ToDouble(dtArrangeBillBox.Rows[0]["DEPickOutNum"]);//数量
                stockOutInDetailModel.nextBoxNo = "";//拆箱目的箱号
                stockOutInDetailModel.isrtEmpId = this.empId;
                stockOutInDetailModel.isrtDt = System.DateTime.Now.ToString();

                stockOutInDetailBB.AddRecord(stockOutInDetailModel);

                #endregion 保存出入库明细数据

                //更改箱子库位和托盘信息
                commBB.ExecuteSql(@"update dbo.BArrangeBillBox set oldPalletNo=palletNo,oldRegion=region,
                                    palletNo='',region='',preWareNo=wareNo,preWareLocatorNo=wareLocatorNo,
                                    wareNo='" + strWareNo + "',wareLocatorNo='" + strWareLocatorNo + "',isOutStocking=0 where boxNo='" + strBoxNo + "'");

                //更改箱子入库时间和入库人员(第一次入流利货架时保存入库信息,如果从流利货架拣出,再入库,不再更改入库信息)
                commBB.ExecuteSql(@"update dbo.BArrangeBillBox set inStockDt=getDate(),inStockEmpId=" + this.EmpID.ToString() + ",inStockNum=" + stockOutInDetailModel.num.ToString()
                    + " where boxNo='" + strBoxNo + "' and isnull(wareNo,'')<>'' and inStockDt is null");

                if (this.transaction == null) trans.Commit();
                ret = true;
            }
            catch
            {
                if (transaction == null) trans.Rollback("TranSave");
                throw new Exception("流利货架入库出错!");
            }
            finally
            {
                stockOutInDetailBB.Dispose();
                arrangeBillBoxBB.Dispose();
                materialBB.Dispose();
                commBB.Dispose();
            }

            return ret;
        }
Esempio n. 16
0
        //*****************************************************************************
        //do it later      do it later      do it later
        //*****************************************************************************
        /// <summary>
        /// 保存托盘指定库位信息
        /// </summary>
        /// <param name="tallyBillModel">称重理货单明细</param>
        /// <param name="strWareNo"></param>
        /// <returns></returns>
        public bool SetPalletWarelocator(BTallyBillData tallyBillModel, string strWareNo)
        {
            bool ret = false;
            SqlTransaction trans = null;
            BTallyBillBB tallyBillBB = new BTallyBillBB(this.connection);
            UStockOutInDetailBB stockOutInDetailBB = new UStockOutInDetailBB(this.connection);
            SCommBB commBB = new SCommBB(this.connection);
            BTallyBillDetailBB tallyBillDetailBB = new BTallyBillDetailBB();
            BArrangeBillBoxBB arrangeBillBoxBB = new BArrangeBillBoxBB();
            LMaterialBB materialBB = new LMaterialBB();

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

                DataTable dtTallyBillDetail = new DataTable();
                DataTable dtBox = new DataTable();
                DataTable dtMaterial = new DataTable();
                UStockData stockModel = new UStockData();
                UStockOutInDetailData stockOutInDetailModel = new UStockOutInDetailData();

                //保存称重理货单数据
                tallyBillBB.ModifyRecord(tallyBillModel);

                //获取理货单明细
                dtTallyBillDetail = tallyBillDetailBB.GetList("mainId=" + tallyBillModel.id).Tables[0];

                for (int i = 0; i < dtTallyBillDetail.Rows.Count; i++)
                {
                    dtBox = arrangeBillBoxBB.GetVList("boxNo='" + dtTallyBillDetail.Rows[i]["boxNo"].ToString() + "'").Tables[0];
                    dtMaterial = materialBB.GetList("materialNo='" + dtBox.Rows[0]["materialNo"].ToString() + "'").Tables[0];

                    //保存库存明细数据
                    stockModel = new UStockData();

                    stockModel.wareNo = strWareNo;//仓库
                    stockModel.wareLocatorNo = tallyBillModel.wareLocatorNo;//库位
                    stockModel.stockDt = System.DateTime.Today.ToString();//库存日期
                    stockModel.palletNo = tallyBillModel.palletNo;//托盘号
                    stockModel.materialNo = dtBox.Rows[0]["materialNo"].ToString();//物料编号
                    stockModel.boxNo = dtTallyBillDetail.Rows[i]["boxNo"].ToString();//箱号
                    stockModel.factMonomerNum = Convert.ToDouble(dtMaterial.Rows[0]["U_UintQty"]);//单体数量
                    stockModel.factPackNum = Convert.ToDouble(dtMaterial.Rows[0]["U_BoxQty"]);//整箱数量
                    stockModel.num = Convert.ToDouble(dtBox.Rows[0]["leavingNum"])
                        + Convert.ToDouble(dtBox.Rows[0]["DEPickOutNum"]);//数量
                    stockModel.isOutStocking = false;//是否正在出库
                    stockModel.stockMark = "保存托盘指定库位信息";
                    stockModel.isrtDt = System.DateTime.Now.ToString();//操作时间
                    stockModel.isrtEmpId = this.empId;//操作人员

                    stockBB.AddRecord(stockModel);

                    //保存出入库明细数据
                    stockOutInDetailModel = new UStockOutInDetailData();

                    stockOutInDetailModel.billNo = dtBox.Rows[0]["arriveBillNo"].ToString();//单据编号
                    stockOutInDetailModel.outInType = "05";//理货入库
                    stockOutInDetailModel.isOut = false;//是否出库
                    stockOutInDetailModel.stockDt = System.DateTime.Today.ToString();//库存日期
                    stockOutInDetailModel.dt = System.DateTime.Today.ToString();//操作日期
                    stockOutInDetailModel.wareNo = strWareNo;//仓库
                    stockOutInDetailModel.wareLocatorNo = tallyBillModel.wareLocatorNo;//库位
                    stockOutInDetailModel.salverNo = tallyBillModel.palletNo;//托盘号
                    stockOutInDetailModel.boxNo = dtTallyBillDetail.Rows[i]["boxNo"].ToString();//箱号
                    stockOutInDetailModel.materialNo = dtBox.Rows[0]["materialNo"].ToString();//物料编号
                    stockOutInDetailModel.factMonomerNum = Convert.ToDouble(dtMaterial.Rows[0]["U_UintQty"]);//单体数量
                    stockOutInDetailModel.factPackNum = Convert.ToDouble(dtMaterial.Rows[0]["U_BoxQty"]);//整箱数量
                    stockOutInDetailModel.num = Convert.ToDouble(dtBox.Rows[0]["leavingNum"])
                        + Convert.ToDouble(dtBox.Rows[0]["DEPickOutNum"]);//数量
                    stockOutInDetailModel.nextBoxNo = "";//拆箱目的箱号
                    stockOutInDetailModel.isrtEmpId = this.empId;
                    stockOutInDetailModel.isrtDt = System.DateTime.Now.ToString();

                    stockOutInDetailBB.AddRecord(stockOutInDetailModel);

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

                if (this.transaction == null) trans.Commit();
                ret = true;
            }
            catch
            {
                if (transaction == null) trans.Rollback("TranSave");
                throw new Exception("指定库位出错了!");
            }
            finally
            {
                tallyBillBB.Dispose();
                stockOutInDetailBB.Dispose();
                tallyBillDetailBB.Dispose();
                arrangeBillBoxBB.Dispose();
                materialBB.Dispose();
                commBB.Dispose();
            }

            return ret;
        }
Esempio n. 17
0
        /// <summary>
        /// 质检区拆托合托功能 不涉及到出入库操作
        /// </summary>
        /// <param name="pickOutPlanID"></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"></param>
        /// <returns></returns>
        public bool SavePickOutInfo_DECheck(int pickOutPlanID, string strStockUpBillNo, int palletIndex, string strNewPalletNo,
          string strOldBoxNo, string strNewBoxNo, int pickOutNum, string strOperType,int checkEmpID)
        {
            bool ret = false;
            SqlTransaction trans = null;
            SCommBB commBB = new SCommBB(this.connection);
            BArrangeBillBoxBB arrangeBillBoxBB = new BArrangeBillBoxBB(this.connection);
            LMaterialBB materialBB = new LMaterialBB();
            LWareBB wareBB = new LWareBB();
            bool checkResult = false;//质检结果,拆出来的全是不合格的

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

                }
                else
                {
                    this.stockBB.Transaction = this.transaction;
                    commBB.Transaction = this.transaction;
                    arrangeBillBoxBB.Transaction = this.transaction;

                }

                DataTable dtArrangeBillBox = new DataTable();
                DataTable dtPallet = new DataTable();
                DataTable dtMaterial = new DataTable();
                DataTable dtStock = new DataTable();
                string  strPreWareLocatorNo = "";

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

                //扫描箱所在库位
                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];

                //更改原箱的信息,增加新箱的信息

                        commBB.ExecuteSql("update dbo.BArrangeBillBox set FactNum = "+dtArrangeBillBox.Rows[0]["factNum"]+"-"+pickOutNum+" where boxNo='" + strOldBoxNo + "'");

                //增加新箱信息
                        BArrangeBillBoxData newArrangeBillBoxModel = new BArrangeBillBoxData();
                        newArrangeBillBoxModel.arriveBillNo = dtArrangeBillBox.Rows[0]["arriveBillNo"].ToString();//到货单号
                        newArrangeBillBoxModel.financeBillNo = dtArrangeBillBox.Rows[0]["financeBillNo"].ToString();//采购订单号
                        newArrangeBillBoxModel.arrangeBillNo = "";//排托单号
                        newArrangeBillBoxModel.stockUpBillNo = "";//备货单编号
                        newArrangeBillBoxModel.boxNo = strNewBoxNo;//箱号
                        newArrangeBillBoxModel.oldBoxNo = strOldBoxNo;//原箱号
                        newArrangeBillBoxModel.materialNo = dtArrangeBillBox.Rows[0]["materialNo"].ToString();//物料编号
                        newArrangeBillBoxModel.factNum = double.Parse(pickOutNum.ToString());
                        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();//库区
                        newArrangeBillBoxModel.wareLocatorNo = dtArrangeBillBox.Rows[0]["wareLocatorNo"].ToString();//库区
                        newArrangeBillBoxModel.checkResult = checkResult;
                        newArrangeBillBoxModel.checkResultDt = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        newArrangeBillBoxModel.checkResultEmpId = checkEmpID;

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

                materialBB.Dispose();
                wareBB.Dispose();

            }

            return ret;
        }
Esempio n. 18
0
        /// <summary>
        /// 执行叉车任务
        /// </summary>
        /// <returns></returns>
        public bool ExecuteEffectForkliftTask(int taskId)
        {
            bool ret = false;
            SqlTransaction trans = null;
            SCommBB commBB = new SCommBB(this.connection);
            BTallyBillBB tallyBillBB = new BTallyBillBB(this.connection);
            UStockBB stockBB = new UStockBB(this.connection);
            UStockOutInDetailBB stockOutInDetailBB = new UStockOutInDetailBB(this.connection);
            BArrangeBillBoxBB arrangeBillBoxBB = new BArrangeBillBoxBB(this.connection);
            BTallyBillDetailBB tallyBillDetailBB = new BTallyBillDetailBB();
            LMaterialBB materialBB = new LMaterialBB();
            LWareLocatorBB wareLocatorBB = new LWareLocatorBB();
            LWareBB wareBB = new LWareBB();
            CPickOutPlanBB pickOutPlanBB = new CPickOutPlanBB();
            CDEPickOutBoxBB DEPickOutBoxBB = new CDEPickOutBoxBB(this.connection);

            try
            {
                if (this.transaction == null)
                {
                    trans = this.connection.BeginTransaction("TransSave");
                    this.forkliftTaskBB.Transaction = trans;
                    commBB.Transaction = trans;
                    tallyBillBB.Transaction = trans;
                    stockBB.Transaction = trans;
                    stockOutInDetailBB.Transaction = trans;
                    arrangeBillBoxBB.Transaction = trans;
                    DEPickOutBoxBB.Transaction = trans;

                }
                else
                {
                    this.forkliftTaskBB.Transaction = this.transaction;
                    commBB.Transaction = this.transaction;
                    tallyBillBB.Transaction = this.transaction;
                    stockBB.Transaction = this.transaction;
                    stockOutInDetailBB.Transaction = this.transaction;
                    arrangeBillBoxBB.Transaction = this.transaction;
                    DEPickOutBoxBB.Transaction = this.transaction;
                }

                BForkliftTaskData forkliftTaskModel = new BForkliftTaskData();
                UStockData stockModel = new UStockData();
                UStockOutInDetailData stockOutInDetailModel = new UStockOutInDetailData();
                DataTable dtPreWare = new DataTable();
                DataTable dtNextWare = new DataTable();
                DataTable dtBox = new DataTable();
                DataTable dtMaterial = new DataTable();
                DataTable dtPallet = new DataTable();

                string strSql = "";

                #region 修改叉车任务的处理信息

                //修改叉车任务的处理信息
                forkliftTaskModel = forkliftTaskBB.GetModel(taskId);

                forkliftTaskModel.isDeal = true;
                forkliftTaskModel.dealEmpId = this.empId;
                forkliftTaskModel.dealDt = System.DateTime.Now.ToString();

                //if (forkliftTaskModel.taskType == "01")
                //{

                //}
                //forkliftTaskBB.ModifyRecord(forkliftTaskModel);

                #endregion 修改叉车任务的处理信息

                //获取源库区信息
                dtPreWare = wareBB.GetList("wareNo='" + forkliftTaskModel.preWareNo + "'").Tables[0];

                //获取目的库区信息
                dtNextWare = wareBB.GetList("wareNo='" + forkliftTaskModel.nextWareNo + "'").Tables[0];

                //获取托盘上的所有物料箱
                dtPallet = arrangeBillBoxBB.GetList("palletNo='" + forkliftTaskModel.palletNo + "' and isnull(wareNo,'')<>''").Tables[0];

                //2015-01-30 添加 用于增加备货单号
                if (forkliftTaskModel.taskType == "01")
                {
                    if (dtPallet.Rows.Count > 0)
                    {
                        forkliftTaskModel.stockUpBillNo = dtPallet.Rows[0]["arriveBillNo"].ToString();
                    }
                }
                forkliftTaskBB.ModifyRecord(forkliftTaskModel);
                if (dtPallet.Rows.Count == 0)
                {
                    //如果托盘上没有箱,释放库位
                    commBB.ExecuteSql("update dbo.LWareLocator set isUsing=0 where wareLocatorNo='"
                        + forkliftTaskModel.nextLocatorNo + "'");
                }

                #region 更改箱子库位

                //更改流利货架拣货箱库位信息
                commBB.ExecuteSql("update dbo.CDEPickOutBox set isOutStock=1,updtDt=getDate(),updtEmpId="
                        + this.EmpID.ToString() + " where palletNo='" + forkliftTaskModel.palletNo + "' and isOutStock=0");

                //更改排托箱库位信息
                commBB.ExecuteSql("update dbo.BArrangeBillBox set preWareNo=wareNo,wareNo='" + forkliftTaskModel.nextWareNo
                    + "',preWareLocatorNo=wareLocatorNo,wareLocatorNo='" + forkliftTaskModel.nextLocatorNo
                    + "' where palletNo='" + forkliftTaskModel.palletNo + "' and isnull(wareNo,'')<>''");

                #endregion 更改箱子库位

                //释放源库位
                commBB.ExecuteSql("update dbo.LWareLocator set isUsing=0 where wareLocatorNo='"
                    + forkliftTaskModel.preLocatorNo + "'");

                if (forkliftTaskModel.taskType == "03" || forkliftTaskModel.taskType == "11")
                {
                    #region 从理货区到正式库区、从质检区到正式库区(非标准箱)

                    object obj = null;
                    int tallyBillId = 0;
                    BTallyBillData tallyBillModel = new BTallyBillData();

                    obj = commBB.ExecuteScalar("select top 1 id from dbo.BTallyBill where palletNo='"
                        + forkliftTaskModel.palletNo + "' and instantState='02' order by id desc");
                    if (obj != null)
                    {
                        #region 修改排托单信息

                        tallyBillId = Convert.ToInt32(obj);
                        tallyBillModel = tallyBillBB.GetModel(tallyBillId);

                        tallyBillModel.instantState = "03";//指定状态为“已入库”
                        tallyBillModel.isInStock = true;// 入库状态
                        tallyBillModel.wareNo = forkliftTaskModel.nextWareNo;//库区
                        tallyBillModel.wareLocatorNo = forkliftTaskModel.nextLocatorNo;//库位

                        tallyBillBB.ModifyRecord(tallyBillModel);

                        #endregion 修改排托单信息
                    }

                    #region 出入库和出入库明细数据操作

                    if (dtNextWare.Rows[0]["wareSortNo"].ToString() != "D"
                        && dtNextWare.Rows[0]["wareSortNo"].ToString() != "E")
                    {
                        dtBox = arrangeBillBoxBB.GetVList("palletNo='" + forkliftTaskModel.palletNo + "' and isnull(wareNo,'')<>''").Tables[0];

                        for (int i = 0; i < dtBox.Rows.Count; i++)
                        {
                            dtMaterial = materialBB.GetList("materialNo='" + dtBox.Rows[i]["materialNo"].ToString() + "'").Tables[0];

                            //保存库存明细数据
                            stockModel = new UStockData();

                            stockModel.wareNo = forkliftTaskModel.nextWareNo;//仓库
                            stockModel.wareLocatorNo = forkliftTaskModel.nextLocatorNo;//库位
                            stockModel.stockDt = System.DateTime.Today.ToString();//库存日期
                            stockModel.palletNo = forkliftTaskModel.palletNo;//托盘号
                            stockModel.materialNo = dtBox.Rows[i]["materialNo"].ToString();//物料编号
                            stockModel.boxNo = dtBox.Rows[i]["boxNo"].ToString();//箱号
                            stockModel.factMonomerNum = Convert.ToDouble(dtMaterial.Rows[0]["U_UintQty"]);//单体数量
                            stockModel.factPackNum = Convert.ToDouble(dtMaterial.Rows[0]["U_BoxQty"]);//整箱数量
                            stockModel.num = Convert.ToDouble(dtBox.Rows[i]["leavingNum"])
                                + Convert.ToDouble(dtBox.Rows[i]["DEPickOutNum"]);//数量
                            stockModel.isOutStocking = false;//是否正在出库
                            stockModel.stockMark = "从理到正式库2";
                            stockModel.isrtDt = System.DateTime.Now.ToString();//操作时间
                            stockModel.isrtEmpId = this.EmpID;//操作人

                            stockBB.AddRecord(stockModel);

                            //保存出入库明细数据
                            stockOutInDetailModel = new UStockOutInDetailData();

                            stockOutInDetailModel.billNo = dtBox.Rows[i]["arriveBillNo"].ToString();//单据编号
                            stockOutInDetailModel.outInType = "05";//理货入库
                            stockOutInDetailModel.isOut = false;//是否出库
                            stockOutInDetailModel.stockDt = System.DateTime.Today.ToString();//库存日期
                            stockOutInDetailModel.dt = System.DateTime.Today.ToString();//操作日期
                            stockOutInDetailModel.wareNo = forkliftTaskModel.nextWareNo;//仓库
                            stockOutInDetailModel.wareLocatorNo = forkliftTaskModel.nextLocatorNo;//库位
                            stockOutInDetailModel.salverNo = forkliftTaskModel.palletNo;//托盘号
                            stockOutInDetailModel.boxNo = dtBox.Rows[i]["boxNo"].ToString();//箱号
                            stockOutInDetailModel.materialNo = dtBox.Rows[i]["materialNo"].ToString();//物料编号
                            stockOutInDetailModel.factMonomerNum = Convert.ToDouble(dtMaterial.Rows[0]["U_UintQty"]);//单体数量
                            stockOutInDetailModel.factPackNum = Convert.ToDouble(dtMaterial.Rows[0]["U_BoxQty"]);//整箱数量
                            stockOutInDetailModel.num = Convert.ToDouble(dtBox.Rows[i]["leavingNum"])
                                + Convert.ToDouble(dtBox.Rows[i]["DEPickOutNum"]);//数量
                            stockOutInDetailModel.isrtEmpId = this.empId;
                            stockOutInDetailModel.isrtDt = System.DateTime.Now.ToString();

                            stockOutInDetailBB.AddRecord(stockOutInDetailModel);

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

                    //更改排托箱检测结果
                    commBB.ExecuteSql("update dbo.BArrangeBillBox set checkResult=1,checkResultDt=getDate(),checkResultEmpId="
                        + this.EmpID.ToString() + " where palletNo='" + forkliftTaskModel.palletNo
                        + "' and isnull(wareNo,'')<>'' and checkResult=0 and checkResultDt is null");

                    #endregion 出入库和出入库明细数据操作

                    #endregion 从理货区到正式库区、从质检区到正式库区
                }
                else if (forkliftTaskModel.taskType == "05")
                {
                    #region 05 从正式库区到拣货区

                    //更改排托箱库位信息-库位赋值原库位
                    //commBB.ExecuteSql("update dbo.BArrangeBillBox set wareNo=preWareNo,wareLocatorNo=preWareLocatorNo where palletNo='"
                    //    + forkliftTaskModel.palletNo + "' and isnull(wareNo,'')<>''");

                    //锁定原库位
                    //commBB.ExecuteSql("update dbo.LWareLocator set isUsing=1 where wareLocatorNo='"
                    //    + forkliftTaskModel.preLocatorNo + "'");

                    #endregion 05 从正式库区到拣货区
                }
                else if (forkliftTaskModel.taskType == "06")
                {
                    #region 从拣货区到正式库区

                    //库存处理放在包装线体上

                    ////获取托盘箱明细
                    //dtBox = arrangeBillBoxBB.GetVList("palletNo='" + forkliftTaskModel.palletNo
                    //    + "' and isnull(wareNo,'')<>''").Tables[0];

                    //if (dtNextWare.Rows[0]["wareSortNo"].ToString() != "D"
                    //        && dtNextWare.Rows[0]["wareSortNo"].ToString() != "E")
                    //{
                    //    for (int i = 0; i < dtBox.Rows.Count; i++)
                    //    {
                    //        //保存库存明细数据
                    //        stockModel = new UStockData();

                    //        stockModel.wareNo = forkliftTaskModel.nextWareNo;//仓库
                    //        stockModel.wareLocatorNo = forkliftTaskModel.nextLocatorNo;//库位
                    //        stockModel.stockDt = System.DateTime.Today.ToString();//库存日期
                    //        stockModel.palletNo = forkliftTaskModel.palletNo;//托盘号
                    //        stockModel.materialNo = dtBox.Rows[i]["materialNo"].ToString();//物料编号
                    //        stockModel.boxNo = dtBox.Rows[i]["boxNo"].ToString();//箱号
                    //        stockModel.factMonomerNum = Convert.ToDouble(dtMaterial.Rows[0]["U_UintQty"]);//单体数量
                    //        stockModel.factPackNum = Convert.ToDouble(dtMaterial.Rows[0]["U_BoxQty"]);//整箱数量
                    //        stockModel.num = Convert.ToDouble(dtBox.Rows[i]["leavingNum"])
                    //            + Convert.ToDouble(dtBox.Rows[i]["DEPickOutNum"]);//数量
                    //        //stockModel.isOutStocking = Convert.ToBoolean(dtBox.Rows[i]["isOutStocking"]);//是否正在出库
                    //        stockModel.isOutStocking = false;//是否正在出库
                    //        stockModel.stockMark = "从拣货返回正式库";
                    //        stockModel.isrtDt = System.DateTime.Now.ToString();//操作时间
                    //        stockModel.isrtEmpId = this.EmpID;//操作人

                    //        stockBB.AddRecord(stockModel);

                    //        //保存出入库明细数据
                    //        stockOutInDetailModel = new UStockOutInDetailData();

                    //        stockOutInDetailModel.billNo = "";//单据编号
                    //        stockOutInDetailModel.outInType = "09";//拣货返回正式库
                    //        stockOutInDetailModel.isOut = false;//是否出库
                    //        stockOutInDetailModel.stockDt = System.DateTime.Today.ToString();//库存日期
                    //        stockOutInDetailModel.dt = System.DateTime.Today.ToString();//操作日期
                    //        stockOutInDetailModel.wareNo = forkliftTaskModel.nextWareNo;//仓库
                    //        stockOutInDetailModel.wareLocatorNo = forkliftTaskModel.nextLocatorNo;//库位
                    //        stockOutInDetailModel.salverNo = forkliftTaskModel.palletNo;//托盘号
                    //        stockOutInDetailModel.boxNo = dtBox.Rows[i]["boxNo"].ToString();//箱号
                    //        stockOutInDetailModel.materialNo = dtBox.Rows[i]["materialNo"].ToString();//物料编号
                    //        stockOutInDetailModel.factMonomerNum = Convert.ToDouble(dtMaterial.Rows[0]["U_UintQty"]);//单体数量
                    //        stockOutInDetailModel.factPackNum = Convert.ToDouble(dtMaterial.Rows[0]["U_BoxQty"]);//整箱数量
                    //        stockOutInDetailModel.num = Convert.ToDouble(dtBox.Rows[i]["leavingNum"])
                    //            + Convert.ToDouble(dtBox.Rows[i]["DEPickOutNum"]);//数量

                    //        stockOutInDetailBB.AddRecord(stockOutInDetailModel);

                    //        //更改物料箱是否正在出库状态
                    //        commBB.ExecuteSql("update dbo.BArrangeBillBox set isOutStocking=0 where boxNo='"
                    //            + dtBox.Rows[i]["boxNo"].ToString() + "'");

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

                    #endregion 从拣货区到正式库区
                }
                else if (forkliftTaskModel.taskType == "07")
                {
                    #region 从拣货区出库

                    //根据托盘号,更改备货单明细的状态(05 出库完成)
                    strSql = "update dbo.CStockUpDetail set instantState='05' where palletNo='" + forkliftTaskModel.palletNo + "'";
                    commBB.ExecuteSql(strSql);

                    //如果备货单明细的状态全部为“05 出库完成”,更改备货单状态为“10 出库完成”
                    strSql = @"update dbo.CStockUpBill set instantState='10'
                           where not exists(select 1 from dbo.CStockUpDetail as t where t.stockUpBillNo=dbo.CStockUpBill.stockUpBillNo and instantState<>'05')";
                    commBB.ExecuteSql(strSql);
                    //如果备货单明细的状态不全为“05 出库完成”,更改备货单状态为“09 出库中”
                    strSql = @"update dbo.CStockUpBill set instantState='09'
                           where exists(select 1 from dbo.CStockUpDetail as t where t.stockUpBillNo=dbo.CStockUpBill.stockUpBillNo and instantState<>'05')";
                    commBB.ExecuteSql(strSql);

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

                    //更改到货箱库位信息
                    commBB.ExecuteSql("update dbo.BArrangeBillBox set isPalletUsing=0 where palletNo='"
                        + forkliftTaskModel.palletNo + "' and isnull(wareNo,'')<>''");

                    #endregion 从排托区返回收货区
                }
                else if (forkliftTaskModel.taskType == "10")
                {
                    #region 从收货区到质检区(非标准箱)

                    //更改到货箱库位信息
                    //commBB.ExecuteSql("update dbo.BArrangeBillBox set isPalletUsing=0 where palletNo='" + forkliftTaskModel.palletNo + "' and isnull(wareNo)<>''");

                    #endregion 从收货区到质检区(非标准箱)
                }
                else if (forkliftTaskModel.taskType == "12")
                {
                    #region 移库处理

                    #region 源库区、库位处理

                    //释放源正式库位
                    commBB.ExecuteSql("update dbo.LWareLocator set isUsing=0 where wareLocatorNo='"
                        + forkliftTaskModel.preLocatorNo + "'");

                    //如果从正式库出,删除库存明细
                    if (dtPreWare.Rows[0]["wareType"].ToString() == "03")//正式库区
                    {
                        //删除库存明细(处理逻辑以后更改成正常的出入库明细)
                        commBB.ExecuteSql("delete from dbo.UStock where palletNo='" + forkliftTaskModel.palletNo + "'");

                        //增加出入库明细-出库
                    }

                    #endregion 源库区、库位处理

                    #region 目的库区、库位处理

                    //占用目的库位
                    commBB.ExecuteSql("update dbo.LWareLocator set isUsing=1 where wareLocatorNo='"
                        + forkliftTaskModel.nextLocatorNo + "'");

                    if (dtNextWare.Rows[0]["wareType"].ToString() == "03")//正式库区
                    {
                        //DataTable dtDEPickOutBox = new DataTable();

                        ////获取原托盘所在库位
                        //dtArrangeBillBox = arrangeBillBoxBB.GetList("palletNo='" + forkliftTaskModel.palletNo + "' and isnull(wareNo,'')<>''").Tables[0];

                        ////获取流利货架拣货箱信息
                        //dtDEPickOutBox = DEPickOutBoxBB.GetList("palletNo='" + forkliftTaskModel.palletNo + "' and isOutStock=0").Tables[0];

                        ////排托箱信息入正式库
                        //for (int i = 0; i < dtArrangeBillBox.Rows.Count; i++)
                        //{
                        //    dtMaterial = materialBB.GetList("materialNo='" + dtArrangeBillBox.Rows[i]["materialNo"].ToString() + "'").Tables[0];

                        //    //保存库存明细数据
                        //    stockModel = new UStockData();

                        //    stockModel.wareNo = forkliftTaskModel.nextWareNo;//仓库
                        //    stockModel.wareLocatorNo = forkliftTaskModel.nextLocatorNo;//库位
                        //    stockModel.stockDt = System.DateTime.Today.ToString();//库存日期
                        //    stockModel.palletNo = forkliftTaskModel.palletNo;//托盘号
                        //    stockModel.materialNo = dtArrangeBillBox.Rows[i]["materialNo"].ToString();//物料编号
                        //    stockModel.boxNo = dtArrangeBillBox.Rows[i]["boxNo"].ToString();//箱号
                        //    stockModel.factMonomerNum = Convert.ToDouble(dtMaterial.Rows[0]["U_UintQty"]);//单体数量
                        //    stockModel.factPackNum = Convert.ToDouble(dtMaterial.Rows[0]["U_BoxQty"]);//整箱数量
                        //    stockModel.num = Convert.ToDouble(dtArrangeBillBox.Rows[i]["leavingNum"]) + Convert.ToDouble(dtArrangeBillBox.Rows[i]["DEPickOutNum"]);//数量
                        //    stockModel.isOutStocking = false;//是否正在出库
                        //    stockModel.stockMark = "移库(正式箱)";

                        //    stockBB.AddRecord(stockModel);
                        //}

                        ////流利货架拣货箱信息入正式库
                        //for (int i = 0; i < dtDEPickOutBox.Rows.Count; i++)
                        //{
                        //    dtMaterial = materialBB.GetList("materialNo='" + dtDEPickOutBox.Rows[i]["materialNo"].ToString() + "'").Tables[0];

                        //    //保存库存明细数据
                        //    stockModel = new UStockData();

                        //    stockModel.wareNo = forkliftTaskModel.nextWareNo;//仓库
                        //    stockModel.wareLocatorNo = forkliftTaskModel.nextLocatorNo;//库位
                        //    stockModel.stockDt = System.DateTime.Today.ToString();//库存日期
                        //    stockModel.palletNo = forkliftTaskModel.palletNo;//托盘号
                        //    stockModel.materialNo = dtDEPickOutBox.Rows[i]["materialNo"].ToString();//物料编号
                        //    stockModel.boxNo = dtDEPickOutBox.Rows[i]["boxNo"].ToString();//箱号
                        //    stockModel.factMonomerNum = Convert.ToDouble(dtMaterial.Rows[0]["U_UintQty"]);//单体数量
                        //    stockModel.factPackNum = Convert.ToDouble(dtMaterial.Rows[0]["U_BoxQty"]);//整箱数量
                        //    stockModel.num = Convert.ToDouble(dtDEPickOutBox.Rows[i]["num"]);//数量
                        //    stockModel.isOutStocking = false;//是否正在出库
                        //    stockModel.stockMark = "移库(拣货箱)";

                        //    stockBB.AddRecord(stockModel);
                        //}
                    }

                    #endregion 目的库区、库位处理

                    #endregion 移库处理
                }
                else if (forkliftTaskModel.taskType == "20")
                {
                    //托盘出库
                    DataTable dt = new DataTable();
                    dt = arrangeBillBoxBB.GetListOnlyStockUpBillNO("palletNo ='" + forkliftTaskModel.palletNo + "' and ISNULL(stockUpBillNo,'')<>''").Tables[0];

                    commBB.ExecuteSql("update dbo.BArrangeBillBox set oldPalletNo=palletNo,palletNo='',preWareNo=wareNo,wareNo='',preWareLocatorNo=wareLocatorNo,wareLocatorNo='',"
                          + "outStockDt=getDate(),outStockEmpId=" + this.EmpID.ToString()
                          + " where palletNo='" + forkliftTaskModel.palletNo + "' and isnull(wareNo,'')<>''");
                    commBB.ExecuteSql("update dbo.LWareLocator set isUsing=0 where wareLocatorNo='"
               + forkliftTaskModel.preLocatorNo + "'");

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {

                        strSql = @"update dbo.CStockUpDetail set instantState='05' where stockUpBillNo ='" + dt.Rows[i]["stockUpBillNo"].ToString() + "'";
                        commBB.ExecuteSql(strSql);
                        //如果备货单明细的状态全部为“05 出库完成”,更改备货单状态为“10 出库完成”,并且是关联到一个被货单的形式下
                        strSql = @"update dbo.CStockUpBill set instantState='10'
                           where stockUpBillNo = '" + dt.Rows[i]["stockUpBillNO"].ToString() + "'";
                        commBB.ExecuteSql(strSql);
                    }

                }
                else if (forkliftTaskModel.taskType == "30")//从质检区到异常区
                {
                    //首先作出库处理
                    //string command = @"Update BArrangeBillBox set oldPalletNo=palletNo,palletNo='',preWareNo=wareNo,wareNo='YCQ',preWareLocatorNo=wareLocatorNo,wareLocatorNo='N01.01',"
                    //      + "outStockDt=getDate(),outStockEmpId=" + this.EmpID.ToString()
                    //      + " where palletNo='" + forkliftTaskModel.palletNo + "' and isnull(wareNo,'')<>''";
                    //commBB.ExecuteSql(command);

                     DataSet ds = commBB.Query("select palletNo from BArrangeBillBox where wareLocatorNo = '" + forkliftTaskModel.preLocatorNo + "' group by palletNo");

                     if (ds.Tables[0].Rows.Count <= 1)
                     {
                         commBB.ExecuteSql("Update dbo.LWareLocator set isUsing=0 where wareLocatorNo='"  + forkliftTaskModel.preLocatorNo + "'");
                     }
                    commBB.ExecuteSql("Update dbo.LWareLocator set isUsing=0 where wareLocatorNo='" + forkliftTaskModel.nextLocatorNo + "'");//N01.01不占用

                }

                if (this.transaction == null) trans.Commit();
                ret = true;
            }
            catch (Exception ex)
            {
                if (this.transaction == null) trans.Rollback("TransSave");
                throw ex;
            }
            finally
            {
                commBB.Dispose();
                tallyBillBB.Dispose();
                stockBB.Dispose();
                stockOutInDetailBB.Dispose();
                tallyBillDetailBB.Dispose();
                arrangeBillBoxBB.Dispose();
                materialBB.Dispose();
                wareLocatorBB.Dispose();
                wareBB.Dispose();
                pickOutPlanBB.Dispose();
                DEPickOutBoxBB.Dispose();
            }

            return ret;
        }
        //*****************************************************************************
        //do it later      do it later      do it later
        //*****************************************************************************
        /// <summary>
        /// 保存产品检测结果
        /// </summary>
        /// <param name="productCheckDetailModel">产品检测结果实例</param>
        /// <returns></returns>
        public bool SaveRecord(BProductCheckDetailData productCheckDetailModel, string strCheckItemNo, string strMaterialNo)
        {
            bool ret = false;
            SqlTransaction trans = null;
            BWeigtHistoryBB weightHistoryBB = new BWeigtHistoryBB(this.connection);
            SCommBB commBB = new SCommBB(this.connection);

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

                StringBuilder strSql = new StringBuilder();
                BWeigtHistoryData weightHistoryModel = new BWeigtHistoryData();

                //保存产品检测结果实例
                this.productCheckDetailBB.AddRecord(productCheckDetailModel);

                //更改产品检测单状态为“检测中”
                strSql.Append("update checkBill set instantState='03' ");
                strSql.Append("from dbo.BCheckBill as checkBill ");
                strSql.Append("left join dbo.BCheckDetail as checkDetail on checkDetail.checkBillId=checkBill.Id ");
                strSql.Append("where checkDetail.id=" + productCheckDetailModel.checkDetailId.ToString());

                commBB.ExecuteSql(strSql.ToString());

                //如果为称重,向称重记录表插入一条数据
                if (strCheckItemNo == "1004")
                {
                    weightHistoryModel.materialNo = strMaterialNo;//物料编号
                    weightHistoryModel.dt = productCheckDetailModel.checkDt;//称重时间
                    weightHistoryModel.weight = productCheckDetailModel.weight;//称重
                    weightHistoryModel.isrtDt = System.DateTime.Now.ToString();//添加时间
                    weightHistoryModel.isrtEmpId = this.empId;//添加人

                    weightHistoryBB.AddRecord(weightHistoryModel);
                }

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

            return ret;
        }
Esempio n. 20
0
        /// <summary>
        /// 删除退货单信息
        /// </summary>
        /// <param name="id">退货单ID</param>
        /// <param name="strBackBillNo">退货单编号</param>
        /// <returns></returns>
        public bool DeleteRecord(int id, string strBackBillNo)
        {
            bool ret = false;
            SCommBB commBB = new SCommBB(this.connection);
            SqlTransaction trans = null;

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

                //删除退货单信息
                this.backBillBB.DeleteRecord(id);

                //删除退货单明细信息
                commBB.ExecuteSql("delete from dbo.BBackDetail where backBillNo='" + strBackBillNo + "'");

                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;
        }
Esempio n. 21
0
        //*****************************************************************************
        //do it later      do it later      do it later
        //*****************************************************************************
        /// <summary>
        /// 保存备货计划
        /// </summary>
        /// <param name="data">备货单实例</param>
        /// <param name="dtStockUpDetall">备货明细数据源</param>
        /// <param name="issubmit">是否提交</param>
        /// <returns></returns>
        public bool SaveBArrangeBill(CStockUpBillData data, DataTable dtStockUpDetall, bool isSubmit)
        {
            bool ret = false;
            CStockUpDetailBB stockUpDetailBB = new CStockUpDetailBB(connection);
            CStockUpBillBB stockUpBillBB = new CStockUpBillBB(connection);
            SCommBB commBB = new SCommBB(this.connection);
            SqlTransaction trans = null;

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

                int mainId = 0;
                CStockUpDetailData stockUpDetailModel = new CStockUpDetailData();
                string strSaleBillNos = "", strAbsEntrys = "", strLineNums = "";
                string[] saleBillNoArray = null, absEntryArray = null, lineNumArray = null;

                if (data.id == 0)
                {
                    #region 新增备货单

                    //新增备货主表数据
                    mainId = stockUpBillBB.AddRecord(data);

                    //新增备货单明细数据
                    foreach (DataRow dr in dtStockUpDetall.Rows)
                    {
                        if (dr["isdel"].ToString() == "0")
                        {
                            stockUpDetailModel = new CStockUpDetailData();

                            stockUpDetailModel.financeBillNo = dr["financeBillNo"].ToString();
                            stockUpDetailModel.financeBillSort = dr["financeBillSort"].ToString();
                            stockUpDetailModel.materialNo = dr["materialNo"].ToString();
                            stockUpDetailModel.num = Convert.ToInt32(dr["num"]);
                            stockUpDetailModel.instantState = "01";
                            stockUpDetailModel.palletIndex = Convert.ToInt32(dr["palletIndex"]);
                            stockUpDetailModel.stockUpBillNo = data.stockUpBillNo;
                            stockUpDetailModel.saleBillNo = dr["saleBillNo"].ToString();
                            stockUpDetailModel.DocEntry = Convert.ToInt32(dr["DocEntry"]);
                            stockUpDetailModel.absEntry = Convert.ToInt32(dr["absEntry"]);//销售提货单ID
                            stockUpDetailModel.lineNum = Convert.ToInt32(dr["lineNum"]);//销售订单行号
                            stockUpDetailModel.GZT = "";//分配工作台

                            stockUpDetailBB.AddRecord(stockUpDetailModel);
                        }
                    }

                    #endregion 新增备货单
                }
                else
                {
                    #region 修改备货单

                    //修改备货主表数据
                    stockUpBillBB.ModifyRecord(data);

                    //维护备货单明细数据
                    foreach (DataRow dr in dtStockUpDetall.Rows)
                    {
                        if (Convert.ToInt32(dr["id"]) > 0 && dr["isdel"].ToString() == "1")//删除方法
                        {
                            stockUpDetailBB.DeleteRecord(Convert.ToInt32(dr["id"]));

                        }
                        else if (Convert.ToInt32(dr["id"]) > 0 && dr["isdel"].ToString() == "0")//修改
                        {
                            stockUpDetailModel = stockUpDetailBB.GetModel(Convert.ToInt32(dr["id"]));

                            stockUpDetailModel.num = Convert.ToInt32(dr["num"]);

                            stockUpDetailBB.ModifyRecord(stockUpDetailModel);

                        }
                        else if (Convert.ToInt32(dr["id"]) == 0 && dr["isdel"].ToString() == "0")//添加
                        {
                            stockUpDetailModel = new CStockUpDetailData();

                            stockUpDetailModel.financeBillNo = dr["financeBillNo"].ToString();
                            stockUpDetailModel.financeBillSort = dr["financeBillSort"].ToString();
                            stockUpDetailModel.materialNo = dr["materialNo"].ToString();
                            stockUpDetailModel.num = Convert.ToInt32(dr["num"]);
                            stockUpDetailModel.instantState = "01";
                            stockUpDetailModel.palletIndex = Convert.ToInt32(dr["palletIndex"]);
                            stockUpDetailModel.stockUpBillNo = data.stockUpBillNo;
                            stockUpDetailModel.saleBillNo = dr["saleBillNo"].ToString();
                            stockUpDetailModel.DocEntry = Convert.ToInt32(dr["DocEntry"]);//销售订单ID
                            stockUpDetailModel.absEntry = Convert.ToInt32(dr["absEntry"]);//销售提货单ID
                            stockUpDetailModel.lineNum = Convert.ToInt32(dr["lineNum"]);//销售订单行号
                            stockUpDetailModel.GZT = "";//分配工作台

                            stockUpDetailBB.AddRecord(stockUpDetailModel);

                        }
                    }

                    #endregion 修改备货单
                }

                //根据提货单ID,更改销售订单状态
                strSaleBillNos = data.saleBillNos;
                strAbsEntrys = data.absEntrys;//提货单ID组合
                strLineNums = data.lineNums;
                saleBillNoArray = strSaleBillNos.Split(',');//销售订单编号数组
                absEntryArray = strAbsEntrys.Split(',');//提货单ID数组
                lineNumArray = strLineNums.Split(',');

                for (int n = 0; n < saleBillNoArray.Length; n++)
                {
                    //更改提货单状态
                    commBB.ExecuteSql("update dbo.CSaleBill set instantState='02',stockupBillNo='" + data.stockUpBillNo
                        + "' where saleBillNo='" + saleBillNoArray[n] + "' and absEntry='" + absEntryArray[n]
                        + "' and lineNum='" + lineNumArray[n] + "'");
                }

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

            return ret;
        }
Esempio n. 22
0
        //*****************************************************************************
        //do it later      do it later      do it later
        //*****************************************************************************
        /// <summary>
        /// 保存检测单数据
        /// </summary>
        /// <param name="checkBillModel">检测单实例</param>
        /// <param name="detailModelList">检测单明细实例列表</param>
        /// <param name="isReNew">是否进行过初始化,如果进行过,则保存时,先删除旧数据。0否1是</param>
        /// <returns></returns>
        public string SavelData(BCheckBillData checkBillModel, List<BCheckDetailData> detailModelList,string isReNew)
        {
            SqlTransaction trans = null;
            BCheckDetailBB checkDetailBB = new BCheckDetailBB(this.connection);
            SCommBB commBB = new SCommBB(this.connection);

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

                string strBillNo = "";

                if (isReNew == "1")//进行过初始化,则先删掉旧数据
                {
                    string strSQL = " delete from BCheckDetail where checkBillId='" + checkBillModel.id + "'";
                    commBB.Query(strSQL);
                }

                strBillNo = checkBillModel.checkBillNo;
                if (strBillNo == "")//新增
                {
                    checkBillModel.checkBillNo = checkBillBB.GetCurrentInBillNoByPreBillNo();
                    strBillNo = checkBillModel.checkBillNo;

                    //保存检测单主数据
                    int mainId = checkBillBB.AddRecord(checkBillModel);
                    checkBillModel.id = mainId;

                    //保存检测单明细数据
                    foreach (BCheckDetailData model in detailModelList)
                    {
                        if (model.openBoxNum != 0 && model.checkNum != 0)
                        {
                            model.checkBillId = mainId;
                            checkDetailBB.AddRecord(model);
                        }
                    }
                }
                else//修改
                {
                    //修改检测单主数据
                    checkBillBB.ModifyRecord(checkBillModel);

                    //明细
                    foreach (BCheckDetailData model in detailModelList)
                    {
                        if (model.id > 0 && model.checkBillId > 0)//修改 且未删除的明细
                        {
                            checkDetailBB.ModifyRecord(model);
                        }
                        else if (model.id > 0 && model.checkBillId == -1)//修改时,被删了。需从数据库删除
                        {
                            checkDetailBB.DeleteRecord(model.id);
                        }
                        else if (model.id == 0)//本次新增的检测明细项目
                        {
                            if (model.openBoxNum != 0 && model.checkNum != 0)
                            {
                                model.checkBillId = checkBillModel.id;
                                checkDetailBB.AddRecord(model);
                            }
                        }
                    }
                }

                if (transaction == null) trans.Commit();
                return strBillNo;
            }
            catch (Exception ex)
            {
                if (transaction == null) trans.Rollback("TranSave");
                throw new Exception(ex.Message);
            }
            finally
            {
                checkDetailBB.Dispose();
                commBB.Dispose();
            }
        }
Esempio n. 23
0
        //*****************************************************************************
        //do it later      do it later      do it later
        //*****************************************************************************
        /// <summary>
        /// 物料箱检测结果转换
        /// </summary>
        /// <param name="dtBox"></param>
        /// <param name="isRegular"></param>
        /// <param name="strMark"></param>
        /// <returns></returns>
        public bool ConvertBox(DataTable dtBox, bool isRegular, string strMark)
        {
            bool ret = false;
            BArrangeBillBoxResultChangeBB arrangeBillBoxResultChangeBB = new BArrangeBillBoxResultChangeBB(this.connection);
            SCommBB commBB = new SCommBB(this.connection);
            SqlTransaction trans = null;

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

                BArrangeBillBoxResultChangeData arrangeBillBoxResultChangeModel = new BArrangeBillBoxResultChangeData();

                foreach (DataRow dataRow in dtBox.Rows)
                {
                    string strBoxNo = "";
                    DataTable dtArrangeBox = new DataTable();

                    strBoxNo = dataRow["boxNo"].ToString();//箱号
                    dtArrangeBox = this.arrangeBillBoxBB.GetList("boxNo='" + strBoxNo + "'").Tables[0];

                    //更改原箱的检测结果
                    commBB.ExecuteSql("update dbo.BArrangeBillBox set checkResult='" + isRegular
                        + "',checkResultDt='" + System.DateTime.Now.ToString() + "',checkResultEmpId=" + this.empId + " where boxNo='" + strBoxNo + "'");

                    //新增箱变更记录
                    arrangeBillBoxResultChangeModel = new BArrangeBillBoxResultChangeData();

                    arrangeBillBoxResultChangeModel.boxNo = strBoxNo;//箱号
                    arrangeBillBoxResultChangeModel.checkResult = isRegular;//是否合格
                    arrangeBillBoxResultChangeModel.checkResultDt = System.DateTime.Now.ToString();//判定时间
                    arrangeBillBoxResultChangeModel.checkResultEmpId = this.empId;//判定人员
                    arrangeBillBoxResultChangeModel.preCheckResult = Convert.ToBoolean(dtArrangeBox.Rows[0]["checkResult"]);//上一次判定结果
                    arrangeBillBoxResultChangeModel.preCheckResultDt = dtArrangeBox.Rows[0]["checkResultDt"].ToString();//上一次判定时间
                    arrangeBillBoxResultChangeModel.preCheckResultEmpId = Convert.ToInt32(dtArrangeBox.Rows[0]["checkResultEmpId"]);//上一次判定人员

                    arrangeBillBoxResultChangeBB.AddRecord(arrangeBillBoxResultChangeModel);
                }

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

            return ret;
        }
Esempio n. 24
0
        //*****************************************************************************
        //do it later      do it later      do it later
        //*****************************************************************************
        /// <summary>
        /// 保存排托出库信息
        /// </summary>
        /// <param name="stockUpDetailID">备货单明细ID</param>
        /// <param name="strNewPalletNo">新托盘号</param>
        /// <param name="strOldBoxNo">原箱号</param>
        /// <param name="strNewBoxNo">新箱号</param>
        /// <param name="num">数量</param>
        /// <returns></returns>
        public bool SaveOutStockInfo(int stockUpDetailID, string strNewPalletNo, string strOldBoxNo,
            string strNewBoxNo, double num)
        {
            bool ret = false;
            SqlTransaction trans = null;
            BArrangeBillBoxBB arraneBillBoxBB = new BArrangeBillBoxBB(this.connection);
            BForkliftTaskBC forkliftTaskBC = new BForkliftTaskBC(this.connection);
            CDEPickOutBoxBB DEPickOutBoxBB = new CDEPickOutBoxBB(this.connection);
            CStockUpDetailBB stockUpDetailBB = new CStockUpDetailBB(this.connection);
            CSaleDetailBB saleDetailBB = new CSaleDetailBB(this.connection);
            SCommBB commBB = new SCommBB(this.connection);
            UStockBB stockBB = new UStockBB(this.connection);
            UStockOutInDetailBB stockOutInDetailBB = new UStockOutInDetailBB(this.connection);
            LMaterialBB materialBB = new LMaterialBB(this.connection);

            try
            {
                if (this.transaction == null)
                {
                    trans = this.connection.BeginTransaction("TransSaveOutStockInfo");
                    this.pickOutBillBB.Transaction = trans;
                    arraneBillBoxBB.Transaction = trans;
                    forkliftTaskBC.Transaction = trans;
                    DEPickOutBoxBB.Transaction = trans;
                    stockUpDetailBB.Transaction = trans;
                    saleDetailBB.Transaction = trans;
                    commBB.Transaction = trans;
                    stockBB.Transaction = trans;
                    stockOutInDetailBB.Transaction = trans;
                    materialBB.Transaction = trans;
                }
                else
                {
                    this.pickOutBillBB.Transaction = this.transaction;
                    arraneBillBoxBB.Transaction = this.transaction;
                    forkliftTaskBC.Transaction = this.transaction;
                    DEPickOutBoxBB.Transaction = this.transaction;
                    stockUpDetailBB.Transaction = this.transaction;
                    saleDetailBB.Transaction = this.transaction;
                    commBB.Transaction = this.transaction;
                    stockBB.Transaction = this.transaction;
                    stockOutInDetailBB.Transaction = this.transaction;
                    materialBB.Transaction = this.transaction;
                }

                CStockUpDetailData stockUpDetailModel = new CStockUpDetailData();
                vCStockUpDetailData vStockUpDetailModel = new vCStockUpDetailData();
                DataTable dtArrangeBillBox = new DataTable();
                DataTable dtDEPickOutBox = new DataTable();
                DataTable dtWareLocator = new DataTable();
                DataTable dtStockUpDetail = new DataTable();
                string strSql = "", strPrePalletNo = "", strPreWareLocatorNo = "";

                //获取备货单明细实例
                stockUpDetailModel = stockUpDetailBB.GetModel(stockUpDetailID);

                //拆托拣货箱信息
                dtDEPickOutBox = DEPickOutBoxBB.GetVList("boxNo='" + strOldBoxNo + "'").Tables[0];

                //普通拣货箱信息
                dtArrangeBillBox = arraneBillBoxBB.GetVList("boxNo='" + strOldBoxNo + "' and wareNo<>''").Tables[0];

                //扫描箱以前所在库位
                if (dtArrangeBillBox.Rows[0]["preWareLocatorNo"].ToString() != "")
                {
                    strPrePalletNo = dtArrangeBillBox.Rows[0]["palletNo"].ToString();//原托盘条码号
                    strPreWareLocatorNo = dtArrangeBillBox.Rows[0]["preWareLocatorNo"].ToString();//物料箱以前所在库位
                }

                //获取排托区下线库位信息
                strSql = @"select wareLocator.wareNo,wareLocator.downWareLocatorNo as wareLocatorNo
                           from dbo.BArrangeBillBox as arrangeBillBoxBox
                           left join dbo.LWareLocator as wareLocator on wareLocator.wareLocatorNo=arrangeBillBoxBox.wareLocatorNo
                           where arrangeBillBoxBox.boxNo='" + strOldBoxNo + "'";

                dtWareLocator = commBB.Query(strSql).Tables[0];

                #region 新增销售拣货单信息

                CPickOutBillData pickOutBillModel = new CPickOutBillData();

                //新增销售拣货单信息
                pickOutBillModel.stockUpDetailID = stockUpDetailID;//备货单明细ID

                //从哪个拣货库区、库位赋值
                if (dtDEPickOutBox.Rows.Count > 0)
                {
                    pickOutBillModel.wareNo = dtDEPickOutBox.Rows[0]["preWareNo"].ToString();//以前的仓库编号
                    pickOutBillModel.wareLocatorNo = dtDEPickOutBox.Rows[0]["preWareLocatorNo"].ToString();//以前的库位编号
                }
                else
                {
                    pickOutBillModel.wareNo = dtArrangeBillBox.Rows[0]["preWareNo"].ToString();//以前的仓库编号
                    pickOutBillModel.wareLocatorNo = dtArrangeBillBox.Rows[0]["preWareLocatorNo"].ToString();//以前的库位编号
                }

                pickOutBillModel.preWareNo = "";//以前的仓库编号
                pickOutBillModel.preWareLocatorNo = "";//以前的库位编号
                pickOutBillModel.oldPalletNo = dtArrangeBillBox.Rows[0]["palletNo"].ToString();//原托盘号
                pickOutBillModel.oldRegion = dtArrangeBillBox.Rows[0]["region"].ToString();//原托内区域
                pickOutBillModel.oldBoxNo = strOldBoxNo;//原箱号
                pickOutBillModel.newBoxNo = strNewBoxNo;//新箱号
                pickOutBillModel.num = num;//数量
                pickOutBillModel.isrtEmpId = this.empId;//添加人
                pickOutBillModel.isrtDt = System.DateTime.Now.ToString();//添加时间
                pickOutBillModel.instantState = "01";//未发货

                pickOutBillBB.AddRecord(pickOutBillModel);

                #endregion 新增销售拣货单信息

                #region 新增新的排托箱

                DataTable dtArrangeBillBoxNew = new DataTable();

                dtArrangeBillBoxNew = arraneBillBoxBB.GetVList("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 = stockUpDetailModel.stockUpBillNo;//备货单编号
                    newArrangeBillBoxModel.boxNo = strNewBoxNo;//箱号
                    newArrangeBillBoxModel.oldBoxNo = strOldBoxNo;//原箱号
                    newArrangeBillBoxModel.materialNo = stockUpDetailModel.materialNo;//转换后物料编号
                    newArrangeBillBoxModel.oldMaterialNo = 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();//原托内区域

                    //新箱库区、库位赋值,值为下线线体
                    if (dtWareLocator.Rows.Count > 0
                       && dtWareLocator.Rows[0]["wareLocatorNo"] != DBNull.Value
                       && dtWareLocator.Rows[0]["wareLocatorNo"].ToString() != "")
                    {
                        newArrangeBillBoxModel.wareNo = dtWareLocator.Rows[0]["wareNo"].ToString();//库区
                        newArrangeBillBoxModel.wareLocatorNo = dtWareLocator.Rows[0]["wareLocatorNo"].ToString();//库位
                    }

                    newArrangeBillBoxModel.preWareNo = "";//原库区
                    newArrangeBillBoxModel.preWareLocatorNo = "";//原库位
                    newArrangeBillBoxModel.isBoxArrange = true;//是否排托
                    newArrangeBillBoxModel.isPalletUsing = true;//托盘是否正在使用
                    newArrangeBillBoxModel.acceptEmpId = this.EmpID;//接收人
                    newArrangeBillBoxModel.acceptDt = System.DateTime.Now.ToString();//接收时间
                    newArrangeBillBoxModel.isOutStocking = false;//是否正在出库

                    arraneBillBoxBB.AddRecord(newArrangeBillBoxModel);
                }

                #endregion 新增新的排托箱

                #region 库存所有操作

                DataTable dtStock = new DataTable();
                DataTable dtMaterial = new DataTable();
                UStockOutInDetailData stockOutInDetailModel = new UStockOutInDetailData();

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

                //增加出入库明细-拣货箱出库
                dtStock = stockBB.GetList("boxNo='" + strOldBoxNo + "'").Tables[0];
                if (dtStock.Rows.Count > 0)//原箱有库存
                {
                    dtMaterial = materialBB.GetList("materialNo='" + dtStock.Rows[0]["materialNo"].ToString() + "'").Tables[0];

                    //保存出入库明细数据
                    stockOutInDetailModel = new UStockOutInDetailData();

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

                    stockOutInDetailBB.AddRecord(stockOutInDetailModel);
                }

                #endregion 库存所有操作

                #region 更改备货单明细的新托盘号、状态

                //更改备货单明细的新托盘号、状态
                vStockUpDetailModel = stockUpDetailBB.GetVModel(stockUpDetailID);

                stockUpDetailModel.palletNo = strNewPalletNo;//新托盘号

                if (vStockUpDetailModel.num > vStockUpDetailModel.factNum)
                {
                    stockUpDetailModel.instantState = "02";//更改状态为“备货中”
                }
                else
                {
                    stockUpDetailModel.instantState = "03";//更改状态为“备货完成”
                }

                stockUpDetailBB.ModifyRecord(stockUpDetailModel);

                #endregion 更改备货单明细的新托盘号、状态

                #region 生成从拣货区到打托区叉车任务

                bool isFinish = true;

                //如果某个托盘的备货单明细已经全部备货完成,生成托盘的叉车任务
                strSql = @"select palletNo,instantState from dbo.CStockUpDetail where stockUpBillNo='" + stockUpDetailModel.stockUpBillNo
                    + "' and palletIndex='" + stockUpDetailModel.palletIndex.ToString() + "'";

                dtStockUpDetail = commBB.Query(strSql).Tables[0];

                foreach (DataRow row in dtStockUpDetail.Rows)
                {
                    if (row["instantState"].ToString() == "01" || row["instantState"].ToString() == "02")
                    {
                        isFinish = false;
                        break;
                    }
                }

                if (isFinish)
                {
                    //保存从拣货区到打托区叉车任务
                    forkliftTaskBC.SaveForkliftTask(dtStockUpDetail.Rows[0]["palletNo"].ToString(), "", "", "14", this.empId);
                }

                #endregion 生成从拣货区到打托区叉车任务

                #region 更改备货单状态

                //如果备货单明细的状态全部为“03 备货完成”,更改备货单状态为“08 备货完成”
                strSql = @"update dbo.CStockUpBill set instantState='08'
                           where not exists(select 1 from dbo.CStockUpDetail as t where t.stockUpBillNo=dbo.CStockUpBill.stockUpBillNo and instantState<>'03')";

                commBB.ExecuteSql(strSql);

                #endregion 更改备货单状态

                #region 更改箱锁定状态

                int stockId = 0, boxId = 0;
                object obj = null;

                //查找库存
                obj = commBB.ExecuteScalar("select top 1 id from dbo.UStock where boxNo='" + strOldBoxNo + "' and num>0 and isOutStocking=1");
                if (obj == null)
                {
                    obj = commBB.ExecuteScalar("select top 1 id from dbo.UStock where palletNo='" + strPrePalletNo + "' and num>0 and isOutStocking=1 order by id");
                    if (obj != null)
                    {
                        stockId = Convert.ToInt32(obj);
                    }
                }
                else
                {
                    stockId = Convert.ToInt32(obj);
                }

                //查找物料箱
                obj = commBB.ExecuteScalar("select top 1 id from dbo.BArrangeBillBox where boxNo='" + strOldBoxNo + "' and wareNo<>'' and isOutStocking=1");
                if (obj == null)
                {
                    obj = commBB.ExecuteScalar("select top 1 id from dbo.BArrangeBillBox where palletNo='" + strPrePalletNo + "' and wareNo<>'' and isOutStocking=1 order by id");
                    if (obj != null)
                    {
                        boxId = Convert.ToInt32(obj);
                    }
                }
                else
                {
                    boxId = Convert.ToInt32(obj);
                }

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

                //更改原箱的是否锁定状态
                strSql = "update dbo.BArrangeBillBox set isOutStocking=0 where id='" + boxId.ToString() + "'";
                commBB.ExecuteSql(strSql);

                #endregion 更改箱锁定状态

                #region 如果原箱剩余数量为零,更改原箱的托盘号

                if (strNewBoxNo == strOldBoxNo)
                {
                    if (dtWareLocator.Rows.Count > 0
                        && dtWareLocator.Rows[0]["wareLocatorNo"] != DBNull.Value
                        && dtWareLocator.Rows[0]["wareLocatorNo"].ToString() != "")
                    {
                        strSql = @"update dbo.BArrangeBillBox set oldMaterialNo=materialNo,materialNo='" + stockUpDetailModel.materialNo
                            + "',oldPalletNo=palletNo,palletNo='" + strNewPalletNo + "',preWareNo=wareNo,preWareLocatorNo=wareLocatorNo,wareNo='"
                            + dtWareLocator.Rows[0]["wareNo"].ToString() + "',wareLocatorNo='" + dtWareLocator.Rows[0]["wareLocatorNo"].ToString()
                            + "',oldRegion=region,region='' where boxNo='" + strOldBoxNo + "'";

                        commBB.ExecuteSql(strSql);
                    }
                }

                //如果箱内剩余数量为0,清空托盘号和库区、库位信息
                dtArrangeBillBox = arraneBillBoxBB.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='' where boxNo='" + strOldBoxNo + "'");
                }

                #endregion 如果原箱剩余数量为零,更改原箱的托盘号

                #region 原库位释放

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

                commBB.ExecuteSql(strSql);

                #endregion 原库位释放

                #region 出入库所有操作

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

                #endregion 出入库所有操作

                if (this.transaction == null) trans.Commit();
                ret = true;
            }
            catch (Exception ex)
            {
                if (this.transaction == null) trans.Rollback("TransSaveOutStockInfo");
                throw ex;
            }
            finally
            {
                arraneBillBoxBB.Dispose();
                forkliftTaskBC.Dispose();
                stockUpDetailBB.Dispose();
                commBB.Dispose();
                saleDetailBB.Dispose();
                DEPickOutBoxBB.Dispose();
                stockBB.Dispose();
                stockOutInDetailBB.Dispose();
                materialBB.Dispose();
            }

            return ret;
        }
Esempio n. 25
0
        /// <summary>
        /// 提交检测单
        /// </summary>
        /// <param name="checkBillModel">检测单实例</param>
        /// <returns></returns>
        public void CommitData(BCheckBillData checkBillModel)
        {
            SqlTransaction trans = null;
            LCheckDetailBB lCheckDetailBB = new LCheckDetailBB();
            BCheckDetailBB checkDetailBB = new BCheckDetailBB();
            SCommBB commBB = new SCommBB(this.connection);

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

                DataSet dsCheckDetail = new DataSet();
                DataSet dsMaterialCheckDetail = new DataSet();
                DataSet dsArriveDetail = new DataSet();
                string strSql = "";
                DataRow[] myDataRowArray = null;

                //获取物料对应的检测项
                dsMaterialCheckDetail = lCheckDetailBB.GetList("materialNo='" + checkBillModel.materialNo + "'");

                //获取检测单对应到货单信息
                strSql = "select id,num from BArriveDetail where arriveBillNo='" + checkBillModel.arriveBillNo
                    + "' and financeBillNo='" + checkBillModel.financeBillNo + "' and materialNo='" + checkBillModel.materialNo + "'";
                dsArriveDetail = commBB.Query(strSql);

                //提交检测单
                this.checkBillBB.ModifyRecord(checkBillModel);

                //获取检测单下的所有检测明细
                dsCheckDetail = checkDetailBB.GetVList("checkBillId=" + checkBillModel.id);
                foreach (DataRow row in dsCheckDetail.Tables[0].Rows)
                {
                    if (Convert.ToBoolean(row["isAddupCheck"]))//检测明细是累计检测项
                    {
                        strSql = "update dbo.LCheckDetail set arrivedAmount=0 where id=" + row["checkDetailId"].ToString();
                        commBB.Query(strSql);
                        continue;
                    }

                    //当前物料存在累计检测项,当前没有检测,累计到货数量
                    myDataRowArray = dsMaterialCheckDetail.Tables[0].Select("id=" + row["checkDetailId"].ToString()
                        + " and isAddupCheck=1");
                    if (myDataRowArray.Length > 0)
                    {
                        strSql = "update dbo.LCheckDetail set arrivedAmount=isnull(arrivedAmount,0)+" + dsArriveDetail.Tables[0].Rows[0]["num"].ToString()
                            + " where id=" + row["checkDetailId"].ToString();
                        commBB.Query(strSql);
                    }
                }

                if (transaction == null) trans.Commit();
            }
            catch (Exception ex)
            {
                if (transaction == null) trans.Rollback("TranCommit");
                throw new Exception(ex.Message);
            }
            finally
            {
                lCheckDetailBB.Dispose();
                checkDetailBB.Dispose();
                commBB.Dispose();
            }
        }
        /// <summary>
        /// 删除称重理货单明细
        /// </summary>
        /// <param name="strBoxNo"></param>
        /// <returns></returns>
        public bool DeleteRecord(string strBoxNo)
        {
            bool ret = false;
            SqlTransaction trans = null;
            SCommBB commBB = new SCommBB(this.connection);

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

                //更改箱子称重重量和实际数量
                commBB.ExecuteSql("update dbo.BArrangeBillBox set wareLocatorNo=preWareLocatorNo,weight=0,palletNo=oldPalletNo,region=oldRegion where boxNo='" + strBoxNo + "'");

                //删除称重理货明细
                commBB.ExecuteSql("delete from dbo.BTallyBillDetail where boxNo='" + strBoxNo + "'");

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

            return ret;
        }
Esempio n. 27
0
        /// <summary>
        /// 提交排托单
        /// </summary>
        /// <param name="strArriveBillNo">到货单号</param>
        /// <returns></returns>
        public bool CommitArrangeBill(string strArriveBillNo)
        {
            bool ret = false;
            SCommBB commBB = new SCommBB(this.connection);
            SqlTransaction trans = null;

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

                string strSql = "";

                //更改到货单提交信息
                strSql = "update dbo.BArriveBill set commitEmpId=" + this.empId.ToString()
                    + ",commitDt='" + System.DateTime.Now.ToString() + "',instantState='03' where billNo='" + strArriveBillNo + "'";

                commBB.ExecuteSql(strSql);

                //更改排托单提交信息
                strSql = "update dbo.BArrangeBill set commitEmpId=" + this.empId.ToString()
                    + ",commitDt='" + System.DateTime.Now.ToString() + "',instantState='02' where arrangeBillNo='" + "PT" + strArriveBillNo + "'";

                commBB.ExecuteSql(strSql);

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

            return ret;
        }
        /// <summary>
        /// 保存非标准箱从质检区入库信息
        /// </summary>
        /// <param name="strPalletNo">托盘条码号</param>
        /// <param name="strNextWareNo">目的库区编码</param>
        /// <param name="strNextWareLocatorNo">目的库位编码</param>
        /// <returns></returns>
        public bool SaveNoStandBoxInStockInfo(string strPalletNo, string strNextWareNo, string strNextWareLocatorNo)
        {
            bool ret = false;
            SqlTransaction trans = null;
            SCommBB commBB = new SCommBB(this.connection);
            BTallyBillBB tallyBillBB = new BTallyBillBB(this.connection);
            BArrangeBillBoxBB arrangeBillBoxBB = new BArrangeBillBoxBB(this.connection);
            BForkliftTaskBB forkliftTaskBB = new BForkliftTaskBB(this.connection);

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

                int mainId = 0;
                StringBuilder strSql = new StringBuilder();
                DataTable dtArrangeBillBox = new DataTable();
                BTallyBillData tallyBillModel = new BTallyBillData();
                BTallyBillDetailData tallyBillDetailModel = new BTallyBillDetailData();
                BForkliftTaskData forkliftTaskModel = new BForkliftTaskData();

                //保存理货信息
                tallyBillModel = new BTallyBillData();

                tallyBillModel.palletNo = strPalletNo;//托盘条码号
                tallyBillModel.isInStock = false;//是否入库
                tallyBillModel.isrtDt = System.DateTime.Now.ToString();//添加时间
                tallyBillModel.isrtEmpId = this.empId;//添加人
                tallyBillModel.instantState = "02";//理货完成

                mainId = tallyBillBB.AddRecord(tallyBillModel);//称重理货单ID赋值

                dtArrangeBillBox = arrangeBillBoxBB.GetList("palletNo='" + strPalletNo + "' and isnull(wareNo,'')<>''").Tables[0];
                foreach (DataRow row in dtArrangeBillBox.Rows)
                {
                    //保存称重理货明细数据
                    tallyBillDetailModel = new BTallyBillDetailData();

                    tallyBillDetailModel.mainId = mainId.ToString();//称重理货单ID
                    tallyBillDetailModel.region = "0";//区域ID
                    tallyBillDetailModel.oldPalletNo = strPalletNo;//原托盘号
                    tallyBillDetailModel.boxNo = row["boxNo"].ToString();//箱号
                    tallyBillDetailModel.isrtDt = System.DateTime.Now.ToString();//添加时间
                    tallyBillDetailModel.isrtEmpId = this.empId;//添加人

                    tallyBillDetailBB.AddRecord(tallyBillDetailModel);
                }

                //生成叉车任务
                if (dtArrangeBillBox.Rows.Count > 0)
                {
                    forkliftTaskModel = new BForkliftTaskData();

                    forkliftTaskModel.taskType = "11";//任务类型为:从质检区到正式区
                    forkliftTaskModel.palletNo = strPalletNo;//托盘号
                    forkliftTaskModel.preWareNo = dtArrangeBillBox.Rows[0]["wareNo"].ToString();//源库区
                    forkliftTaskModel.preLocatorNo = dtArrangeBillBox.Rows[0]["wareLocatorNo"].ToString();//源库位
                    forkliftTaskModel.nextWareNo = strNextWareNo;//目的库区
                    forkliftTaskModel.nextLocatorNo = strNextWareLocatorNo;//目的库位
                    forkliftTaskModel.effectDt = System.DateTime.Now.ToString();//生效时间
                    forkliftTaskModel.isDeal = false;//是否处理

                    forkliftTaskBB.AddRecord(forkliftTaskModel);

                    //更新目的库区占用状态
                    if (strNextWareLocatorNo != "")
                    {
                        //更改库位的使用状态
                        commBB.ExecuteSql("update dbo.LWareLocator set isUsing=1 where wareLocatorNo='"
                            + strNextWareLocatorNo + "'");
                    }
                }

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

            return ret;
        }
        //*****************************************************************************
        //do it later      do it later      do it later
        //*****************************************************************************
        /// <summary>
        /// 保存称重理货明细信息,同时更改箱子称重数据
        /// </summary>
        /// <param name="mainId">称重理货单ID</param>
        /// <param name="regionId">区域ID</param>
        /// <param name="strNewPalletNo">新托盘条码号</param>
        /// <param name="strOldPalletNo">原托盘号</param>
        /// <param name="strBoxNo">箱号</param>
        /// <param name="weight">称重重量</param>
        /// <param name="factNum">实际数量</param>
        /// <param name="arriveDetailId">到货单明细ID</param>
        /// <param name="firstBoxSingleWeight">首箱单重</param>
        /// <param name="tallyNoPassReasonId">理货不合格原因</param>
        /// <returns></returns>
        public bool SaveRecord(int mainId, int regionId, string strNewPalletNo, string strOldPalletNo, string strBoxNo,
            float weight, int factNum, int arriveDetailId, double firstBoxSingleWeight, int tallyNoPassReasonId)
        {
            bool ret = false;
            SqlTransaction trans = null;
            SCommBB commBB = new SCommBB(this.connection);
            BArriveDetailBB arriveDetailBB = new BArriveDetailBB(this.connection);
            BArrangeBillBoxBB arrangeBillBoxBB = new BArrangeBillBoxBB(this.connection);

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

                DataSet ds = new DataSet();
                DataTable dtArrangeBillBox = new DataTable();
                BTallyBillDetailData tallyBillDetailModel = new BTallyBillDetailData();
                StringBuilder strSql = new StringBuilder();
                DataTable dtWareLocator = new DataTable();

                //保存称重理货明细数据
                if (mainId != 0)
                {
                    tallyBillDetailModel.mainId = mainId.ToString();//称重理货单ID
                    tallyBillDetailModel.region = regionId.ToString();//区域ID
                    tallyBillDetailModel.oldPalletNo = strOldPalletNo;//原托盘号
                    tallyBillDetailModel.boxNo = strBoxNo;//箱号
                    tallyBillDetailModel.isrtDt = System.DateTime.Now.ToString();//添加时间
                    tallyBillDetailModel.isrtEmpId = this.empId;//添加人

                    tallyBillDetailBB.AddRecord(tallyBillDetailModel);

                    //获取排托区下线库位信息
                    strSql.Append(@"select wareLocator.wareNo,wareLocator.downWareLocatorNo as wareLocatorNo ");
                    strSql.Append(@"from dbo.BArrangeBillBox as arrangeBillBoxBox ");
                    strSql.Append(@"left join dbo.LWareLocator as wareLocator on wareLocator.wareLocatorNo=arrangeBillBoxBox.wareLocatorNo ");
                    strSql.Append(@"where arrangeBillBoxBox.boxNo='" + strBoxNo + "'");

                    dtWareLocator = commBB.Query(strSql.ToString()).Tables[0];
                    if (dtWareLocator.Rows.Count > 0
                        && dtWareLocator.Rows[0]["wareLocatorNo"] != DBNull.Value
                        && dtWareLocator.Rows[0]["wareLocatorNo"].ToString() != "")
                    {
                        dtArrangeBillBox = arrangeBillBoxBB.GetVList("boxNo='" + strBoxNo + "'").Tables[0];
                        //首先将语句完整后 再将数据传递到后台当中

                        string command = "update dbo.BArrangeBillBox set preWareLocatorNo=wareLocatorNo,wareLocatorNo='" + dtWareLocator.Rows[0]["wareLocatorNo"].ToString() + "',weight='" + weight.ToString()
                            + "',factNum=factNum-" + Convert.ToString(Convert.ToInt32(dtArrangeBillBox.Rows[0]["leavingNum"]) + Convert.ToInt32(dtArrangeBillBox.Rows[0]["DEPickOutNum"]) - factNum)
                            + ",oldPalletNo=palletNo,oldRegion=region,palletNo='" + strNewPalletNo
                            + "',region='" + regionId.ToString() + "',noPassReasonId='" + tallyNoPassReasonId.ToString() + "' where boxNo='" + strBoxNo + "'";

                        if(command.Contains("--"))
                        {
                            command =command.Replace("--", "+");
                        }
                        //更改箱子称重重量和实际数量
                        //commBB.ExecuteSql(command);
                        string conn = "Data Source=172.16.0.160;Initial Catalog=GMWJ;User=wms;Password=sasa";
                        try
                        {
                            SQLHelperDM.ExecuteNonQuery(conn, command);
                        }
                        catch (Exception ee)
                        {
                            string errorRecord = "Insert into SqlText values ('" + ee.Message + "','Hello World','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "')";
                            SQLHelperDM.ExecuteNonQuery(conn, errorRecord);//在数据库表当中增加相应的判断错误处理,因为在程序运行当中经常出现将数据全部更改的错误
                            ret = false;

                            //在此处将所有的插入数据存储到一个表当中 用来进行记录
                        }

                        string record = "Insert into SqlText values ('" +command.Replace('\'',' ') + "','你好','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "')";
                        SQLHelperDM.ExecuteNonQuery(conn, record);//在数据库表当中增加相应的判断错误处理,因为在程序运行当中经常出现将数据全部更改的错误
                    }

                    //更改到货单明细的首箱单重
                    if (firstBoxSingleWeight == 0)
                    {
                        BArriveDetailData arriveDetailModel = new BArriveDetailData();

                        arriveDetailModel = arriveDetailBB.GetModel(arriveDetailId);

                        if (arriveDetailModel != null)
                        {
                            arriveDetailModel.firstBoxSingleWeight = Math.Round(weight / factNum, 4);

                            arriveDetailBB.ModifyRecord(arriveDetailModel);
                        }
                    }
                }
                else
                {
                    ret = false;
                    throw new Exception("保存错误,不存在理货单!");
                }

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

            return ret;
        }
        /// <summary>
        /// 保存非标准箱入质检区信息
        /// </summary>
        /// <param name="strPalletNo">托盘号</param>
        /// <returns></returns>
        public bool SaveNoStandBoxInCheckInfo(string strPalletNo)
        {
            bool ret = false;
            SqlTransaction trans = null;
            SCommBB commBB = new SCommBB(this.connection);
            BForkliftTaskBB forkliftTaskBB = new BForkliftTaskBB(this.connection);
            BArrangeBillBoxBB arrangeBillBoxBB = new BArrangeBillBoxBB(this.connection);
            BArrangeBillFactDetailBB arrangeBillFactDetailBB = new BArrangeBillFactDetailBB(this.connection);

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

                DataTable dtArrangeBillBox = new DataTable();
                string strArriveBillNo = "", strFinanceBillNo = "";
                BArrangeBillFactData arrangeBillFactModel = new BArrangeBillFactData();
                BArrangeBillFactDetailData arrangeBillFactDetailModel = new BArrangeBillFactDetailData();
                BArrangeBillBoxData arrangeBillBoxModel = new BArrangeBillBoxData();
                int mainId = 0;

                //获取到货箱信息
                dtArrangeBillBox = arrangeBillBoxBB.GetList("palletNo='" + strPalletNo + "' and isnull(wareNo,'')<>''").Tables[0];
                if (dtArrangeBillBox.Rows.Count > 0)
                {
                    strArriveBillNo = dtArrangeBillBox.Rows[0]["arriveBillNo"].ToString();//到货单号
                    strFinanceBillNo = dtArrangeBillBox.Rows[0]["financeBillNo"].ToString();//采购单号
                }

                #region 维护排托收货单信息

                //维护排托收货单信息
                arrangeBillFactModel.arrangeBillNo = "PT" + strArriveBillNo;//排托单号
                arrangeBillFactModel.arriveBillNo = strArriveBillNo;//到货单号
                arrangeBillFactModel.financeBillNo = strFinanceBillNo;//采购订单号
                arrangeBillFactModel.palletIndex = "0";//托盘序号
                arrangeBillFactModel.palletNo = strPalletNo;//托盘条码号
                arrangeBillFactModel.isTally = false;//是否已理货
                arrangeBillFactModel.isrtEmpId = this.empId;//添加人
                arrangeBillFactModel.isrtDt = System.DateTime.Now.ToString();//添加时间
                arrangeBillFactModel.instantState = "02";//状态

                mainId = arrangeBillFactBB.AddRecord(arrangeBillFactModel);

                #endregion 维护排托收货单信息

                #region 维护排托箱信息

                foreach (DataRow row in dtArrangeBillBox.Rows)
                {
                    //保存排托收货单明细信息
                    arrangeBillFactDetailModel = new BArrangeBillFactDetailData();

                    arrangeBillFactDetailModel.mainId = mainId.ToString();//排托收货单ID
                    arrangeBillFactDetailModel.boxNo = row["boxNo"].ToString();//箱号
                    arrangeBillFactDetailModel.region = "0";//区域
                    arrangeBillFactDetailModel.isrtEmpId = this.empId;
                    arrangeBillFactDetailModel.isrtDt = System.DateTime.Now.ToString();

                    arrangeBillFactDetailBB.AddRecord(arrangeBillFactDetailModel);

                    //更改到货箱排托标志
                    commBB.ExecuteSql("update dbo.BArrangeBillBox set isBoxArrange=1 where boxNo='" + row["boxNo"].ToString() + "'");
                }

                #endregion 维护排托箱信息

                #region 生成叉车任务

                BForkliftTaskData forkliftTaskModel = new BForkliftTaskData();

                if (dtArrangeBillBox.Rows.Count > 0)
                {
                    forkliftTaskModel = new BForkliftTaskData();

                    forkliftTaskModel.taskType = "10";//任务类型为:从收货区到质检区
                    forkliftTaskModel.palletNo = strPalletNo;//托盘号
                    forkliftTaskModel.preWareNo = dtArrangeBillBox.Rows[0]["wareNo"].ToString();//源库区
                    forkliftTaskModel.preLocatorNo = dtArrangeBillBox.Rows[0]["wareLocatorNo"].ToString();//源库位
                    forkliftTaskModel.effectDt = System.DateTime.Now.ToString();//生效时间
                    forkliftTaskModel.isDeal = false;//是否处理

                    forkliftTaskBB.AddRecord(forkliftTaskModel);
                }

                #endregion 生成叉车任务

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

            return ret;
        }