Ejemplo n.º 1
0
        private void AddRetailRdRecords(Guid consumeListId, Guid rdId, int rdFlag, Guid invId,
                                        Guid mainUnit, Guid sTUnit, decimal exchRate, string batch, decimal num,
                                        decimal price, DXInfo.Models.CurrentStock oldCurStock)
        {
            DXInfo.Models.RdRecords rdRecords;
            if (string.IsNullOrEmpty(batch))
            {
                rdRecords = uow.RdRecords.GetAll().Where(w => w.RdId == rdId &&
                                                         w.InvId == invId &&
                                                         w.Price == price).FirstOrDefault();
            }
            else
            {
                rdRecords = uow.RdRecords.GetAll().Where(w => w.RdId == rdId &&
                                                         w.InvId == invId &&
                                                         w.Batch == batch).FirstOrDefault();
            }
            bool isExist = true;

            if (rdRecords != null)
            {
                rdRecords.Num = rdRecords.Num + num;
            }
            else
            {
                isExist         = false;
                rdRecords       = new DXInfo.Models.RdRecords();
                rdRecords.RdId  = rdId;
                rdRecords.InvId = invId;
                rdRecords.Num   = num;
                rdRecords.Price = price;
                rdRecords.Batch = batch;
            }
            rdRecords.MainUnit = mainUnit;
            rdRecords.STUnit   = sTUnit;
            rdRecords.ExchRate = exchRate;
            rdRecords.Amount   = rdRecords.Num * price;

            if (isShelfLife)
            {
                if (oldCurStock != null)
                {
                    rdRecords.MadeDate      = oldCurStock.MadeDate;
                    rdRecords.ShelfLife     = oldCurStock.ShelfLife;
                    rdRecords.ShelfLifeType = oldCurStock.ShelfLifeType;
                    rdRecords.InvalidDate   = oldCurStock.InvalidDate;
                }
            }

            if (!isExist)
            {
                uow.RdRecords.Add(rdRecords);
            }
            else
            {
                uow.RdRecords.Update(rdRecords);
            }
            uow.Commit();
            AddConsumeListRds(consumeListId, rdRecords.Id);
        }
Ejemplo n.º 2
0
        private bool RetailUpdateCurrent(DXInfo.Models.CurrentStock oldCurStock, int rdFlag, decimal num, decimal quantity)
        {
            bool ret = true;

            ret = RetailUpdateCurrentStock(oldCurStock.Id, rdFlag, num, quantity);
            if (ret && isLocator)
            {
                ret = RetailUpdateCurrentInvLocator(oldCurStock.WhId, oldCurStock.InvId, oldCurStock.Batch, rdFlag, num, quantity);
            }
            uow.Commit();
            return(ret);
        }
Ejemplo n.º 3
0
 private DXInfo.Models.CurrentStock GetCurInStock(Guid rdsId)
 {
     DXInfo.Models.CurrentStock oldCurStock = null;
     DXInfo.Models.RdRecords    rds         = uow.RdRecords.GetById(g => g.Id == rdsId);
     if (rds != null)
     {
         DXInfo.Models.RdRecord rd = uow.RdRecord.GetById(g => g.Id == rds.RdId);
         if (rd != null)
         {
             if (string.IsNullOrEmpty(rds.Batch))
             {
                 oldCurStock = (from d in uow.CurrentStock.GetAll()
                                where d.WhId == rd.WhId && d.InvId == rds.InvId && d.Batch == null
                                orderby d.Num
                                select d).FirstOrDefault();
             }
             else
             {
                 oldCurStock = (from d in uow.CurrentStock.GetAll()
                                where d.WhId == rd.WhId && d.InvId == rds.InvId && d.Batch == rds.Batch
                                orderby d.Num
                                select d).FirstOrDefault();
             }
             if (oldCurStock == null)
             {
                 oldCurStock               = new DXInfo.Models.CurrentStock();
                 oldCurStock.WhId          = rd.WhId;
                 oldCurStock.InvId         = rds.InvId;
                 oldCurStock.MainUnit      = rds.MainUnit;
                 oldCurStock.STUnit        = rds.STUnit;
                 oldCurStock.ExchRate      = rds.ExchRate;
                 oldCurStock.Quantity      = rds.Quantity;
                 oldCurStock.Num           = rds.Num;
                 oldCurStock.Batch         = rds.Batch;
                 oldCurStock.Price         = rds.Price;
                 oldCurStock.Amount        = oldCurStock.Num * oldCurStock.Price;
                 oldCurStock.InvalidDate   = rds.InvalidDate;
                 oldCurStock.MadeDate      = rds.MadeDate;
                 oldCurStock.ShelfLife     = rds.ShelfLife;
                 oldCurStock.ShelfLifeType = rds.ShelfLifeType;
                 uow.CurrentStock.Add(oldCurStock);
                 uow.Commit();
             }
         }
     }
     return(oldCurStock);
 }
Ejemplo n.º 4
0
 private bool RetailUpdateCurrentStock(Guid curStockId, int rdFlag, decimal num, decimal quantity)
 {
     DXInfo.Models.CurrentStock oldCurStock = uow.CurrentStock.GetById(g => g.Id == curStockId);
     if (oldCurStock == null)
     {
         return(false);
     }
     if (rdFlag == 1)
     {
         if (num > oldCurStock.Num)
         {
             return(false);
         }
     }
     oldCurStock.Quantity = rdFlag == 0 ? oldCurStock.Quantity + quantity : oldCurStock.Quantity - quantity;
     oldCurStock.Num      = rdFlag == 0 ? oldCurStock.Num + num : oldCurStock.Num - num;
     oldCurStock.Amount   = oldCurStock.Price * oldCurStock.Num;
     uow.CurrentStock.Update(oldCurStock);
     uow.Commit();
     return(true);
 }
Ejemplo n.º 5
0
 private DXInfo.Models.CurrentStock GetCurOutStock(Guid invId, string batch, decimal num)
 {
     DXInfo.Models.CurrentStock oldCurStock = null;
     if (string.IsNullOrEmpty(batch))
     {
         oldCurStock = (from d in uow.CurrentStock.GetAll()
                        join d1 in uow.Warehouse.GetAll() on d.WhId equals d1.Id into dd1
                        from dd1s in dd1.DefaultIfEmpty()
                        where dd1s.Dept == deptId && d.InvId == invId && d.Batch == null && d.Num > num
                        orderby d.Num
                        select d).FirstOrDefault();
     }
     else
     {
         oldCurStock = (from d in uow.CurrentStock.GetAll()
                        join d1 in uow.Warehouse.GetAll() on d.WhId equals d1.Id into dd1
                        from dd1s in dd1.DefaultIfEmpty()
                        where dd1s.Dept == deptId && d.InvId == invId && d.Batch == batch && d.Num > num
                        orderby d.Num
                        select d).FirstOrDefault();
     }
     return(oldCurStock);
 }