private void buttonSave_Click(object sender, EventArgs e) { try { if (buttonSave.Text.Equals("Confirm")) { int updateQuantity = Convert.ToInt32(textBoxStockInQuantity.Text); _item.AvailableQuantity += updateQuantity; _stockIn.Quantity = updateQuantity; _stockInManager.UpdateAvailableQuantity(_item); _stockInManager.UpdateStockIn(_stockIn); buttonSave.Text = "Save"; } else { if (comboBoxCompanyName.Text.Equals("-Select-")) { MessageBox.Show("Enter a company!"); return; } if (comboBoxCategoryName.Text.Equals("-Select-")) { MessageBox.Show("Enter a category"); return; } if (comboBoxItemName.Text.Equals("-Select-")) { MessageBox.Show("Enter an Item"); return; } _stockIn.Date = dateTimePickerUserDefineDate.Value.ToString("yyyy-MM-dd"); _stockIn.ItemID = Convert.ToInt32(comboBoxItemName.SelectedValue); if (String.IsNullOrEmpty(textBoxStockInQuantity.Text)) { MessageBox.Show("Enter a quantity!"); return; } _stockIn.Quantity = Convert.ToInt32(textBoxStockInQuantity.Text); AddStockIn(_stockIn); //update avaiableQuantity _item.ID = _stockIn.ID; _dataTable = _stockInManager.GetItemById(_item); int currentQuantity = Convert.ToInt32(_dataTable.Rows[0]["AvailableQuantity"]); _item.AvailableQuantity = currentQuantity + _stockIn.Quantity; _stockInManager.UpdateAvailableQuantity(_item); } TextBoxDefaultValue(); textBoxStockInQuantity.Text = ""; DisplayAllRecords(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
protected void itemDropDownList_SelectedIndexChanged(object sender, EventArgs e) { ItemViewModel aItemViewModel = new ItemViewModel(); int ItemId = Convert.ToInt32(itemDropDownList.SelectedItem.Value); aItemViewModel = aStockInManager.GetItemById(ItemId); reorderLevelTextBox.Text = aItemViewModel.ReorderLevel.ToString(); availableQuantityTextBox.Text = aItemViewModel.Quantity.ToString(); }