private void itemsComboBox_SelectedIndexChanged(object sender, EventArgs e) { try { if (itemsComboBox.SelectedIndex > 0) { item.Id = Convert.ToInt32(itemsComboBox.SelectedValue); reorderLeveTextBox.Text = _itemManager.GetItemReorderLevel(item).ToString(); int stockInQuantity = Convert.ToInt32(_stockInManager.GetItemAvailableQuantity(item.Id)); int stockOutQuantity = Convert.ToInt32(_stockOutManager.GetItemStockOutQuantity(item.Id)); int availableQuantity = stockInQuantity - stockOutQuantity; availableQuantityTextBox.Text = availableQuantity.ToString(); reorderLevelMessageLabel.Text = ""; } else { reorderLeveTextBox.Clear(); availableQuantityTextBox.Clear(); reorderLevelMessageLabel.Text = ""; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void SearchButton_Click(object sender, EventArgs e) { try { if (companiesComboBox.SelectedIndex <= 0 && categoriesComboBox.SelectedIndex <= 0) { MessageBox.Show("Please select your search criteria!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (companiesComboBox.SelectedIndex > 0 && categoriesComboBox.SelectedIndex > 0) { List <Item> items = new List <Item>(); int companyId = Convert.ToInt32(companiesComboBox.SelectedValue); int categoryId = Convert.ToInt32(categoriesComboBox.SelectedValue); var itemList = _itemManager.GetItems().Where(c => c.CompanyId == companyId && c.CategoryId == categoryId).ToList(); foreach (var data in itemList) { Item item = new Item(); int stockInQuantity = 0; int stockOutQuantity = 0; stockInQuantity += _stockInManager.GetItemAvailableQuantity(data.Id); stockOutQuantity += _stockOutManager.GetItemStockOutQuantity(data.Id); item.Id = data.Id; item.ItemName = data.ItemName; item.CompanyName = data.CompanyName; item.CategoryName = data.CategoryName; item.ReorderLevel = data.ReorderLevel; item.AvailableQuantity = stockInQuantity - stockOutQuantity; items.Add(item); } BindItemsGridView(items); return; } if (companiesComboBox.SelectedIndex > 0) { int companyId = Convert.ToInt32(companiesComboBox.SelectedValue); var itemList = _itemManager.GetItems().Where(c => c.CompanyId == companyId).ToList(); List <Item> items = new List <Item>(); foreach (var data in itemList) { Item item = new Item(); int stockInQuantity = 0; int stockOutQuantity = 0; stockInQuantity += _stockInManager.GetItemAvailableQuantity(data.Id); stockOutQuantity += _stockOutManager.GetItemStockOutQuantity(data.Id); item.Id = data.Id; item.ItemName = data.ItemName; item.CompanyName = data.CompanyName; item.CategoryName = data.CategoryName; item.ReorderLevel = data.ReorderLevel; item.AvailableQuantity = stockInQuantity - stockOutQuantity; items.Add(item); } BindItemsGridView(items); return; } if (categoriesComboBox.SelectedIndex > 0) { int categoryId = Convert.ToInt32(categoriesComboBox.SelectedValue); var itemList = _itemManager.GetItems().Where(c => c.CategoryId == categoryId).ToList(); List <Item> items = new List <Item>(); foreach (var data in itemList) { Item item = new Item(); int stockInQuantity = 0; int stockOutQuantity = 0; stockInQuantity += _stockInManager.GetItemAvailableQuantity(data.Id); stockOutQuantity += _stockOutManager.GetItemStockOutQuantity(data.Id); item.Id = data.Id; item.ItemName = data.ItemName; item.CompanyName = data.CompanyName; item.CategoryName = data.CategoryName; item.ReorderLevel = data.ReorderLevel; item.AvailableQuantity = stockInQuantity - stockOutQuantity; items.Add(item); } BindItemsGridView(items); return; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void itemNameComboBox_SelectedIndexChanged(object sender, EventArgs e) { try { ComboBox cmb = (ComboBox)sender; int selectedIndex = cmb.SelectedIndex; int selectedValue = (int)cmb.SelectedValue; string itemId = String.Format("{0}", selectedValue); stockinModel.ItemId = Convert.ToInt32(itemId); int itemID = Convert.ToInt32(itemNameComboBox.SelectedValue); int reOrderLavel = _stockInManagers.ReOrderLavel(stockinModel); reorderLavelTextBox.Text = reOrderLavel.ToString(); int avaiLavelQty = _stockInManagers.GetItemAvailableQuantity(itemID) - _stockOutManager.GetItemStockOutQuantity(itemID); availableQtyTextBox.Text = avaiLavelQty.ToString(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }