private void Delit_Click(object sender, EventArgs e) { string query7 = " DELETE FROM workers where workerId ='" + woid + "' "; MySqlConnection databaseConnection7 = new MySqlConnection(connectionString); MySqlCommand commandDatabase7 = new MySqlCommand(query7, databaseConnection7); MySqlDataReader reader7; try { databaseConnection7.Open(); commandDatabase7.ExecuteReader(); MessageBox.Show("the worker has ben Delited"); this.Hide(); showworkers h1 = new showworkers(clientid1); h1.Show(); databaseConnection7.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); MessageBox.Show("Problem with Query"); } }
private void button3_Click(object sender, EventArgs e) { showworkers s1 = new showworkers(clientid1); s1.Show(); this.Hide(); }
private void update_Click(object sender, EventArgs e) { if (name.Text != "" || surname.Text != "" || email.Text != "" || username.Text != "" || password.Text != "") { string query10 = "select * from job where jobName ='" + jobbox.Text + "'"; string connectionString = "datasource=localhost;port=3306;username=root;password=;database=events;sslMode=none"; MySqlConnection databaseConnection10 = new MySqlConnection(connectionString); MySqlCommand commandDatabase = new MySqlCommand(query10, databaseConnection10); MySqlDataReader reader0; try { databaseConnection10.Open(); reader0 = commandDatabase.ExecuteReader(); if (reader0.HasRows) { while (reader0.Read()) { string m = reader0.GetString(0); jobid = m; } } else { MessageBox.Show("No results found!"); } databaseConnection10.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); MessageBox.Show("Problem with Query"); } string date = dob.Value.ToString("yyyy-MM-dd"); string query2 = "UPDATE workers SET name='" + name.Text + "',surname='" + surname.Text + "',dateOfBirth='" + date + "',email='" + email.Text + "',jobid=' " + jobid + "',username='******',password='******' where workerId = '" + woid + "'"; MySqlConnection databaseConnection2 = new MySqlConnection(connectionString); MySqlCommand commandDatabase2 = new MySqlCommand(query2, databaseConnection2); MySqlDataReader reader2; try { databaseConnection2.Open(); commandDatabase2.ExecuteReader(); MessageBox.Show("the worker was created"); this.Hide(); showworkers h1 = new showworkers(clientid1); h1.Show(); databaseConnection2.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); MessageBox.Show("Problem with Query"); } } else { MessageBox.Show("fill al inputs"); } }