|
@@ -2,6 +2,7 @@
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Text;
|
|
|
|
+using System.Text.RegularExpressions;
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Controls;
|
|
@@ -41,29 +42,41 @@ namespace Met_Fam
|
|
Address = txtAdres.Text,
|
|
Address = txtAdres.Text,
|
|
ID_Role = 2,
|
|
ID_Role = 2,
|
|
};
|
|
};
|
|
- bool u = true;
|
|
|
|
- foreach (var item in code)
|
|
|
|
|
|
+ Regex checkSurName = new Regex(@"^[А-я]+$");
|
|
|
|
+ Regex checkName = new Regex(@"^[А-я]+$");
|
|
|
|
+ Regex checkLogin = new Regex(@"\b\w{2,10}\b");
|
|
|
|
+ Regex checkPassword = new Regex(@"\b\w{2,10}\b");
|
|
|
|
+ Regex checkNumberPhone = new Regex("^((\\+?7|8))\\d{10}$");
|
|
|
|
+ if (((!checkName.IsMatch(txtName.Text)) || (!checkSurName.IsMatch(txtSuName.Text)) || (!checkLogin.IsMatch(txtLogin.Text)) || (!checkPassword.IsMatch(txtPass.Password)) || (!checkNumberPhone.IsMatch(txtPhon.Text))))
|
|
{
|
|
{
|
|
- if (txtLogin.Text == item.Login_User)
|
|
|
|
- {
|
|
|
|
- u = false;
|
|
|
|
- MessageBox.Show("Такой пользователь уже существует");
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
|
|
+ MessageBox.Show("Ошибка ввода");
|
|
}
|
|
}
|
|
- if (u)
|
|
|
|
|
|
+ else
|
|
{
|
|
{
|
|
- try
|
|
|
|
|
|
+ bool u = true;
|
|
|
|
+ foreach (var item in code)
|
|
{
|
|
{
|
|
- DataBase.BaseModel.User.Add(user);
|
|
|
|
- DataBase.BaseModel.SaveChanges();
|
|
|
|
- DataBase.BaseModel = new MFSystemEntities();
|
|
|
|
- new WindowShop(user).Show();
|
|
|
|
- this.Close();
|
|
|
|
|
|
+ if (txtLogin.Text == item.Login_User)
|
|
|
|
+ {
|
|
|
|
+ u = false;
|
|
|
|
+ MessageBox.Show("Такой пользователь уже существует");
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- catch (Exception ex)
|
|
|
|
|
|
+ if (u)
|
|
{
|
|
{
|
|
- MessageBox.Show(ex.Message);
|
|
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ DataBase.BaseModel.User.Add(user);
|
|
|
|
+ DataBase.BaseModel.SaveChanges();
|
|
|
|
+ DataBase.BaseModel = new MFSystemEntities();
|
|
|
|
+ new WindowShop(user).Show();
|
|
|
|
+ this.Close();
|
|
|
|
+ }
|
|
|
|
+ catch (Exception ex)
|
|
|
|
+ {
|
|
|
|
+ MessageBox.Show(ex.Message);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|