Ejemplo n.º 1
0
        private void openDriverComp()
        {
            //Create a new ship schedule
            dlgOpen dlg = new dlgOpen();

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                //Validate
                DriverComp    driverComp = new DriverComp(dlg.AgentNumber, dlg.AgentName, dlg.StartDate, dlg.EndDate, App.Mediator);
                winDriverComp win        = null;
                for (int i = 0; i < this.MdiChildren.Length; i++)
                {
                    win = (winDriverComp)this.MdiChildren[i];
                    if (win.Compensation.Title == driverComp.Title)
                    {
                        //Already open; bring to forefront
                        win.Activate();
                        if (win.WindowState == FormWindowState.Minimized)
                        {
                            win.WindowState = FormWindowState.Normal;
                        }
                        break;
                    }
                    else
                    {
                        win = null;
                    }
                }
                if (win == null)
                {
                    this.mMessageMgr.AddMessage("Opening " + driverComp.AgentName.Trim() + " driver pay for week ending " + driverComp.EndDate + "...");
                    win                       = new winDriverComp(driverComp);
                    win.WindowState           = (this.MdiChildren.Length > 0) ? this.MdiChildren[0].WindowState : FormWindowState.Maximized;
                    win.MdiParent             = this;
                    win.Activated            += new EventHandler(OnDCActivated);
                    win.Deactivate           += new EventHandler(OnDCDeactivated);
                    win.Closing              += new CancelEventHandler(OnDCClosing);
                    win.Closed               += new EventHandler(OnDCClosed);
                    win.ServiceStatesChanged += new EventHandler(OnDCServiceChange);
                    win.StatusMessage        += new StatusEventHandler(OnDCStatus);
                    win.Show();
                }
            }
        }
Ejemplo n.º 2
0
        private void OnItemClick(object sender, System.EventArgs e)
        {
            //Menu services
            bool show = false;

            try {
                ToolStripItem menu = (ToolStripItem)sender;
                switch (menu.Name)
                {
                case "msFileNew":
                case "tsNew":
                    break;

                case "msFileOpen":
                case "tsOpen":
                    dlgOpen dlg = new dlgOpen();
                    dlg.Font = this.Font;
                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        CompensationAgent compAgent = new CompensationAgent(dlg.AgentNumber, dlg.AgentName, dlg.StartDate, dlg.EndDate);
                        winDriverComp     win       = null;
                        int winCount = this.MdiChildren.Length;
                        for (int i = 0; i < this.MdiChildren.Length; i++)
                        {
                            win = (winDriverComp)this.MdiChildren[i];
                            if (win.Agent.Title == compAgent.Title)
                            {
                                win.Activate();
                                if (win.WindowState == FormWindowState.Minimized)
                                {
                                    win.WindowState = FormWindowState.Normal;
                                }
                                break;
                            }
                            else
                            {
                                win = null;
                            }
                        }
                        if (win == null)
                        {
                            this.mMessageMgr.AddMessage("Opening " + compAgent.AgentName.Trim() + " driver pay for week ending " + compAgent.EndDate + "...");
                            win                       = new winDriverComp(compAgent);
                            win.MdiParent             = this;
                            win.Activated            += new EventHandler(OnDCActivated);
                            win.Deactivate           += new EventHandler(OnDCDeactivated);
                            win.Closing              += new CancelEventHandler(OnDCClosing);
                            win.Closed               += new EventHandler(OnDCClosed);
                            win.ServiceStatesChanged += new EventHandler(OnDCServiceChange);
                            win.StatusMessage        += new StatusEventHandler(OnDCStatus);
                            win.WindowState           = (winCount > 0) ? this.MdiChildren[0].WindowState : FormWindowState.Maximized;
                            win.Show();
                        }
                    }
                    break;

                case "msFileSave":
                case "tsSave":
                    this.mActiveDC.Save();
                    break;

                case "msFileSaveAs":
                    this.mActiveDC.SaveAs();
                    break;

                case "msFileAddRoutes":
                case "tsAddRoutes":
                    this.mActiveDC.AddRoutes();
                    break;

                case "msFileExport":
                case "tsExport":
                    this.mActiveDC.Export();
                    break;

                case "msFileSetup":            this.mActiveDC.PrintSetup(); break;

                case "msFilePrint":            this.mActiveDC.Print(true); break;

                case "tsPrint":                this.mActiveDC.Print(false);; break;

                case "msFilePreview":          this.mActiveDC.PrintPreview(); break;

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

                case "msEditCut":
                case "tsCut":
                    this.mActiveDC.Cut();
                    break;

                case "msEditCopy":
                case "tsCopy":
                    this.mActiveDC.Copy();
                    break;

                case "msEditPaste":
                case "tsPaste":
                    this.mActiveDC.Paste();
                    break;

                case "msEditDelete":
                case "tsDelete":
                    this.mActiveDC.Delete();
                    break;

                case "msEditCheckAll":
                    this.mActiveDC.CheckAll();
                    break;

                case "msEditFind":
                    break;

                case "msViewRefresh":
                case "tsRefresh":
                    this.Cursor = Cursors.WaitCursor;
                    this.mActiveDC.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.ssMain.Font = fd.Font;
                    }
                    break;

                case "msViewRoutes":
                    this.mActiveDC.RoutesVisible = (this.msViewRoutes.Checked = (!this.msViewRoutes.Checked));
                    break;

                case "msViewTermConfigs":
                    show = this.msViewTermConfigs.Checked = !this.msViewTermConfigs.Checked;
                    if (show)
                    {
                        this.tabMain.TabPages.Add(this.tabTerm);
                    }
                    else
                    {
                        this.tabMain.TabPages.Remove(this.tabTerm);
                    }
                    if (show)
                    {
                        this.tabMain.SelectedTab = this.tabTerm;
                    }
                    this.tabMain.Visible = this.splitterH.Visible = (this.tabMain.TabPages.Count > 0);
                    break;

                case "msViewEquip":
                    show = this.msViewEquip.Checked = !this.msViewEquip.Checked;
                    if (show)
                    {
                        this.tabMain.TabPages.Add(this.tabEquip);
                    }
                    else
                    {
                        this.tabMain.TabPages.Remove(this.tabEquip);
                    }
                    if (show)
                    {
                        this.tabMain.SelectedTab = this.tabEquip;
                    }
                    this.tabMain.Visible = this.splitterH.Visible = (this.tabMain.TabPages.Count > 0);
                    break;

                case "msViewRates":
                    show = this.msViewRates.Checked = !this.msViewRates.Checked;
                    if (show)
                    {
                        this.tabMain.TabPages.Add(this.tabRates);
                    }
                    else
                    {
                        this.tabMain.TabPages.Remove(this.tabRates);
                    }
                    if (show)
                    {
                        this.tabMain.SelectedTab = this.tabRates;
                    }
                    this.tabMain.Visible = this.splitterH.Visible = (this.tabMain.TabPages.Count > 0);
                    break;

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

                case "msViewStatusBar":        this.ssMain.Visible = (this.msViewStatusBar.Checked = (!this.msViewStatusBar.Checked)); 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.Product + " Application", App.Version, App.Copyright, App.Configuration).ShowDialog(this); break;
                }
            }
            catch (Exception ex) { App.ReportError(ex, true, LogLevel.Warning); }
            finally { setUserServices(); this.Cursor = Cursors.Default; }
        }