Ejemplo n.º 1
0
        /// <summary>
        /// 解锁
        /// </summary>
        /// <param name="p_StorgeLockID">锁定记录ID</param>
        /// <param name="sqlTrans">事务类</param>
        public void RUnLock(int p_StorgeLockID, decimal p_UnLockQty, string p_Remark, bool p_AboveFlag, IDBTransAccess sqlTrans)
        {
            try
            {
                StorgeLock entity = new StorgeLock(sqlTrans);
                entity.ID = p_StorgeLockID;
                entity.SelectByID();

                StorgeLockHisRule rule      = new StorgeLockHisRule();
                StorgeLockHis     entityhis = new StorgeLockHis(sqlTrans);

                //entityhis.StorgeID = p_StorgeLockID;
                //entityhis.LockStorgeID = p_StorgeLockID;
                entityhis.ID   = entity.ID;
                entityhis.WHID = entity.WHID;
                // entityhis.StorgeID = entity.StorgeID;
                entityhis.ItemCode = entity.ItemCode;
                entityhis.ItemName = entity.ItemName;
                entityhis.ItemStd  = entity.ItemStd;
                entityhis.LockOPID = entity.LockOPID;
                //entityhis.LockQty = entity.LockQty;
                entityhis.LockSO      = entity.LockSO;
                entityhis.Batch       = entity.Batch;
                entityhis.VendorBatch = entity.VendorBatch;
                entityhis.ColorName   = entity.ColorName;
                entityhis.ColorNum    = entity.ColorNum;
                entityhis.JarNum      = entity.JarNum;
                entityhis.VendorBatch = entity.VendorBatch;
                entityhis.LockTime    = entity.LockTime;
                entityhis.NeedDate    = entity.NeedDate;
                entityhis.LockDesc    = entity.Remark;
                //entityhis.LockTypeID = (int)LockType.解除锁定;

                //entityhis.LockQty = p_UnLockQty;
                //entityhis.UnLockQty = p_UnLockQty;
                //entityhis.UnlockOPID = ParamConfig.LoginID;
                //entityhis.UnlockTime = DateTime.Now;
                //entityhis.UnlockDesc = p_Remark;
                entityhis.Remark = p_Remark;

                entityhis.LastUpdOP   = ParamConfig.LoginName;
                entityhis.LastUpdTime = DateTime.Now;

                if (p_UnLockQty >= entity.LockQty)//已经全部解锁
                {
                    if (p_AboveFlag && (p_UnLockQty > entity.LockQty))
                    {
                        throw new Exception("解锁数量:" + p_UnLockQty.ToString() + " 大于当前锁定数量:" + entity.LockQty.ToString() + ",解锁失败");
                    }
                    this.RDelete(entity, sqlTrans);
                    StorgeRule rules = new StorgeRule();
                    // rules.UpdateStorge(entity.StorgeID, SysConvert.ToFloat(entity.LockQty), false, sqlTrans);
                }
                else//未全部解锁
                {
                    entity.LockQty     = entity.LockQty - p_UnLockQty;
                    entity.LastUpdOP   = ParamConfig.LoginName;
                    entity.LastUpdTime = DateTime.Now.Date;
                    this.RUpdate(entity, sqlTrans);
                    StorgeRule rules = new StorgeRule();
                    //rules.UpdateStorge(entity.StorgeID, SysConvert.ToFloat(p_UnLockQty), false, sqlTrans);
                }

                rule.RAdd(entityhis, sqlTrans);//新增解锁历史记录
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 锁定库存(传入事务处理)
        /// </summary>
        /// <param name="p_BE">要新增的实体</param>
        /// <param name="sqlTrans">事务类</param>
        public void RLock(BaseEntity p_BE, bool p_CheckLockNum, IDBTransAccess sqlTrans)
        {
            try
            {
                this.CheckCorrect(p_BE);
                StorgeLock entity = (StorgeLock)p_BE;

                string sql = string.Empty;
                //DataTable dt;
                //if (p_CheckLockNum)//校验是否超过最大锁定次数
                //{
                //    ParamSetRule ruleparam = new ParamSetRule();
                //    sql = "SELECT COUNT(*) FROM WH_StorgeLockHis WHERE ItemCode=" + SysString.ToDBString(entity.ItemCode);
                //    sql += " AND LockOPID=" + SysString.ToDBString(entity.LockOPID);
                //    sql += " AND LockTime BETWEEN " + SysString.ToDBString(DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-1");
                //    sql += " AND " + SysString.ToDBString(DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month).ToString());
                //    dt = sqlTrans.Fill(sql);
                //    if (SysConvert.ToInt32(dt.Rows[0][0]) >= ruleparam.RShowInt((int)ParamSet.锁定次数))
                //    {
                //        throw new Exception("纱种:" + entity.ItemName + " 本月已达到最大锁定次数" + dt.Rows[0][0].ToString() + ",锁定失败");
                //    }
                //}

                StorgeLockHisRule rule      = new StorgeLockHisRule();
                StorgeLockHis     entityhis = new StorgeLockHis(sqlTrans);
                entityhis.ID   = entity.ID;
                entityhis.WHID = entity.WHID;
                //entityhis.StorgeID = entity.StorgeID;
                entityhis.ItemCode = entity.ItemCode;
                entityhis.ItemName = entity.ItemName;
                entityhis.ItemStd  = entity.ItemStd;
                entityhis.LockDesc = entity.Remark;
                entityhis.LockOPID = entity.LockOPID;
                //entityhis.LockQty = entity.LockQty;
                entityhis.LockSO      = entity.LockSO;
                entityhis.LockTime    = entity.LockTime;
                entityhis.NeedDate    = entity.NeedDate;
                entityhis.Batch       = entity.Batch;
                entityhis.VendorBatch = entity.VendorBatch;
                entityhis.ColorName   = entity.ColorName;
                entityhis.ColorNum    = entity.ColorNum;
                entityhis.JarNum      = entity.JarNum;
                //entityhis.WHTypeID = entity.WHTypeID;
                //entityhis.LockTypeID = (int)LockType.锁定;
                entity.LastUpdOP   = ParamConfig.LoginName;
                entity.LastUpdTime = DateTime.Now;
                this.RAdd(entity, sqlTrans);
                //更新库存
                StorgeRule rules = new StorgeRule();
                // rules.UpdateStorge(entity.StorgeID, SysConvert.ToFloat(entity.LockQty), true, sqlTrans);
                //新增锁定历史数据
                rule.RAdd(entityhis, sqlTrans);
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }