Exemplo n.º 1
0
        public void UpdateNoteTemplateName(int templateid, string templatename)
        {
            mrsClient = new RetailSystemClient();
            mrsClient.Endpoint.Address = new System.ServiceModel.EndpointAddress(Internal.Utilities.GetMetriconRetailSystemWcfClientEndpointUrl());

            mrsClient.CheckNewNoteTemplateNameExistsCompleted += delegate(object o, CheckNewNoteTemplateNameExistsCompletedEventArgs es)
            {
                if (es.Error == null)
                {
                    if (es.Result.ToString().ToUpper() == "OK")
                    {
                        ((NotesTemplateViewModel)LayoutRoot.DataContext).UpdateNoteTemplateName(templateid, (App.Current as App).CurrentUserId, templatename, "NAME");
                    }
                    else
                    {
                        MessageBox.Show(es.Result.ToString());
                        ((NotesTemplateViewModel)LayoutRoot.DataContext).SearchNotesTemplate();
                    }
                }
                else
                {
                    ExceptionHandler.PopUpErrorMessage(es.Error, "CheckNewNoteTemplateNameExistsCompleted");
                }
            };

            mrsClient.CheckNewNoteTemplateNameExistsAsync(templateid, templatename);
            mrsClient = null;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Populate User's details
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void mrsClient_GetCurrentUserCompleted(object sender, GetCurrentUserCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                User currentUser = e.Result;
                if (currentUser != null)
                {
                    txtFullName.Text = currentUser.FullName;
                    txtRegion.Text   = currentUser.RegionName;

                    _currentApp.CurrentUserFullName      = currentUser.FullName;
                    _currentApp.CurrentUserId            = currentUser.UserId;
                    _currentApp.CurrentRegionId          = currentUser.RegionId;
                    _currentApp.CurrentUserStateID       = currentUser.StateId.ToString();
                    _currentApp.CurrentUserPrimaryRoleId = currentUser.PrimaryRoleId;

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

                    mrsClient.GetUserRolesCompleted += new EventHandler <GetUserRolesCompletedEventArgs>(mrsClient_GetUserRolesCompleted);
                    mrsClient.GetUserRolesAsync(currentUser.UserId);
                }
                else
                {
                    UserValidationError();
                }
            }
            else
            {
                ExceptionHandler.PopUpErrorMessage(e.Error, "GetCurrentUserCompleted");
                UserValidationError();
            }
        }
Exemplo n.º 3
0
        void mrsClient_GetEstimateStatusesCompleted(object sender, GetEstimateStatusesCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                cmbStatus.ItemsSource = e.Result;

                //Remove SelectionChanged EventHandler before modifying value
                cmbStatus.SelectionChanged -= new Telerik.Windows.Controls.SelectionChangedEventHandler(cmbStatus_SelectionChanged);

                if (_currentApp.SelectedStatusId > 0)
                {
                    cmbStatus.SelectedValue = _currentApp.SelectedStatusId;
                }
                else
                {
                    cmbStatus.SelectedValue      = (int)EstimateRevisionStatus.WorkInProgress;
                    _currentApp.SelectedStatusId = (int)EstimateRevisionStatus.WorkInProgress;
                }
                //Add SelectionChanged EventHandler
                cmbStatus.SelectionChanged += new Telerik.Windows.Controls.SelectionChangedEventHandler(cmbStatus_SelectionChanged);
            }
            else
            {
                ExceptionHandler.PopUpErrorMessage(e.Error, "GetEstimateStatusesCompleted");
            }
        }
Exemplo n.º 4
0
        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();
            }
        }
Exemplo n.º 5
0
 void mrsClient_GetRoleAccessModuleCompleted(object sender, GetRoleAccessModuleCompletedEventArgs e)
 {
     if (e.Error == null)
     {
       _currentApp.CurrentRoleAccessModule = e.Result;
     }
     else
     {
         ExceptionHandler.PopUpErrorMessage(e.Error, "GetRoleAccessModuleCompleted");
         UserValidationError();
     }
 }
Exemplo n.º 6
0
        void mrsClient_GetEstimateCountCompleted(object sender, GetEstimateCountCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                System.Collections.ObjectModel.ObservableCollection<int> estimateCount = e.Result;

                HlnkNewJobs.Content = estimateCount[0].ToString() + " New Job";
                if (estimateCount[0] > 1)
                    HlnkNewJobs.Content += "s";

                HlnkWorkspace.Content = estimateCount[1].ToString() + " Work In Progress Job";
                if (estimateCount[1] > 1)
                    HlnkWorkspace.Content += "s";

                HlnkAccepted.Content = estimateCount[2].ToString() + " Completed Job";
                if (estimateCount[2] > 1)
                    HlnkAccepted.Content += "s";

                HlnkRejected.Content = estimateCount[3].ToString() + " Rejected Job";
                if (estimateCount[3] > 1)
                    HlnkRejected.Content += "s";

                HlnkOnHold.Content = estimateCount[4].ToString() + " On Hold Job";
                if (estimateCount[4] > 1)
                    HlnkOnHold.Content += "s";

                HlnkCancelled.Content = estimateCount[5].ToString() + " Cancelled Job";
                if (estimateCount[5] > 1)
                    HlnkCancelled.Content += "s";

                HlnkAppointment.Content = estimateCount[6].ToString() + " Appointment";
                if (estimateCount[6] > 1)
                    HlnkAppointment.Content += "s";
                HlnkAppointment.Content += " for today";

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

                mrsClient.GetRevisionTypeAccessCompleted += new EventHandler<GetRevisionTypeAccessCompletedEventArgs>(mrsClient_GetRevisionTypeAccessCompleted);
                mrsClient.GetRevisionTypeAccessAsync(_currentApp.CurrentUserRoleId);
            }
            else
                ExceptionHandler.PopUpErrorMessage(e.Error, "GetEstimateCountCompleted");
        }
Exemplo n.º 7
0
        void mrsClient_MoveEstimateDetailItemCompleted(object sender, MoveEstimateDetailItemCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                //this.DialogResult = true;
                //RadWindow window = this.ParentOfType<RadWindow>();
                //if (window != null)
                //{
                //    window.DialogResult = true;
                //    window.Close();
                //}
            }
            else
            {
                ExceptionHandler.PopUpErrorMessage(e.Error, "MoveEstimateDetailItemCompleted");
            }

            //BusyIndicator1.IsBusy = false;
        }
Exemplo n.º 8
0
        //void mrsClient_GetOnHoldEstimateCountCompleted(object sender, GetOnHoldEstimateCountCompletedEventArgs e)
        //{
        //    txtAlert.Text = string.Empty;
        //    if (e.Error == null)
        //    {
        //        int onholdCount = e.Result;
        //        if (onholdCount > 0)
        //        {
        //            if (onholdCount == 1)
        //                txtAlert.Text = "You have 1 On Hold job.";
        //            else
        //                txtAlert.Text = "You have " + onholdCount.ToString() + " On Hold jobs.";
        //        }
        //        if (revisionTypeIds.IndexOf("2") >= 0) // Only check resubmitted jobs when user have access to Sales Accept revision
        //        {
        //            RetailSystemClient mrsClient = new RetailSystemClient();
        //            mrsClient.Endpoint.Address = new System.ServiceModel.EndpointAddress(Utilities.GetMetriconRetailSystemWcfClientEndpointUrl());
        //            mrsClient.GetResubmittedEstimateCountCompleted += new EventHandler<GetResubmittedEstimateCountCompletedEventArgs>(mrsClient_GetResubmittedEstimateCountCompleted);
        //            if (_currentApp.IsManager)
        //                mrsClient.GetResubmittedEstimateCountAsync(0, _currentApp.CurrentRegionId);
        //            else
        //                mrsClient.GetResubmittedEstimateCountAsync(_currentApp.CurrentUserId, 0);
        //        }
        //        else
        //        {
        //            if (txtAlert.Text == string.Empty)
        //                AlertPanel.Visibility = System.Windows.Visibility.Collapsed;
        //            else
        //                AlertPanel.Visibility = System.Windows.Visibility.Visible;
        //        }
        //    }
        //    else
        //        ExceptionHandler.PopUpErrorMessage(e.Error, "GetOnHoldEstimateCountCompleted");
        //}
        void mrsClient_GetResubmittedEstimateCountCompleted(object sender, GetResubmittedEstimateCountCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                int resubmitCount = e.Result;

                if (resubmitCount > 0)
                {
                    if (txtAlert.Text != string.Empty)
                        txtAlert.Text += "\r\n";

                    if (resubmitCount == 1)
                        txtAlert.Text += "You have 1 re-submitted job in Work In Progress list.";
                    else
                        txtAlert.Text += "You have " + resubmitCount.ToString() + " re-submitted jobs in Work In Progress list.";
                }
                else
                    AlertPanel.Visibility = System.Windows.Visibility.Collapsed;
            }
            else
                ExceptionHandler.PopUpErrorMessage(e.Error, "GetResubmittedEstimateCountCompleted");
        }
Exemplo n.º 9
0
        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();
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Populate User's details
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void mrsClient_GetCurrentUserCompleted(object sender, GetCurrentUserCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                User currentUser = e.Result;
                if (currentUser != null)
                {
                    _currentApp.CurrentUserFullName = currentUser.FullName;
                    _currentApp.CurrentUserId = currentUser.UserId;
                    _currentApp.CurrentRegionId = currentUser.RegionId;
                    _currentApp.LoginPriceRegionId = currentUser.LoginPriceRegionId;
                    _currentApp.CurrentUserStateID = currentUser.StateId.ToString();
                    _currentApp.CurrentUserPrimaryRoleId = currentUser.PrimaryRoleId;

                    txtFullName.Text = String.Format("Welcome {0} from {1}", currentUser.FullName, currentUser.RegionName);

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

                    mrsClient.GetUserRolesCompleted += new EventHandler<GetUserRolesCompletedEventArgs>(mrsClient_GetUserRolesCompleted);
                    mrsClient.GetUserRolesAsync(currentUser.UserId);

                    mrsClient.GetRoleAccessModuleCompleted += new EventHandler<GetRoleAccessModuleCompletedEventArgs>(mrsClient_GetRoleAccessModuleCompleted);
                    mrsClient.GetRoleAccessModuleAsync(currentUser.PrimaryRoleId);

                }
                else
                    UserValidationError();
            }
            else
            {
                ExceptionHandler.PopUpErrorMessage(e.Error, "GetCurrentUserCompleted");
                UserValidationError();
            }

            BusyIndicator1.IsBusy = false;
        }
Exemplo n.º 11
0
        void mrsClient_GetRevisionTypeAccessCompleted(object sender, GetRevisionTypeAccessCompletedEventArgs e)
        {
            revisionTypeIds = string.Empty;
            if (e.Error == null)
            {
                foreach (var item in e.Result)
                {
                    if (revisionTypeIds == string.Empty)
                        revisionTypeIds = "#" + item.RevisionTypeId.ToString() + "#";
                    else
                        revisionTypeIds += ",#" + item.RevisionTypeId.ToString() + "#";
                }

                WorkspacePanel.Visibility = System.Windows.Visibility.Visible;

                if (revisionTypeIds == "#1#") // If the selected Role allows access to Sales Consultant revision only
                {
                    NewJobsPanel.Visibility = System.Windows.Visibility.Collapsed;
                    AcceptedPanel.Visibility = System.Windows.Visibility.Collapsed;
                    RejectedPanel.Visibility = System.Windows.Visibility.Collapsed;
                    OnHoldPanel.Visibility = System.Windows.Visibility.Collapsed;
                    CancelledPanel.Visibility = System.Windows.Visibility.Collapsed;
                    AppointmentPanel.Visibility = System.Windows.Visibility.Collapsed;
                }

                else
                {
                    NewJobsPanel.Visibility = System.Windows.Visibility.Visible;
                    AcceptedPanel.Visibility = System.Windows.Visibility.Visible;
                    OnHoldPanel.Visibility = System.Windows.Visibility.Visible;
                    CancelledPanel.Visibility = System.Windows.Visibility.Visible;

                    if (revisionTypeIds.IndexOf("#2#") >= 0) // Only check resubmitted jobs when user have access to Sales Accept revision
                    {
                        RejectedPanel.Visibility = System.Windows.Visibility.Visible;

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

                        mrsClient.GetResubmittedEstimateCountCompleted += new EventHandler<GetResubmittedEstimateCountCompletedEventArgs>(mrsClient_GetResubmittedEstimateCountCompleted);
                        if (_currentApp.IsManager)
                            mrsClient.GetResubmittedEstimateCountAsync(0, _currentApp.CurrentRegionId);
                        else
                            mrsClient.GetResubmittedEstimateCountAsync(_currentApp.CurrentUserId, 0);
                    }
                    else
                    {
                        RejectedPanel.Visibility = System.Windows.Visibility.Collapsed;
                        AlertPanel.Visibility = System.Windows.Visibility.Collapsed;
                    }

                    // Only display appointment to Studio M roles
                    if (revisionTypeIds.IndexOf("#7#") >= 0 ||
                        revisionTypeIds.IndexOf("#8#") >= 0 ||
                        revisionTypeIds.IndexOf("#9#") >= 0 ||
                        revisionTypeIds.IndexOf("#10#") >= 0 ||
                        revisionTypeIds.IndexOf("#11#") >= 0 ||
                        revisionTypeIds.IndexOf("#12#") >= 0)
                    {
                        AppointmentPanel.Visibility = System.Windows.Visibility.Visible;
                    }
                    else
                    {
                        AppointmentPanel.Visibility = System.Windows.Visibility.Collapsed;
                    }
                }

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

                //mrsClient.GetOnHoldEstimateCountCompleted += new EventHandler<GetOnHoldEstimateCountCompletedEventArgs>(mrsClient_GetOnHoldEstimateCountCompleted);
                //if (_currentApp.IsManager)
                //    mrsClient.GetOnHoldEstimateCountAsync(revisionTypeIds, 0, _currentApp.CurrentRegionId);
                //else
                //    mrsClient.GetOnHoldEstimateCountAsync(revisionTypeIds, _currentApp.CurrentUserId, 0);

            }
            else
                ExceptionHandler.PopUpErrorMessage(e.Error, "GetRevisionTypeAccessCompleted");

            if (BusyIndicator2.IsBusy)
                BusyIndicator2.IsBusy = false;
        }
Exemplo n.º 12
0
        void mrsClient_GetRevisionTypeAccessCompleted(object sender, GetRevisionTypeAccessCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                e.Result.Insert(0, new RevisionType()
                {
                    RevisionTypeName = "All", RevisionTypeId = 0
                });

                if (e.Result.Count > 1)
                {
                    //Remove SelectionChanged EventHandler before modifying value
                    cmbRevisionType.SelectionChanged -= new Telerik.Windows.Controls.SelectionChangedEventHandler(cmbRevisionType_SelectionChanged);

                    cmbRevisionType.ItemsSource = e.Result;
                    if (_currentApp.SelectedRevisionTypeId > 0)
                    {
                        bool revisionTypeFound = false;

                        foreach (RevisionType revisionType in e.Result)
                        {
                            if (revisionType.RevisionTypeId == _currentApp.SelectedRevisionTypeId)
                            {
                                cmbRevisionType.SelectedValue = _currentApp.SelectedRevisionTypeId;
                                revisionTypeFound             = true;
                                break;
                            }
                        }

                        if (!revisionTypeFound)
                        {
                            cmbRevisionType.SelectedIndex = 0;
                            RevisionType selectedRevisionType = (RevisionType)cmbRevisionType.SelectedItem;
                            _currentApp.SelectedRevisionTypeId = selectedRevisionType.RevisionTypeId;
                        }
                    }
                    else
                    {
                        cmbRevisionType.SelectedIndex = 0;
                        RevisionType selectedRevisionType = (RevisionType)cmbRevisionType.SelectedItem;
                        _currentApp.SelectedRevisionTypeId = selectedRevisionType.RevisionTypeId;
                    }
                    //Add SelectionChanged EventHandler
                    cmbRevisionType.SelectionChanged += new Telerik.Windows.Controls.SelectionChangedEventHandler(cmbRevisionType_SelectionChanged);

                    if (MainFrame.Source != null && MainFrame.Source.OriginalString == "/EstimateList.xaml")
                    {
                        MainFrame.Refresh();
                    }
                    else
                    {
                        MainFrame.Navigate(new Uri("/EstimateList.xaml", UriKind.Relative));
                    }
                }
                else
                {
                    UserValidationError();
                }
            }
            else
            {
                ExceptionHandler.PopUpErrorMessage(e.Error, "GetRevisionTypeAccessCompleted");
                UserValidationError();
            }
        }