Ejemplo n.º 1
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="p_Entity">实体类</param>
        /// <returns>操作影响的记录行数</returns>
        public override int Delete(BaseEntity p_Entity)
        {
            try
            {
                PackBox MasterEntity = (PackBox)p_Entity;
                if (MasterEntity.ID == 0)
                {
                    return(0);
                }

                //删除主表数据
                string Sql = "";
                Sql = "DELETE FROM WH_PackBox WHERE " + "ID=" + SysString.ToDBString(MasterEntity.ID);
                //执行
                int AffectedRows = 0;
                if (!this.sqlTransFlag)
                {
                    AffectedRows = this.ExecuteNonQuery(Sql);
                }
                else
                {
                    AffectedRows = sqlTrans.ExecuteNonQuery(Sql);
                }

                return(AffectedRows);
            }
            catch (BaseException E)
            {
                throw new BaseException(E.Message, E);
            }
            catch (Exception E)
            {
                throw new BaseException(FrameWorkMessage.GetAlertMessage((int)Message.CommonDBDelete), E);
            }
        }
Ejemplo n.º 2
0
        //private void ProcDataTable(DataTable p_dt)
        //{
        //    foreach (DataRow dr in p_dt.Rows)
        //    {
        //        string sql = "select PrintCD from WO_BProductCheckDts where 1=1";
        //        sql += " AND DISN=" + SysString.ToDBString(SysConvert.ToString(dr["BoxNo"]));
        //        DataTable dt = SysUtils.Fill(sql);
        //        if (dt.Rows.Count != 0)
        //        {
        //            dr["PrintCD"] = SysConvert.ToString(dt.Rows[0]["PrintCD"]);
        //        }
        //    }
        //}

        /// <summary>
        /// 删除
        /// </summary>
        public override void EntityDelete()
        {
            PackBoxRule rule   = new PackBoxRule();
            PackBox     entity = EntityGet();

            rule.RDelete(entity);
        }
Ejemplo n.º 3
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                if (SysConvert.ToDecimal(txtQty.Text.Trim()) <= 0)
                {
                    this.ShowMessage("清输入数量");
                    return;
                }

                PackBox entity = new PackBox();
                entity.ID = m_ID;
                entity.SelectByID();

                if (entity.Qty < SysConvert.ToDecimal(txtQty.Text.Trim()))
                {
                    this.ShowMessage("需开匹的数量要小于原有数量");
                    return;
                }

                PackBoxKPRule rule = new PackBoxKPRule();
                rule.RAdd(m_ID, SysConvert.ToDecimal(txtQty.Text.Trim()), FParamConfig.LoginID);
                m_KPFinishFlag = true;
                this.ShowInfoMessage("开匹完成");
                this.Close();
            }
            catch (Exception E)
            {
                this.ShowMessage(E.Message);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 新增(传入事务处理)
        /// </summary>
        /// <param name="p_BE">要新增的实体</param>
        /// <param name="sqlTrans">事务类</param>
        public void RAdd(int p_ID, decimal p_Qty, string p_OPID, IDBTransAccess sqlTrans)
        {
            try
            {
                PackBoxKPRule rule   = new PackBoxKPRule();
                PackBox       entity = new PackBox(sqlTrans);
                entity.ID = p_ID;
                entity.SelectByID();

                FormNoControlRule frule   = new FormNoControlRule();
                PackBoxKP         pentity = new PackBoxKP();
                pentity.FormNo    = frule.RGetFormNo((int)FormNoControlEnum.开匹单号, sqlTrans);
                pentity.FormDate  = DateTime.Now;
                pentity.MakeDate  = DateTime.Now;
                pentity.MakeOPID  = p_OPID;
                pentity.SaleOPID  = p_OPID;
                pentity.KPOPID    = p_OPID;
                pentity.BoxNo     = entity.BoxNo;
                pentity.Qty       = entity.Qty;
                pentity.TargetQty = p_Qty;

                rule.RAdd(pentity, sqlTrans);

                rule.RSubmit(pentity.ID, 1, sqlTrans);
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 获得实体
        /// </summary>
        /// <returns></returns>
        private PackBox EntityGet()
        {
            PackBox entity = new PackBox();

            entity.ID = HTDataID;
            return(entity);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 根据获得实体箱号
        /// </summary>
        /// <param name="p_BoxNo">箱号</param>
        /// <returns>返回箱号实体</returns>
        public PackBox RGetEntityByBoxNo(string p_BoxNo, IDBTransAccess sqlTrans)
        {
            PackBox   entity = new PackBox(sqlTrans);
            string    sql    = "SELECT ID FROM WH_PackBox WHERE BoxNo=" + SysString.ToDBString(p_BoxNo);//寻找ID
            DataTable dt     = sqlTrans.Fill(sql);

            if (dt.Rows.Count != 0)
            {
                entity.ID = SysConvert.ToInt32(dt.Rows[0]["ID"]);
                entity.SelectByID();
            }
            return(entity);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// 拷贝数据到实体内
 /// </summary>
 /// <param name="p_MainDts"></param>
 /// <param name="p_BE"></param>
 public void CopyEntityData(IOFormDts p_MainDts, IOFormDtsPack p_BE, PackBox p_PBEntity)
 {
     p_PBEntity.ColorName     = p_MainDts.ColorName;
     p_PBEntity.ColorNum      = p_MainDts.ColorNum;
     p_PBEntity.CompanyTypeID = p_MainDts.CompanyTypeID;
     p_PBEntity.GoodsCode     = p_MainDts.GoodsCode;
     p_PBEntity.GoodsLevel    = p_MainDts.GoodsLevel;
     p_PBEntity.ItemCode      = p_MainDts.ItemCode;
     p_PBEntity.ItemName      = p_MainDts.ItemName;
     p_PBEntity.ItemStd       = p_MainDts.ItemStd;
     p_PBEntity.JarNum        = p_MainDts.JarNum;
     p_PBEntity.Batch         = p_MainDts.Batch;
     p_PBEntity.VendorBatch   = p_MainDts.VendorBatch;
     p_PBEntity.MWeight       = p_MainDts.MWeight;
     p_PBEntity.MWidth        = p_MainDts.MWidth;
     p_PBEntity.Qty           = p_BE.Qty;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="p_BE">要删除的实体</param>
 /// <param name="sqlTrans">事务类</param>
 public void RDelete(BaseEntity p_BE, IDBTransAccess sqlTrans)
 {
     try
     {
         this.CheckCorrect(p_BE);
         PackBox    entity  = (PackBox)p_BE;
         PackBoxCtl control = new PackBoxCtl(sqlTrans);
         control.Delete(entity);
     }
     catch (BaseException)
     {
         throw;
     }
     catch (Exception E)
     {
         throw new BaseException(E.Message);
     }
 }
Ejemplo n.º 9
0
        /// <summary>
        /// 新增(传入事务处理)
        /// </summary>
        /// <param name="p_BE">要新增的实体</param>
        /// <param name="sqlTrans">事务类</param>
        public void RAdd(BaseEntity p_BE, IDBTransAccess sqlTrans)
        {
            try
            {
                this.CheckCorrect(p_BE);
                PackBox    entity  = (PackBox)p_BE;
                PackBoxCtl control = new PackBoxCtl(sqlTrans);
                entity.ID = (int)EntityIDTable.GetID((long)SysEntity.WH_PackBox, sqlTrans);
                if (entity.BoxNo == string.Empty)//条码号不存在
                {
                    entity.CreateTime = DateTime.Now;

                    FormNoControlRule rulest = new FormNoControlRule();

                    //处理生成箱号
                    entity.BoxNo = rulest.RGetFormNo((int)FormNoControlEnum.码单箱号, sqlTrans);
                    rulest.RAddSort((int)FormNoControlEnum.码单箱号, sqlTrans);
                }
                else//已存在
                {
                    string sql = "SELECT BoxNo FROM WH_PackBox WHERE BoxNo=" + SysString.ToDBString(entity.BoxNo);
                    if (sqlTrans.Fill(sql).Rows.Count != 0)//条码号已存在,则生成新条码
                    {
                        entity.CreateTime = DateTime.Now;

                        FormNoControlRule rulest = new FormNoControlRule();

                        //处理生成箱号
                        entity.BoxNo = rulest.RGetFormNo((int)FormNoControlEnum.码单箱号, sqlTrans);
                        rulest.RAddSort((int)FormNoControlEnum.码单箱号, sqlTrans);
                    }
                }

                control.AddNew(entity);
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }
Ejemplo n.º 10
0
 private void frmLoadPack_Load(object sender, EventArgs e)
 {
     try
     {
         if (m_ID == 0)
         {
             this.ShowMessage("未找到此匹数据");
             this.Close();
         }
         else
         {
             PackBox entity = new PackBox();
             entity.ID = m_ID;
             entity.SelectByID();
             lblInfo1.Text = entity.BoxNo;
             lblInfo2.Text = entity.Qty.ToString();
         }
     }
     catch (Exception E)
     {
     }
 }
Ejemplo n.º 11
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 + "和单据明细属性不匹配");
            }
        }
Ejemplo n.º 12
0
 /// <summary>
 /// 拷贝数据到实体内
 /// </summary>
 /// <param name="p_MainDts"></param>
 /// <param name="p_BE"></param>
 public void CopyEntityData(PackBox p_PBEntitySouce, PackBox p_PBEntity)
 {
     p_PBEntity.CompanyTypeID = p_PBEntitySouce.CompanyTypeID;
     p_PBEntity.GoodsCode     = p_PBEntitySouce.GoodsCode;
     p_PBEntity.GoodsLevel    = p_PBEntitySouce.GoodsLevel;
     p_PBEntity.MWeight       = p_PBEntitySouce.MWeight;
     p_PBEntity.MWidth        = p_PBEntitySouce.MWidth;
     p_PBEntity.ItemCode      = p_PBEntitySouce.ItemCode;
     p_PBEntity.ItemName      = p_PBEntitySouce.ItemName;
     p_PBEntity.ItemStd       = p_PBEntitySouce.ItemStd;
     p_PBEntity.Batch         = p_PBEntitySouce.Batch;
     p_PBEntity.VendorBatch   = p_PBEntitySouce.VendorBatch;
     p_PBEntity.WHID          = p_PBEntitySouce.WHID;
     p_PBEntity.SectionID     = p_PBEntitySouce.SectionID;
     p_PBEntity.SBitID        = p_PBEntitySouce.SBitID;
     p_PBEntity.Unit          = p_PBEntitySouce.Unit;
     p_PBEntity.ColorName     = p_PBEntitySouce.ColorName;
     p_PBEntity.ColorNum      = p_PBEntitySouce.ColorNum;
     p_PBEntity.JarNum        = p_PBEntitySouce.JarNum;
     p_PBEntity.OrderFormNo   = p_PBEntitySouce.OrderFormNo;
     p_PBEntity.ItemModel     = p_PBEntitySouce.ItemModel;
 }
Ejemplo n.º 13
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;
                }
                pbentity.DID    = p_MainDts.ID;
                pbentity.SubSeq = entity.SubSeq;
                PackBoxRule pbrule = new PackBoxRule();
                pbrule.RAdd(pbentity, sqlTrans);



                entity.DID   = p_MainDts.ID; //20141009 zhoufc
                entity.BoxNo = pbentity.BoxNo;
                this.RAdd(entity, sqlTrans); //后插入的原因是箱号是在插入箱号实体时生成的
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }
Ejemplo n.º 14
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);
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 审核
        /// </summary>
        /// <param name="p_FormID">单据ID</param>
        /// <param name="p_Type">0/1/2/3:弃审/审核</param>
        public void RSubmit(int p_FormID, int p_Type, IDBTransAccess sqlTrans)
        {
            try
            {
                int       p_TempType = p_Type;//处理状态
                string    sql        = string.Empty;
                PackBoxKP entity     = new PackBoxKP(sqlTrans);
                entity.ID = p_FormID;
                entity.SelectByID();
                if (entity.SubmitFlag == p_Type)//如果相同异常
                {
                    throw new Exception("单据状态重复设置,请关闭程序重新打开操作");
                }


                //开匹数据提交

                PackBoxRule pbrule         = new PackBoxRule();
                PackBox     pbentitysource = pbrule.RGetEntityByBoxNo(entity.BoxNo, sqlTrans);
                if (pbentitysource.ID != 0)
                {
                    if (pbentitysource.BoxStatusID == (int)EnumBoxStatus.入库)
                    {
                        if (p_Type == (int)YesOrNo.Yes)//开匹操作
                        {
                            if ((pbentitysource.Qty <= entity.TargetQty && pbentitysource.Qty != 0 && entity.TargetQty != 0) || (pbentitysource.Weight <= entity.TargetWeight && pbentitysource.Weight != 0 && entity.TargetWeight != 0) || (pbentitysource.Yard <= entity.TargetYard && pbentitysource.Yard != 0 && entity.TargetYard != 0))
                            {
                                throw new Exception("操作错误,源条码数量或者码数或者公斤数小于等于开匹目标数量或者码数或者公斤数!");
                            }

                            entity.Qty    = pbentitysource.Qty;//赋值主表数量,防止调整过数量
                            entity.Weight = pbentitysource.Weight;
                            entity.Yard   = pbentitysource.Yard;
                            PackBox pbentity = new PackBox(sqlTrans);//目标箱号实体
                            pbentity.SelectByID();
                            CopyEntityData(pbentitysource, pbentity);
                            pbentity.SourceTypeID = (int)PackBoxSourceType.开匹;
                            pbentity.BoxStatusID  = (int)EnumBoxStatus.入库;
                            pbentity.Qty          = entity.TargetQty;
                            pbentity.Weight       = entity.TargetWeight;
                            pbentity.Yard         = entity.Yard;
                            pbentity.SourceBoxNo  = pbentitysource.BoxNo;
                            pbrule.RAdd(pbentity, sqlTrans);

                            pbentitysource.Qty    = pbentitysource.Qty - pbentity.Qty;//修改源箱号数量
                            pbentitysource.Weight = pbentitysource.Weight - pbentity.Weight;
                            pbentitysource.Yard   = pbentitysource.Yard - pbentity.Yard;
                            pbentitysource.KPFlag = (int)YesOrNo.Yes;//修改源箱号开匹标志
                            pbrule.RUpdate(pbentitysource, sqlTrans);
                            entity.TargetBoxNo = pbentity.BoxNo;

                            //插入开匹明细数据
                            PackBoxKPDtsRule dtsRule    = new PackBoxKPDtsRule();
                            PackBoxKPDts     entitydts1 = new PackBoxKPDts(sqlTrans);
                            entitydts1.MainID       = entity.ID;
                            entitydts1.Seq          = 1;
                            entitydts1.BoxNo        = entity.BoxNo;
                            entitydts1.ColorNO      = entity.ColorNO;
                            entitydts1.ColorName    = entity.ColorName;
                            entitydts1.SourceQty    = pbentitysource.Qty + pbentity.Qty;       //主数据更新时把数据删除了
                            entitydts1.SourceWeight = pbentitysource.Weight + pbentity.Weight; //主数据更新时把数据删除了
                            entitydts1.SourceYard   = pbentitysource.Yard + pbentity.Yard;     //主数据更新时把数据删除了
                            entitydts1.Qty          = pbentitysource.Qty;                      //主数据更新时把数据删除了
                            entitydts1.Weight       = pbentitysource.Weight;                   //主数据更新时把数据删除了
                            entitydts1.Yard         = pbentitysource.Yard;                     //主数据更新时把数据删除了
                            dtsRule.RAdd(entitydts1, sqlTrans);

                            PackBoxKPDts entitydts2 = new PackBoxKPDts(sqlTrans);
                            entitydts2.MainID    = entity.ID;
                            entitydts2.Seq       = 2;
                            entitydts2.BoxNo     = entity.TargetBoxNo;
                            entitydts2.ColorNO   = entity.ColorNO;
                            entitydts2.ColorName = entity.ColorName;
                            entitydts2.SourceQty = 0;
                            entitydts2.Qty       = entity.TargetQty;
                            entitydts2.Weight    = entity.TargetWeight;
                            entitydts2.Yard      = entity.TargetYard;
                            dtsRule.RAdd(entitydts2, sqlTrans);
                            #region 查找仓库结算类型
                            string    sqlCal       = "SELECT FieldName FROM UV1_WH_WH WHERE WHID=" + SysString.ToDBString(pbentity.WHID);//获得仓库结算类型字段
                            DataTable dt           = sqlTrans.Fill(sqlCal);
                            string    FieldNamestr = string.Empty;
                            if (dt.Rows.Count != 0)
                            {
                                FieldNamestr += SysConvert.ToString(dt.Rows[0]["FieldName"]);
                            }
                            sql  = "UPDATE WH_Storge SET PieceQty=PieceQty+1 WHERE 1=1";
                            sql += " AND WHID=" + SysString.ToDBString(pbentity.WHID);
                            sql += " AND SectionID=" + SysString.ToDBString(pbentity.SectionID);
                            sql += " AND SBitID=" + SysString.ToDBString(pbentity.SBitID);
                            int CalFieldName = (int)WHCalMethodFieldName.ItemCode;
                            if (FieldNamestr != string.Empty)
                            {
                                string[] FieldName = FieldNamestr.Split('+');
                                for (int i = 0; i < FieldName.Length; i++)
                                {
                                    string    sqlFieldName = "SELECT ID FROM Enum_WHCalMethodFieldName WHERE Name=" + SysString.ToDBString(FieldName[i]);//找到库存结算字段对应的ID
                                    DataTable dtFieldName  = sqlTrans.Fill(sqlFieldName);
                                    if (dtFieldName.Rows.Count != 0 && dtFieldName.Rows[0]["ID"].ToString() != "")
                                    {
                                        CalFieldName = SysConvert.ToInt32(dtFieldName.Rows[0]["ID"]);
                                    }
                                    switch (CalFieldName)
                                    {
                                    case (int)WHCalMethodFieldName.ItemCode:    //产品编码
                                        sql += " AND ISNULL(ItemCode,'')=" + SysString.ToDBString(pbentity.ItemCode);
                                        break;

                                    case (int)WHCalMethodFieldName.ColorNum:    //色号
                                        sql += " AND ISNULL(ColorNum,'')=" + SysString.ToDBString(pbentity.ColorNum);
                                        break;

                                    case (int)WHCalMethodFieldName.ColorName:    //颜色
                                        sql += " AND ISNULL(ColorName,'')=" + SysString.ToDBString(pbentity.ColorName);
                                        break;

                                    case (int)WHCalMethodFieldName.Batch:       //批号
                                        sql += " AND ISNULL(Batch,'')=" + SysString.ToDBString(pbentity.Batch);
                                        break;

                                    case (int)WHCalMethodFieldName.VendorBatch:      //客户批号
                                        sql += " AND ISNULL(VendorBatch,'')=" + SysString.ToDBString(pbentity.VendorBatch);
                                        break;

                                    case (int)WHCalMethodFieldName.JarNum:      //缸号
                                        sql += " AND ISNULL(JarNum,'')=" + SysString.ToDBString(pbentity.JarNum);
                                        break;

                                    case (int)WHCalMethodFieldName.MWidth:    //门幅
                                        sql += " AND ISNULL(MWidth,'')=" + SysString.ToDBString(pbentity.MWidth);
                                        break;

                                    case (int)WHCalMethodFieldName.MWeight:    //克重
                                        sql += " AND ISNULL(MWeight,'')=" + SysString.ToDBString(pbentity.MWeight);
                                        break;

                                    case (int)WHCalMethodFieldName.DtsOrderFormNo:    //克重
                                        sql += " AND ISNULL(OrderFormNo,0)=" + SysString.ToDBString(pbentity.OrderFormNo);
                                        break;

                                    default:
                                        throw new Exception("结算异常,结算定义的字段底层未对应:" + CalFieldName + ",请联系管理员");
                                    }
                                }
                            }
                            #endregion
                            sqlTrans.ExecuteNonQuery(sql);
                        }
                        else//撤销开匹操作
                        {
                            PackBox pbentity = pbrule.RGetEntityByBoxNo(entity.TargetBoxNo, sqlTrans);//目标箱号实体
                            if (pbentitysource.ID == 0)
                            {
                                throw new Exception("操作错误,未找到目标条码");
                            }
                            //开始检验是否允许撤销提交
                            if (pbentity.WHID == pbentitysource.WHID && pbentity.SectionID == pbentitysource.SectionID &&
                                pbentity.SBitID == pbentitysource.SBitID)
                            {
                            }
                            else//库区有改变
                            {
                                throw new Exception("操作错误,开匹后的条码的移库了,必须撤销删除移库单后再进行移库操作");
                            }
                            #region 判断开匹后的条码有没有再次被开匹
                            sql = "SELECT * FROM WH_PackBox WHERE SourceBoxNo =" + SysString.ToDBString(pbentity.BoxNo);
                            DataTable dtSource = sqlTrans.Fill(sql);
                            if (dtSource.Rows.Count > 0)
                            {
                                throw new Exception("操作错误,开匹后的条码又开过匹,必须撤销该条码的开匹后再进行撤销");
                            }
                            #endregion
                            #region 判断开匹后的条码的状态
                            sql = "SELECT BoxStatusID FROM WH_PackBox WHERE BoxNo=" + SysString.ToDBString(pbentity.BoxNo);
                            DataTable dtBoxStatus = sqlTrans.Fill(sql);
                            if (dtBoxStatus.Rows.Count != 0)
                            {
                                if (SysConvert.ToInt32(dtBoxStatus.Rows[0]["BoxStatusID"]) != (int)EnumBoxStatus.入库)
                                {
                                    throw new Exception("条码" + pbentity.BoxNo + "状态未处于入库状态,不能撤销");
                                }
                            }
                            #endregion
                            //结束检验是否允许撤销提交
                            //pbrule.RCheckDelete(entity.TargetBoxNo, sqlTrans);//校验是否允许删除
                            pbrule.RDelete(pbentity, sqlTrans);

                            pbentitysource.Qty    = pbentitysource.Qty + pbentity.Qty;//修改源箱号数量
                            pbentitysource.Weight = pbentitysource.Weight + pbentity.Weight;
                            pbentitysource.Yard   = pbentitysource.Yard + pbentity.Yard;
                            #region 判断该匹是否有其开匹
                            sql = "SELECT * FROM WH_PackBox WHERE SourceBoxNo =" + SysString.ToDBString(pbentitysource.BoxNo);
                            DataTable dtpbentitysource = sqlTrans.Fill(sql);
                            if (dtpbentitysource.Rows.Count == 0)
                            {
                                pbentitysource.KPFlag = (int)YesOrNo.No;//修改源箱号开匹标志
                            }
                            #endregion
                            pbrule.RUpdate(pbentitysource, sqlTrans);
                            entity.TargetBoxNo = "";                                       //目标箱号
                            sql = "DELETE FROM WH_PackBoxKPDts WHERE MainID=" + entity.ID; //删除开匹明细数据
                            sqlTrans.ExecuteNonQuery(sql);

                            #region 查找仓库结算类型
                            string    sqlCal       = "SELECT FieldName FROM UV1_WH_WH WHERE WHID=" + SysString.ToDBString(pbentity.WHID);//获得仓库结算类型字段
                            DataTable dt           = sqlTrans.Fill(sqlCal);
                            string    FieldNamestr = string.Empty;
                            if (dt.Rows.Count != 0)
                            {
                                FieldNamestr += SysConvert.ToString(dt.Rows[0]["FieldName"]);
                            }
                            sql  = "UPDATE WH_Storge SET PieceQty=PieceQty-1 WHERE 1=1";
                            sql += " AND WHID=" + SysString.ToDBString(pbentity.WHID);
                            sql += " AND SectionID=" + SysString.ToDBString(pbentity.SectionID);
                            sql += " AND SBitID=" + SysString.ToDBString(pbentity.SBitID);
                            int CalFieldName = (int)WHCalMethodFieldName.ItemCode;
                            if (FieldNamestr != string.Empty)
                            {
                                string[] FieldName = FieldNamestr.Split('+');
                                for (int i = 0; i < FieldName.Length; i++)
                                {
                                    string    sqlFieldName = "SELECT ID FROM Enum_WHCalMethodFieldName WHERE Name=" + SysString.ToDBString(FieldName[i]);//找到库存结算字段对应的ID
                                    DataTable dtFieldName  = sqlTrans.Fill(sqlFieldName);
                                    if (dtFieldName.Rows.Count != 0 && dtFieldName.Rows[0]["ID"].ToString() != "")
                                    {
                                        CalFieldName = SysConvert.ToInt32(dtFieldName.Rows[0]["ID"]);
                                    }
                                    switch (CalFieldName)
                                    {
                                    case (int)WHCalMethodFieldName.ItemCode:    //产品编码
                                        sql += " AND ISNULL(ItemCode,'')=" + SysString.ToDBString(pbentity.ItemCode);
                                        break;

                                    case (int)WHCalMethodFieldName.ColorNum:    //色号
                                        sql += " AND ISNULL(ColorNum,'')=" + SysString.ToDBString(pbentity.ColorNum);
                                        break;

                                    case (int)WHCalMethodFieldName.ColorName:    //颜色
                                        sql += " AND ISNULL(ColorName,'')=" + SysString.ToDBString(pbentity.ColorName);
                                        break;

                                    case (int)WHCalMethodFieldName.Batch:       //批号
                                        sql += " AND ISNULL(Batch,'')=" + SysString.ToDBString(pbentity.Batch);
                                        break;

                                    case (int)WHCalMethodFieldName.VendorBatch:      //客户批号
                                        sql += " AND ISNULL(VendorBatch,'')=" + SysString.ToDBString(pbentity.VendorBatch);
                                        break;

                                    case (int)WHCalMethodFieldName.JarNum:      //缸号
                                        sql += " AND ISNULL(JarNum,'')=" + SysString.ToDBString(pbentity.JarNum);
                                        break;

                                    case (int)WHCalMethodFieldName.MWidth:    //门幅
                                        sql += " AND ISNULL(MWidth,'')=" + SysString.ToDBString(pbentity.MWidth);
                                        break;

                                    case (int)WHCalMethodFieldName.MWeight:    //克重
                                        sql += " AND ISNULL(MWeight,'')=" + SysString.ToDBString(pbentity.MWeight);
                                        break;

                                    case (int)WHCalMethodFieldName.DtsOrderFormNo:    //克重
                                        sql += " AND ISNULL(OrderFormNo,0)=" + SysString.ToDBString(pbentity.OrderFormNo);
                                        break;

                                    default:
                                        throw new Exception("结算异常,结算定义的字段底层未对应:" + CalFieldName + ",请联系管理员");
                                    }
                                }
                            }
                            #endregion
                            sqlTrans.ExecuteNonQuery(sql);
                        }
                    }
                    else
                    {
                        throw new Exception("操作错误,源条码不处于入库状态");
                    }
                }
                else
                {
                    throw new Exception("操作错误,未找到源条码");
                }

                entity.SubmitFlag = p_Type;
                this.RUpdate(entity, sqlTrans);//更新主表状态
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="p_Entity">实体类</param>
        /// <returns>操作影响的记录行数</returns>
        public override int AddNew(BaseEntity p_Entity)
        {
            try
            {
                PackBox MasterEntity = (PackBox)p_Entity;
                if (MasterEntity.ID == 0)
                {
                    return(0);
                }

                //新增主表数据
                StringBuilder MasterField = new StringBuilder();
                StringBuilder MasterValue = new StringBuilder();
                MasterField.Append("INSERT INTO WH_PackBox(");
                MasterValue.Append(" VALUES(");
                MasterField.Append("ID" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.ID) + ",");
                MasterField.Append("CompanyTypeID" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.CompanyTypeID) + ",");
                MasterField.Append("BoxNo" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.BoxNo) + ",");
                MasterField.Append("WHID" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.WHID) + ",");
                MasterField.Append("SectionID" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.SectionID) + ",");
                MasterField.Append("SBitID" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.SBitID) + ",");
                MasterField.Append("GoodsCode" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.GoodsCode) + ",");
                MasterField.Append("GoodsLevel" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.GoodsLevel) + ",");
                MasterField.Append("MWidth" + ",");
                if (MasterEntity.MWidth != 0)
                {
                    MasterValue.Append(SysString.ToDBString(MasterEntity.MWidth) + ",");
                }
                else
                {
                    MasterValue.Append("null,");
                }

                MasterField.Append("MWeight" + ",");
                if (MasterEntity.MWeight != 0)
                {
                    MasterValue.Append(SysString.ToDBString(MasterEntity.MWeight) + ",");
                }
                else
                {
                    MasterValue.Append("null,");
                }

                MasterField.Append("ItemCode" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.ItemCode) + ",");
                MasterField.Append("ItemName" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.ItemName) + ",");
                MasterField.Append("ItemStd" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.ItemStd) + ",");
                MasterField.Append("Batch" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.Batch) + ",");
                MasterField.Append("VendorBatch" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.VendorBatch) + ",");
                MasterField.Append("Weight" + ",");
                if (MasterEntity.Weight != 0)
                {
                    MasterValue.Append(SysString.ToDBString(MasterEntity.Weight) + ",");
                }
                else
                {
                    MasterValue.Append("null,");
                }

                MasterField.Append("Qty" + ",");
                if (MasterEntity.Qty != 0)
                {
                    MasterValue.Append(SysString.ToDBString(MasterEntity.Qty) + ",");
                }
                else
                {
                    MasterValue.Append("null,");
                }

                MasterField.Append("Unit" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.Unit) + ",");
                MasterField.Append("ColorNum" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.ColorNum) + ",");
                MasterField.Append("ColorName" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.ColorName) + ",");
                MasterField.Append("JarNum" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.JarNum) + ",");
                MasterField.Append("CreateTime" + ",");
                if (MasterEntity.CreateTime != SystemConfiguration.DateTimeDefaultValue)
                {
                    MasterValue.Append(SysString.ToDBString(MasterEntity.CreateTime.ToString("yyyy-MM-dd HH:mm:ss")) + ",");
                }
                else
                {
                    MasterValue.Append("null,");
                }

                MasterField.Append("BoxStatusID" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.BoxStatusID) + ",");
                MasterField.Append("InFormNo" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.InFormNo) + ",");
                MasterField.Append("OutFormNo" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.OutFormNo) + ",");
                MasterField.Append("Remark" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.Remark) + ",");
                MasterField.Append("SourceTypeID" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.SourceTypeID) + ",");
                MasterField.Append("KPFlag" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.KPFlag) + ",");
                MasterField.Append("SourceBoxNo" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.SourceBoxNo) + ",");
                MasterField.Append("DID" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.DID) + ",");
                MasterField.Append("CreateSourceID" + ",");
                MasterValue.Append(SysString.ToDBString(MasterEntity.CreateSourceID) + ",");
                MasterField.Append("OrderFormNo" + ")");
                MasterValue.Append(SysString.ToDBString(MasterEntity.OrderFormNo) + ")");



                //执行
                int AffectedRows = 0;
                if (!this.sqlTransFlag)
                {
                    AffectedRows = this.ExecuteNonQuery(MasterField.Append(MasterValue.ToString()).ToString());
                }
                else
                {
                    AffectedRows = sqlTrans.ExecuteNonQuery(MasterField.Append(MasterValue.ToString()).ToString());
                }
                return(AffectedRows);
            }
            catch (BaseException E)
            {
                throw new BaseException(E.Message, E);
            }
            catch (Exception E)
            {
                throw new BaseException(FrameWorkMessage.GetAlertMessage((int)Message.CommonDBInsert), E);
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="p_Entity">实体类</param>
        /// <returns>操作影响的记录行数</returns>
        public override int Update(BaseEntity p_Entity)
        {
            try
            {
                PackBox MasterEntity = (PackBox)p_Entity;
                if (MasterEntity.ID == 0)
                {
                    return(0);
                }

                //更新主表数据
                StringBuilder UpdateBuilder = new StringBuilder();
                UpdateBuilder.Append("UPDATE WH_PackBox SET ");
                UpdateBuilder.Append(" ID=" + SysString.ToDBString(MasterEntity.ID) + ",");
                UpdateBuilder.Append(" CompanyTypeID=" + SysString.ToDBString(MasterEntity.CompanyTypeID) + ",");
                UpdateBuilder.Append(" BoxNo=" + SysString.ToDBString(MasterEntity.BoxNo) + ",");
                UpdateBuilder.Append(" WHID=" + SysString.ToDBString(MasterEntity.WHID) + ",");
                UpdateBuilder.Append(" SectionID=" + SysString.ToDBString(MasterEntity.SectionID) + ",");
                UpdateBuilder.Append(" SBitID=" + SysString.ToDBString(MasterEntity.SBitID) + ",");
                UpdateBuilder.Append(" GoodsCode=" + SysString.ToDBString(MasterEntity.GoodsCode) + ",");
                UpdateBuilder.Append(" GoodsLevel=" + SysString.ToDBString(MasterEntity.GoodsLevel) + ",");

                if (MasterEntity.MWidth != 0)
                {
                    UpdateBuilder.Append(" MWidth=" + SysString.ToDBString(MasterEntity.MWidth) + ",");
                }
                else
                {
                    UpdateBuilder.Append(" MWidth=null,");
                }


                if (MasterEntity.MWeight != 0)
                {
                    UpdateBuilder.Append(" MWeight=" + SysString.ToDBString(MasterEntity.MWeight) + ",");
                }
                else
                {
                    UpdateBuilder.Append(" MWeight=null,");
                }

                UpdateBuilder.Append(" ItemCode=" + SysString.ToDBString(MasterEntity.ItemCode) + ",");
                UpdateBuilder.Append(" ItemName=" + SysString.ToDBString(MasterEntity.ItemName) + ",");
                UpdateBuilder.Append(" ItemStd=" + SysString.ToDBString(MasterEntity.ItemStd) + ",");
                UpdateBuilder.Append(" Batch=" + SysString.ToDBString(MasterEntity.Batch) + ",");
                UpdateBuilder.Append(" VendorBatch=" + SysString.ToDBString(MasterEntity.VendorBatch) + ",");

                if (MasterEntity.Weight != 0)
                {
                    UpdateBuilder.Append(" Weight=" + SysString.ToDBString(MasterEntity.Weight) + ",");
                }
                else
                {
                    UpdateBuilder.Append(" Weight=null,");
                }


                if (MasterEntity.Qty != 0)
                {
                    UpdateBuilder.Append(" Qty=" + SysString.ToDBString(MasterEntity.Qty) + ",");
                }
                else
                {
                    UpdateBuilder.Append(" Qty=null,");
                }

                UpdateBuilder.Append(" Unit=" + SysString.ToDBString(MasterEntity.Unit) + ",");
                UpdateBuilder.Append(" ColorNum=" + SysString.ToDBString(MasterEntity.ColorNum) + ",");
                UpdateBuilder.Append(" ColorName=" + SysString.ToDBString(MasterEntity.ColorName) + ",");
                UpdateBuilder.Append(" JarNum=" + SysString.ToDBString(MasterEntity.JarNum) + ",");

                if (MasterEntity.CreateTime != SystemConfiguration.DateTimeDefaultValue)
                {
                    UpdateBuilder.Append(" CreateTime=" + SysString.ToDBString(MasterEntity.CreateTime.ToString("yyyy-MM-dd HH:mm:ss")) + ",");
                }
                else
                {
                    UpdateBuilder.Append(" CreateTime=null,");
                }

                UpdateBuilder.Append(" BoxStatusID=" + SysString.ToDBString(MasterEntity.BoxStatusID) + ",");
                UpdateBuilder.Append(" InFormNo=" + SysString.ToDBString(MasterEntity.InFormNo) + ",");
                UpdateBuilder.Append(" OutFormNo=" + SysString.ToDBString(MasterEntity.OutFormNo) + ",");
                UpdateBuilder.Append(" Remark=" + SysString.ToDBString(MasterEntity.Remark) + ",");
                UpdateBuilder.Append(" SourceTypeID=" + SysString.ToDBString(MasterEntity.SourceTypeID) + ",");
                UpdateBuilder.Append(" KPFlag=" + SysString.ToDBString(MasterEntity.KPFlag) + ",");
                UpdateBuilder.Append(" SourceBoxNo=" + SysString.ToDBString(MasterEntity.SourceBoxNo) + ",");
                UpdateBuilder.Append(" DID=" + SysString.ToDBString(MasterEntity.DID) + ",");
                UpdateBuilder.Append(" CreateSourceID=" + SysString.ToDBString(MasterEntity.CreateSourceID) + ",");
                UpdateBuilder.Append(" OrderFormNo=" + SysString.ToDBString(MasterEntity.OrderFormNo));

                UpdateBuilder.Append(" WHERE " + "ID=" + SysString.ToDBString(MasterEntity.ID));



                //执行
                int AffectedRows = 0;
                if (!this.sqlTransFlag)
                {
                    AffectedRows = this.ExecuteNonQuery(UpdateBuilder.ToString());
                }
                else
                {
                    AffectedRows = sqlTrans.ExecuteNonQuery(UpdateBuilder.ToString());
                }
                return(AffectedRows);
            }
            catch (BaseException E)
            {
                throw new BaseException(E.Message, E);
            }
            catch (Exception E)
            {
                throw new BaseException(FrameWorkMessage.GetAlertMessage((int)Message.CommonDBUpdate), E);
            }
        }
Ejemplo n.º 18
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);
            }
        }
Ejemplo n.º 19
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;
                }
            }
        }
Ejemplo n.º 20
0
 /// <summary>
 /// 检查将要操作的数据是否符合业务规则
 /// </summary>
 /// <param name="p_BE"></param>
 private void CheckCorrect(BaseEntity p_BE)
 {
     PackBox entity = (PackBox)p_BE;
 }