Example #1
0
        private void FetchListViewContentFromDatabase()
        {
            string productid = null;

            try
            {
                if (string.IsNullOrEmpty(listViewStockSearch.FocusedItem.Text))
                {
                }
                else
                {
                    productid = listViewStockSearch.FocusedItem.Text;
                    UpdateStock update = new UpdateStock();
                    update.prodid = productid;
                    DataTable table = update.GetStockTable();

                    foreach (DataRow row in table.Rows)
                    {
                        txtbProductID.Text   = row["ProductID"].ToString();
                        txtbProductName.Text = row["ProductName"].ToString();
                        txtbDescription.Text = row["ProductDescription"].ToString();
                        txtbSupplierID.Text  = row["SupplierID"].ToString();
                        txtbCategoryID.Text  = row["CategoryID"].ToString();
                        txtbQuantity.Text    = row["Quantity"].ToString();
                        txtbUnitPrice.Text   = row["UnitPrice"].ToString();
                    }
                }
            }
            catch
            {
                Interaction.MsgBox("Please select record to update", MsgBoxStyle.Exclamation, "Update");
                return;
            }
        }
Example #2
0
        private void UpdateStockDetails()
        {
            int         Quantity    = Convert.ToInt32(txtbQuantity.Text);
            UpdateStock stockupdate = new UpdateStock();

            stockupdate.ProductID   = txtbProductID.Text;
            stockupdate.ProductName = txtbProductName.Text;
            stockupdate.ProductDesc = txtbDescription.Text;
            stockupdate.SuppplierID = txtbSupplierID.Text;
            stockupdate.CategoryID  = txtbCategoryID.Text;
            stockupdate.Quantity    = Quantity;
            stockupdate.Unitprice   = txtbUnitPrice.Text;
            stockupdate.UpdateStockDetails();

            txtbProductID.Text   = null;
            txtbProductName.Text = null;
            txtbDescription.Text = null;
            txtbSupplierID.Text  = null;
            txtbCategoryID.Text  = null;
            txtbQuantity.Text    = null;
            txtbUnitPrice.Text   = null;
            txtSearch.Text       = null;
            listViewStockSearch.Items.Clear();
            MessageBox.Show("Record updated successfully", "Data Updated", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Example #3
0
        private void AddToSell()
        {
            string product_name = null;

            try
            {
                if (string.IsNullOrEmpty(listViewSearch.FocusedItem.Text))
                {
                }
                else
                {
                    product_name = listViewSearch.FocusedItem.Text;
                    UpdateStock getStocks = new UpdateStock();
                    getStocks.Kwrd = product_name;
                    DataTable Table = getStocks.dTable();

                    foreach (DataRow row in Table.Rows)
                    {
                        txtbProd.Text  = row["ProductName"].ToString();
                        txtbPrice.Text = row["UnitPrice"].ToString();
                    }
                    txtbSearch.Text = null;
                    listViewSearch.Items.Clear();
                }
            }
            catch
            {
                Interaction.MsgBox("Please select record to add", MsgBoxStyle.Exclamation, "Add to Cart");
                return;
            }
        }
Example #4
0
        private void RetrieveStockInfo()
        {
            try
            {
                UpdateStock stock = new UpdateStock();
                stock.Kwrd = txtSearch.Text;
                DataTable table = stock.dTable();

                ListViewItem entry = null;
                listViewStockSearch.Items.Clear();

                foreach (DataRow row in table.Rows)
                {
                    entry = new ListViewItem(row["ProductID"].ToString());
                    entry.SubItems.Add(row["ProductName"].ToString());
                    entry.SubItems.Add(row["ProductDescription"].ToString());
                    entry.SubItems.Add(row["SupplierID"].ToString());
                    entry.SubItems.Add(row["CategoryID"].ToString());
                    entry.SubItems.Add(row["Quantity"].ToString());
                    entry.SubItems.Add(row["UnitPrice"].ToString());
                    listViewStockSearch.Items.Add(entry);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public void Put(Guid id, [FromBody] UpdateStock s)
        {
            var entity = _repository.GetById(id);

            entity.Update(s.Name, s.Code, s.StockRecords);
            // magic
            _repository.Edit(entity);
        }
Example #6
0
        public ProductEvent UpdateStockAction(UpdateStock message)
        {
            var product = Products.FirstOrDefault(p => p.Id == message.ProductId);

            if (product == null)
            {
                return(new ProductNotFound());
            }

            var newAmountChanged = product.InStock + message.AmountChanged;

            if (newAmountChanged < 0)
            {
                return(new InsufficientStock());
            }

            product.InStock = newAmountChanged;
            return(new StockUpdated(product));
        }
Example #7
0
        public ProductEvent UpdateStock(UpdateStock message)
        {
            var maybeProduct = _repository.GetById(message.ProductId);

            if (!maybeProduct.HasValue)
            {
                return(new ProductNotFound());
            }

            var product = maybeProduct.Value;

            if (product.InStock + message.AmountChanged >= 0)
            {
                product.InStock += message.AmountChanged;
                return(new StockUpdated(product));
            }

            return(new InsufficientStock());
        }
Example #8
0
        double discount;          // Sets discount value as well as return the value to zero when necessary.
        //public string AmountPaid;
        //public string getAmountToPay;

        //public string displayChange;

        private void RetrieveStock()
        {
            UpdateStock getStocks = new UpdateStock();

            getStocks.Kwrd = txtbSearch.Text;
            DataTable Table = getStocks.dTable();

            ListViewItem entry = null;

            listViewSearch.Items.Clear();

            foreach (DataRow row in Table.Rows)
            {
                entry = new ListViewItem(row["ProductName"].ToString());
                entry.SubItems.Add(row["ProductDescription"].ToString());
                entry.SubItems.Add(row["UnitPrice"].ToString());
                listViewSearch.Items.Add(entry);
            }
        }
Example #9
0
        public ProductEventBase UpdateStockAction(UpdateStock message)
        {
            var product = this.Products
                          .FirstOrDefault(p => p.Id == message.ProductId);

            if (product == null)
            {
                return(new ProductNotFound());
            }
            if (product.Stock + message.AmountChanged >= 0)
            {
                product.Stock += message.AmountChanged;
                return(new StockUpdated(product));
            }
            else
            {
                return(new OutOfStock());
            }
        }
        public ProductEvent UpdateStockAction(UpdateStock message)
        {
            var product = this.Products
                          .FirstOrDefault(p => p.Id == message.ProductId);

            if (product is Product)
            {
                if (product.InStock + message.AmountChanged >= 0)
                {
                    product.InStock += message.AmountChanged;
                    return(new StockUpdated(product));
                }
                else
                {
                    return(new InsuffientStock());
                }
            }

            return(new ProductNotFound());
        }
Example #11
0
        public ProductEvent UpdateStockAction(UpdateStock message)
        {
            _productRepository = new ProductRepository(new DatabaseFactory("server=172.29.208.1;Port=3306;user id=developer;password=NY8dzHQg;persistsecurityinfo=True;database=akkanetdemo;SslMode=none"));

            var product = _productRepository.Get(t => t.Id == message.ProductId);

            if (product != null)
            {
                if (product.InStock + message.AmountChanged >= 0)
                {
                    product.InStock += message.AmountChanged;
                    _productRepository.Update(product);
                    _productRepository.UnitOfWork.SaveChangesAsync();
                    return(new StockUpdated(product));
                }
                else
                {
                    return(new InsuffientStock());
                }
            }

            return(new ProductNotFound());
        }
Example #12
0
        public void UpdateStockWithQuantityAfterSale()
        {
            int Quantity, saleQuantity; string prodname;
            int availQuantity = 0;

            foreach (ListViewItem Item in listViewPurchase.Items)
            {
                prodname     = Item.SubItems[0].Text;
                saleQuantity = Convert.ToInt32(Item.SubItems[1].Text);
                DataTable   stocktable;
                UpdateStock stockupdate = new UpdateStock();
                stockupdate.Kwrd = prodname;
                stocktable       = stockupdate.dTable();

                foreach (DataRow row in stocktable.Rows)
                {
                    availQuantity = Convert.ToInt32(row["Quantity"]);
                }

                Quantity = availQuantity - saleQuantity;
                //MessageBox.Show(Convert.ToString(Quantity));
                GetStockDetails update = new GetStockDetails(prodname, Quantity);
            }
        }
Example #13
0
 public async Task <IActionResult> UpdateStock([FromBody] UpdateStock.Request request,
                                               [FromServices] UpdateStock updateStock) =>
 Ok(await updateStock.Do(request));
Example #14
0
 /// <summary>
 /// Update the stock of a single product
 /// </summary>
 /// <param name="updateStockModel">Detail, which article should get which stock</param>
 /// <returns>Result of the operation</returns>
 public ApiResult <CurrentStockInfo> UpdateStock(UpdateStock updateStockModel)
 {
     return(post <ApiResult <CurrentStockInfo> >("/products/updatestock", updateStockModel));
 }
 public Task <IEnumerable <object> > UpdateStock([FromBody] IEnumerable <Stock> stocks,
                                                 [FromServices] UpdateStock updateStock) =>
 updateStock.Do(stocks);
Example #16
0
 public async Task <IActionResult> UpdateStock([FromBody] UpdateStockDto updateStockDto,
                                               [FromServices] UpdateStock updateStock)
 {
     return(Ok(await updateStock.ExecAsync(updateStockDto)));
 }
Example #17
0
 public Task UpdateStock(int id,
                         [FromBody] IEnumerable <UpdateStock.StockForm> stocks,
                         [FromServices] UpdateStock updateStock) =>
 updateStock.ForProduct(id, stocks);