示例#1
0
        private void btnStatus_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count > 0)
            {
                var M_Status = new Mitarbeiter_Status();

                //Load data from datagridview from this
                M_Status.txtM_DNr.Text = this.dataGridView1.CurrentRow.Cells[1].Value.ToString();

                M_Status.ShowDialog();
            }
        }
        //Add krankenstand and update mitarbeiter_status
        //Insert from Mitarbeiter_Status
        private void Add_Krankendstand_and_MitStatus()
        {
            //Insert Krankenstand START**********************
            //Validating
            if (dateTimePicker_von.CustomFormat == " ")
            {
                this.dateTimePicker_von.Focus();
                MessageBox.Show("Bitte Arbeitstage von eingebenn!", "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
            {
                if (txtAnzahlTage.TextLength == 0)
                {
                    txtAnzahlTage.Text = "0";
                    //this.txtAnzahlTage.Focus();
                    //MessageBox.Show("Bitte Anzahl der Tage eingeben!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    //return;
                }

                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())
                    {
                    }

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

                try //Update Mitarbeiter status START**********************
                {
                    string          Query       = "update um_db.mitarbeiter set status='" + "krank" + "' where M_DNr='" + this.txtDNNr.Text + "' ;";
                    MySqlConnection conDataBase = new MySqlConnection(constring);
                    MySqlCommand    cmdDataBase = new MySqlCommand(Query, conDataBase);
                    MySqlDataReader myReader;

                    //Connection Open
                    conDataBase.Open();

                    myReader = cmdDataBase.ExecuteReader();
                    MessageBox.Show("Mitarbeiter wurde als Krank geschpeichert.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    while (myReader.Read())
                    {
                    }

                    //Open form Mitarbeiter
                    Mitarbeiter obj_mitarbeiter = (Mitarbeiter)Application.OpenForms["Mitarbeiter"];
                    //Refresh datagridview on form Mitarbeiter
                    obj_mitarbeiter.load_table();
                    obj_mitarbeiter.dataGridView1.Update();
                    obj_mitarbeiter.dataGridView1.Refresh();

                    //Close Connection
                    conDataBase.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    this.Close();
                    //Close Form Mitarbeiter_Status
                    Mitarbeiter_Status obj_mitarbeiter_Status = (Mitarbeiter_Status)Application.OpenForms["Mitarbeiter_Status"];
                    obj_mitarbeiter_Status.Close();
                }
                //Update Mitarbeiter status END**********************
            }
        }
示例#3
0
        public void Add_Urlabe_and_MitStatus()
        {
            //Insert Urlaub to db START******************
            //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
                {
                    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.Text + "') ;";
                    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())
                    {
                    }

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

            try //Change mitarbeiter status START******************
            {
                //Set Mitarbeiter status as Urlaub
                string          Query_status       = "update um_db.mitarbeiter set status='" + "urlaub" + "' where M_DNr='" + this.comboDNr.SelectedItem.ToString() + "';";
                MySqlConnection conDataBase_status = new MySqlConnection(constring);
                MySqlCommand    cmdDataBase_status = new MySqlCommand(Query_status, conDataBase_status);
                MySqlDataReader myReader_status;

                //Connection Open
                conDataBase_status.Open();
                myReader_status = cmdDataBase_status.ExecuteReader();
                MessageBox.Show("Mitarbeiter wurde als in Urlaub geschpeichert.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                while (myReader_status.Read())
                {
                }

                //Open form Mitarbeiter
                Mitarbeiter obj_mitarbeiter = (Mitarbeiter)Application.OpenForms["Mitarbeiter"];
                //Refresh datagridview on form Urlaube
                obj_mitarbeiter.load_table();
                obj_mitarbeiter.dataGridView1.Update();
                obj_mitarbeiter.dataGridView1.Refresh();

                //Close Connection
                conDataBase_status.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                this.Close();
                //Close Form Mitarbeiter_Status
                Mitarbeiter_Status obj_mitarbeiter_Status = (Mitarbeiter_Status)Application.OpenForms["Mitarbeiter_Status"];
                obj_mitarbeiter_Status.Close();
            } //Change mitarbeiter status END******************
        }