|
@@ -1,88 +0,0 @@
|
|
|
-using System;
|
|
|
-using System.Collections.Generic;
|
|
|
-using System.Data.Entity.Validation;
|
|
|
-using System.Linq;
|
|
|
-using System.Text;
|
|
|
-using System.Threading.Tasks;
|
|
|
-using System.Windows;
|
|
|
-using System.Windows.Controls;
|
|
|
-using System.Windows.Data;
|
|
|
-using System.Windows.Documents;
|
|
|
-using System.Windows.Input;
|
|
|
-using System.Windows.Media;
|
|
|
-using System.Windows.Media.Imaging;
|
|
|
-using System.Windows.Shapes;
|
|
|
-
|
|
|
-namespace CopyCenter
|
|
|
-{
|
|
|
- /// <summary>
|
|
|
- /// Interaction logic for RegistrationWindow.xaml
|
|
|
- /// </summary>
|
|
|
- public partial class RegistrationWindow : Window
|
|
|
- {
|
|
|
- gr672_liiEntities db;
|
|
|
- public RegistrationWindow()
|
|
|
- {
|
|
|
- InitializeComponent();
|
|
|
- db = new gr672_liiEntities();
|
|
|
- }
|
|
|
-
|
|
|
- private void Registration_Click(object sender, RoutedEventArgs e)
|
|
|
- {
|
|
|
- if (login.Text == "" || password.Password == "" || lastname.Text == "" || firstname.Text == "" || middlename.Text == "" || contactnumber.Text == "")
|
|
|
- {
|
|
|
- MessageBox.Show("Введено неверное значение");
|
|
|
- return;
|
|
|
- }
|
|
|
- if (db.User.Select(item => item.Login).Contains(login.Text))
|
|
|
- {
|
|
|
- MessageBox.Show("Такой логин уже существует в системе");
|
|
|
- return;
|
|
|
- }
|
|
|
- User newUser = new User()
|
|
|
- {
|
|
|
- Login = login.Text,
|
|
|
- Password = password.Password,
|
|
|
- LastName = lastname.Text,
|
|
|
- FirstName = firstname.Text,
|
|
|
- MiddleName = middlename.Text,
|
|
|
- ContactNumber = Convert.ToInt32(contactnumber.Text)
|
|
|
- };
|
|
|
- db.User.Add(newUser);
|
|
|
- db.SaveChanges();
|
|
|
-
|
|
|
- MessageBox.Show("Вы успешно зарегистрировались");
|
|
|
- AuthorizationWindow aw = new AuthorizationWindow();
|
|
|
- aw.Show();
|
|
|
- this.Close();
|
|
|
- }
|
|
|
-
|
|
|
- private void Cancel(object sender, RoutedEventArgs e)
|
|
|
- {
|
|
|
- AuthorizationWindow aw = new AuthorizationWindow();
|
|
|
- aw.Show();
|
|
|
- this.Close();
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-//// try
|
|
|
-//// {
|
|
|
-
|
|
|
-//// DB.DB.SaveChanges();
|
|
|
-
|
|
|
-//// }
|
|
|
-//// catch (DbEntityValidationException ex)
|
|
|
-//// {
|
|
|
-//// foreach (DbEntityValidationResult validationError in ex.EntityValidationErrors)
|
|
|
-//// {
|
|
|
-//// Response.Write("Object: "+validationError.Entry.Entity.ToString());
|
|
|
-//// Response.Write("
|
|
|
-////");
|
|
|
-//// foreach (DbValidationError err in validationError.ValidationErrors)
|
|
|
-//// {
|
|
|
-//// Response.Write(err.ErrorMessage + "
|
|
|
-////");
|
|
|
-//// }
|
|
|
-//// }
|
|
|
-//// }
|