Пример #1
0
        public EmployeeRegisterViewModel(EmployeeRegisterView employeeRegisterView)
        {
            view           = employeeRegisterView;
            qualifications = new List <string>()
            {
                "I", "II", "III", "IV", "V", "VI", "VII"
            };

            userService     = new UserService();
            sectorService   = new SectorService();
            employeeService = new EmployeeService();
            positionService = new PositionService();
            managerService  = new ManagerService();

            User         = new tblUser();
            Employee     = new tblEmployee();
            SectorList   = sectorService.GetSectors();
            PositionList = positionService.GetPositions();

            //if (SectorList.Count==0)
            //{
            //    ViewNoSectorMessage = Visibility.Visible;

            //}
            //else
            //{
            //    ViewNoSectorMessage = Visibility.Hidden;

            //}
        }
Пример #2
0
        public ActionResult SignUp(EmployeeRegisterView regEmp)
        {
            using (GerGarageDbEntities db = new GerGarageDbEntities())
            {
                EmployeeRegistry emp = new EmployeeRegistry();

                emp.EmployeeFirstName = regEmp.EmployeeFirstName;
                emp.EmployeeLastName  = regEmp.EmployeeLastName;
                emp.EmployeeContact   = regEmp.EmployeeContact;
                emp.EmployeeEmailId   = regEmp.EmployeeEmailId;
                emp.EmployeePassword  = regEmp.EmployeePassword;


                EmployeeLogin logEmp = new EmployeeLogin();
                logEmp.EmployeeEmailId  = regEmp.EmployeeEmailId;
                logEmp.EmployeePassword = regEmp.EmployeePassword;
                if (ModelState.IsValid)
                {
                    db.EmployeeRegistries.Add(emp);
                    db.EmployeeLogins.Add(logEmp);
                    db.SaveChanges();



                    return(RedirectToAction("Login"));
                }
                return(View());
            }
        }
Пример #3
0
        private void AsEmployeeExecute()
        {
            try
            {
                if (managerService.GetManagers().Count == 0)
                {
                    string str = string.Format("You can't create emplooye account\n" +
                                               "There are no managers in database");
                    MessageBox.Show(str);
                    return;
                }

                if (sectorService.GetSectors().Count == 0)
                {
                    string str = string.Format("You can't create emplooye account\n" +
                                               "There are no sectors in database");
                    MessageBox.Show(str);
                    return;
                }
                EmployeeRegisterView registerView = new EmployeeRegisterView();
                registerView.ShowDialog();
                view.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Пример #4
0
        private void AsManagerExecute()
        {
            string passwordFromFile = ReadPasswordFromFile();

            int tryCounter = 3;

            try
            {
                ManagerRegisterView registerView = new ManagerRegisterView();

                MessageBoxResult result = MessageBox.Show("Are you sure that you want to register as manager?" +
                                                          "", "My App",
                                                          MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No);


                switch (result)
                {
                case MessageBoxResult.Yes:
                    for (int i = 0; i < 3; i++)
                    {
                        InputDialogSample inputDialog = new InputDialogSample("Please enter password from file " +
                                                                              "ManagerAccess.txt:", "");
                        if (inputDialog.ShowDialog() == true)
                        {
                            if (inputDialog.Answer.Equals(passwordFromFile))
                            {
                                registerView.ShowDialog();
                                LoginView loginView = new LoginView();
                                loginView.Show();
                                view.Close();
                                return;
                            }
                            else
                            {
                                tryCounter--;
                                if (tryCounter != 0)
                                {
                                    MessageBox.Show("Wrong password. You have " + tryCounter + " more attempts");
                                }

                                if (tryCounter == 0)
                                {
                                    MessageBox.Show("You can't create manager account.\n" +
                                                    "Create employee account.");

                                    if (managerService.GetManagers().Count == 0)
                                    {
                                        string str = string.Format("You can't create emplooye account\n" +
                                                                   "There are no managers in database");
                                        MessageBox.Show(str);
                                        return;
                                    }

                                    canAsManager = false;
                                    EmployeeRegisterView employeeRegisterView =
                                        new EmployeeRegisterView();
                                    employeeRegisterView.ShowDialog();


                                    return;
                                }
                            }
                        }
                    }


                    break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }