private void buttonInventoryAdd_Click(object sender, EventArgs e) { UIConfirmation confirmation = new UIConfirmation(); confirmation.ShowDialog(); if (confirmation.isConfirmed) { confirmation.Close(); //INSERT into inventory values = "\"" + textInventoryCategory.Text + "\"" + ", \"" + textInventoryItem.Text + "\", " + textInventoryCost.Text + ", " + textInventoryPrice.Text + ", " + textInventoryQty.Text; log.RunQuery(3, "Inventory", "category, itemName, costPerUnitBought, pricePerUnitSold, quantity", "", values); ViewInventory(); viewNotifications(); MySqlConnection sqlConn = new MySqlConnection("datasource=35.198.212.34;port=3306;username=root;password=;database=dp2;sslmode=none"); MySqlCommand callEvent = new MySqlCommand("call update_allRateOfSales();", sqlConn); sqlConn.Open(); callEvent.ExecuteScalar(); callEvent = new MySqlCommand("call update_allDaysUntilDepletion();", sqlConn); callEvent.ExecuteScalar(); callEvent = new MySqlCommand("call update_allDateToOrder();", sqlConn); callEvent.ExecuteScalar(); sqlConn.Close(); //set cursor focus to category upon adding item AND clear text boxes textInventoryItem.Clear(); textInventoryCost.Clear(); textInventoryPrice.Clear(); textInventoryQty.Clear(); textInventoryItem.Focus(); } else { confirmation.Close(); } }
private void buttonInventoryDelete_Click(object sender, EventArgs e) { UIConfirmation confirmation = new UIConfirmation("Are you sure?", "Yes", "Cancel"); confirmation.ShowDialog(); if (confirmation.isConfirmed) { //DELETE ROW foreach (DataGridViewCell oneCell in dataGridInventory.SelectedCells) { if (oneCell.Selected) { int rowIndex = oneCell.RowIndex; selectedRow = dataGridInventory.Rows[rowIndex].Cells[0].Value.ToString(); log.RunQuery(2, "Inventory ", "", "itemID=" + "\'" + selectedRow + "\'", ""); ViewInventory(); } } } }