Ejemplo n.º 1
0
        private void setUserServices()
        {
            //Set user services
            try {
                //Set menu states
                IToolbar window = (IToolbar)this.mActiveForm;
                this.msFileNew.Enabled       = this.tsbNew.Enabled = window != null && window.CanNew;
                this.msFileOpen.Enabled      = this.tsbOpen.Enabled = window != null && window.CanOpen;
                this.msFileCancel.Enabled    = this.tsbCancel.Enabled = window != null && window.CanCancel;
                this.msFileSave.Enabled      = this.tsbSave.Enabled = false;
                this.msFileSaveAs.Enabled    = window != null && window.CanSave;
                this.msFilePageSetup.Enabled = true;
                this.msFilePrint.Enabled     = this.tsbPrint.Enabled = window != null && window.CanPrint;
                this.msFilePreview.Enabled   = window != null && window.CanPreview;
                this.msFileExit.Enabled      = true;
                this.msEditSearch.Enabled    = false;
                this.msViewRefresh.Enabled   = this.tsbRefresh.Enabled = window != null;
                this.msViewToolbar.Enabled   = this.msViewStatusBar.Enabled = true;
                this.msToolsConfig.Enabled   = true;
                this.msHelpAbout.Enabled     = true;

                if (this.mActiveForm is IPSPToolbar)
                {
                    IPSPToolbar pspwindow = (IPSPToolbar)this.mActiveForm;
                    this.tsbApprove.Enabled        = pspwindow.CanApproveClient;
                    this.tsbDeny.Enabled           = pspwindow.CanDenyClient;
                    this.tsbPrintLabels.Enabled    = pspwindow.CanPrintLabels;
                    this.tsbPrintPaperwork.Enabled = pspwindow.CanPrintPaperwork;
                }
                else
                {
                    this.tsbApprove.Enabled = this.tsbDeny.Enabled = this.tsbPrintLabels.Enabled = this.tsbPrintPaperwork.Enabled = false;
                }

                if (this.mActiveForm is IQuoteToolbar)
                {
                    IQuoteToolbar quotewindow = (IQuoteToolbar)this.mActiveForm;
                    this.tsbApproveQuote.Enabled = quotewindow.CanApproveQuote;
                    this.tsbTenderQuote.Enabled  = quotewindow.CanTenderQuote;
                    this.tsbViewTender.Enabled   = quotewindow.CanViewTender;
                    this.tsbBookQuote.Enabled    = quotewindow.CanBookQuote;
                }
                else
                {
                    this.tsbApproveQuote.Enabled = this.tsbTenderQuote.Enabled = this.tsbViewTender.Enabled = this.tsbBookQuote.Enabled = false;
                }

                this.ssMain.OnOnlineStatusUpdate(null, new OnlineStatusArgs(FreightGateway.ServiceState, FreightGateway.ServiceAddress));
            }
            catch (Exception ex) { App.ReportError(ex, false, LogLevel.Warning); }
            finally { Application.DoEvents(); }
        }
Ejemplo n.º 2
0
        private void OnItemClick(object sender, System.EventArgs e)
        {
            //Menu services
            IToolbar      window      = null;
            IPSPToolbar   pspwindow   = null;
            IQuoteToolbar quotewindow = null;

            try {
                ToolStripItem menu = (ToolStripItem)sender;
                switch (menu.Name)
                {
                case "msFileNew":
                case "tsbNew":
                    window = (IToolbar)this.mActiveForm;
                    window.New();
                    break;

                case "msFileOpen":
                case "tsbOpen":
                    window = (IToolbar)this.mActiveForm;
                    window.Open();
                    break;

                case "msFileCancel":
                case "tsbCancel":
                    window = (IToolbar)this.mActiveForm;
                    window.Cancel();
                    break;

                case "msFileSave":
                case "tsbSave":
                    break;

                case "msFileSaveAs":
                    SaveFileDialog dlgSave = new SaveFileDialog();
                    dlgSave.AddExtension     = true;
                    dlgSave.Filter           = "Excel files (*.xls)|*.xls|All files (*.*)|*.*";
                    dlgSave.FilterIndex      = 0;
                    dlgSave.Title            = "Export...";
                    dlgSave.FileName         = "";
                    dlgSave.CheckFileExists  = false;
                    dlgSave.OverwritePrompt  = true;
                    dlgSave.InitialDirectory = System.IO.Directory.GetCurrentDirectory();
                    if (dlgSave.ShowDialog(this) == DialogResult.OK)
                    {
                        window = (IToolbar)this.mActiveForm;
                        window.Save(dlgSave.FileName);
                    }
                    break;

                case "msFilePageSetup":
                    UltraGridPrinter.PageSettings();
                    break;

                case "msFilePrint":
                    window = (IToolbar)this.mActiveForm;
                    window.Print(true);
                    break;

                case "tsbPrint":
                    window = (IToolbar)this.mActiveForm;
                    window.Print(false);
                    break;

                case "msFilePreview":
                    window = (IToolbar)this.mActiveForm;
                    window.PrintPreview();
                    break;

                case "msFileExit":
                    this.Close();
                    break;

                case "msViewRefresh":
                case "tsbRefresh":
                    this.Cursor = Cursors.WaitCursor;
                    this.mMessageMgr.AddMessage("Refreshing...");
                    this.mActiveForm.Refresh();
                    break;

                case "msViewFont":
                    FontDialog fd = new FontDialog();
                    fd.FontMustExist = true;
                    fd.Font          = this.Font;
                    if (fd.ShowDialog() == DialogResult.OK)
                    {
                        this.Font = this.msMain.Font = this.tsMain.Font = this.tsNav.Font = this.ssMain.Font = fd.Font;
                    }
                    break;

                case "msViewToolbar":
                    this.msViewToolbar.Checked = (!this.msViewToolbar.Checked);
                    this.tsMain.Visible        = this.msViewToolbar.Checked;
                    break;

                case "msViewStatusBar":
                    this.msViewStatusBar.Checked = (!this.msViewStatusBar.Checked);
                    this.ssMain.Visible          = this.msViewStatusBar.Checked;
                    break;

                case "msApprove":
                case "tsbApprove":
                    pspwindow = (IPSPToolbar)this.mActiveForm;
                    pspwindow.ApproveClient();
                    break;

                case "msDeny":
                case "tsbDeny":
                    pspwindow = (IPSPToolbar)this.mActiveForm;
                    pspwindow.DenyClient();
                    break;

                case "msPrintLabels":
                case "tsbPrintLabels":
                    pspwindow = (IPSPToolbar)this.mActiveForm;
                    pspwindow.PrintLabels();
                    break;

                case "msPrintPaperwork":
                case "tsbPrintPaperwork":
                    pspwindow = (IPSPToolbar)this.mActiveForm;
                    pspwindow.PrintPaperwork();
                    break;

                case "tsbApproveQuote":
                    quotewindow = (IQuoteToolbar)this.mActiveForm;
                    quotewindow.ApproveQuote();
                    break;

                case "tsbTenderQuote":
                    quotewindow = (IQuoteToolbar)this.mActiveForm;
                    quotewindow.TenderQuote();
                    break;

                case "tsbViewTender":
                    quotewindow = (IQuoteToolbar)this.mActiveForm;
                    quotewindow.ViewTender();
                    break;

                case "tsbBookQuote":
                    quotewindow = (IQuoteToolbar)this.mActiveForm;
                    quotewindow.BookQuote();
                    break;

                case "msToolsConfig":
                    App.ShowConfig();
                    break;

                case "msWinCascade": this.LayoutMdi(MdiLayout.Cascade); break;

                case "msWinTileH": this.LayoutMdi(MdiLayout.TileHorizontal); break;

                case "msWinTileV": this.LayoutMdi(MdiLayout.TileVertical); break;

                case "msHelpAbout": new dlgAbout(App.Description, App.Version, App.Copyright, App.Configuration).ShowDialog(this); break;
                }
            }
            catch (Exception ex) { App.ReportError(ex, true, LogLevel.Error); }
            finally { setUserServices(); this.Cursor = Cursors.Default; }
        }