예제 #1
0
        public static StockOut Create(Department department,IDictionary<Product,long> productList, string createId,DateTime createDate,StockDefinitionStatus definitionStatus,string description,int confirmFlag = 1)
        {
            CoralPOS.Models.StockOut stockOut = new CoralPOS.Models.StockOut
            {
                CreateDate = createDate,
                ConfirmFlg = confirmFlag,
                CreateId = createId,
                UpdateId = createId,
                UpdateDate = createDate,
                Description = description,
                Department = department,
                DefinitionStatus = definitionStatus,
                ExclusiveKey = 0,
                DelFlg = 0,
                StockOutDate = createDate,
                StockOutDetails = new List<StockOutDetail>(),

            };
            foreach (var stockInProduct in productList)
            {
                CoralPOS.Models.StockOutDetail detail = new StockOutDetail
                {
                    StockOut = stockOut,
                    CreateDate = createDate,
                    UpdateDate = createDate,
                    CreateId = createId,
                    UpdateId = createId,
                    Description = description,
                    DelFlg = 0,
                    ExclusiveKey = 0,
                    Quantity = stockInProduct.Value,
                    Product = stockInProduct.Key,
                    ProductMaster = stockInProduct.Key.ProductMaster,
                    GoodQuantity = stockInProduct.Value,
                    DefectStatusId = definitionStatus.DefectStatusId
                };
                stockOut.StockOutDetails.Add(detail);
            }
            return stockOut;
        }
예제 #2
0
        protected bool Equals(StockOut entity)
        {
            if (entity == null) return false;
            if (!base.Equals(entity)) return false;

            return true;
        }
예제 #3
0
 protected override void OnInitialize()
 {
     FromDate = DateTime.Now;
     ToDate = DateTime.Now;
     CategoryList = CategoryLogic.FindAll(new ObjectCriteria<Category>()) as IList;
     Departments = DepartmentLogic.FindAll(new ObjectCriteria<Department>()) as IList;
     IList searchedStockOut = Flow.Session.Get(FlowConstants.STOCK_OUT_SEARCH_RESULT) as IList;
     CoralPOS.Models.StockOut selectedStockOut = Flow.Session.Get(FlowConstants.SAVE_STOCK_OUT) as CoralPOS.Models.StockOut;
     if (searchedStockOut == null)
     {
         SelectedStockOut = new CoralPOS.Models.StockOut();
     }
     else
     {
         if(selectedStockOut!=null) SelectedStockOut = selectedStockOut;
         else
         {
             SelectedStockOut = new CoralPOS.Models.StockOut();
         }
     }
 }
예제 #4
0
 public void Update(StockOut data)
 {
     long definitionStatusId = data.DefinitionStatus.DefectStatusId;
     if (definitionStatusId == DefinitionStatus.TEMP_STOCKOUT
            || definitionStatusId == DefinitionStatus.PROTOTYPE) return;
     foreach (StockOutDetail outDetail in data.StockOutDetails)
     {
         string productId = outDetail.Product.ProductId;
         ObjectCriteria<MainStock> findStock = new ObjectCriteria<MainStock>();
         findStock.Add(stk => stk.Product.ProductId == productId);
         MainStock currentStock = MainStockDao.FindFirst(findStock) as MainStock;
         /*MainStock currentStock = (MainStock)MainStockDao.ExecuteExposedSession(delegate(ISession session)
                                                                                    {
                                                                                        var query =
                                                                                            session.QueryOver<MainStock>()
                                                                                                .Where(
                                                                                                    stk =>
                                                                                                    stk.Product.ProductId ==
                                                                                                    productId);
                                                                                        return query.SingleOrDefault();
                                                                                    });*/
         if (currentStock == null) // create new stock
         {
             throw new DataIntegrityViolationException("Could not find the product id in stock");
         }
         else // update current stock
         {
             // * ---- CHUA CO PHAN XUAT HANG HU LOI HONG MAT O DAY --------
             currentStock.Quantity -= outDetail.Quantity;
             currentStock.GoodQuantity -= outDetail.Quantity;
             currentStock.ExclusiveKey += 1;
             if (currentStock.Quantity < 0 || currentStock.GoodQuantity < 0)
                 throw new DataIntegrityViolationException("Stock quantity of " + currentStock.Product.ProductId + " is zero.");
             MainStockDao.Update(currentStock);
         }
     }
 }
예제 #5
0
 public void Delete(StockOut data)
 {
     StockOutDao.Delete(data);
 }
예제 #6
0
 public StockOut Add(StockOut data)
 {
     StockOutDao.Add(data);
     return data;
 }
예제 #7
0
 public void Update(StockOut data)
 {
     StockOutDao.Update(data);
 }