示例#1
0
        private void btnAuszahlen_Click(object sender, EventArgs e)
        {
            //Convert Kontostand textbox to integer
            decimal Kontostand;

            Kontostand = Convert.ToDecimal(txtKontostand.Text);
            Kontostand = decimal.Parse(txtKontostand.Text);

            //Convert Kontostand textbox to integer
            decimal RegStdtoDecimal;

            RegStdtoDecimal = Convert.ToDecimal(AuszahlenStd.Text);
            RegStdtoDecimal = decimal.Parse(AuszahlenStd.Text);

            //AUsbezahlte stunden Calculated
            decimal ausbezahlteStd = Kontostand - RegStdtoDecimal;


            //Get date and time Now
            DateTime DateTimeNow = DateTime.Now;
            DateTime DateNow     = Convert.ToDateTime(DateTimeNow);

            //Show MessageBox
            var myMessageBox = new MyMessageBox();

            myMessageBox.btnJa.Text   = "Ja";
            myMessageBox.btnNein.Text = "Nein";
            myMessageBox.Text         = "Wichtige Hinweis:";
            myMessageBox.txtText.Text = "\n   Sind Sie sicher " + (AuszahlenStd.Text) + " Stunden auszuzahlen?";
            DialogResult result = myMessageBox.ShowDialog();

            //If MessageBox "OK" Clicked
            if (result == DialogResult.OK)
            {
                try
                {
                    string          Query       = "update um_db.stundenliste_konto set Kontostand='" + ausbezahlteStd.ToString() + "', Datum_Aktualisiert='" + DateNow.ToString() + "' where DNr='" + this.txtDNr.Text + "' and Jahr='" + comboJahr.SelectedItem.ToString() + "';";
                    MySqlConnection conDataBase = new MySqlConnection(constring);
                    MySqlCommand    cmdDataBase = new MySqlCommand(Query, conDataBase);
                    MySqlDataReader myReader;

                    //Connection Open
                    conDataBase.Open();

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

                    txtKontostand.Text   = ausbezahlteStd.ToString();
                    txtAktualisiert.Text = DateNow.ToString();
                    AuszahlenStd.Text    = "0,00";

                    //Close Connection
                    conDataBase.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
示例#2
0
        //****************search datagridview for existing row END***********************

        //Check Termine from Databse Function START***************************************************
        public void show_Termin()
        {
            try
            {
                //Get Stopped time from txtTime textbox
                string nowTime_Stopped = txtTime.Text;

                //Select "Start" rows in database.table "events"
                string          Query            = "select * from um_db.events where Start='" + nowTime_Stopped + "' ;";
                MySqlConnection Main_conDataBase = new MySqlConnection(constring);
                MySqlCommand    cmdDataBase      = new MySqlCommand(Query, Main_conDataBase);
                MySqlDataReader myReader;
                //Open Connection
                Main_conDataBase.Open();
                myReader = cmdDataBase.ExecuteReader();
                myReader.Read();

                //get Start row from Database
                string sEID    = myReader.GetString("EID");
                string sTitel  = myReader.GetString("Titel");
                string sStart2 = myReader.GetString("Start");
                string sEnde   = myReader.GetString("Ende");
                string sOrt    = myReader.GetString("Ort");
                string sText   = myReader.GetString("Text");

                //Get Count Status Rows for this Termin ***** START ************************************
                string          Query4       = "select count(Status) from um_db.events where Status='" + "Laufend" + "';";
                MySqlConnection conDataBase4 = new MySqlConnection(constring);
                MySqlCommand    cmdDataBase4 = new MySqlCommand(Query4, conDataBase4);
                conDataBase4.Open();

                int GesehenRows = 0;
                GesehenRows = int.Parse(cmdDataBase4.ExecuteScalar().ToString());
                conDataBase4.Close();
                //Get Count Status Rows for this Termin ***** END ***************************************

                //Show Termin Notification START**************
                //Show Home Notifyicon1 in Taskbar
                Home obj_Home = (Home)Application.OpenForms["Home"];
                //NotifyIcon balloon
                obj_Home.notifyIcon1.Visible        = true;
                obj_Home.notifyIcon1.BalloonTipText = "Sie haben eine neue Termin.";
                obj_Home.notifyIcon1.ShowBalloonTip(500);

                //Show Termin MessageBox
                var myMessageBox = new MyMessageBox();
                myMessageBox.Text         = "Termin Notifikation:";
                myMessageBox.txtText.Text = sTitel + "\n\nPlus (" + GesehenRows + ") laufende Termnine";

                DialogResult result = myMessageBox.ShowDialog();
                //Show Termin Notification END******************

                //If MessageBox "OK" Clicked
                if (result == DialogResult.OK)
                {
                    //Set string for "Status" = Yes row in the table events
                    string t_erledigt = "Termin erledigt";

                    try     //Update edata Table, set Status row to Yes ***** START *****
                    {
                        string          Query2       = "update um_db.events set Status='" + t_erledigt + "' where EID='" + sEID + "' ;";
                        MySqlConnection conDataBase2 = new MySqlConnection(constring);
                        MySqlCommand    cmdDataBase2 = new MySqlCommand(Query2, conDataBase2);
                        MySqlDataReader myReader2;

                        //Connection Open
                        conDataBase2.Open();

                        myReader2 = cmdDataBase2.ExecuteReader();

                        //Refresh datagridView
                        load_table_events();

                        //Open TerminView
                        Termine_View termine_view = new Termine_View();

                        //Load data from datagridview to form Feiertage_Update
                        termine_view.txtEID.Text = sEID;

                        termine_view.txtTitel.Text = sTitel;

                        termine_view.date1.Text = sStart2;

                        termine_view.date2.Text = sEnde;

                        termine_view.txtOrt.Text = sOrt;

                        termine_view.richTextBox1.Text = sText;

                        termine_view.lblStatus.Text = "Termin erledigt.";

                        //Disable buttons
                        if (termine_view.btnErledigt != null)
                        {
                            termine_view.btnErledigt.Enabled = false;
                        }
                        if (termine_view.btnVerpasst != null)
                        {
                            termine_view.btnVerpasst.Enabled = false;
                        }
                        if (termine_view.btnLaufend != null)
                        {
                            termine_view.btnLaufend.Enabled = false;
                        }
                        //SHow form
                        termine_view.ShowDialog();

                        //Close Connection
                        conDataBase2.Close();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }    //Update events Table, set Status row to Yes ***** END *****

                    //Start timer1 again for other Termine
                    timer1.Enabled = true;
                    timer1.Start();
                }
                //If MessageBox "Nein" Clicked
                else if (result == DialogResult.Cancel)
                {
                    //Set string for "Verpasst" = Status row in the table events
                    string Verpasst = "Termin verpasst";
                    try     //Update events Table, set Verpasst row to Verpasst ***** START *****
                    {
                        string          Query2       = "update um_db.events set Status='" + Verpasst + "' where EID='" + sEID + "' ;";
                        MySqlConnection conDataBase2 = new MySqlConnection(constring);
                        MySqlCommand    cmdDataBase2 = new MySqlCommand(Query2, conDataBase2);
                        MySqlDataReader myReader2;

                        //Connection Open
                        conDataBase2.Open();

                        myReader2 = cmdDataBase2.ExecuteReader();

                        //Refresh datagridView
                        load_table_events();

                        //Close Connection
                        conDataBase2.Close();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                    //Update events Table, set Status row to Verpasst ***** END *****

                    //Show messagebox that these event has been ignored and updated to "Verpasst"
                    DialogResult result2 = MessageBox.Show("Sie haben den Termin Ignoriert!", "Wichtige Information:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    if (result == DialogResult.OK)
                    {
                        this.Close();
                    }

                    //Start timer1 again for other Termine
                    timer1.Enabled = true;
                    timer1.Start();
                }

                //Close Connection
                Main_conDataBase.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }//Check Termine from Database Function END*******************************