private void button3_Click(object sender, EventArgs e) { if (txtFeiertag.TextLength == 0) { this.txtFeiertag.Focus(); MessageBox.Show("Bitte Feiertag eingeben!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { try { string Query = "update um_db.feiertage set FEID='" + this.txtFEID.Text + "',Monat='" + txtMonat.Text + "',von='" + this.dateTimePicker_von.Text + "',bis='" + this.dateTimePicker_bis.Text + "',Tag='" + this.txtTag.Text + "',Feiertag='" + this.txtFeiertag.Text + "',gesetzlich='" + gesetzlich + "',Jahr='" + this.txtJahr.Text + "' where FEID='" + this.txtFEID.Text + "' ;"; MySqlConnection conDataBase = new MySqlConnection(constring); MySqlCommand cmdDataBase = new MySqlCommand(Query, conDataBase); MySqlDataReader myReader; //Connection Open conDataBase.Open(); myReader = cmdDataBase.ExecuteReader(); MessageBox.Show("Die Daten wurden aktualisiert.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); while (myReader.Read()) { } //Refresh datagridview on form Urlaube obj_Feiertage.load_table(); obj_Feiertage.dataGridView1.Update(); obj_Feiertage.dataGridView1.Refresh(); obj_Feiertage.comboJahr.SelectedItem = currentYear; //Close Connection conDataBase.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { this.Close(); } } }
private void button2_Click(object sender, EventArgs e) { if (txtJahr.SelectedIndex == -1) { this.txtJahr.Focus(); MessageBox.Show("Bitte Jahr wählen!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else if (txtMonat.SelectedIndex == -1) { this.txtJahr.Focus(); MessageBox.Show("Bitte Monat wählen!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else if (txtTag.SelectedIndex == -1) { this.txtJahr.Focus(); MessageBox.Show("Bitte Tag wählen!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else if (txtFeiertag.TextLength == 0) { this.txtFeiertag.Focus(); MessageBox.Show("Bitte Feiertag eingeben!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { try { string Query = "insert into um_db.feiertage (Monat,von,bis,Tag,Feiertag,gesetzlich,Jahr) values('" + txtMonat.Text + "','" + this.dateTimePicker_von.Text + "','" + this.dateTimePicker_bis.Text + "','" + this.txtTag.Text + "','" + this.txtFeiertag.Text + "','" + gesetzlich + "','" + this.txtJahr.Text + "') ;"; MySqlConnection conDataBase = new MySqlConnection(constring); MySqlCommand cmdDataBase = new MySqlCommand(Query, conDataBase); MySqlDataReader myReader; //Open Connection conDataBase.Open(); myReader = cmdDataBase.ExecuteReader(); MessageBox.Show("Feiertag erfolgreich eingegeben.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); while (myReader.Read()) { } //Refresh datagridview on form Notizen obj_feiertage.load_table(); obj_feiertage.dataGridView1.Update(); obj_feiertage.dataGridView1.Refresh(); obj_feiertage.comboJahr.SelectedItem = currentYear; //Close Connection conDataBase.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { this.Close(); } } }