//Show Termine_View FOrm private void dataGridView1_DoubleClick(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count > 0) { Termine_View termine_view = new Termine_View(); //Load data from datagridview to form Feiertage_Update termine_view.txtEID.Text = this.dataGridView1.CurrentRow.Cells[0].Value.ToString(); termine_view.txtTitel.Text = this.dataGridView1.CurrentRow.Cells[1].Value.ToString(); termine_view.date1.Text = this.dataGridView1.CurrentRow.Cells[2].Value.ToString(); termine_view.date2.Text = this.dataGridView1.CurrentRow.Cells[3].Value.ToString(); termine_view.txtOrt.Text = this.dataGridView1.CurrentRow.Cells[4].Value.ToString(); termine_view.richTextBox1.Text = this.dataGridView1.CurrentRow.Cells[5].Value.ToString(); termine_view.lblStatus.Text = this.dataGridView1.CurrentRow.Cells[6].Value.ToString(); termine_view.ShowDialog(); } }
//****************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*******************************