/// <summary> /// called when the form's Show() method is called /// </summary> /// <param name="e"></param> protected override void OnShown(EventArgs e) { base.OnShown(e); //if there is a default db, open it, if not, open the view database form if (_config.AppSettings.Settings[Constants.Settings.DEFAULT_DB].Value == "") { this.OpenViewDatabaseForm(); } else { FileInfo db = new FileInfo(_config.AppSettings.Settings[Constants.Settings.DEFAULT_DB].Value); if (db.Exists) { this.CurrentDatabase = db; ViewBooksForm form = new ViewBooksForm(Constants.LibraryMode.LIBRARY); form.MdiParent = this; form.Show(); } else { _config.AppSettings.Settings[Constants.Settings.DEFAULT_DB].Value = ""; _config.Save(System.Configuration.ConfigurationSaveMode.Modified); this.OpenViewDatabaseForm(); } } }
private void viewWishlistToolStripMenuItem1_Click(object sender, EventArgs e) { ViewBooksForm form = new ViewBooksForm(Constants.LibraryMode.WISHLIST); form.MdiParent = this; form.Show(); }
void ViewLibraryToolStripMenuItemClick(object sender, EventArgs e) { ViewBooksForm form = new ViewBooksForm(Constants.LibraryMode.LIBRARY); form.MdiParent = this; form.Show(); }
/// <summary> /// Called when the "open" button is clicked on this form /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnOpen_Click(object sender, EventArgs e) { FileInfo currentDB = this.getSelectedDatabase(); if (currentDB == null) return; MainForm parent = this.MdiParent as MainForm; BaseInfoDAO dao = new BaseInfoDAO(currentDB.FullName); BaseInfo baseInfo = dao.GetBaseInfo(); if (!baseInfo.Password.Equals("")) { PasswordPrompt prompt = new PasswordPrompt(baseInfo.Password); if (prompt.ShowDialog() != DialogResult.OK) return; } MainForm form = (MainForm)this.MdiParent; form.CurrentDatabase = currentDB; this.Close(); foreach (Form f in parent.MdiChildren) f.Close(); ViewBooksForm booksForm = new ViewBooksForm(Constants.LibraryMode.LIBRARY); booksForm.MdiParent = form; booksForm.Show(); }
private void viewLoanedBooksToolStripMenuItem1_Click(object sender, EventArgs e) { ViewBooksForm form = new ViewBooksForm(Constants.LibraryMode.LOANEDBOOKS); form.MdiParent = this; form.Show(); }
/// <summary> /// Called when the "open" button is clicked on this form /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnOpen_Click(object sender, EventArgs e) { FileInfo currentDB = this.getSelectedDatabase(); if (currentDB == null) { return; } MainForm parent = this.MdiParent as MainForm; BaseInfoDAO dao = new BaseInfoDAO(currentDB.FullName); BaseInfo baseInfo = dao.GetBaseInfo(); if (!baseInfo.Password.Equals("")) { PasswordPrompt prompt = new PasswordPrompt(baseInfo.Password); if (prompt.ShowDialog() != DialogResult.OK) { return; } } MainForm form = (MainForm)this.MdiParent; form.CurrentDatabase = currentDB; this.Close(); foreach (Form f in parent.MdiChildren) { f.Close(); } ViewBooksForm booksForm = new ViewBooksForm(Constants.LibraryMode.LIBRARY); booksForm.MdiParent = form; booksForm.Show(); }
/// <summary> /// called when OK button is clicked /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnOk_Click(object sender, EventArgs e) { int errors = 0; //check and make sure everything is filled out errors += UIUtils.ValidationHelper(this.txtOwner.Text.Length == 0,this.errorProvider1,this.txtOwner,ErrorMessages.Common.REQUIRED_FIELD); errors += UIUtils.ValidationHelper(this.txtLibrary.Text.Length == 0,this.errorProvider1,this.txtLibrary,ErrorMessages.Common.REQUIRED_FIELD); errors += UIUtils.ValidationHelper(this.chkProtected.Checked == true && this.txtPassword.Text.Length == 0,this.errorProvider1,this.txtPassword,ErrorMessages.NewDBForm.PASSWORD); if (errors > 0) return; //copy the empty database and rename it FileInfo emptyDB = new FileInfo("emdata"); if(!emptyDB.Exists) { MessageBox.Show(emptyDB.FullName); MessageBox.Show(ErrorMessages.NewDBForm.EMPTY_DB_MISSING,"Error",MessageBoxButtons.OK,MessageBoxIcon.Error); this.Close(); return; } string newFileName = this.txtLibrary.Text.Replace(" ","_") + ".plb"; //check to make sure we're not writing over anything FileInfo newFile = new FileInfo(newFileName); if (newFile.Exists) { MessageBox.Show(ErrorMessages.NewDBForm.DB_ALREADY_EXISTS, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } try { newFile = emptyDB.CopyTo(newFileName); } catch (Exception e1) { ExceptionHandler.HandleException(e1); this.Close(); return; } if (!newFile.Exists) { MessageBox.Show(ErrorMessages.NewDBForm.DB_NOT_CREATED, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //if we reached here, we have a database, now initialize it BaseInfoDAO dao = new BaseInfoDAO(newFileName); bool success = dao.InitializeDatabase(this.txtOwner.Text, this.txtLibrary.Text, this.txtPassword.Text); if (!success) { MessageBox.Show(ErrorMessages.NewDBForm.DB_NOT_CREATED, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); newFile.Delete(); } else { if (DialogResult.Yes == MessageBox.Show(Messages.NewDBForm.DB_CREATED, "Success", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { MainForm form = (MainForm)this.MdiParent; form.CurrentDatabase = newFile; //check and see if there is a ViewDB window open, if so, close it Form[] children = form.MdiChildren; foreach (Form f in children) { if (f is ViewDatabasesForm) f.Close(); } ViewBooksForm f2 = new ViewBooksForm(Constants.LibraryMode.LIBRARY); f2.MdiParent = this.MdiParent; f2.Show(); } else { //check for a view database window, and refresh it MainForm form = (MainForm)this.MdiParent; Form[] children = form.MdiChildren; foreach (Form f in children) { if (f is ViewDatabasesForm) f.Refresh(); } } } this.Close(); }
/// <summary> /// called when the form's Show() method is called /// </summary> /// <param name="e"></param> protected override void OnShown(EventArgs e) { base.OnShown(e); //if there is a default db, open it, if not, open the view database form if (_config.AppSettings.Settings[Constants.Settings.DEFAULT_DB].Value == "") { this.OpenViewDatabaseForm(); } else { FileInfo db = new FileInfo(_config.AppSettings.Settings[Constants.Settings.DEFAULT_DB].Value); if (db.Exists) { this.CurrentDatabase = db; ViewBooksForm form = new ViewBooksForm(Constants.LibraryMode.LIBRARY); form.MdiParent = this; form.Show(); } else { _config.AppSettings.Settings[Constants.Settings.DEFAULT_DB].Value = ""; _config.Save(System.Configuration.ConfigurationSaveMode.Modified); this.OpenViewDatabaseForm(); } } }
void ViewLibraryToolStripMenuItemClick(object sender, EventArgs e) { ViewBooksForm form = new ViewBooksForm(Constants.LibraryMode.LIBRARY); form.MdiParent = this; form.Show(); }
private void viewWishlistToolStripMenuItem1_Click(object sender, EventArgs e) { ViewBooksForm form = new ViewBooksForm(Constants.LibraryMode.WISHLIST); form.MdiParent = this; form.Show(); }
private void viewLoanedBooksToolStripMenuItem1_Click(object sender, EventArgs e) { ViewBooksForm form = new ViewBooksForm(Constants.LibraryMode.LOANEDBOOKS); form.MdiParent = this; form.Show(); }
/// <summary> /// Called when right click -> view loan history is clicked /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void viewLoanHistoryToolStripMenuItem_Click(object sender, EventArgs e) { foreach (string id in this.SelectedIds) { ViewBooksForm form = new ViewBooksForm(Constants.LibraryMode.LOANHISTORY, id); form.MdiParent = this.ParentForm.MdiParent; form.Show(); } }
/// <summary> /// called when OK button is clicked /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnOk_Click(object sender, EventArgs e) { int errors = 0; //check and make sure everything is filled out errors += UIUtils.ValidationHelper(this.txtOwner.Text.Length == 0, this.errorProvider1, this.txtOwner, ErrorMessages.Common.REQUIRED_FIELD); errors += UIUtils.ValidationHelper(this.txtLibrary.Text.Length == 0, this.errorProvider1, this.txtLibrary, ErrorMessages.Common.REQUIRED_FIELD); errors += UIUtils.ValidationHelper(this.chkProtected.Checked == true && this.txtPassword.Text.Length == 0, this.errorProvider1, this.txtPassword, ErrorMessages.NewDBForm.PASSWORD); if (errors > 0) { return; } //copy the empty database and rename it FileInfo emptyDB = new FileInfo("emdata"); if (!emptyDB.Exists) { MessageBox.Show(emptyDB.FullName); MessageBox.Show(ErrorMessages.NewDBForm.EMPTY_DB_MISSING, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; } string newFileName = this.txtLibrary.Text.Replace(" ", "_") + ".plb"; //check to make sure we're not writing over anything FileInfo newFile = new FileInfo(newFileName); if (newFile.Exists) { MessageBox.Show(ErrorMessages.NewDBForm.DB_ALREADY_EXISTS, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } try { newFile = emptyDB.CopyTo(newFileName); } catch (Exception e1) { ExceptionHandler.HandleException(e1); this.Close(); return; } if (!newFile.Exists) { MessageBox.Show(ErrorMessages.NewDBForm.DB_NOT_CREATED, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //if we reached here, we have a database, now initialize it BaseInfoDAO dao = new BaseInfoDAO(newFileName); bool success = dao.InitializeDatabase(this.txtOwner.Text, this.txtLibrary.Text, this.txtPassword.Text); if (!success) { MessageBox.Show(ErrorMessages.NewDBForm.DB_NOT_CREATED, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); newFile.Delete(); } else { if (DialogResult.Yes == MessageBox.Show(Messages.NewDBForm.DB_CREATED, "Success", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { MainForm form = (MainForm)this.MdiParent; form.CurrentDatabase = newFile; //check and see if there is a ViewDB window open, if so, close it Form[] children = form.MdiChildren; foreach (Form f in children) { if (f is ViewDatabasesForm) { f.Close(); } } ViewBooksForm f2 = new ViewBooksForm(Constants.LibraryMode.LIBRARY); f2.MdiParent = this.MdiParent; f2.Show(); } else { //check for a view database window, and refresh it MainForm form = (MainForm)this.MdiParent; Form[] children = form.MdiChildren; foreach (Form f in children) { if (f is ViewDatabasesForm) { f.Refresh(); } } } } this.Close(); }