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; } }
static void Main(string[] args) { LibraryApp libApp = new LibraryApp(); libApp.Initialization(); libApp.Run(); }
public void IsDateInRightFormatTest(string date, bool expected) { LibraryApp app = new LibraryApp(); bool result = app.IsDateInRightFormat(date); Assert.AreEqual(expected, result); }
private void mnuSave_Click(object sender, EventArgs e) { if (dlgSaveFile.ShowDialog() == DialogResult.OK) { LibraryApp.WriteBooks(dlgSaveFile.FileName, lstBooks.Items); dataModified = false; } }
public void ValidateStringTest(string input, bool expected) { LibraryApp app = new LibraryApp(); bool result = app.ValidateString(input); Assert.AreEqual(expected, result); }
public void IsDigitsOnlyFormatTest(string number, bool expected) { LibraryApp app = new LibraryApp(); bool result = app.IsDigitsOnly(number); Assert.AreEqual(expected, result); }
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); } }
static void Main(string[] args) { var app = new LibraryApp(); app.StartApp(); }