예제 #1
0
 public void Delete(ReturnProduct data)
 {
     ReturnProductDAO.Delete(data);
 }
예제 #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            // validate data
            if (!ValidateData())
            {
                return;
            }

            var createdStockList = new List<Stock>();
            var createReturnProductList = new List<ReturnProduct>();
            var stockInDetailList = new List<StockInDetail>();

            for (int i = 0; i < dgvStockInDetail.RowCount; i++)
            {
                var index = NumberUtility.ParseInt(dgvStockInDetail[MAX_COLUMN - 1, i].Value);
                var acceptQty = NumberUtility.ParseLong(dgvStockInDetail[ACCEPT_QUANTITY_POS, i].Value);
                var returnQty = NumberUtility.ParseLong(dgvStockInDetail[RETURN_QUANTITY_POS, i].Value);
                var stockInDetail = (StockInDetail)StockInDetailList[index];

                // approve for product
                if (acceptQty != 0)
                {
                    Stock currentStock = null;
                    if (_currentEventArgs != null && _currentEventArgs.StockList != null)
                    {
                        foreach (Stock stock in _currentEventArgs.StockList)
                        {
                            if (stock.Product.ProductId == stockInDetail.Product.ProductId)
                            {
                                currentStock = stock;
                                currentStock.Quantity += acceptQty;
                                break;
                            }
                        }
                        if (currentStock == null)
                        {
                            currentStock = new Stock
                                               {
                                                   Quantity = acceptQty,
                                                   Product = ((StockInDetail)StockInDetailList[index]).Product
                                               };
                        }
                        createdStockList.Add(currentStock);
                    }
                }
                // return the product
                if (returnQty != 0)
                {
                    var returnProduct = new ReturnProduct
                                            {
                                                ProductId = ((StockInDetail)StockInDetailList[index]).Product.ProductId,
                                                Quantity = returnQty
                                            };

                    createReturnProductList.Add(returnProduct);
                }
                if (stockInDetail.Quantity == acceptQty + returnQty)
                {
                    stockInDetail.StockInType = (long)StockInDetail.StockInStatus.COMPLETELY_STOCKED;
                    stockInDetailList.Add(stockInDetail);
                }
            }
            if (createdStockList.Count > 0 || createReturnProductList.Count > 0)
            {
                var eventArgs = new StockCreateEventArgs { CreateStockList = createdStockList, CreateReturnProductList = createReturnProductList, UpdateStockInDetailList = stockInDetailList };
                EventUtility.fireEvent(CreateStockEvent, this, eventArgs);

                EventUtility.fireEvent(SearchStockInDetailEvent, this, _currentEventArgs);
                StockInDetailList = _currentEventArgs.StockInDetailList;
                PopulateDataGrid(_currentEventArgs);
            }
        }
예제 #3
0
 public ReturnProduct Add(ReturnProduct data)
 {
     ReturnProductDAO.Add(data);
     return data;
 }
예제 #4
0
 public void Update(ReturnProduct data)
 {
     ReturnProductDAO.Update(data);
 }
예제 #5
0
 /// <summary>
 /// Delete ReturnProduct from database.
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public void Delete(ReturnProduct data)
 {
     HibernateTemplate.Delete(data);
 }
예제 #6
0
 /// <summary>
 /// Add ReturnProduct to database.
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public ReturnProduct Add(ReturnProduct data)
 {
     HibernateTemplate.Save(data);
     return data;
 }
예제 #7
0
 /// <summary>
 /// Update ReturnProduct to database.
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public void Update(ReturnProduct data)
 {
     HibernateTemplate.Update(data);
 }