public void display_stocks_table() { stocks = new classes.Inventory_Stocks(); stocks_table = stocks.select_stocks_table(); dgvInventoryStocks.DataSource = stocks_table; dgvInventoryStocks.AutoGenerateColumns = false; if ((dgvInventoryStocks.Columns.Contains("get_stock") && dgvInventoryStocks.Columns["get_stock"].Visible) && (dgvInventoryStocks.Columns.Contains("add_stock") && dgvInventoryStocks.Columns["add_stock"].Visible)) { } else { DataGridViewButtonColumn get_stock = new DataGridViewButtonColumn(); { get_stock.Name = "get_stock"; get_stock.HeaderText = "Get Stock"; get_stock.Text = "Get Stock"; get_stock.UseColumnTextForButtonValue = true; this.dgvInventoryStocks.Columns.Add(get_stock); } DataGridViewButtonColumn add_stock = new DataGridViewButtonColumn(); { add_stock.Name = "add_stock"; add_stock.HeaderText = "Add Stock"; add_stock.Text = "Add Stock"; add_stock.UseColumnTextForButtonValue = true; this.dgvInventoryStocks.Columns.Add(add_stock); } } }
private void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtStocksWillGet.Text)) { MessageBox.Show("Please indicate how much stocks you will get.", "Get Item Stocks", MessageBoxButtons.OK, MessageBoxIcon.Error); txtStocksWillGet.Focus(); return; } else { int remaining_stocks = Convert.ToInt32(txtRemainingStocks.Text); int get_stocks = Convert.ToInt16(txtStocksWillGet.Text); if (get_stocks > remaining_stocks) { MessageBox.Show("Insufficient Stocks.", "Get Item Stocks", MessageBoxButtons.OK, MessageBoxIcon.Error); txtStocksWillGet.Text = ""; txtStocksWillGet.Focus(); return; } else { if (get_stocks < 1) { MessageBox.Show("The stocks you should get must be 1 and above.", "Get Item Stocks", MessageBoxButtons.OK, MessageBoxIcon.Error); txtStocksWillGet.Text = ""; txtStocksWillGet.Focus(); return; } else { remaining_stocks = remaining_stocks - get_stocks; stocks = new classes.Inventory_Stocks(); if (stocks.update_stock(inventory_id, remaining_stocks)) { MessageBox.Show("Success! The new stocks is " + remaining_stocks.ToString(), "Get Item Stocks", MessageBoxButtons.OK, MessageBoxIcon.Information); uc.frmDashboard.admin.inv.ucStocks.instance.display_stocks_chart(); uc.frmDashboard.admin.inv.ucStocks.instance.display_stocks_table(); this.Close(); } else { return; } } } } }
private void update_stocks() { stocks = new classes.Inventory_Stocks(); stocks.quantity = Convert.ToInt32(txtNewStock.Text); stocks.unit_of_measurement = cbUnit.Text; if (stocks.create_stocks()) { if (stocks.update_stock(productinformation_id)) { MessageBox.Show("Stocks has been updated!", "Update Stocks", MessageBoxButtons.OK, MessageBoxIcon.Question); frmViewItem.instance.display_selected_inventory(inventory_id); this.Close(); } } else { return; } }
public void display_stocks_chart() { stocks = new classes.Inventory_Stocks(); var result = stocks.select_stocks_chart(); high_stocks = result.Item1; critical_stocks = result.Item2; low_stocks = result.Item3; pieChartStocks.Series = new SeriesCollection { new PieSeries { Title = "High", Values = new ChartValues <int> { high_stocks }, DataLabels = true }, new PieSeries { Title = "Critical", Values = new ChartValues <int> { critical_stocks }, DataLabels = true }, new PieSeries { Title = "Low", Values = new ChartValues <int> { low_stocks }, DataLabels = true } }; pieChartStocks.LegendLocation = LegendLocation.Bottom; }
private void btnSave_Click(object sender, EventArgs e) { //MessageBox.Show(quantity.ToString() + " " + unit_of_measurement); classes.Inventory_Stocks stocks = new classes.Inventory_Stocks(); stocks.quantity = quantity; stocks.unit_of_measurement = unit_of_measurement; if (stocks.create_stocks()) { if (hasCapacity == true) { classes.Inventory_Capacity cp = new classes.Inventory_Capacity(); cp.capacity = capacity; cp.capacity_size = capacity_size; cp.create_capacity(); } classes.Inventory_ProductInformation pi = new classes.Inventory_ProductInformation(); pi.inventory_type = inventory_type; pi.item_name = item_name; pi.description = description; pi.brand = brand; pi.model = model; pi.serial_number = serial_number; pi.hasCapacity = hasCapacity; pi.expire_at = date_expired; if (pi.create_product_information()) { classes.Inventory inv = new classes.Inventory(); inv.category_id = category_id; inv.category_name = category_name; inv.supplier_id = supplier_id; inv.supplier_name = supplier_name; inv.property_number = property_number; inv.department_id = department_id; inv.department_name = department_name; inv.status = status; inv.date_acquired = date_acquired; if (inv.create_inventory()) { MessageBox.Show(item_name + " has been added", "Inventory", MessageBoxButtons.OK, MessageBoxIcon.Information); admin.inv.ucInventory.instance.display_inventory_data(); ((Form)this.TopLevelControl).Close(); } else { return; } } else { return; } } else { return; } }