private void dataGridView1_DoubleClick(object sender, EventArgs e) { Mitarbeiter_Profile M_Profile = new Mitarbeiter_Profile(); if (dataGridView1.SelectedRows.Count > 0) { //Load data from ddb table Mitarbeiter M_Profile.lblMID.Text = this.dataGridView1.CurrentRow.Cells[1].Value.ToString(); M_Profile.lblM_DNr.Text = this.dataGridView1.CurrentRow.Cells[2].Value.ToString(); this.Hide(); M_Profile.ShowDialog(); } }
public void Show_Profile() { if (dataGridView1.SelectedRows.Count > 0) { Mitarbeiter_Profile M_Profile = new Mitarbeiter_Profile(); //Load data from ddb table Mitarbeiter M_Profile.lblMID.Text = this.dataGridView1.CurrentRow.Cells[0].Value.ToString(); M_Profile.lblM_DNr.Text = this.dataGridView1.CurrentRow.Cells[1].Value.ToString(); this.Hide(); M_Profile.ShowDialog(); } }
private void btnLoschen_Click(object sender, EventArgs e) { string KID = this.lblMITID.Text; if (MessageBox.Show("Sind Sie sicher?", "Löschen", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { string Query = "delete from um_db.krankenstand where KID='" + KID + "' ;"; MySqlConnection conDataBase = new MySqlConnection(constring); MySqlCommand cmdDataBase = new MySqlCommand(Query, conDataBase); MySqlDataReader myReader; //Connection open conDataBase.Open(); myReader = cmdDataBase.ExecuteReader(); MessageBox.Show("Krankenstand erfolgreich gelöscht.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); while (myReader.Read()) { } //Refresh datagridview on form Mitarbeiter_Profile Mitarbeiter_Profile obj_mitarbeiter_profile = (Mitarbeiter_Profile)Application.OpenForms["Mitarbeiter_Profile"]; //Refresh datagridview on form Notizen obj_mitarbeiter_profile.dataGridView_Krank.Rows.Remove(obj_mitarbeiter_profile.dataGridView_Krank.CurrentRow); obj_mitarbeiter_profile.dataGridView_Krank.DataSource = null; obj_mitarbeiter_profile.load_table_Krankenstand(); obj_mitarbeiter_profile.dataGridView_Krank.Update(); obj_mitarbeiter_profile.dataGridView_Krank.Refresh(); //Close Connection conDataBase.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { this.Close(); } } }
private void btnSpeichern_Click(object sender, EventArgs e) { //Validating if (dateTimePicker_von.CustomFormat == " ") { this.dateTimePicker_von.Focus(); MessageBox.Show("Bitte alle Felder ausfüllen!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } ////Validating //else if (dateTimePicker_bis.CustomFormat == " ") //{ // this.dateTimePicker_bis.Focus(); // MessageBox.Show("Bitte alle Felder ausfüllen!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Warning); // return; //} ////Validating //else if (txtAnzahlTage.TextLength == 0) //{ // this.txtAnzahlTage.Focus(); // MessageBox.Show("Bitte Anzahl der Tage eingeben!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Warning); // return; //} else { //avoid integer null value if (txtAnzahlTage.TextLength == 0) { txtAnzahlTage.Text = "0"; } if (dateTimePicker_bis.CustomFormat == " ") { dateTimePicker_bis.CustomFormat = " "; } try { string Query = "update um_db.krankenstand set K_von='" + this.dateTimePicker_von.Text + "', K_bis='" + this.dateTimePicker_bis.Text + "', K_anzahl_tage='" + this.txtAnzahlTage.Text + "' where KID='" + this.lblMITID.Text + "' ;"; MySqlConnection conDataBase = new MySqlConnection(constring); MySqlCommand cmdDataBase = new MySqlCommand(Query, conDataBase); MySqlDataReader myReader; //Connection Open conDataBase.Open(); myReader = cmdDataBase.ExecuteReader(); MessageBox.Show("Krakenstand erfolgreich aktualisiert.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); while (myReader.Read()) { } //Refresh datagridview on form Mitarbeiter_Profile Mitarbeiter_Profile obj_mitarbeiter_profile = (Mitarbeiter_Profile)Application.OpenForms["Mitarbeiter_Profile"]; //Refresh datagridview on form Krankenstand obj_mitarbeiter_profile.dataGridView_Krank.Rows.Remove(obj_mitarbeiter_profile.dataGridView_Krank.CurrentRow); obj_mitarbeiter_profile.dataGridView_Krank.DataSource = null; obj_mitarbeiter_profile.load_table_Krankenstand(); obj_mitarbeiter_profile.dataGridView_Krank.Update(); obj_mitarbeiter_profile.dataGridView_Krank.Refresh(); //Close Connection conDataBase.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { this.Close(); } } }
//Add just krankendstand //Insert from Mitarbeiter_Profile public void Add_just_Krankendstand() { //Validating von if (dateTimePicker_von.CustomFormat == " ") { this.dateTimePicker_von.Focus(); MessageBox.Show("Bitte Arbeitstage von eingeben!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } ////Validating bis //else if (dateTimePicker_bis.CustomFormat == " ") //{ // //this.dateTimePicker_bis.Focus(); // //MessageBox.Show("Bitte alle Felder ausfüllen!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Warning); // //return; //} ////Validating anzahlTage //else if (txtAnzahlTage.TextLength == 0) //{ // txtAnzahlTage.Text = "0"; // //this.txtAnzahlTage.Focus(); // //MessageBox.Show("Bitte Anzahl der Tage eingeben!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Warning); // //return; //} else { //avoid integer null value if (txtAnzahlTage.TextLength == 0) { txtAnzahlTage.Text = "0"; } try { string Query = "insert into um_db.krankenstand (M_DNr,K_von,K_bis,K_anzahl_tage) values('" + txtDNNr.Text + "','" + this.dateTimePicker_von.Text + "','" + this.dateTimePicker_bis.Text + "','" + this.txtAnzahlTage.Text + "') ;"; MySqlConnection conDataBase = new MySqlConnection(constring); MySqlCommand cmdDataBase = new MySqlCommand(Query, conDataBase); MySqlDataReader myReader; //Connection Open conDataBase.Open(); myReader = cmdDataBase.ExecuteReader(); MessageBox.Show("Krakenstand erfolgreich geschpeichert.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); while (myReader.Read()) { } //Refresh datagridview on form Mitarbeiter_Profile Mitarbeiter_Profile obj_mitarbeiter_profile = (Mitarbeiter_Profile)Application.OpenForms["Mitarbeiter_Profile"]; //Refresh datagridview on form Krankenstand obj_mitarbeiter_profile.load_table_Krankenstand(); obj_mitarbeiter_profile.dataGridView_Krank.Update(); obj_mitarbeiter_profile.dataGridView_Krank.Refresh(); obj_mitarbeiter_profile.lblCheckRows.Visible = false; //Close Connection conDataBase.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { this.Close(); } } }
private void btnDNrSpeichern_Click(object sender, EventArgs e) { if (numeric_DNr.Text == "0") { MessageBox.Show("DNr muss mehr als 0 sein!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.numeric_DNr.Focus(); numeric_DNr.BackColor = Color.Tomato; return; } else if (numeric_DNr.Text == "") { MessageBox.Show("Bitte DNr eingeben.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.numeric_DNr.Focus(); numeric_DNr.BackColor = Color.Tomato; return; } //Check DNr on database START ************************** MySqlConnection myConn2 = new MySqlConnection(constring); MySqlCommand command = new MySqlCommand(constring, myConn2); command.CommandText = "SELECT M_DNr FROM um_db.mitarbeiter WHERE M_DNr = '" + this.numeric_DNr.Value + "'"; //Connection Open myConn2.Open(); MySqlDataReader Reader; Reader = command.ExecuteReader(); int count = 0; while (Reader.Read()) { count = count + 1; } //Connection Close Reader.Close(); myConn2.Close(); if (count > 1) { myConn2.Open(); Reader = command.ExecuteReader(); myConn2.Close(); MessageBox.Show("Doppelte DNr!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.numeric_DNr.Focus(); numeric_DNr.BackColor = Color.Tomato; return; } else if (count == 1) { MessageBox.Show("DNr existiert bereits!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.numeric_DNr.Focus(); numeric_DNr.BackColor = Color.Tomato; return; } //Check DNr on database END ************************** else if (this.txtBeschAls.TextLength == 0) { MessageBox.Show("Bitte (Beschäftigt als) ausfüllen.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.txtBeschAls.Focus(); txtBeschAls.BackColor = Color.Tomato; return; } else if (this.comboBox_lei.SelectedIndex == -1) { MessageBox.Show("Bitte (Beschäftigt bei) wählen.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.comboBox_lei.Focus(); comboBox_lei.BackColor = Color.Tomato; return; } else if (this.txtMS.TextLength == 0) { MessageBox.Show("Bitte (Monatliche Arbeitsstunden) ausfüllen.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.txtMS.Focus(); txtMS.BackColor = Color.Tomato; return; } else if (this.txtBrGehalt.TextLength == 0) { MessageBox.Show("Bitte (Brutto Gehalt) ausfüllen.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.txtBrGehalt.Focus(); txtBrGehalt.BackColor = Color.Tomato; return; } else { try //Update Mitarbeiter { string UpdateM_Query = "update um_db.mitarbeiter set M_DNr='" + this.numeric_DNr.Value + "', status='" + "aktiv" + "', M_Leiarbeiter='" + this.comboBox_lei.SelectedItem.ToString() + "', M_RegStunden='" + this.txtMS.Text + "', M_Besch_als='" + this.txtBeschAls.Text + "', M_Gehalt='" + this.txtBrGehalt.Text + "', M_Eintritt='" + this.einTritt.Text + "' where MITID='" + this.lblMITID.Text + "' ;"; MySqlConnection conDataBase = new MySqlConnection(constring); MySqlCommand cmdDataBase = new MySqlCommand(UpdateM_Query, conDataBase); MySqlDataReader myReader2; //Connection Open conDataBase.Open(); myReader2 = cmdDataBase.ExecuteReader(); MessageBox.Show("Bewerber wurde als Mitarbeiter geschpeichert.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); while (myReader2.Read()) { } //Create Mitarbeiter folder after DNr is created start try { // Create new folder in "C:\ volume or in this case our app Debug folder. Directory.CreateDirectory("MDoku" + "\\" + this.numeric_DNr.Value); // Create an already-existing directory (does nothing). Directory.CreateDirectory(@"MDoku" + "\\" + this.numeric_DNr.Value); //MessageBox.Show("Ordner erstellt!"); } catch (Win32Exception ex) { MessageBox.Show(ex.Message); } //Create Mitarbeiter folder after DNr is created end //Connection Close conDataBase.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { //Show Mitarbeiter Profile Mitarbeiter_Profile M_Profile = new Mitarbeiter_Profile(); M_Profile.lblMID.Text = this.lblMITID.Text; M_Profile.lblM_DNr.Text = this.numeric_DNr.Value.ToString(); this.Hide(); this.Dispose(); M_Profile.ShowDialog(); //Insert into nachrichten START ************************************************************** //Get date and time Now DateTime DateTimeNow = DateTime.Now; //Message String string NeueMitMsg = "Bewerber wurde als Mitarbeiter mit DNr (" + this.numeric_DNr.Value.ToString() + ") geschpeichert."; try { string Query_alsMit = "insert into um_db.nachrichten (msg,menu,datetime) values('" + NeueMitMsg + "','" + "Bewerber" + "','" + DateTimeNow + "');"; MySqlConnection conDataBase_alsMit = new MySqlConnection(constring); MySqlCommand cmdDataBase_alsMit = new MySqlCommand(Query_alsMit, conDataBase_alsMit); MySqlDataReader myReader_alsMit; //Open Connection conDataBase_alsMit.Open(); myReader_alsMit = cmdDataBase_alsMit.ExecuteReader(); while (myReader_alsMit.Read()) { } //Close Connection conDataBase_alsMit.Close(); } catch (Exception) { MessageBox.Show("Bewerber Als Mitatbeiter Speichern Fehler: in Nachrichten eingeben!"); } //Insert into nachrichten END ****************************************************************** } } }