예제 #1
0
 public RepositoryController GetInstance()
 {
     if (controller == null)
     {
         controller = new RepositoryController();
     }
     return(controller);
 }
예제 #2
0
 public void OnPropertyChanged([CallerMemberName] string prop = "")
 {
     if (PropertyChanged != null)
     {
         PropertyChanged(this, new PropertyChangedEventArgs(prop));
         IRepController controller = new RepositoryController();
         controller.UpdateProductPositionInDB(this);
     }
 }
예제 #3
0
        public void Execute()
        {
            try
            {
                var    md5      = MD5.Create();
                byte[] hash     = md5.ComputeHash(Encoding.UTF8.GetBytes(user_password));
                string password = "";
                foreach (byte bit in hash)
                {
                    password += bit;
                }


                string expression = "+375([1-9]{2})[0-9]{3}-[0-9]{2}-[0-9]{2}";
                if (!Regex.IsMatch(phone, "[+]375[(][1-9]{2}[)][0-9]{3}-[0-9]{2}-[0-9]{2}", RegexOptions.None))
                {
                    throw new Exception("Мобильный номер введен в неверной форме");
                }

                LogisticCompany.model.IRepController repository = new LogisticCompany.model.RepositoryController();
                Employee employee = repository.GetEmployeeFromDB(sorname, phone);
                if (employee != null)
                {
                    if (employee.password.Equals(password))
                    {
                        if (employee.role.Equals("Администратор") || employee.SecondName.Equals("Admin"))
                        {
                            LogisticCompany.MainWindow.GetInstance().Content = LogisticCompany.view.AdminWindow.GetInstance(employee).Content;
                        }
                        if (employee.role.Equals("Сотрудник") || employee.SecondName.Equals("Employee"))
                        {
                            LogisticCompany.MainWindow.GetInstance().Content = LogisticCompany.view.EmployeeWindow.GetInstance(employee).Content;
                        }
                    }
                    else
                    {
                        MessageBox.Show("Введены неверные данные\t");
                    }
                }
                else
                {
                    throw new Exception("Пользователь не найден");
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }