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

@@ -1,4 +1,5 @@
using KlassenBIB;
using Database;
using KlassenBIB;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -24,8 +25,18 @@ namespace SanSystem
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)
{
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.Nummer = txt_pro_nr.Text;
projekt.Ort = txt_ort.Text;
@@ -33,5 +44,15 @@ namespace SanSystem
this.Close();
//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();
}
}
}
}