Userfehler eingaben abgefangen

Beim erstellen von neue Projekte wird auf usereingaben geachtet
This commit is contained in:
HuskyTeufel
2022-03-25 11:36:56 +01:00
parent 097274303b
commit dea733183e
6 changed files with 44 additions and 10 deletions

View File

@@ -62,6 +62,7 @@
this.txt_pro_nr.Name = "txt_pro_nr"; this.txt_pro_nr.Name = "txt_pro_nr";
this.txt_pro_nr.Size = new System.Drawing.Size(250, 26); this.txt_pro_nr.Size = new System.Drawing.Size(250, 26);
this.txt_pro_nr.TabIndex = 3; this.txt_pro_nr.TabIndex = 3;
this.txt_pro_nr.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txt_pro_nr_KeyPress);
// //
// txt_ort // txt_ort
// //
@@ -81,7 +82,7 @@
this.btn_save.UseVisualStyleBackColor = true; this.btn_save.UseVisualStyleBackColor = true;
this.btn_save.Click += new System.EventHandler(this.btn_save_Click); this.btn_save.Click += new System.EventHandler(this.btn_save_Click);
// //
// FrmNewProjekt // frmNewProjekt
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
@@ -91,8 +92,8 @@
this.Controls.Add(this.txt_pro_nr); this.Controls.Add(this.txt_pro_nr);
this.Controls.Add(this.label2); this.Controls.Add(this.label2);
this.Controls.Add(this.label1); this.Controls.Add(this.label1);
this.Name = "FrmNewProjekt"; this.Name = "frmNewProjekt";
this.Text = "FrmNewProjekt"; this.Text = "Neues Projekt hinzufügen";
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();

View File

@@ -1,4 +1,5 @@
using KlassenBIB; using Database;
using KlassenBIB;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@@ -24,8 +25,18 @@ namespace SanSystem
InitializeComponent(); InitializeComponent();
} }
private bool project_already_excist(string projektnummer)
{
return Datenbank.Instance.TeufelDB.Projekte.FindAll(x => x.Nummer.Equals(projektnummer)).Count > 0;
}
private void btn_save_Click(object sender, EventArgs e) private void btn_save_Click(object sender, EventArgs e)
{ {
if(project_already_excist(txt_pro_nr.Text))
{
MessageBox.Show(string.Format("Projekt mit den nummer {0} excistiert bereits. Projekt wird nicht angelegt", txt_pro_nr.Text));
return;
}
Projekt projekt = new Projekt(); Projekt projekt = new Projekt();
projekt.Nummer = txt_pro_nr.Text; projekt.Nummer = txt_pro_nr.Text;
projekt.Ort = txt_ort.Text; projekt.Ort = txt_ort.Text;
@@ -33,5 +44,15 @@ namespace SanSystem
this.Close(); this.Close();
//Global.Instance.ChangeProjekt(txt_pro_nr.Text); //Global.Instance.ChangeProjekt(txt_pro_nr.Text);
} }
private void txt_pro_nr_KeyPress(object sender, KeyPressEventArgs e)
{
if(e.KeyChar == '/' || e.KeyChar == '\\')
{
e.Handled = true;
MessageBox.Show("Es sind keine Zeichen wie '/' oder '\\' erlaubt ");
txt_pro_nr.Focus();
}
}
} }
} }

View File

@@ -32,10 +32,19 @@ namespace SanSystem
private void btn_gen_Click(object sender, EventArgs e) private void btn_gen_Click(object sender, EventArgs e)
{ {
MassenStatistik massenStatistik = null; MassenStatistik massenStatistik = null;
List<Inspektionsobjekt> objekte;
if (inspektionsobjekts == null) if (inspektionsobjekts == null)
massenStatistik = new MassenStatistik(Datenbank.Instance.loadedProjekt.Objekte, dt_targetDatum.Value); objekte = Datenbank.Instance.loadedProjekt.Objekte;
else else
massenStatistik = new MassenStatistik(inspektionsobjekts, dt_targetDatum.Value); objekte = inspektionsobjekts;
if(objekte.Count < 1)
{
MessageBox.Show("Es wurde keine Objekte gefunden. Funktion wird abgebrochen");
this.Close();
return;
}
massenStatistik = new MassenStatistik(objekte, dt_targetDatum.Value);
} }
} }

View File

@@ -22,8 +22,10 @@ namespace SanSystem
this.inspektionsobjekts = inspektionsobjekts; this.inspektionsobjekts = inspektionsobjekts;
targetDatum = datum; targetDatum = datum;
List<Inspektionsobjekt> objekte = SearchForWaranties();
BuildBericht(SearchForWaranties()); if (objekte.Count < 1)
return;
BuildBericht(objekte);
} }
static string ConvertToDecimals(double input, uint kommazahl = 2) static string ConvertToDecimals(double input, uint kommazahl = 2)
{ {
@@ -38,6 +40,7 @@ namespace SanSystem
double gesamtLiner = 0; double gesamtLiner = 0;
double gesamtHarz = 0; double gesamtHarz = 0;
if (list.Count < 1) return;
foreach (Inspektionsobjekt objekt in list) foreach (Inspektionsobjekt objekt in list)
{ {
DataRow dr = inliner.NewRow(); DataRow dr = inliner.NewRow();

View File

@@ -377,7 +377,7 @@ namespace SanSystem
private async void OnExportedExecuted(string destinationPath) private async void OnExportedExecuted(string destinationPath)
{ {
Task<bool> export = Task.Factory.StartNew(() => BüroExporter.Export(Datenbank.Instance.loadedProjekt, destinationPath)); Task<bool> export = Task.Factory.StartNew(() => BüroExporter.Export(Datenbank.Instance.loadedProjekt, destinationPath));
export.ContinueWith(task => MessageBox.Show("Büro export abgeschlossen")); await export.ContinueWith(task => MessageBox.Show("Büro export abgeschlossen"));
} }
} }

View File

@@ -56,7 +56,7 @@ namespace UpdateLib
} }
catch(Exception e) catch(Exception e)
{ {
MessageBox.Show("Fehler beim uberprüfen von Updates\nVersuchen Sie später nochmal!\n\nFehlertext: " + e.Message, "Update", MessageBoxButtons.OK, MessageBoxIcon.Error); //MessageBox.Show("Fehler beim uberprüfen von Updates\nVersuchen Sie später nochmal!\n\nFehlertext: " + e.Message, "Update", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }