コード例 #1
0
ファイル: MainPage.xaml.cs プロジェクト: maverick126/MRS
        void mrsClient_GetUserRolesCompleted(object sender, GetUserRolesCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                cmbUserRole.ItemsSource = e.Result;

                if (cmbUserRole.Items.Count > 0)
                {
                    //Remove SelectionChanged EventHandler before modifying value
                    cmbUserRole.SelectionChanged -= new Telerik.Windows.Controls.SelectionChangedEventHandler(cmbUserRole_SelectionChanged);
                    //Modify value
                    if (_currentApp.CurrentUserRoleId > 0)
                    {
                        cmbUserRole.SelectedValue = _currentApp.CurrentUserRoleId;
                    }
                    else if (_currentApp.CurrentUserPrimaryRoleId > 0)
                    {
                        cmbUserRole.SelectedValue = _currentApp.CurrentUserPrimaryRoleId;
                    }

                    if (cmbUserRole.SelectedItem == null)
                    {
                        cmbUserRole.SelectedIndex = 0;
                    }


                    //Add SelectionChanged EventHandler
                    cmbUserRole.SelectionChanged += new Telerik.Windows.Controls.SelectionChangedEventHandler(cmbUserRole_SelectionChanged);

                    UserRole selectedRole = (UserRole)cmbUserRole.SelectedItem;

                    _currentApp.CurrentUserRoleId = selectedRole.RoleId;
                    _currentApp.IsManager         = selectedRole.IsManager;



                    RetailSystemClient mrsClient = new RetailSystemClient();
                    mrsClient.Endpoint.Address = new System.ServiceModel.EndpointAddress(Internal.Utilities.GetMetriconRetailSystemWcfClientEndpointUrl());

                    mrsClient.GetRevisionTypeAccessCompleted += new EventHandler <GetRevisionTypeAccessCompletedEventArgs>(mrsClient_GetRevisionTypeAccessCompleted);
                    mrsClient.GetRevisionTypeAccessAsync(selectedRole.RoleId);

                    mrsClient.GetRoleAccessModuleCompleted += new EventHandler <GetRoleAccessModuleCompletedEventArgs>(mrsClient_GetRoleAccessModuleCompleted);
                    mrsClient.GetRoleAccessModuleAsync(_currentApp.CurrentUserRoleId);
                }
                else
                {
                    UserValidationError();
                }
            }
            else
            {
                ExceptionHandler.PopUpErrorMessage(e.Error, "GetUserRolesCompleted");
                UserValidationError();
            }
        }
コード例 #2
0
ファイル: Dashboard.xaml.cs プロジェクト: maverick126/MRS
        void mrsClient_GetUserRolesCompleted(object sender, GetUserRolesCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                cmbUserRole.ItemsSource = e.Result;

                if (cmbUserRole.Items.Count > 0)
                {
                    //Remove SelectionChanged EventHandler before modifying value
                    //cmbUserRole.SelectionChanged -= new Telerik.Windows.Controls.SelectionChangedEventHandler(cmbUserRole_SelectionChanged);
                    //Modify value
                    if (_currentApp.CurrentUserRoleId > 0)
                        cmbUserRole.SelectedValue = _currentApp.CurrentUserRoleId;
                    else if (_currentApp.CurrentUserPrimaryRoleId > 0)
                        cmbUserRole.SelectedValue = _currentApp.CurrentUserPrimaryRoleId;

                    if (cmbUserRole.SelectedItem == null)
                        cmbUserRole.SelectedIndex = 0;
                    //Add SelectionChanged EventHandler
                    //cmbUserRole.SelectionChanged += new Telerik.Windows.Controls.SelectionChangedEventHandler(cmbUserRole_SelectionChanged);

                    UserRole selectedRole = (UserRole)cmbUserRole.SelectedItem;

                    _currentApp.CurrentUserRoleId = selectedRole.RoleId;

                    //if (System.Windows.Browser.HtmlPage.Document.QueryString.ContainsKey("ref"))
                    //    if (System.Windows.Browser.HtmlPage.Document.QueryString["ref"] == "SQS")
                    //        this.NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
                }
                else
                    UserValidationError();
            }
            else
            {
                ExceptionHandler.PopUpErrorMessage(e.Error, "GetUserRolesCompleted");
                UserValidationError();
            }
        }