/// <summary>
        /// 保存其它单据时检查匹配性
        /// </summary>
        public void RSaveOtherCheck(IOFormDts p_MainDts, BaseEntity p_BE, IDBTransAccess sqlTrans)
        {
            this.CheckCorrect(p_BE);
            IOFormDtsPack entity = (IOFormDtsPack)p_BE;

            if (entity.BoxNo == string.Empty)
            {
                throw new Exception("异常,没有读取到码单箱号");
            }
            PackBoxRule pbrule   = new PackBoxRule();
            PackBox     pbentity = pbrule.RGetEntityByBoxNo(entity.BoxNo, sqlTrans);

            if (pbentity.BoxStatusID != (int)EnumBoxStatus.入库)
            {
                throw new Exception("异常,码单箱号" + entity.BoxNo + "当前未处于入库状态,不允许操作");
            }
            if (pbentity.ItemCode != p_MainDts.ItemCode || pbentity.ColorNum != p_MainDts.ColorNum ||
                pbentity.ColorName != p_MainDts.ColorName)//|| pbentity.GoodsLevel != p_MainDts.GoodsLevel 先不管等级
            {
                throw new Exception("异常,码单箱号" + entity.BoxNo + "和单据明细属性不匹配");
            }
        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="p_BE">要修改的实体</param>
        /// <param name="sqlTrans">事务类</param>
        public void RUpdate(IOFormDts p_MainDts, BaseEntity p_BE, IDBTransAccess sqlTrans)
        {
            try
            {
                this.CheckCorrect(p_BE);
                IOFormDtsPack entity = (IOFormDtsPack)p_BE;
                this.RUpdate(p_BE, sqlTrans);

                PackBoxRule pbrule   = new PackBoxRule();
                PackBox     pbentity = pbrule.RGetEntityByBoxNo(entity.BoxNo, sqlTrans); //获得箱单实体

                CopyEntityData(p_MainDts, entity, pbentity);                             //拷贝数据

                pbrule.RUpdate(pbentity, sqlTrans);                                      //更新
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }
Exemple #3
0
        /// <summary>
        /// 处理装箱单状态
        /// </summary>
        void PackBoxProc(int p_FormListTopType, IOForm p_entity, IOFormDts[] p_entitydts, int p_Type, IDBTransAccess sqlTrans)
        {
            string sql = string.Empty;

            sql = "SELECT Seq,BoxNo,Qty,FactQty FROM WH_IOFormDtsPack WHERE MainID=" + SysString.ToDBString(p_entity.ID) + " ORDER BY MainID,Seq";
            DataTable dtBoxNo = sqlTrans.Fill(sql);

            for (int i = 0; i < dtBoxNo.Rows.Count; i++)
            {
                //寻找对应仓库单据明细序号
                int ioformdtsdex = -1;
                for (int m = 0; m < p_entitydts.Length; m++)
                {
                    if (p_entitydts[m].Seq == SysConvert.ToInt32(dtBoxNo.Rows[i]["Seq"]))//找到相同的SEQ了
                    {
                        ioformdtsdex = m;
                        break;
                    }
                }
                if (ioformdtsdex == -1)//未找到,异常
                {
                    throw new Exception("码单异常,未找到单据明细,行号:" + SysConvert.ToInt32(dtBoxNo.Rows[0]["Seq"]));
                }


                //寻找码单序号
                PackBoxRule pbrule = new PackBoxRule();
                PackBox     entity = pbrule.RGetEntityByBoxNo(dtBoxNo.Rows[i]["BoxNo"].ToString(), sqlTrans);
                if (entity.ID == 0)
                {
                    throw new Exception("异常,码单明细数据未存储到码单箱号表内,可以尝试重新输入码单明细保存");
                }


                switch (p_FormListTopType)
                {
                case (int)WHFormList.入库:
                    if (p_Type == (int)YesOrNo.Yes)    //提交
                    {
                        if (entity.BoxStatusID != (int)EnumBoxStatus.未入库)
                        {
                            throw new Exception("当前码单" + dtBoxNo.Rows[i]["BoxNo"].ToString() + "不是处于未入库状态,不允许改变未入库状态");
                        }
                        entity.WHID        = p_entitydts[ioformdtsdex].WHID;
                        entity.SectionID   = p_entitydts[ioformdtsdex].SectionID;
                        entity.SBitID      = p_entitydts[ioformdtsdex].SBitID;
                        entity.InFormNo    = p_entity.FormNo;
                        entity.BoxStatusID = (int)EnumBoxStatus.入库;
                    }
                    else    //撤销提交
                    {
                        if (entity.BoxStatusID != (int)EnumBoxStatus.入库)
                        {
                            throw new Exception("当前码单" + dtBoxNo.Rows[i]["BoxNo"].ToString() + "不是处于入库状态,不允许改变为未入库状态");
                        }
                        entity.BoxStatusID = (int)EnumBoxStatus.未入库;
                    }

                    pbrule.RUpdate(entity, sqlTrans);    //更新数据
                    break;

                case (int)WHFormList.出库:
                    if (p_Type == (int)YesOrNo.Yes)    //提交
                    {
                        if (entity.BoxStatusID != (int)EnumBoxStatus.入库)
                        {
                            throw new Exception("当前码单" + dtBoxNo.Rows[i]["BoxNo"].ToString() + "不是处于入库状态,不允许改变为出库状态");
                        }

                        entity.OutFormNo   = p_entity.FormNo;
                        entity.BoxStatusID = (int)EnumBoxStatus.出库;
                    }
                    else    //撤销提交
                    {
                        if (entity.BoxStatusID != (int)EnumBoxStatus.出库)
                        {
                            throw new Exception("当前码单" + dtBoxNo.Rows[i]["BoxNo"].ToString() + "不是处于出库状态,不允许改变未入库状态");
                        }
                        entity.BoxStatusID = (int)EnumBoxStatus.入库;
                    }

                    pbrule.RUpdate(entity, sqlTrans);    //更新数据
                    break;

                case (int)WHFormList.盘点:            //盘点应当改变数量,要单独处理
                    if (p_Type == (int)YesOrNo.Yes) //提交
                    {
                        if (entity.BoxStatusID != (int)EnumBoxStatus.入库)
                        {
                            throw new Exception("当前码单" + dtBoxNo.Rows[i]["BoxNo"].ToString() + "不是处于入库状态,不允许移库");
                        }
                        entity.Qty = SysConvert.ToDecimal(dtBoxNo.Rows[i]["FactQty"]);
                    }
                    else    //撤销提交
                    {
                        if (entity.BoxStatusID != (int)EnumBoxStatus.入库)
                        {
                            throw new Exception("当前码单" + dtBoxNo.Rows[i]["BoxNo"].ToString() + "不是处于入库状态,不允许移库");
                        }
                        entity.Qty = SysConvert.ToDecimal(dtBoxNo.Rows[i]["Qty"]);
                    }

                    pbrule.RUpdate(entity, sqlTrans);    //更新数据
                    break;

                case (int)WHFormList.移库:            //移库应改变区位状态,要单独处理
                    if (p_Type == (int)YesOrNo.Yes) //提交
                    {
                        if (entity.BoxStatusID != (int)EnumBoxStatus.入库)
                        {
                            throw new Exception("当前码单" + dtBoxNo.Rows[i]["BoxNo"].ToString() + "不是处于入库状态,不允许移库");
                        }

                        if (entity.Qty != SysConvert.ToDecimal(dtBoxNo.Rows[i]["Qty"]))
                        {
                            throw new Exception("当前码单" + dtBoxNo.Rows[i]["BoxNo"].ToString() + "数量已改变,不允许操作,请检查是否进行过开匹操作");
                        }
                        entity.WHID      = p_entitydts[ioformdtsdex].ToWHID;
                        entity.SectionID = p_entitydts[ioformdtsdex].ToSectionID;
                        entity.SBitID    = p_entitydts[ioformdtsdex].ToSBitID;
                    }
                    else    //撤销提交
                    {
                        if (entity.BoxStatusID != (int)EnumBoxStatus.入库)
                        {
                            throw new Exception("当前码单" + dtBoxNo.Rows[i]["BoxNo"].ToString() + "不是处于入库状态,不允许移库");
                        }
                        if (entity.Qty != SysConvert.ToDecimal(dtBoxNo.Rows[i]["Qty"]))
                        {
                            throw new Exception("当前码单" + dtBoxNo.Rows[i]["BoxNo"].ToString() + "数量已改变,不允许操作,请检查是否进行过开匹操作");
                        }
                        entity.WHID      = p_entitydts[ioformdtsdex].WHID;
                        entity.SectionID = p_entitydts[ioformdtsdex].SectionID;
                        entity.SBitID    = p_entitydts[ioformdtsdex].SBitID;
                    }

                    pbrule.RUpdate(entity, sqlTrans);    //更新数据
                    break;
                }
            }
        }