Exemple #1
0
        public void CancelOutStock(OutStore outStore, string updatedBy)
        {
            //restore instore
            var instore = _instore.GetById(outStore.InstoreId);
            instore.RemainNumber += outStore.Number;
            instore.RemainTotalPrice += outStore.TotalPrice.Value;
            instore.UpdatedBy = updatedBy;
            instore.Update(instore);

            var stock = _stock.GetByInstoreId(instore.Id);
            stock.Number += outStore.Number;
            stock.TotalPrice += outStore.TotalPrice.Value;
            stock.UpdatedBy = updatedBy;
            stock.UpdatedDate = DateTime.Now;
            _stock.Update(stock);

            //delete outore
            _outStore.Delete(outStore.Id);
        }
Exemple #2
0
        public void OutStcok(OutStore outStore, string updatedBy)
        {
            var code = outStore.Code;
            var uintPrice = outStore.UnitPrice;
            var instores = _instore.GetByCodeUnitPrice(code, uintPrice.Value);

            foreach (var instore in instores)
            {
                if (instore.RemainNumber >= outStore.Number)
                {
                    outStore.InstoreId = instore.Id;
                    _outStore.Create(outStore);

                    instore.RemainNumber -= outStore.Number;
                    instore.RemainTotalPrice -= outStore.Number * outStore.UnitPrice.Value;
                    instore.UpdatedDate = DateTime.Now;
                    instore.UpdatedBy = updatedBy;
                    _instore.Update(instore);

                    var stock = _stock.GetByInstoreId(instore.Id);
                    stock.Number -= outStore.Number;
                    stock.TotalPrice -= outStore.Number * outStore.UnitPrice.Value;
                    stock.UpdatedDate = DateTime.Now;
                    stock.UpdatedBy = updatedBy;
                    _stock.Update(stock);

                    return;
                }
                else
                {
                    outStore.InstoreId = instore.Id;
                    var newOutStore = new OutStore();
                    newOutStore.Code = outStore.Code;
                    newOutStore.CreatedBy = updatedBy;
                    newOutStore.CreatedDate = DateTime.Now;
                    newOutStore.Department = outStore.Department;
                    newOutStore.Id = Guid.NewGuid().ToString();
                    newOutStore.InstoreId = outStore.InstoreId;
                    newOutStore.Number = instore.RemainNumber;
                    newOutStore.TotalPrice = instore.RemainTotalPrice;
                    newOutStore.UnitPrice = instore.UnitPrice;
                    newOutStore.Type = instore.Type;
                    newOutStore.UpdatedBy = updatedBy;
                    newOutStore.UpdatedDate = DateTime.Now;
                    _outStore.Create(newOutStore);

                    instore.RemainNumber = 0;
                    instore.RemainTotalPrice = 0;
                    instore.UpdatedBy = updatedBy;
                    instore.UpdatedDate = DateTime.Now;
                    _instore.Update(instore);

                    var stock = _stock.GetByInstoreId(instore.Id);
                    stock.Number = 0;
                    stock.TotalPrice = 0;
                    stock.UpdatedDate = DateTime.Now;
                    stock.UpdatedBy = updatedBy;
                    _stock.Update(stock);

                    outStore.Number -= newOutStore.Number;
                    outStore.TotalPrice -= newOutStore.TotalPrice;
                    if (outStore.Number == 0)
                    {
                        return;
                    }
                }
            }
        }
Exemple #3
0
 public BizLayer.OutStore GetBizModel(OutStoreModel ost)
 {
     BizLayer.OutStore bizOst = null;
     if (ost != null)
     {
         bizOst = new BizLayer.OutStore();
         bizOst.Code = ost.Code;
         bizOst.Id = ost.Id;
         bizOst.Number = ost.Number;
         bizOst.UnitPrice = ost.UnitPrice;
         bizOst.TotalPrice = ost.TotalPrice;
         bizOst.Department = ost.Department;
         bizOst.InstoreId = ost.InstoreId;
         bizOst.Type = ost.Type;
         bizOst.CreatedBy = ost.CreatedBy;
         bizOst.CreatedDate = ost.CreatedDate;
         bizOst.UpdatedBy = ost.UpdatedBy;
         bizOst.UpdatedDate = ost.UpdatedDate;
     }
     return bizOst;
 }