private void UpdateStackOut(string action) { stockOut = new StockOut(); stockOut.Date = dateTimePicker.Value.ToString("yyyy-MM-dd"); foreach (DataGridViewRow row in stockOutDataGridView.Rows) { stockOut.Quantity = Convert.ToInt32(row.Cells["quantityDataGridViewTextBoxColumn"].Value.ToString()); stockOut.ItemID = Convert.ToInt32(row.Cells["itemIDDataGridViewTextBoxColumn"].Value.ToString()); stockOut.Action = action; item.ID = stockOut.ItemID; dataTable = _stockOutManager.GetItem(item); int quantity = Convert.ToInt32(dataTable.Rows[0]["AvailableQuantity"]); quantity -= stockOut.Quantity; item.AvailableQuantity = quantity; _stockOutManager.UpdateItem(item); int isUpdated = 0; isUpdated = _stockOutManager.InsertStockOut(stockOut); if (isUpdated > 0) { messageLabel.Text = "Item: " + itemComboBox.Text + " Saved"; } } listStockOut = new List <StockOut>(); stockOutDataGridView.DataSource = null; stockOutDataGridView.DataSource = listStockOut; }
private void companyComboBox_SelectedIndexChanged_1(object sender, EventArgs e) { Item item = new Item(); itemBindingSource.DataSource = null; item.CompanyID = Convert.ToInt32(companyComboBox.SelectedValue); itemBindingSource.DataSource = _stockOutManager.GetItem(item); }