private void button11_Click(object sender, EventArgs e) { medicines deletemed = new medicines(); deletemed.deleteMED(textBox12.Text); string query = "datasource=35.205.24.161;port=3306;username=m3dic;password=\"M3dic\""; MySqlConnection conDataBase = new MySqlConnection(query); MySqlCommand cmdDataBase = new MySqlCommand("select name as `product`, price ,mgf as `MGF`, expiry , description, manufacturer, quantity from M3dic.medicines", conDataBase); try { MySqlDataAdapter sda = new MySqlDataAdapter(); sda.SelectCommand = cmdDataBase; DataTable dbdataset = new DataTable(); sda.Fill(dbdataset); BindingSource bSorce = new BindingSource(); bSorce.DataSource = dbdataset; dataGridView3.DataSource = bSorce; sda.Update(dbdataset); } catch (Exception) { MessageBox.Show("Database error, please contact support", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } textBox12.Text = null; textBox15.Text = null; textBox19.Text = null; textBox13.Text = null; textBox16.Text = null; textBox20.Text = null; }
private void button1_Click(object sender, EventArgs e) { if (checkinput()) { medicines add = new medicines(); add.addmedicine(textBox1.Text, textBox2.Text, textBox3.Text, textBox4.Text, textBox5.Text, textBox6.Text, textBox7.Text); MessageBox.Show("Successfully added new medicine", "Medicine added", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Please fill all gaps!", "Invalid input", MessageBoxButtons.OK, MessageBoxIcon.Error); } }