public int updateQuantity(MySqlConnection conn, Pesticides pesticides) { string query = "UPDATE pesticide SET pesticideQuantity = '" + pesticides.PesticideQuantity + "' " + "WHERE pesticideType = '" + pesticides.PesticideType + "'"; MySqlCommand sqlCmd = new MySqlCommand(query, conn); return(sqlCmd.ExecuteNonQuery()); }
public int addNewPesticide(MySqlConnection conn, Pesticides pesticides) { string addPesticideQuery = "INSERT INTO pesticide (pesticideType, pesticideQuantity, company)" + "VALUES ('" + pesticides.PesticideType + "', '" + pesticides.PesticideQuantity + "', '" + pesticides.Company + "')"; MySqlCommand sqlComm = new MySqlCommand(addPesticideQuery, conn); return(sqlComm.ExecuteNonQuery()); }
private void btnSaveUpd_Click(object sender, EventArgs e) { DBcon.connect(); Pesticides pes = new Pesticides(); pes.PesticideType = comboBoxUpdType.Text; pes.PesticideQuantity = Decimal.Parse(numericUpDownUpdateQ.Value.ToString()); PesticideHandler pesHandlr = new PesticideHandler(); pesHandlr.updateQuantity(DBcon.getConn(), pes); MessageBox.Show("Fertiliser added"); this.Hide(); }
private void btnSaveP_Click(object sender, EventArgs e) { DBcon.connect(); Pesticides pes = new Pesticides(); pes.PesticideType = comboBoxPesType.Text; pes.PesticideQuantity = Decimal.Parse(numericUpDownPesQauntity.Value.ToString()); pes.Company = textBoxPesComp.Text; PesticideHandler pesHandlr = new PesticideHandler(); pesHandlr.addNewPesticide(DBcon.getConn(), pes); MessageBox.Show("Fertiliser added"); this.Hide(); }