public void SaveExecute(object parametar)
        {
            Worker editWorker = new Worker();

            editWorker.WorkerId             = worker.WorkerId;
            editWorker.WorkExperience       = worker.WorkExperience;
            editWorker.QualificationLevelId = worker.QualificationLevelId;
            editWorker.GenderId             = worker.GenderId;
            decimal salary = Salary.SalaryCalculate(editWorker.WorkExperience, editWorker.QualificationLevelId, editWorker.GenderId, salaryInput);

            editWorker.Salary = salary;

            try
            {
                int userId = service.AddNewWorker(editWorker);
                if (userId != 0)
                {
                    MessageBox.Show("You have successfully added salary");
                    ManagerLogedInView managerView = new ManagerLogedInView(manager);
                    managerView.Show();
                    addSalaryOneWorker.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Пример #2
0
        public void SaveExecute(object parametar)
        {
            var passwordBox = parametar as PasswordBox;
            var password    = passwordBox.Password;
            var email       = User.Email.ToLower();

            User.Password = password;
            User.Email    = email;
            User.RoleId   = 1;
            try
            {
                if (User.HotelUserId == 0)
                {
                    bool uniqueUserName = service.CheckUsername(User.Username);
                    bool uniqueEmail    = service.CheckEmail(User.Email);

                    if (uniqueUserName && uniqueEmail)
                    {
                        int userId = service.AddHotelUser(User);
                        if (userId != 0)
                        {
                            UserWorker.HotelUserId          = userId;
                            UserWorker.GenderId             = selectedGender.GenderId;
                            UserWorker.HotelFloor           = selectedFloor;
                            UserWorker.EngagmentId          = selectedEngagment.EngagmentId;
                            UserWorker.QualificationLevelId = selectedQualificationLevel.QualificationLevelId;
                            UserWorker.ManagerId            = service.GetManagerByFloorNumber(selectedFloor);

                            if (service.AddNewWorker(UserWorker) != 0)
                            {
                                MessageBox.Show("You have successfully added new worker");
                                OwnerView ownerView = new OwnerView();
                                ownerView.Show();
                                addworkerview.Close();
                            }
                        }
                    }
                    else if (!uniqueUserName)
                    {
                        MessageBox.Show("Username already exists!");
                    }
                    else if (!uniqueEmail)
                    {
                        MessageBox.Show("Email already exists!");
                    }
                    else
                    {
                        //int userId = service.AddClinicUser(User);
                        //if (userId != 0)
                        //{
                        //    UserDoctor.ClinicUserId = userId;
                        //    UserDoctor.DepartmentId = selectedDepartment.DepartmentId;
                        //    UserDoctor.WorkShiftId = selectedWorkShift.WorkShiftId;
                        //    UserDoctor.ClinicManagerId = selectedManager.ClinicManagerId;

                        //    if (service.AddNewDoctor(UserDoctor) != 0)
                        //    {
                        //        MessageBox.Show("You have successfully added new doctor");
                        //        Logging.LoggAction("AddDoctorViewModel", "Info", "Succesfull added new doctor");

                        //        DoctorView doctorView = new DoctorView(UserAdmin);
                        //        doctorView.Show();
                        //        addDoctorView.Close();
                        //    }
                        //}
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }