Exemplo n.º 1
0
        //button Speichern Update Urlaube
        private void button2_Click(object sender, EventArgs e)
        {
            //Validating
            if (txtAnzahlTage.TextLength == 0)
            {
                this.txtAnzahlTage.Focus();
                MessageBox.Show("Bitte Anzahl der Tage eingeben!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            else
            {
                try
                {
                    string          Query       = "update um_db.urlaube set Type='" + UrlaubTypeUpdate + "', Arbeitstage_von='" + this.dateTimePicker_von.Text + "', Arbeitstage_bis='" + this.dateTimePicker_bis.Text + "', Anzahl_Tage='" + this.txtAnzahlTage.Text + "', M_Vorname='" + this.txtVorname.Text + "', M_Nachname='" + this.txtNachname.Text + "', DN_Nr='" + this.txtDNNr.Text + "' where URLID='" + this.txtURLID.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
                    u_urlaubee.load_table();
                    u_urlaubee.dataGridView1.Update();
                    u_urlaubee.dataGridView1.Refresh();

                    //Close Connection
                    conDataBase.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    this.Close();
                }
            }
        }
Exemplo n.º 2
0
        public void Add_just_Urlaub()
        {
            //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
            {
                try //Insert Urlaub to db START
                {
                    string          Query       = "insert into um_db.urlaube (Type,Arbeitstage_von,Arbeitstage_bis,Anzahl_Tage,M_Vorname,M_Nachname,DN_Nr) values('" + UrlaubTypeInsert + "','" + this.dateTimePicker_von.Text + "','" + this.dateTimePicker_bis.Text + "','" + this.txtAnzahlTage.Text + "','" + this.txtVorname.Text + "','" + this.txtNachname.Text + "','" + this.comboDNr.SelectedItem.ToString() + "') ;";
                    MySqlConnection conDataBase = new MySqlConnection(constring);
                    MySqlCommand    cmdDataBase = new MySqlCommand(Query, conDataBase);
                    MySqlDataReader myReader;

                    //Connection Open
                    conDataBase.Open();

                    myReader = cmdDataBase.ExecuteReader();
                    MessageBox.Show("Urlaub erfolgreich eingegeben.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    while (myReader.Read())
                    {
                    }

                    //To avoid error in Mitarbeiterstatus add Urlaub
                    if (btnSpeichern.Text == "   Speichern")
                    {
                        //Open form Urlaube
                        Urlaube obj_urlaube = (Urlaube)Application.OpenForms["Urlaube"];
                        //Refresh datagridview on form Urlaube
                        obj_urlaube.load_table();
                        obj_urlaube.dataGridView1.Update();
                        obj_urlaube.dataGridView1.Refresh();
                    }

                    //Close Connection
                    conDataBase.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    this.Close();
                } //Insert Urlaub to db END
            }
        }