Exemplo n.º 1
0
 public AddTickets(Controller_ProductServices parentWindow)
 {
     //Madhu - Fix BZ defect 147
     this.parentWindow = parentWindow;
     _SetupInProgress  = true;
     InitializeComponent();
     Setup();
 }
        /// <summary>
        /// Main execution function for NewPawnLoanFlowExecutor
        /// </summary>
        /// <param name="inputData"></param>
        /// <returns></returns>
        private object executorFxn(object inputData)
        {
            if (inputData == null)
            {
                inputData = FindStateByTabClicked();
            }



            PawnCustInformationFlowState inputState = (PawnCustInformationFlowState)inputData;

            switch (inputState)
            {
            case PawnCustInformationFlowState.ViewReadOnlyCustomerInformation:

                ShowForm viewCustInfoReadOnlyBlk = CommonAppBlocks.Instance.ViewCustomerInfoShowBlock(this.parentForm, this.viewCustFormNavAction);
                if (!viewCustInfoReadOnlyBlk.execute())
                {
                    throw new ApplicationException("Cannot execute View customer information block");
                }
                CommonAppBlocks.Instance.ShowFlowTabController(this.parentForm, viewCustInfoReadOnlyBlk.ClassForm, FlowTabController.State.Customer);
                SetTabsInForm();
                ((ViewCustomerInformation)viewCustInfoReadOnlyBlk.ClassForm).ShowReadOnly = true;
                break;

            case PawnCustInformationFlowState.ViewCustomerInformation:

                ShowForm viewCustInfoBlk = CommonAppBlocks.Instance.ViewCustomerInfoShowBlock(this.parentForm, this.viewCustFormNavAction);
                if (!viewCustInfoBlk.execute())
                {
                    throw new ApplicationException("Cannot execute View customer information block");
                }
                LoadCustomerLoanKeys loanKeysBlk = new LoadCustomerLoanKeys();
                if (!loanKeysBlk.execute())
                {
                    throw new ApplicationException("Cannot get Loan keys for selected customer");
                }

                CommonAppBlocks.Instance.ShowFlowTabController(this.parentForm, viewCustInfoBlk.ClassForm, FlowTabController.State.Customer);
                break;

            case PawnCustInformationFlowState.ViewPawnCustomerProductDetails:
                //If form already there in session then show that else open a new one
                Controller_ProductServices productServFrm = new Controller_ProductServices();
                Form currentForm = GlobalDataAccessor.Instance.DesktopSession.HistorySession.Lookup(productServFrm);
                if (currentForm.GetType() == typeof(Controller_ProductServices))
                {
                    currentForm.Show();
                    currentForm.Activate();
                    CommonAppBlocks.Instance.ShowFlowTabController(this.parentForm, currentForm, FlowTabController.State.ProductsAndServices);
                    if (GlobalDataAccessor.Instance.DesktopSession.PickupProcessContinue)
                    {
                        GlobalDataAccessor.Instance.DesktopSession.LockProductsTab           = true;
                        ((Controller_ProductServices)currentForm).NavControlBox.IsCustom     = true;
                        ((Controller_ProductServices)currentForm).NavControlBox.CustomDetail = "LoanService";
                        ((Controller_ProductServices)currentForm).NavControlBox.Action       = NavBox.NavAction.SUBMIT;
                        ((Controller_ProductServices)currentForm).ContinuePickup             = true;
                    }
                }
                else
                {
                    //Get the loan keys for the selected customer
                    //Before calling view pawn cust prod details
                    LoadCustomerLoanKeys loanKeysDataBlk = new LoadCustomerLoanKeys();
                    if (!loanKeysDataBlk.execute())
                    {
                        throw new ApplicationException("Cannot get Loan keys for selected customer");
                    }

                    ShowForm pawnCustProdDetBlk =
                        CommonAppBlocks.Instance.CreateProductServicesBlock(this.parentForm,
                                                                            this.productServicesFormNavAction);
                    if (!pawnCustProdDetBlk.execute())
                    {
                        throw new ApplicationException("Cannot execute View Pawn Customer Product Details block");
                    }

                    CommonAppBlocks.Instance.ShowFlowTabController(this.parentForm, pawnCustProdDetBlk.ClassForm,
                                                                   FlowTabController.State.ProductsAndServices);
                }

                break;

            case PawnCustInformationFlowState.ViewPawnCustomerStats:

                ShowForm pawnCustStatsBlk = CommonAppBlocks.Instance.CreateStatsBlock(this.parentForm, this.productStatsFormNavAction);
                if (!pawnCustStatsBlk.execute())
                {
                    throw new ApplicationException("Cannot execute View Pawn Customer Stats block");
                }
                CommonAppBlocks.Instance.ShowFlowTabController(this.parentForm, pawnCustStatsBlk.ClassForm, FlowTabController.State.Stats);
                SetTabsInForm();
                break;

            case PawnCustInformationFlowState.ItemHistory:
                ShowForm itemHistBlk = CommonAppBlocks.Instance.CreateItemHistoryShowBlock(this.parentForm, this.itemHistoryFormNavAction);
                if (!itemHistBlk.execute())
                {
                    throw new ApplicationException("Cannot execute Item History block");
                }
                CommonAppBlocks.Instance.ShowFlowTabController(this.parentForm, itemHistBlk.ClassForm, FlowTabController.State.ItemHistory);
                SetTabsInForm();
                break;

            case PawnCustInformationFlowState.ProductHistory:
                ShowForm prodHistBlk = CommonAppBlocks.Instance.CreateProductHistoryShowBlock(this.parentForm, this.productHistoryFormNavAction);
                if (!prodHistBlk.execute())
                {
                    throw new ApplicationException("Cannot execute Product History block");
                }
                CommonAppBlocks.Instance.ShowFlowTabController(this.parentForm, prodHistBlk.ClassForm, FlowTabController.State.ProductHistory);
                SetTabsInForm();
                break;

            case PawnCustInformationFlowState.ViewReceipt:
                ViewReceipt receiptForm = new ViewReceipt();
                Form        recptForm   = GlobalDataAccessor.Instance.DesktopSession.HistorySession.Lookup(receiptForm);
                if (recptForm.GetType() == typeof(ViewReceipt))
                {
                    recptForm.BringToFront();
                }
                else
                {
                    ShowForm viewReceiptBlk =
                        CommonAppBlocks.Instance.CreateViewReceiptBlock(
                            this.parentForm, this.viewReceiptFormNavAction);
                    if (!viewReceiptBlk.execute())
                    {
                        throw new ApplicationException("Cannot execute view receipt block");
                    }
                }
                break;

            case PawnCustInformationFlowState.InvokeMMPIChildFlow:
                //Initiate the child workflow
                CommonAppBlocks.Instance.HideFlowTabController();
                GlobalDataAccessor.Instance.DesktopSession.AppController.invokeWorkflow(MMPIFUNCTIONALITYNAME,
                                                                                        this.parentForm, this.endStateNotifier, this);
                break;

            case PawnCustInformationFlowState.ManagePawnApplication:
                ShowForm managePawnAppBlock = CommonAppBlocks.Instance.CreateManagePawnApplicationBlock(this.parentForm, this.managePawnAppFormNavAction);
                if (!managePawnAppBlock.execute())
                {
                    throw new ApplicationException("Cannot execute Manage Pawn Applicaction block");
                }
                break;

            case PawnCustInformationFlowState.ExistingCustomer:
                ShowForm existCustBlk = CommonAppBlocks.Instance.CreateExistingCustomerBlock(this.parentForm, this.existCustomerFormNavAction);
                if (!existCustBlk.execute())
                {
                    throw new ApplicationException("Cannot execute ExistingCustomer block");
                }
                break;

            case PawnCustInformationFlowState.TenderIn:
                ShowForm tenderInBlk = CommonAppBlocks.Instance.TenderInShowBlock(this.parentForm, this.TenderInFormAction);
                if (!tenderInBlk.execute())
                {
                    throw new ApplicationException("Cannot execute Tender In block");
                }


                break;


            case PawnCustInformationFlowState.CancelFlow:
                CommonAppBlocks.Instance.HideFlowTabController();
                if (this.endStateNotifier != null)
                {
                    this.endStateNotifier.execute();
                }
                break;

            case PawnCustInformationFlowState.ExitFlow:
                if (parentFlow != null)
                {
                    this.parentFlow.execute();
                }
                break;

            default:
                throw new ApplicationException("Invalid Pawn Cust Information flow state");
            }

            return(true);
        }
        private void productServicesFormNavAction(object sender, object data)
        {
            if (sender == null || data == null)
            {
                throw new ApplicationException("Product Services form navigation action handler received invalid data");
            }
            NavBox prodsrvNavBox = (NavBox)sender;
            Controller_ProductServices prodSrvForm = (Controller_ProductServices)data;

            NavBox.NavAction lookupAction = prodsrvNavBox.Action;
            switch (lookupAction)
            {
            case NavBox.NavAction.SUBMIT:
                if (prodsrvNavBox.IsCustom)
                {
                    string custDet = prodsrvNavBox.CustomDetail;
                    if (custDet.Equals("LoanService", StringComparison.OrdinalIgnoreCase))
                    {
                        if (GlobalDataAccessor.Instance.DesktopSession.LockProductsTab)
                        {
                            CommonAppBlocks.Instance.SetFlowTabEnabled(FlowTabController.State.Customer, false);
                            CommonAppBlocks.Instance.SetFlowTabEnabled(FlowTabController.State.ProductsAndServices, true);
                            CommonAppBlocks.Instance.SetFlowTabEnabled(FlowTabController.State.Stats, false);
                            CommonAppBlocks.Instance.SetFlowTabEnabled(FlowTabController.State.ItemHistory, false);
                            CommonAppBlocks.Instance.SetFlowTabEnabled(FlowTabController.State.ProductHistory, false);
                        }
                        else
                        {
                            CommonAppBlocks.Instance.SetFlowTabEnabled(FlowTabController.State.Customer, true);
                            CommonAppBlocks.Instance.SetFlowTabEnabled(FlowTabController.State.ProductsAndServices, true);
                            CommonAppBlocks.Instance.SetFlowTabEnabled(FlowTabController.State.Stats, true);
                            CommonAppBlocks.Instance.SetFlowTabEnabled(FlowTabController.State.ItemHistory, true);
                            CommonAppBlocks.Instance.SetFlowTabEnabled(FlowTabController.State.ProductHistory, true);
                        }
                        return;
                    }
                    if (custDet.Equals("Reload", StringComparison.OrdinalIgnoreCase))
                    {
                        GlobalDataAccessor.Instance.DesktopSession.HistorySession.Back();
                        CommonAppBlocks.Instance.HideFlowTabController();
                        this.nextState = PawnCustInformationFlowState.ViewPawnCustomerProductDetails;
                    }
                    else if (custDet.Equals("ManagePawnApplication", StringComparison.OrdinalIgnoreCase))
                    {
                        GlobalDataAccessor.Instance.DesktopSession.HistorySession.Trigger = Commons.TriggerTypes.VIEWPAWNCUSTPRODDETAILS;
                        prodSrvForm.Hide();
                        CommonAppBlocks.Instance.HideFlowTabController();
                        this.nextState = PawnCustInformationFlowState.ManagePawnApplication;
                    }
                    else if (custDet.Equals("ProcessTender", StringComparison.OrdinalIgnoreCase))
                    {
                        CommonAppBlocks.Instance.HideFlowTabController();
                        GlobalDataAccessor.Instance.DesktopSession.HistorySession.Desktop();
                        this.nextState = PawnCustInformationFlowState.TenderIn;
                    }

                    else
                    {
                        this.nextState = PawnCustInformationFlowState.ViewReceipt;
                    }
                }
                else
                {
                    this.nextState = PawnCustInformationFlowState.CancelFlow;
                }
                break;

            case NavBox.NavAction.BACKANDSUBMIT:
                GlobalDataAccessor.Instance.DesktopSession.HistorySession.Back();
                if (prodsrvNavBox.IsCustom)
                {
                    string custDet = prodsrvNavBox.CustomDetail;
                    if (custDet.Equals("ProductStats"))
                    {
                        this.nextState = PawnCustInformationFlowState.ViewPawnCustomerStats;
                    }
                    else if (custDet.Equals("Customer"))
                    {
                        this.nextState = PawnCustInformationFlowState.ViewCustomerInformation;
                    }
                    else if (custDet.Equals("ItemHistory"))
                    {
                        this.nextState = PawnCustInformationFlowState.ItemHistory;
                    }
                    else if (custDet.Equals("ProductHistory"))
                    {
                        this.nextState = PawnCustInformationFlowState.ProductHistory;
                    }
                }
                break;

            case NavBox.NavAction.BACK:
                if (prodsrvNavBox.IsCustom && prodsrvNavBox.CustomDetail.Equals("Menu", StringComparison.OrdinalIgnoreCase))
                {
                    this.nextState = PawnCustInformationFlowState.CancelFlow;
                }
                else
                {
                    GlobalDataAccessor.Instance.DesktopSession.HistorySession.Back();
                    CommonAppBlocks.Instance.HideFlowTabController();
                    this.nextState = PawnCustInformationFlowState.ExitFlow;
                }
                break;

            default:
                throw new ApplicationException("" + lookupAction.ToString() + " is not a valid state for Products and services");
            }

            this.executeNextState();
        }