private void comboMonat_SelectedIndexChanged(object sender, EventArgs e) { Stundenliste std = (Stundenliste)Application.OpenForms["Stundenliste"]; //Convert Kontostand textbox to integer int intDNr; intDNr = Convert.ToInt32(std.comboDNr.SelectedItem.ToString()); intDNr = int.Parse(std.comboDNr.SelectedItem.ToString()); this.stundenliste_monatTableAdapter.Monat(this.um_db_DataSet.stundenliste_monat, intDNr, comboJahr.SelectedItem.ToString(), comboMonat.SelectedItem.ToString()); this.einstellungen_firmaTableAdapter.Fill(this.um_db_DataSet.einstellungen_firma); this.reportViewer1.RefreshReport(); }
private void button10_Click(object sender, EventArgs e) { var stundenliste = new Stundenliste(); stundenliste.ShowDialog(); }
private void studenlisteToolStripMenuItem_Click(object sender, EventArgs e) { var stundenliste = new Stundenliste(); stundenliste.ShowDialog(); }
private void btnSpeichern_Click(object sender, EventArgs e) { //Validating if (RegStd.TextLength == 0) { this.RegStd.Focus(); MessageBox.Show("Bitte reguläre Stunden eingeben!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else if (RegStd.Text == "0,00") { this.RegStd.Focus(); MessageBox.Show("Bitte reguläre Stunden eingeben!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { //First create Stunden konto create_stunden_konto(); //Now Year string Jahrr = DateTime.Now.Year.ToString(); //Check if A DNr exist in db Table Stundenliste_konto string DNrForKonto = this.comboDNr.SelectedItem.ToString(); //DateTime Now DateTime dateTime = DateTime.Now; DateTime nowTime = Convert.ToDateTime(dateTime); try //Insert stunden START { string Query2 = "insert into um_db.stundenliste_monat (DNr, Familienname, Vorname, Firma, Monat, Jahr, RegulareStunden, UberStunden, GesamtStunden, StundenDifferenz, Kommentar, Datum) values('" + this.comboDNr.SelectedItem.ToString() + "','" + this.txtNachname.Text + "','" + this.txtVorname.Text + "','" + this.comboFirma.SelectedItem.ToString() + "','" + this.comboMonat.SelectedItem.ToString() + "','" + this.comboJahr.SelectedItem.ToString() + "','" + this.RegStd.Text + "','" + this.UberStd.Text + "','" + this.GesStd.Text + "','" + this.txtStdDif.Text + "','" + this.txtKommentar.Text + "','" + this.dateTimeNow.Text + "') ;"; MySqlConnection conDataBase2 = new MySqlConnection(constring); MySqlCommand cmdDataBase2 = new MySqlCommand(Query2, conDataBase2); MySqlDataReader myReader2; //Connection Open conDataBase2.Open(); myReader2 = cmdDataBase2.ExecuteReader(); //Update Kontostand START*************************** try //Select Kontostand { string Query3 = "select * from um_db.stundenliste_konto where DNr='" + DNrForKonto + "' and Jahr='" + this.comboJahr.SelectedItem.ToString() + "';"; MySqlConnection conDataBase3 = new MySqlConnection(constring); MySqlCommand cmdDataBase3 = new MySqlCommand(Query3, conDataBase3); MySqlDataReader myReader3; //Open Connection conDataBase3.Open(); myReader3 = cmdDataBase3.ExecuteReader(); if (myReader3.HasRows == true) { while (myReader3.Read()) { string kontostand = myReader3.GetString("Kontostand"); //Convert kontostand to decimal decimal anIntegerkontostand; anIntegerkontostand = Convert.ToDecimal(kontostand); anIntegerkontostand = decimal.Parse(kontostand); //Convert txtStdDif to decimal decimal anIntegertxtStdDif; anIntegertxtStdDif = Convert.ToDecimal(txtStdDif.Text); anIntegertxtStdDif = decimal.Parse(txtStdDif.Text); decimal DecKontoStand = anIntegerkontostand + anIntegertxtStdDif; //for db string KontoStandCalculated = DecKontoStand.ToString(); try //Update kontostand { string Query = "update um_db.stundenliste_konto set Kontostand='" + KontoStandCalculated + "', Datum_Aktualisiert='" + nowTime + "', Jahr='" + this.comboJahr.SelectedItem.ToString() + "' where DNr='" + this.comboDNr.Text + "' and Jahr='" + this.comboJahr.SelectedItem.ToString() + "';"; MySqlConnection conDataBase = new MySqlConnection(constring); MySqlCommand cmdDataBase = new MySqlCommand(Query, conDataBase); MySqlDataReader myReader; conDataBase.Open(); myReader = cmdDataBase.ExecuteReader(); //MessageBox.Show("Kontostand Aktualisiert..", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); if (myReader.HasRows == true) { while (myReader.Read()) { } } conDataBase.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } //Close Connection conDataBase3.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); }//Update Kontostand END****************************** MessageBox.Show("Monatliche Stunden erfolgreich eingegeben.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); while (myReader2.Read()) { } //Refresh datagridview on Stundenliste Form Stundenliste std = (Stundenliste)Application.OpenForms["Stundenliste"]; std.getData_form_Load(); std.dataGridView1.Update(); std.dataGridView1.Refresh(); //Close Connection conDataBase2.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { this.Close(); }//Insert Stunden END } }