Пример #1
0
        /// <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 + "和单据明细属性不匹配");
            }
        }
Пример #2
0
        /// <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);
            }
        }
Пример #3
0
        /// <summary>
        /// 新增(传入事务处理)
        /// </summary>
        /// <param name="p_BE">要新增的实体</param>
        /// <param name="sqlTrans">事务类</param>
        public void RAdd(IOForm p_MainEntity, IOFormDts p_MainDts, BaseEntity p_BE, IDBTransAccess sqlTrans)
        {
            try
            {
                this.CheckCorrect(p_BE);
                IOFormDtsPack entity = (IOFormDtsPack)p_BE;

                PackBox pbentity = new PackBox(sqlTrans);
                pbentity.SourceTypeID = (int)PackBoxSourceType.入库单;
                pbentity.BoxStatusID  = (int)EnumBoxStatus.未入库;
                CopyEntityData(p_MainDts, entity, pbentity);
                //if (entity.BoxNo != string.Empty && p_MainEntity.Remark == "EIN")//仅仅在导数据时使用到
                if (entity.BoxNo != string.Empty)    //仅仅在导数据时使用到
                {
                    pbentity.CreateTime = p_MainEntity.FormDate;
                    pbentity.BoxNo      = entity.BoxNo;
                }
                PackBoxRule pbrule = new PackBoxRule();
                pbrule.RAdd(pbentity, sqlTrans);


                entity.BoxNo = pbentity.BoxNo;

                entity.DID = p_MainDts.ID;   //20141009 zhoufc

                this.RAdd(entity, sqlTrans); //后插入的原因是箱号是在插入箱号实体时生成的
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }
Пример #4
0
        /// <summary>
        /// 保存(传入事务处理)
        /// </summary>
        /// <param name="p_BE">要新增的实体</param>
        /// <param name="sqlTrans">事务类</param>
        public void RSave(int p_ID, int p_MainID, int p_Seq, BaseEntity[] p_BE, bool p_UpdateFlag, IDBTransAccess sqlTrans)
        {
            try
            {
                string sql = "";
                if (p_UpdateFlag)                //修改状态下首先清除被删除的码单明细
                {
                    string idStr = string.Empty; //ID字符串
                    idStr = "0";
                    for (int i = 0; i < p_BE.Length; i++)
                    {
                        IOFormDtsPack entity = (IOFormDtsPack)p_BE[i];
                        if (entity.ID != 0)//有ID
                        {
                            if (idStr != string.Empty)
                            {
                                idStr += ",";
                            }
                            idStr += entity.ID.ToString();
                        }
                    }

                    if (idStr != string.Empty)
                    {
                        sql = "DELETE FROM WH_PackBox WHERE BoxNo IN (SELECT BoxNo FROM WH_IOFormDtsPack WHERE DID=" + SysString.ToDBString(p_ID) + " AND ID NOT IN(" + idStr + ") )";
                        sqlTrans.ExecuteNonQuery(sql);                                                                                  //执行条形码删除

                        sql = "DELETE FROM WH_IOFormDtsPack WHERE DID=" + SysString.ToDBString(p_ID) + " AND ID NOT IN(" + idStr + ")"; //WH_IOFormDtsPack WH_PackBox
                        sqlTrans.ExecuteNonQuery(sql);
                    }
                }
                else//新增状态
                {
                    sql = "SELECT TOP 1 ID FROM WH_IOFormDtsPack WHERE DID=" + SysString.ToDBString(p_ID);
                    DataTable dt = sqlTrans.Fill(sql);
                    if (dt.Rows.Count > 0)
                    {
                        throw new BaseException("不能重复保存!");
                    }
                }


                IOForm p_Main = new IOForm(sqlTrans);
                p_Main.ID = p_MainID;
                p_Main.SelectByID();

                IOFormDts p_MainDts = new IOFormDts(sqlTrans);
                p_MainDts.ID = p_ID;
                p_MainDts.SelectByID();



                IOFormDtsPackRule rule     = new IOFormDtsPackRule();
                PackBoxRule       Brule    = new PackBoxRule();
                decimal           Qty      = 0;
                decimal           PieceQty = 0;
                for (int i = 0; i < p_BE.Length; i++)
                {
                    FormNoControlRule frule  = new FormNoControlRule();
                    IOFormDtsPack     entity = (IOFormDtsPack)p_BE[i];
                    int boxNoCreateTypeID    = 0;//箱号条码来源
                    if (entity.ID == 0)
                    {
                        if (entity.BoxNo == string.Empty)//没有箱号条码
                        {
                            entity.BoxNo = frule.RGetFormNo((int)FormNoControlEnum.码单箱号, sqlTrans);
                            rule.RAdd(entity, sqlTrans);
                            frule.RAddSort((int)FormNoControlEnum.码单箱号, sqlTrans);
                        }
                        else//有箱号条码说明是验布产生的条码
                        {
                            boxNoCreateTypeID = 1;//验布来源
                        }
                    }
                    else
                    {
                        rule.RUpdate(entity, sqlTrans);
                    }


                    PackBox entityBox = new PackBox();
                    if (entity.ID != 0)//仓库明细已生成,则寻找箱号ID 此处判断其实无意义,经过上面的代码肯定有ID值了
                    {
                        sql = "SELECT ID FROM WH_PackBox WHERE BoxNo=" + SysString.ToDBString(entity.BoxNo);
                        DataTable dtPackBox = sqlTrans.Fill(sql);
                        if (dtPackBox.Rows.Count != 0)//如果找到条码
                        {
                            entityBox.ID = SysConvert.ToInt32(dtPackBox.Rows[0]["ID"]);
                        }
                        else//如果未找到条码
                        {
                            entityBox.CreateSourceID = boxNoCreateTypeID;////原始条码表加个字段表示来源 0:表示入库录入
                        }
                    }
                    entityBox.BoxNo         = entity.BoxNo;
                    entityBox.WHID          = p_MainDts.WHID;
                    entityBox.SectionID     = p_MainDts.SectionID;
                    entityBox.SBitID        = p_MainDts.SBitID;
                    entityBox.ColorName     = p_MainDts.ColorName;
                    entityBox.ColorNum      = p_MainDts.ColorNum;
                    entityBox.CompanyTypeID = p_MainDts.CompanyTypeID;
                    entityBox.GoodsCode     = p_MainDts.GoodsCode;
                    entityBox.GoodsLevel    = p_MainDts.GoodsLevel;
                    entityBox.ItemCode      = p_MainDts.ItemCode;
                    entityBox.ItemName      = p_MainDts.ItemName;
                    entityBox.ItemStd       = p_MainDts.ItemStd;
                    entityBox.JarNum        = p_MainDts.JarNum;
                    entityBox.Batch         = p_MainDts.Batch;
                    entityBox.VendorBatch   = p_MainDts.VendorBatch;
                    entityBox.MWeight       = p_MainDts.MWeight;
                    entityBox.MWidth        = p_MainDts.MWidth;
                    entityBox.Qty           = entity.Qty;
                    entityBox.Unit          = p_MainDts.Unit;
                    entityBox.BoxStatusID   = (int)EnumBoxStatus.未入库;
                    entityBox.DID           = p_ID;
                    entityBox.InFormNo      = p_Main.FormNo;
                    entityBox.OrderFormNo   = p_MainDts.DtsOrderFormNo;//合同号明细


                    if (entityBox.ID == 0)//没有ID则新增
                    {
                        Brule.RAdd(entityBox, sqlTrans);
                    }
                    else//有ID则修改
                    {
                        Brule.RUpdate(entityBox, sqlTrans);
                    }

                    Qty += entity.Qty;
                    PieceQty++;
                }

                //if (PieceQty == 0)
                //{
                //    throw new BaseException("请填写细码后点击保存");
                //}

                sql  = "UPDATE WH_IOFormDts SET Qty=" + SysString.ToDBString(Qty);
                sql += ",PieceQty=" + SysString.ToDBString(PieceQty);
                sql += ",PackFlag=1 ";
                sql += " WHERE ID=" + SysString.ToDBString(p_ID);
                sqlTrans.ExecuteNonQuery(sql);
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }
Пример #5
0
        /// <summary>
        /// 保存(传入事务处理)
        /// </summary>
        /// <param name="p_Entity"></param>
        /// <param name="p_BE"></param>
        /// <param name="sqlTrans"></param>
        public void RSave(IOForm p_Entity, IOFormDts[] p_EntityDts, ArrayList list, IDBTransAccess sqlTrans)
        {
            try
            {
                string sql = string.Empty;

                int FormListTopType = IOFormDtsRule.GetFormListTopTypeByFormListID(p_Entity.HeadType, sqlTrans); //顶层单据类型
                if (FormListTopType != (int)WHFormList.入库 && FormListTopType != (int)WHFormList.期初入库)            //如果不是入库类型的单据
                {
                    RSaveOther(p_Entity, p_EntityDts, list, sqlTrans);
                    return;
                }


                sql  = "SELECT BoxNo FROM WH_IOFormDtsPack WHERE MainID=" + p_Entity.ID.ToString();
                sql += " AND ID NOT IN" + string.Format("({0})", GetIDExist(list));
                DataTable dtDelete = sqlTrans.Fill(sql);  //删除表结构
                if (dtDelete.Rows.Count != 0)             //有需要删除的数据
                {
                    foreach (DataRow dr in dtDelete.Rows) //校验是否可以删除
                    {
                        PackBoxRule pbrule = new PackBoxRule();
                        pbrule.RCheckDelete(dr["BoxNo"].ToString(), sqlTrans);//检测调用
                    }

                    sql  = "DELETE FROM WH_PackBox WHERE BoxNo IN(SELECT BoxNo FROM WH_IOFormDtsPack WHERE MainID=" + p_Entity.ID.ToString();
                    sql += " AND ID NOT IN" + string.Format("({0})", GetIDExist(list)) + ")";//删除码单明细数据
                    sqlTrans.ExecuteNonQuery(sql);

                    sql  = "DELETE FROM WH_IOFormDtsPack WHERE MainID=" + p_Entity.ID.ToString();
                    sql += " AND ID NOT IN" + string.Format("({0})", GetIDExist(list));
                    sqlTrans.ExecuteNonQuery(sql);//删除原单据里应该删除的明细数据,即数据库里有但是UI里已经删除的数据
                }
                for (int i = 0; i < list.Count; i++)
                {
                    IOFormDtsPack entitydts    = (IOFormDtsPack)list[i];
                    int           ioformdtsdex = -1;
                    for (int m = 0; m < p_EntityDts.Length; m++)
                    {
                        if (p_EntityDts[m].Seq == entitydts.Seq)//找到相同的SEQ了
                        {
                            ioformdtsdex = m;
                            break;
                        }
                    }
                    if (ioformdtsdex == -1)//未找到,异常
                    {
                        throw new Exception("码单输入异常,未找到单据明细,行号:" + entitydts.Seq);
                    }


                    if (entitydts.ID != 0)//ID不为0说明数据库中已经存在
                    {
                        PackBoxRule pbrule = new PackBoxRule();
                        pbrule.RCheckUpdate(entitydts.BoxNo, sqlTrans);//检测调用
                        this.RUpdate(p_EntityDts[ioformdtsdex], entitydts, sqlTrans);
                    }
                    else
                    {
                        entitydts.MainID = p_Entity.ID;
                        this.RAdd(p_Entity, p_EntityDts[ioformdtsdex], entitydts, sqlTrans);
                    }
                }
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }
Пример #6
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;
                }
            }
        }