Esempio n. 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(UStockData model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("set nocount on; ");
            strSql.Append("insert into UStock(");
            strSql.Append(@"wareNo,wareLocatorNo,stockDt,palletNo,materialNo,boxNo,factMonomerNum,factPackNum,num,isOutStocking,
                            stockMark,isrtEmpId,isrtDt)");
            strSql.Append(" values (");
            strSql.Append(@"@wareNo,@wareLocatorNo,@stockDt,@palletNo,@materialNo,@boxNo,@factMonomerNum,@factPackNum,@num,@isOutStocking,
                            @stockMark,@isrtEmpId,@isrtDt)");
            strSql.Append("; select @@identity; set nocount off; ");
            SqlParameter[] parameters = {
                    new SqlParameter("@wareNo", SqlDbType.NVarChar,20),
                    new SqlParameter("@wareLocatorNo", SqlDbType.NVarChar,20),
                    new SqlParameter("@stockDt", SqlDbType.DateTime),
                    new SqlParameter("@palletNo", SqlDbType.VarChar,20),
                    new SqlParameter("@materialNo", SqlDbType.VarChar,20),
                    new SqlParameter("@boxNo", SqlDbType.VarChar,20),
                    new SqlParameter("@factMonomerNum", SqlDbType.Float),
                    new SqlParameter("@factPackNum", SqlDbType.Float),
                    new SqlParameter("@num", SqlDbType.Float),
                    new SqlParameter("@isOutStocking", SqlDbType.Bit),
                    new SqlParameter("@stockMark", SqlDbType.NVarChar,200),
                    new SqlParameter("@isrtEmpId", SqlDbType.Int),
                    new SqlParameter("@isrtDt", SqlDbType.DateTime)
                };
            parameters[0].Value = model.wareNo;
            parameters[1].Value = model.wareLocatorNo;
            parameters[2].Value = model.stockDt == string.Empty ? null : model.stockDt;
            parameters[3].Value = model.palletNo;
            parameters[4].Value = model.materialNo;
            parameters[5].Value = model.boxNo;
            parameters[6].Value = model.factMonomerNum;
            parameters[7].Value = model.factPackNum;
            parameters[8].Value = model.num;
            parameters[9].Value = model.isOutStocking;
            parameters[10].Value = model.stockMark;
            parameters[11].Value = model.isrtEmpId;
            parameters[12].Value = model.isrtDt == string.Empty ? null : model.isrtDt;

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

                if (ret != null && ret != DBNull.Value)
                {
                    id = Convert.ToInt32(ret);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return id;
        }
Esempio n. 2
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 /// <param name="model">model</param>
 public bool ModifyRecord(UStockData model)
 {
     return this.stockDB.ModifyRecord(model);
 }
Esempio n. 3
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 /// <param name="model">model</param>
 public int AddRecord(UStockData model)
 {
     return this.stockDB.AddRecord(model);
 }
Esempio n. 4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model">model</param>
        public bool ModifyRecord(UStockData model)
        {
            bool ret = false;
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update UStock set ");
            strSql.Append("wareNo=@wareNo,");
            strSql.Append("wareLocatorNo=@wareLocatorNo,");
            strSql.Append("stockDt=@stockDt,");
            strSql.Append("palletNo=@palletNo,");
            strSql.Append("materialNo=@materialNo,");
            strSql.Append("boxNo=@boxNo,");
            strSql.Append("factMonomerNum=@factMonomerNum,");
            strSql.Append("factPackNum=@factPackNum,");
            strSql.Append("num=@num,");
            strSql.Append("isOutStocking=@isOutStocking,");
            strSql.Append("stockMark=@stockMark,");
            strSql.Append("isrtEmpId=@isrtEmpId,");
            strSql.Append("isrtDt=@isrtDt");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int),
                    new SqlParameter("@wareNo", SqlDbType.NVarChar,20),
                    new SqlParameter("@wareLocatorNo", SqlDbType.NVarChar,20),
                    new SqlParameter("@stockDt", SqlDbType.DateTime),
                    new SqlParameter("@palletNo", SqlDbType.VarChar,20),
                    new SqlParameter("@materialNo", SqlDbType.VarChar,20),
                    new SqlParameter("@boxNo", SqlDbType.VarChar,20),
                    new SqlParameter("@factMonomerNum", SqlDbType.Float),
                    new SqlParameter("@factPackNum", SqlDbType.Float),
                    new SqlParameter("@num", SqlDbType.Float),
                    new SqlParameter("@isOutStocking", SqlDbType.Bit),
                    new SqlParameter("@stockMark", SqlDbType.NVarChar,200),
                    new SqlParameter("@isrtEmpId", SqlDbType.Int),
                    new SqlParameter("@isrtDt", SqlDbType.DateTime)
                };
            parameters[0].Value = model.id;
            parameters[1].Value = model.wareNo;
            parameters[2].Value = model.wareLocatorNo;
            parameters[3].Value = model.stockDt == string.Empty ? null : model.stockDt;
            parameters[4].Value = model.palletNo;
            parameters[5].Value = model.materialNo;
            parameters[6].Value = model.boxNo;
            parameters[7].Value = model.factMonomerNum;
            parameters[8].Value = model.factPackNum;
            parameters[9].Value = model.num;
            parameters[10].Value = model.isOutStocking;
            parameters[11].Value = model.stockMark;
            parameters[12].Value = model.isrtEmpId;
            parameters[13].Value = model.isrtDt == string.Empty ? null : model.isrtDt;

            try
            {
                SqlHelper.ExecuteNonQuery(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);
                ret = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return ret;
        }
Esempio n. 5
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. 6
0
        /// <summary>
        /// 得到一个model
        /// </summary>
        /// <param name="id">主键值</param>
        /// <returns>model</returns>
        public UStockData GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(@"select id,wareNo,wareLocatorNo,stockDt,palletNo,materialNo,boxNo,factMonomerNum,factPackNum,num,isOutStocking,
                            stockMark,isrtEmpId,isrtDt from UStock");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int)
                };
            parameters[0].Value = id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                DataRow row = ds.Tables[0].Rows[0];
                if (row["id"] != DBNull.Value)
                {
                    model.id = Convert.ToInt32(row["id"]);
                }
                if (row["wareNo"] != DBNull.Value)
                {
                    model.wareNo = Convert.ToString(row["wareNo"]);
                }
                if (row["wareLocatorNo"] != DBNull.Value)
                {
                    model.wareLocatorNo = Convert.ToString(row["wareLocatorNo"]);
                }
                if (row["stockDt"] != DBNull.Value)
                {
                    model.stockDt = Convert.ToString(row["stockDt"]);
                }
                if (row["palletNo"] != DBNull.Value)
                {
                    model.palletNo = Convert.ToString(row["palletNo"]);
                }
                if (row["materialNo"] != DBNull.Value)
                {
                    model.materialNo = Convert.ToString(row["materialNo"]);
                }
                if (row["boxNo"] != DBNull.Value)
                {
                    model.boxNo = Convert.ToString(row["boxNo"]);
                }
                if (row["factMonomerNum"] != DBNull.Value)
                {
                    model.factMonomerNum = Convert.ToDouble(row["factMonomerNum"]);
                }
                if (row["factPackNum"] != DBNull.Value)
                {
                    model.factPackNum = Convert.ToDouble(row["factPackNum"]);
                }
                if (row["num"] != DBNull.Value)
                {
                    model.num = Convert.ToDouble(row["num"]);
                }
                if (row["isOutStocking"] != DBNull.Value)
                {
                    model.isOutStocking = Convert.ToBoolean(row["isOutStocking"]);
                }
                if (row["stockMark"] != DBNull.Value)
                {
                    model.stockMark = Convert.ToString(row["stockMark"]);
                }
                if (row["isrtEmpId"] != DBNull.Value)
                {
                    model.isrtEmpId = Convert.ToInt32(row["isrtEmpId"]);
                }
                if (row["isrtDt"] != DBNull.Value)
                {
                    model.isrtDt = Convert.ToString(row["isrtDt"]);
                }
                return model;
            }
            else
            {
                return null;
            }
        }
Esempio n. 7
0
        /// <summary>
        /// 更新一条"库存明细"信息
        /// </summary>
        /// <param name="model">model</param>
        public bool ModifyRecord(UStockData model)
        {
            bool ret = false;
            SqlTransaction trans = null;
            try
            {
                if (this.transaction == null)
                {
                    trans = this.connection.BeginTransaction("TransModify");
                    this.stockBB.Transaction = trans;
                    this.errorDiaryBB.Transaction = trans;
                    this.operatDiaryBB.Transaction = trans;
                }

                this.stockBB.ModifyRecord(model);

                SOperatDiaryData operatDiaryData = new SOperatDiaryData();
                operatDiaryData.empId = this.empId;
                operatDiaryData.functionId = "";
                operatDiaryData.recordId = model.id.ToString();
                operatDiaryData.operateContent = "库存明细修改一条id为“" + model.id.ToString() + "”的记录";
                this.operatDiaryBB.AddRecord(operatDiaryData);

                if (this.transaction == null) trans.Commit();
                ret = true;
            }
            catch (Exception ex)
            {
                if (this.transaction == null) trans.Rollback("TransModify");
                SErrorDiaryData errorDiaryData = new SErrorDiaryData();
                errorDiaryData.empId = this.empId;
                errorDiaryData.functionId = "";
                errorDiaryData.errorText = "库存明细修改记录“" + model.id.ToString() + "”时报错:" + ex.Message;
                this.errorDiaryBB.AddRecord(errorDiaryData);
                throw ex;
            }
            finally
            {
            }
            return ret;
        }
Esempio n. 8
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. 9
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. 10
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. 11
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. 12
0
        /// <summary>
        /// 增加一条"库存明细"信息
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(UStockData model)
        {
            int id = 0;
            SqlTransaction trans = null;
            try
            {
                if (this.transaction == null)
                {
                    trans = this.connection.BeginTransaction("TransAdd");
                    this.stockBB.Transaction = trans;
                    this.errorDiaryBB.Transaction = trans;
                    this.operatDiaryBB.Transaction = trans;
                }

                id = this.stockBB.AddRecord(model);

                SOperatDiaryData operatDiaryData = new SOperatDiaryData();
                operatDiaryData.empId = this.empId;
                operatDiaryData.functionId = "";
                operatDiaryData.recordId = id.ToString();
                operatDiaryData.operateContent = "库存明细增加一条id为“" + id.ToString() + "”的记录";
                this.operatDiaryBB.AddRecord(operatDiaryData);

                if (this.transaction == null) trans.Commit();
            }
            catch (Exception ex)
            {
                if (this.transaction == null) trans.Rollback("TransAdd");
                SErrorDiaryData errorDiaryData = new SErrorDiaryData();
                errorDiaryData.empId = this.empId;
                errorDiaryData.functionId = "";
                errorDiaryData.errorText = "库存明细增加记录时报错:" + ex.Message;
                this.errorDiaryBB.AddRecord(errorDiaryData);
                throw ex;
            }
            finally
            {
            }
            return id;
        }
Esempio n. 13
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;
        }