Exemplo n.º 1
0
        private bool TestConnection()
        {
            while (true)
            {
                //try
                //{
                if (DBSettings.TestConnection())
                {
                    return(true);
                }
                else
                //{
                //}
                //catch (MyException myex)
                {
                    try
                    {
                        if (DialogResult.No == MessageBox.Show("A connection could not be made to the database.  Please check your connection information.  Click \"Yes\" to try again or \"No\" to exit.", "Database Error", MessageBoxButtons.YesNo))
                        {
                            Environment.Exit(0);
                        }

                        frmOptions frm = new frmOptions();
                        frm.ShowInTaskbar = true;
                        frm.StartPosition = FormStartPosition.CenterScreen;
                        frm.Text          = Application.CompanyName + " " + Application.ProductName + " Database Connection";
                        frm.ShowDialog();

                        if (frm.IsEmpty())
                        {
                            return(false);
                        }
                    }
                    catch (ArgumentException)
                    {
                        frmOptions frm = new frmOptions();
                        frm.ShowInTaskbar = true;
                        frm.StartPosition = FormStartPosition.CenterScreen;
                        frm.Text          = Application.CompanyName + " " + Application.ProductName + " Database Connection";
                        frm.ShowDialog();

                        if (frm.IsEmpty())
                        {
                            return(false);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void mnuMain_Click(object sender, EventArgs e)
        {
            if (CanChangeCurrentDefendant())
            {
                if (sender.Equals(mnuMainFileExit))
                {
                    Environment.Exit(0);
                }
                else if (sender.Equals(mnuMainToolsOptions))
                {
                    frmOptions frm = new frmOptions();
                    frm.FormClosed += new FormClosedEventHandler(frm_FormClosed);
                    frm.ShowDialog(this);

                    BindData();
                }
                else if (sender.Equals(mnuMainListsEmployers))
                {
                    frmEmployers frm = new frmEmployers();

                    if (!frm.IsDisposed)
                    {
                        frm.ShowDialog(this);
                        BindData();
                    }
                }
                else if (sender.Equals(mnuMainListsFeeTypes))
                {
                    frmFeeTypes frm = new frmFeeTypes();
                    if (!frm.IsDisposed)
                    {
                        frm.ShowDialog(this);
                        BindData();
                    }
                }
                else if (sender.Equals(mnuMainListsPaymentArrangementTypes))
                {
                    frmPaymentArrangementTypes frm = new frmPaymentArrangementTypes();
                    if (!frm.IsDisposed)
                    {
                        frm.ShowDialog(this);
                        BindData();
                    }
                }
                else if (sender.Equals(mnuMainListsRestrictedCasePrefixes))
                {
                    frmRestrictedCasePrefixes frm = new frmRestrictedCasePrefixes();
                    if (!frm.IsDisposed)
                    {
                        frm.ShowDialog(this);
                        BindData();
                    }
                }
                else if (sender.Equals(mnuMainReportsMailMerge))
                {
                    this.Cursor = Cursors.WaitCursor;

                    frmMailMerge frm = new frmMailMerge();
                    if (!frm.IsDisposed)
                    {
                        // open, but don't try to own
                        frm.Show();
                    }

                    Application.DoEvents();
                    this.Cursor = Cursors.Default;
                }
                else if (sender.Equals(mnuMainReportsSSRS))
                {
                    this.Cursor = Cursors.WaitCursor;

                    frmSSRS frm = new frmSSRS();
                    if (!frm.IsDisposed)
                    {
                        // open, but don't try to own
                        frm.Show();
                    }

                    Application.DoEvents();

                    this.Cursor = Cursors.Default;
                }
                else if (sender.Equals(mnuMainToolsOptionsPrintDelinquentLetters))
                {
                    PrintDialog diag = new PrintDialog();

                    if (diag.ShowDialog() == DialogResult.OK)
                    {
                        PrintDelinquent print = new PrintDelinquent();
                        print.PrintDocuments(diag.PrinterSettings.PrinterName, DateTime.Now);
                    }
                }
            }
        }