Ejemplo n.º 1
0
        private void MDIForm_Load(object sender, EventArgs e)
        {
            this.WindowState = Properties.Settings.Default.LastMDIWindowState;
            if (Properties.Settings.Default.LastMDIWindowState == FormWindowState.Normal)
            {
                Size lastSize = Properties.Settings.Default.LastMDIFormSize;
                if (!lastSize.IsEmpty)
                {
                    this.Size = Properties.Settings.Default.LastMDIFormSize;
                }
            }

            string filePath = Properties.Settings.Default.LastlyOpenedFYPath;

            if (!string.IsNullOrWhiteSpace(filePath))
            {
                if (File.Exists(filePath))
                {
                    FileInfo fileInfo = new FileInfo(filePath);
                    if (fileInfo.Directory.Parent.FullName.Equals(Properties.Settings.Default.DatabasePath))
                    {
                        FinancialYear financialYear = GlobalMethods.getFinancialYear(filePath);
                        if (financialYear != null)
                        {
                            Global.CurrentFinancialYear = financialYear;
                            this.Text = Global.AssemblyTitle + " (Financial Year: " +
                                        financialYear.ToString() + ")";
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void okButton_Click(object sender, EventArgs e)
        {
            FinancialYear selectedYear = (FinancialYear)financialYearsListBox.SelectedItem;

            string message = "Are you sure that you want to delete the financial year " +
                             selectedYear.ToString() + "?";

            SystemSounds.Question.Play();

            DialogResult result = MessageBox.Show(message, "Confirm Deletion", MessageBoxButtons.YesNo,
                                                  MessageBoxIcon.Question);

            if (result == System.Windows.Forms.DialogResult.No)
            {
                return;
            }

            if (Global.CurrentFinancialYear != null && Global.CurrentFinancialYear.StartYear ==
                selectedYear.StartYear)
            {
                if (!GlobalMethods.closeCurrentlyOpenYear())
                {
                    return;
                }
            }

            if (!deleteFinancialYear(selectedYear))
            {
                return;
            }

            financialYearsListBox.Items.Remove(selectedYear);
            SystemSounds.Asterisk.Play();
            MessageBox.Show("The financial year " + selectedYear.ToString() + " was successfully deleted.",
                            "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Ejemplo n.º 3
0
        private bool deleteFinancialYear(FinancialYear year)
        {
            try
            {
                File.Delete(year.FilePath);
            }
            catch (Exception ex)
            {
                string message = "An error occurred in deleting the database file for the financial year " +
                                 year.ToString() + "\nThe error text is as follows:\n" + Global.getExceptionText(ex);
                SystemSounds.Hand.Play();
                Cursor.Current = Cursors.Default;
                MessageBox.Show(message, "Error Occurred", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                ErrorLogger.LogError(ex);
                return(false);
            }

            return(true);
        }