Exemplo n.º 1
0
        public int updateQuantity(MySqlConnection conn, Fertiliser fertiliser)
        {
            string query = "UPDATE fertiliser SET fertiliserQuantity = '" + fertiliser.FertiliserQuantity + "' " +
                           "WHERE fertiliserType = '" + fertiliser.FertiliserType + "'";

            MySqlCommand sqlCmd = new MySqlCommand(query, conn);

            return(sqlCmd.ExecuteNonQuery());
        }
Exemplo n.º 2
0
        public int addNewFertiliser(MySqlConnection conn, Fertiliser fertiliser)
        {
            string addFertiliserQuery = "INSERT INTO fertiliser (fertiliserType, fertiliserQuantity, fertiliserCompany)"
                                        + "VALUES ('" + fertiliser.FertiliserType + "', '" + fertiliser.FertiliserQuantity + "', '" + fertiliser.FertiliserCompany + "')";

            MySqlCommand sqlComm = new MySqlCommand(addFertiliserQuery, conn);

            return(sqlComm.ExecuteNonQuery());
        }
        private void btnSaveFerUp_Click(object sender, EventArgs e)
        {
            dbcon.connect();

            Fertiliser fert = new Fertiliser();

            fert.FertiliserType     = comboBoxUpdateFer.Text;
            fert.FertiliserQuantity = Decimal.Parse(numericUpDownUpdateQ.Value.ToString());

            FertiliserHandler ferHandlr = new FertiliserHandler();

            ferHandlr.updateQuantity(dbcon.getConn(), fert);

            MessageBox.Show("Fertiliser added");

            this.Hide();
        }
        private void btnSaveF_Click(object sender, EventArgs e)
        {
            dbcon.connect();
            Fertiliser fer = new Fertiliser();

            fer.FertiliserType     = comboBoxFerType.Text;
            fer.FertiliserQuantity = Decimal.Parse(numericUpDownFerQauntity.Value.ToString());
            fer.FertiliserCompany  = textBoxFerComp.Text;

            FertiliserHandler ferHandlr = new FertiliserHandler();

            ferHandlr.addNewFertiliser(dbcon.getConn(), fer);

            MessageBox.Show("Fertiliser added");

            this.Hide();
        }