Пример #1
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);
            }
        }
Пример #2
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);
            }
        }
Пример #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;
                }
            }
        }