internal void CSV_Load(string csv_Importpfad) { //Ließt Rippendaten aus DatabaseConnectionDataContext d = new DatabaseConnectionDataContext(); System.IO.DirectoryInfo csv_directory = new System.IO.DirectoryInfo(csv_Importpfad); var fpr = from x in d.Prüfung where x.fR == 0 && x.Prüfdatum > DateTime.Today - TimeSpan.FromDays(700) select x; foreach (System.IO.FileInfo f in csv_directory.GetFiles()) { if (f.Name.Contains(".csv")) { CSV_Reader csv_Reader = new CSV_Reader(f.FullName); foreach (Prüfung p in fpr) { if (p != null) { Prüfung np = csv_Reader.Read(p); if (np != null) { p.a1m = np.a1m; p.a2m = np.a2m; p.a3m = np.a3m; p.a4m = np.a4m; //10 Mittelwert p.a1_025 = np.a1_025; p.a2_025 = np.a2_025; p.a3_025 = np.a3_025; p.a4_025 = np.a4_025; //15 Mittelwert p.a1_075 = np.a1_075; p.a2_075 = np.a2_075; p.a3_075 = np.a3_075; p.a4_075 = np.a4_075; //20 Mittelwert p.c1 = np.c1; p.c2 = np.c2; p.c3 = np.c3; p.c4 = np.c4; //25 Mittelwert p.se1 = np.se1; p.se2 = np.se2; p.se3 = np.se3; p.se4 = np.se4; //30 Summe p.Beta = np.Beta; p.Alpha = np.Alpha; p.fR = np.fR; d.SubmitChanges(); } } } } } }
private void MakeChoice(Prüfung p) { DatabaseConnectionDataContext d = new DatabaseConnectionDataContext(); var nap = from x in d.Prüfung where x.Charge == p.Charge && Helper.DeleteLetter("S", Helper.DeleteLetter("U", x.Bundnummer)) == Helper.DeleteLetter("N", p.Bundnummer) select x; if (nap.Count() > 0) { Window n = new Nachprüfung_Frage_Window(nap.First(), p); n.Show(); } }
public Nachprüfung_Frage_Window(Prüfung p_old, Prüfung p_new) { InitializeComponent(); this.p_old = p_old; this.p_new = p_new; //Daten der neuen Prüfung textBox_Agt_New.Text = Convert.ToString(p_new.Agt); textBox_P_New.Text = Convert.ToString(p_new.Bundnummer); textBox_Re_New.Text = Convert.ToString(p_new.Re); textBox_Rm_New.Text = Convert.ToString(p_new.Rm); //Daten der alten Prüfung textBox_Agt_Old.Text = Convert.ToString(p_old.Agt); textBox_P_Old.Text = Convert.ToString(p_old.Bundnummer); textBox_Re_Old.Text = Convert.ToString(p_old.Re); textBox_Rm_Old.Text = Convert.ToString(p_old.Rm); }
internal Prüfung Read(Prüfung p) { if (p != null) { string n = Helper.DeleteLetter(Helper.DeleteLetter(Helper.DeleteLetter(Helper.DeleteLetter(Helper.DeleteLetter(p.Bundnummer, "-"), "U"), "N"), "F"), "S"); foreach (Prüfung item in p_List) { if (((Convert.ToDateTime(item.Prüfdatum).ToShortDateString()) == (Convert.ToDateTime(p.Prüfdatum).ToShortDateString())) && item.Charge == p.Charge && item.Bundnummer == n ) { return(item); } } } return(null); }
private Word.Document SetBookmarks_Ergebnis(Word.Document doc, Kunde kunde) { DatabaseConnectionDataContext d = new DatabaseConnectionDataContext(); var fpr = from x in d.Prüfung where x.Art == "Fremdprüfung" && x.Id_Kunde == kunde.Id && (x.Prüfdatum > d1 && x.Prüfdatum < d2) select x; if (fpr.Count() > 0) { Prüfung p = fpr.First(); SetValidBookmark(doc, "Kunde", kunde.Firma); SetValidBookmark(doc, "Wareneingang", Convert.ToDateTime(p.Wareneingangdatum).ToShortDateString()); SetValidBookmark(doc, "Lieferschein", Convert.ToDateTime(p.Lieferscheindatum).ToShortDateString()); SetValidBookmark(doc, "Bemerkungen", p.Bemerkungen); SetValidBookmark(doc, "Hersteller", p.Hersteller); SetValidBookmark(doc, "ChargenNr", Helper.DeleteLetter("F", p.Charge)); SetValidBookmark(doc, "Bundnummer", p.Bundnummer); SetValidBookmark(doc, "Durchmesser", p.Du.ToString()); SetValidBookmark(doc, "Re", p.Re.ToString()); SetValidBookmark(doc, "Rm", p.Rm.ToString()); SetValidBookmark(doc, "RmRe", p.RmRe.ToString()); SetValidBookmark(doc, "Agt", p.Agt.ToString()); SetValidBookmark(doc, "G", p.Dgs.ToString()); SetValidBookmark(doc, "fR", p.fR.ToString()); SetValidBookmark(doc, "Materialart", p.Materialart); SetValidBookmark(doc, "Verarbeitungsdatum", Convert.ToDateTime(p.Produktionsdatum).ToShortDateString()); SetValidBookmark(doc, "Maschine", p.Maschine); } else { MessageBox.Show("Keine gültige Prüfung gefunden!", "Fehler!"); } return(doc); }
private void FillFieldsWithPrüfung(int i) { button_prüfung_bearbeiten.IsEnabled = true; //Grid_Eingabe.IsEnabled = true; neu = false; DatabaseConnectionDataContext d = new DatabaseConnectionDataContext(); var pru = from p in d.Prüfung where p.Id == i select p; if (pru.Count() > 0) { p = pru.First(); datepicker_prüfung.SelectedDate = p.Prüfdatum.Value; datepicker_produktion.SelectedDate = p.Produktionsdatum.Value; //textBox_prüfer_a.Text = p.A.ToString(); textBox_prüfer_agt.Text = p.Agt.ToString(); textBox_prüfer_a1025.Text = p.a1_025.ToString(); textBox_prüfer_a2025.Text = p.a2_025.ToString(); textBox_prüfer_a3025.Text = p.a3_025.ToString(); textBox_prüfer_a4025.Text = p.a4_025.ToString(); textBox_prüfer_a1075.Text = p.a1_075.ToString(); textBox_prüfer_a2075.Text = p.a2_075.ToString(); textBox_prüfer_a3075.Text = p.a3_075.ToString(); textBox_prüfer_a4075.Text = p.a4_075.ToString(); textBox_prüfer_a1m.Text = p.a1m.ToString(); textBox_prüfer_a2m.Text = p.a2m.ToString(); textBox_prüfer_a3m.Text = p.a3m.ToString(); textBox_prüfer_a4m.Text = p.a4m.ToString(); textBox_prüfer_bundNr.Text = p.Bundnummer.ToString(); if (p.Charge != null) { textBox_prüfer_charge.Text = p.Charge.ToString(); } textBox_prüfer_du.Text = p.Du.ToString(); textBox_prüfer_fr.Text = p.fR.ToString(); textBox_prüfer_dgs.Text = p.Dgs.ToString(); textBox_prüfer_rm.Text = p.Rm.ToString(); textBox_prüfer_re.Text = p.Re.ToString(); textBox_prüfer_rmre.Text = p.RmRe.ToString(); textBox_prüfer_se1.Text = p.se1.ToString(); textBox_prüfer_se2.Text = p.se2.ToString(); textBox_prüfer_se3.Text = p.se3.ToString(); textBox_prüfer_se4.Text = p.se4.ToString(); textBox_prüfer_C1.Text = p.c1.ToString(); textBox_prüfer_C2.Text = p.c2.ToString(); textBox_prüfer_C3.Text = p.c3.ToString(); textBox_prüfer_C4.Text = p.c4.ToString(); textBox_prüfung_Alpha.Text = p.Alpha.ToString(); textBox_prüfung_Beta.Text = p.Beta.ToString(); //textBox_prüfung_c.Text = p.C.ToString(); //textBox_prüfung_AgtM.Text = p.AgtM.ToString(); textBox_P_Bemerkungen.Text = p.Bemerkungen; textBox_P_Hersteller.Text = p.Hersteller; textBox_P_Maschine.Text = p.Maschine; textBox_P_Materialart.Text = p.Materialart; } else { MessageBox.Show("Datensatz in Datenbank nicht gefunden!", "Fehler!"); } }
private void button_prüfung_speichern_Click(object sender, RoutedEventArgs e) { DatabaseConnectionDataContext d = new DatabaseConnectionDataContext(); int pid = ( from h in d.Prüfer where h.Name == (string)comboBox_prüfer.SelectedItem select new { h.Id } ).First().Id; if (neu) { p = new Prüfung() { Id_Prüfer = pid, Prüfdatum = datepicker_prüfung.SelectedDate, Produktionsdatum = datepicker_produktion.SelectedDate, Charge = textBox_prüfer_charge.Text, Bundnummer = textBox_prüfer_bundNr.Text, Du = TextboxToDouble(textBox_prüfer_du), Dgs = TextboxToDouble(textBox_prüfer_dgs), Re = TextboxToDouble(textBox_prüfer_re), Rm = TextboxToDouble(textBox_prüfer_rm), RmRe = TextboxToDouble(textBox_prüfer_rmre), //A = TextboxToDouble(textBox_prüfer_a), Agt = TextboxToDouble(textBox_prüfer_agt), fR = TextboxToDouble(textBox_prüfer_fr), Art = (string)comboBox_art.SelectedItem, se1 = TextboxToDouble(textBox_prüfer_se1), se2 = TextboxToDouble(textBox_prüfer_se2), se3 = TextboxToDouble(textBox_prüfer_se3), se4 = TextboxToDouble(textBox_prüfer_se4), a1m = TextboxToDouble(textBox_prüfer_a1m), a2m = TextboxToDouble(textBox_prüfer_a2m), a3m = TextboxToDouble(textBox_prüfer_a3m), a4m = TextboxToDouble(textBox_prüfer_a4m), a1_025 = TextboxToDouble(textBox_prüfer_a1025), a2_025 = TextboxToDouble(textBox_prüfer_a2025), a3_025 = TextboxToDouble(textBox_prüfer_a3025), a4_025 = TextboxToDouble(textBox_prüfer_a4025), a1_075 = TextboxToDouble(textBox_prüfer_a1075), a2_075 = TextboxToDouble(textBox_prüfer_a2075), a3_075 = TextboxToDouble(textBox_prüfer_a3075), a4_075 = TextboxToDouble(textBox_prüfer_a4075), c1 = TextboxToDouble(textBox_prüfer_C1), c2 = TextboxToDouble(textBox_prüfer_C2), c3 = TextboxToDouble(textBox_prüfer_C3), c4 = TextboxToDouble(textBox_prüfer_C4), Alpha = TextboxToDouble(textBox_prüfung_Alpha), Beta = TextboxToDouble(textBox_prüfung_Beta) //C = TextboxToDouble(textBox_prüfung_c), //AgtM = TextboxToDouble(textBox_prüfung_AgtM) , Maschine = textBox_P_Maschine.Text, Materialart = textBox_P_Materialart.Text, Hersteller = textBox_P_Hersteller.Text, Bemerkungen = textBox_P_Bemerkungen.Text }; d.Prüfung.InsertOnSubmit(p); } else { var pru = from i in d.Prüfung where i.Id == p_id select i; Prüfung p = pru.First(); p.Id_Prüfer = pid; p.Prüfdatum = datepicker_prüfung.SelectedDate; p.Produktionsdatum = datepicker_produktion.SelectedDate; p.Charge = textBox_prüfer_charge.Text; p.Bundnummer = textBox_prüfer_bundNr.Text; p.Du = TextboxToDouble(textBox_prüfer_du); p.Dgs = TextboxToDouble(textBox_prüfer_dgs); p.Re = TextboxToDouble(textBox_prüfer_re); p.Rm = TextboxToDouble(textBox_prüfer_rm); p.RmRe = TextboxToDouble(textBox_prüfer_rmre); //p.A = TextboxToDouble(textBox_prüfer_a); p.Agt = TextboxToDouble(textBox_prüfer_agt); p.fR = TextboxToDouble(textBox_prüfer_fr); p.Art = (string)comboBox_art.SelectedItem; p.se1 = TextboxToDouble(textBox_prüfer_se1); p.se2 = TextboxToDouble(textBox_prüfer_se2); p.se3 = TextboxToDouble(textBox_prüfer_se3); p.se4 = TextboxToDouble(textBox_prüfer_se4); p.a1m = TextboxToDouble(textBox_prüfer_a1m); p.a2m = TextboxToDouble(textBox_prüfer_a2m); p.a3m = TextboxToDouble(textBox_prüfer_a3m); p.a4m = TextboxToDouble(textBox_prüfer_a4m); p.a1_025 = TextboxToDouble(textBox_prüfer_a1025); p.a2_025 = TextboxToDouble(textBox_prüfer_a2025); p.a3_025 = TextboxToDouble(textBox_prüfer_a3025); p.a4_025 = TextboxToDouble(textBox_prüfer_a4025); p.a1_075 = TextboxToDouble(textBox_prüfer_a1075); p.a2_075 = TextboxToDouble(textBox_prüfer_a2075); p.a3_075 = TextboxToDouble(textBox_prüfer_a3075); p.a4_075 = TextboxToDouble(textBox_prüfer_a4075); p.c1 = TextboxToDouble(textBox_prüfer_C1); p.c2 = TextboxToDouble(textBox_prüfer_C2); p.c3 = TextboxToDouble(textBox_prüfer_C3); p.c4 = TextboxToDouble(textBox_prüfer_C4); p.Alpha = TextboxToDouble(textBox_prüfung_Alpha); p.Beta = TextboxToDouble(textBox_prüfung_Beta); //p.C = TextboxToDouble(textBox_prüfung_c); //p.AgtM = TextboxToDouble(textBox_prüfung_AgtM); p.Hersteller = textBox_P_Hersteller.Text; p.Materialart = textBox_P_Materialart.Text; p.Maschine = textBox_P_Maschine.Text; p.Bemerkungen = textBox_P_Bemerkungen.Text; } try { d.SubmitChanges(); } catch (Exception) { MessageBox.Show("Keine Verbindung zur Datenbank!", "Fehler!"); } Grid_Eingabe.IsEnabled = false; Grid_Kunde.IsEnabled = false; w.LoadDatagridData(); }
public CSV_Reader(string path) { this.path = path; using (TextFieldParser parser = new TextFieldParser(path)) { parser.TextFieldType = FieldType.Delimited; parser.SetDelimiters(";"); while (!parser.EndOfData) { //Processing row string[] fields = parser.ReadFields(); Prüfung p = new Prüfung(); try { //if (((DateTime.Parse(fields[0]).ToShortDateString()) == (Convert.ToDateTime(p.Produktionsdatum).ToShortDateString())) // && fields[1] == "WR" // && fields[2] == p.Charge // && fields[4] == p.Bundnummer // ) //{ p.Prüfdatum = DateTime.Parse(fields[0]); p.Charge = fields[2]; p.Bundnummer = fields[4]; //5 Durchmesser p.a1m = Convert.ToDouble(fields[6]); p.a2m = Convert.ToDouble(fields[7]); p.a3m = Convert.ToDouble(fields[8]); p.a4m = Convert.ToDouble(fields[9]); //10 Mittelwert p.a1_025 = Convert.ToDouble(fields[11]); p.a2_025 = Convert.ToDouble(fields[12]); p.a3_025 = Convert.ToDouble(fields[13]); p.a4_025 = Convert.ToDouble(fields[14]); //15 Mittelwert p.a1_075 = Convert.ToDouble(fields[16]); p.a2_075 = Convert.ToDouble(fields[17]); p.a3_075 = Convert.ToDouble(fields[18]); p.a4_075 = Convert.ToDouble(fields[19]); //20 Mittelwert p.c1 = Convert.ToDouble(fields[21]); p.c2 = Convert.ToDouble(fields[22]); p.c3 = Convert.ToDouble(fields[23]); p.c4 = Convert.ToDouble(fields[24]); //25 Mittelwert p.se1 = Convert.ToDouble(fields[26]); p.se2 = Convert.ToDouble(fields[27]); p.se3 = Convert.ToDouble(fields[28]); p.se4 = Convert.ToDouble(fields[29]); //30 Summe p.Beta = Convert.ToDouble(fields[36]); p.Alpha = Convert.ToDouble(fields[37]); p.fR = Convert.ToDouble(fields[38]); //} p_List.Add(p); } catch (Exception) { } } } }
private void ReadData() { DatabaseConnectionDataContext d = new DatabaseConnectionDataContext(); XmlNodeList nList = x.SelectNodes(n1); if (nList.Count > 1) { Prüfung p = new Prüfung(); if (n.Contains("U")) { p.Art = "Ungereckt"; } else if (n.Contains("S")) { p.Art = "Stab"; } else if (n.Contains("F")) { p.Art = "Fremdprüfung"; } else if (n.Contains("N")) { p.Art = "Nachprüfung"; } else { p.Art = "Standard"; } foreach (XmlNode xNode in nList) { string s = xNode[STRING_PARAMETER_TYPE].InnerText; switch (s) { case "600": //Bediener //p.Id_Prüfer = 8; //try //{ // d.SubmitChanges(); //} //catch (Exception) //{ //} ////Testet ob Prüfer in Datenbank vorhanden //try //{ // string b = xNode[STRING_VALUE].InnerText; // if (b.Length > 0) // { // var prf = from x in d.Prüfer // where x.Name == b // select x; // if (prf.Count() == 0) // { // d.Prüfer.InsertOnSubmit(new Prüfer { Name = b }); // try // { // d.SubmitChanges(); // } // catch (Exception) // { // } // } // } // try // { // int pfr = (from l in d.Prüfer // where l.Name == b // select l // ).First().Id; // if (pfr == 0) // { // pfr = 2; // } // p.Id_Prüfer = pfr; // d.SubmitChanges(); // } // catch (Exception) // { // p.Id_Prüfer = 2; // d.SubmitChanges(); // } //} //catch (Exception) //{ // MessageBox.Show("Kein Bediener in " + n + " gefunden!", "Achtung!"); //} break; case "601": //Kunde if (p.Art == "Fremdprüfung") { try { string q = xNode[STRING_VALUE].InnerText; var vku = from y in d.Kunde where y.Firma.Contains(q) select y; if (vku.Count() > 0) { p.Id_Kunde = vku.First().Id; } else { Kunde kunde = new Kunde() { Firma = q }; d.Kunde.InsertOnSubmit(kunde); } d.SubmitChanges(); } catch (Exception) { MessageBox.Show("Fremdprüfung: " + n + " konnte kein Kunde zugeordnet werden!", "Achtung!"); } } break; case "603": //LS Datum if (p.Art == "Fremdprüfung") { try { p.Lieferscheindatum = DateTime.Parse(xNode[STRING_VALUE].InnerText); } catch (Exception) { MessageBox.Show("Es konnte kein Lieferscheindatum in der XML-Datei: " + n + " gefunden werden!", "Fehler!"); } } break; case "604": //WE Datum if (p.Art == "Fremdprüfung") { try { p.Wareneingangdatum = DateTime.Parse(xNode[STRING_VALUE].InnerText); } catch (Exception) { MessageBox.Show("Es konnte kein Wareneingangdatum in der XML-Datei: " + n + " gefunden werden!", "Fehler!"); } } break; case "605": //Maschine if (p.Art == "Fremdprüfung") { try { p.Maschine = xNode[STRING_VALUE].InnerText; } catch (Exception) { } } break; case "607": //Prüfdatum try { p.Prüfdatum = DateTime.Parse(xNode[STRING_VALUE].InnerText); } catch (Exception) { MessageBox.Show("Es konnte kein Prüfdatum in der XML-Datei: " + n + " gefunden werden!", "Fehler!"); } break; case "596": //Produktionsdatum try { p.Produktionsdatum = DateTime.Parse(xNode[STRING_VALUE].InnerText); } catch (Exception) { MessageBox.Show("Es konnte kein Produktionsdatum in der XML-Datei: " + n + " gefunden werden!", "Fehler!"); } break; case "597": //Ring-Nr try { p.Bundnummer = xNode[STRING_VALUE].InnerText; } catch (Exception) { MessageBox.Show("Es konnte kein Bundnummer in der XML-Datei: " + n + " gefunden werden!", "Fehler!"); } break; case "533": //DGs p.Dgs = Parse_Double(n, xNode, STRING_VALUE, 0); break; case "9": //ChargenNr try { p.Charge = xNode[STRING_VALUE].InnerText; } catch (Exception) { MessageBox.Show("Es konnte kein ChargenNr in der XML-Datei: " + n + " gefunden werden!", "Fehler!"); } break; case "51": //Durchmesser p.Du = Parse_Double(n, xNode, STRING_VALUE, 2); break; case "318": //Agt p.Agt = Parse_Double(n, xNode, STRING_VALUE, 2); break; case "308": //Rm p.Rm = Parse_Double(n, xNode, STRING_VALUE, 0); break; case "257": //Rp p.Re = Parse_Double(n, xNode, STRING_VALUE, 0); break; default: break; } } //Berechnet Rm/Rp if (p.Rm != 0 && p.Re != 0) { p.RmRe = Math.Round(Convert.ToDouble(p.Rm / p.Re), 2); } p.fR = 0; p.Id_Prüfer = 8; //Speichert Daten in Datenbank d.Prüfung.InsertOnSubmit(p); try { d.SubmitChanges(); } catch (Exception) { MessageBox.Show("Keine Verbindung zur Datenbank!", "Fehler!"); } if (p.Art == "Nachprüfung") { MakeChoice(p); } } }