Пример #1
0
        private void frmAdmin_FormClosing(object sender, FormClosingEventArgs e)
        {
            DialogResult r;

            // Allow the user to save the updated data
            if (!dataModified)
            {
                return;
            }
            r = MessageBox.Show("Save changes before closing?", "Save",
                                MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (r == DialogResult.No)
            {
                return;
            }
            // Save the data in a file.
            if (dlgSaveFile.ShowDialog() != DialogResult.OK)
            {
                e.Cancel = true;
                return;
            }
            try
            {
                LibraryApp.WriteBooks(dlgSaveFile.FileName,
                                      lstBooks.Items);
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message, "Error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                e.Cancel = true;
                return;
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            LibraryApp libApp = new LibraryApp();

            libApp.Initialization();
            libApp.Run();
        }
Пример #3
0
        public void IsDateInRightFormatTest(string date, bool expected)
        {
            LibraryApp app = new LibraryApp();

            bool result = app.IsDateInRightFormat(date);

            Assert.AreEqual(expected, result);
        }
Пример #4
0
 private void mnuSave_Click(object sender, EventArgs e)
 {
     if (dlgSaveFile.ShowDialog() == DialogResult.OK)
     {
         LibraryApp.WriteBooks(dlgSaveFile.FileName, lstBooks.Items);
         dataModified = false;
     }
 }
Пример #5
0
        public void ValidateStringTest(string input, bool expected)
        {
            LibraryApp app = new LibraryApp();


            bool result = app.ValidateString(input);

            Assert.AreEqual(expected, result);
        }
Пример #6
0
        public void IsDigitsOnlyFormatTest(string number, bool expected)
        {
            LibraryApp app = new LibraryApp();


            bool result = app.IsDigitsOnly(number);

            Assert.AreEqual(expected, result);
        }
Пример #7
0
 private void mnuOpen_Click(object sender, EventArgs e)
 {
     try
     {
         lstBooks.Items.Clear();
         if (dlgOpenFile.ShowDialog() == DialogResult.OK)
         {
             LibraryApp.ReadBooks(dlgOpenFile.FileName, lstBooks.Items);
             if (lstBooks.Items.Count > 0)
             {
                 lstBooks.SelectedIndex = 0;
                 mnuDelete.Enabled      = true;
             }
             mnuOpen.Enabled   = false;
             mnuSave.Enabled   = true;
             mnuModify.Enabled = true;
             mnuAdd.Enabled    = true;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Пример #8
0
        static void Main(string[] args)
        {
            var app = new LibraryApp();

            app.StartApp();
        }