Exemplo n.º 1
0
        private void PopulateStaffs()
        {
            try
            {
                List <Staff> staffs = staffService.Models.Where(s => s.Id == "0").ToList();
                if (staffs == null || staffs.Count == 0)
                {
                    staffService.Models.Insert(0, new Infrastructure.MangoService.Staff()
                    {
                        Id = "0", IsActive = true, FullName = "<< Select Satff >>"
                    });
                }

                Staffs = new PagedCollectionView(staffService.Models);
                Staffs.MoveCurrentToFirst();
                Staffs.CurrentChanged += (s, e) =>
                {
                    Staff = Staffs.CurrentItem as Infrastructure.MangoService.Staff;
                };
            }
            catch (Exception ex)
            {
                Utility.DisplayMessage(ex.Message);
            }
        }
Exemplo n.º 2
0
        protected override void SetSelectedModel()
        {
            try
            {
                Model = Models.CurrentItem as Inps;

                if (Staffs != null)
                {
                    ObservableCollection <Infrastructure.MangoService.Staff> staffs = (ObservableCollection <Infrastructure.MangoService.Staff>)Staffs.SourceCollection;
                    Infrastructure.MangoService.Staff staff = staffs.Where(s => s.Id == Model.Staff.Id).SingleOrDefault();
                    Staffs.MoveCurrentTo(staff);
                }

                if (Departments != null)
                {
                    List <Department> departments = (List <Department>)Departments.SourceCollection;
                    Department        department  = departments.Where(d => d.Id == Model.ResponsibleDepartment.Id).SingleOrDefault();
                    Departments.MoveCurrentTo(department);
                }

                UpdateViewState(Edit.Mode.Editing);
            }
            catch (Exception ex)
            {
                Utility.DisplayMessage(ex.Message);
            }
        }
Exemplo n.º 3
0
        protected override void LoadAllCommandCompletedHelper()
        {
            try
            {
                dispatcher.BeginInvoke
                    (() =>
                {
                    if (Utility.FaultExist(service.Fault))
                    {
                        return;
                    }

                    Models = new PagedCollectionView(service.Models);
                    if (service.Models != null && service.Models.Count > 0)
                    {
                        RecordCount = RecordCountLabel + service.Models.Count;
                        Models.MoveCurrentTo(null);
                        Models.CurrentChanged += (s, e) =>
                        {
                            Model = Models.CurrentItem as StaffCdjr;
                            if (Model != null)
                            {
                                if (CompanyDepartmentJobRoles != null)
                                {
                                    ObservableCollection <CompanyDepartmentJobRole> companyDepartmentJobRoles = (ObservableCollection <CompanyDepartmentJobRole>)CompanyDepartmentJobRoles.SourceCollection;
                                    CompanyDepartmentJobRole companyDepartmentJobRole = companyDepartmentJobRoles.Where(l => l.Id == Model.CompanyDepartmentJobRole.Id).SingleOrDefault();
                                    CompanyDepartmentJobRoles.MoveCurrentTo(companyDepartmentJobRole);
                                }

                                if (Staffs != null)
                                {
                                    ObservableCollection <Infrastructure.MangoService.Staff> staffs = (ObservableCollection <Infrastructure.MangoService.Staff>)Staffs.SourceCollection;
                                    Infrastructure.MangoService.Staff staff = staffs.Where(l => l.Id == Model.Staff.Id).SingleOrDefault();
                                    Staffs.MoveCurrentTo(staff);
                                }
                            }

                            UpdateViewState(Edit.Mode.Editing);
                            CanSaveItem = false;
                        };
                    }
                    else
                    {
                        RecordCount = RecordCountLabel + 0;
                    }
                });
            }
            catch (Exception ex)
            {
                Utility.DisplayMessage(ex.Message);
            }
        }
Exemplo n.º 4
0
 public void ChangePassword(Infrastructure.MangoService.Staff staff, string password)
 {
     try
     {
         service = new ServiceClient();
         service.ChangePasswordCompleted += new EventHandler <ChangePasswordCompletedEventArgs>(service_ChangePasswordCompleted);
         service.ChangePasswordAsync(staff, password);
         service.CloseAsync();
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 5
0
 public void LoadAll(Infrastructure.MangoService.Staff staff)
 {
     try
     {
         service = new ServiceClient();
         service.GetRolesCompleted += new EventHandler <GetRolesCompletedEventArgs>(service_GetRolesCompleted);
         service.GetRolesAsync(staff);
         service.CloseAsync();
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 6
0
 private void ResetLoggedInUser()
 {
     try
     {
         LoggedInUser                = new Infrastructure.MangoService.Staff();
         LoggedInUser.Role           = new Role();
         LoggedInUser.Role.UserRight = new UserRight();
         LoggedInUser.Name           = "Guest";
         LoggedInUser.Role.Name      = "Guest";
     }
     catch (Exception ex)
     {
         Utility.DisplayMessage(ex.Message);
     }
 }
Exemplo n.º 7
0
        private void Service_ValidateStaffCompleted(object sender, ValidateStaffCompletedEventArgs e)
        {
            try
            {
                Fault = e.fault;
                if (e.Result != null)
                {
                    LoggedInUser = e.Result.Staff;
                }

                if (UserValidationCompleted != null)
                {
                    UserValidationCompleted(this, e);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 8
0
        //public void OnUserLogin(Dictionary<string, string> staff)
        public void OnUserLogin(Infrastructure.MangoService.Staff staff)
        {
            if (staff != null)
            {
                Image = LoadCompanyLogo(staff.Company.Name);
            }

            LoggedInUser         = staff;
            Utility.LoggedInUser = staff;
            Period = Utility.Period;

            if (staff != null)
            {
                LoginStatus    = LOGOUT;
                IsUserLoggedIn = true;
            }
            else
            {
                IsUserLoggedIn = false;
            }

            RaiseButtonCanExecuteEvent();
        }