/// <summary> /// Constructor /// </summary> /// <param name="libMode"></param> public ViewBooksForm(Constants.LibraryMode libMode) { _libMode = libMode; InitializeComponent(); this.bookGrid1.LibraryMode = _libMode; this.bookGrid1.BookId = null; this.bookSearch1.BookGrid = this.bookGrid1; }
public AddBookForm(Constants.LibraryMode libMode, Constants.AddBookMode addMode, string bookId) { _libraryMode = libMode; _addMode = addMode; InitializeComponent(); //this.chkAutoAdd.CheckedChanged += new EventHandler(chkAutoAdd_CheckedChanged); this.btnSave.Click += new EventHandler(btnSave_Click); this.btnClear.Click += new EventHandler(btnClear_Click); this.btnLookUp.Click += new EventHandler(btnLookUp_Click); this.cboLookupBy.Items.Add(new DDItem("ISBN","isbn")); // TODO: Readd and test // this.cboLookupBy.Items.Add(new DDItem("Lib. Congr. #", "lcc_number")); this.cboLookupBy.SelectedIndex = 0; if (_addMode == Constants.AddBookMode.VIEWONLY) { this.chkAutoAdd.Visible = false; this.btnClear.Visible = false; this.btnLookUp.Visible = false; this.btnSave.Visible = false; this.txtAuthors.ReadOnly = true; this.txtAwards.ReadOnly = true; this.txtDewey.ReadOnly = true; this.txtDeweyNorm.ReadOnly = true; this.txtEdition.ReadOnly = true; this.txtEditors.ReadOnly = true; this.txtISBN.ReadOnly = true; this.txtLanguage.ReadOnly = true; this.txtLCC.ReadOnly = true; this.txtLongTitle.ReadOnly = true; this.txtNotes.ReadOnly = true; this.txtPhysDesc.ReadOnly = true; this.txtPublisher.ReadOnly = true; this.txtShortTitle.ReadOnly = true; this.txtSubjects.ReadOnly = true; this.txtSummary.ReadOnly = true; this.txtURLs.ReadOnly = true; this.txtNewPrice.ReadOnly = true; this.txtUsedPrice.ReadOnly = true; this.txtPricePaid.ReadOnly = true; this.groupBox1.Text = "View Book"; } else if (_addMode == Constants.AddBookMode.EDIT) { this.groupBox2.Enabled = false; this.btnClear.Enabled = false; } this.toolTip1.SetToolTip(this.txtAuthors,"Put each author on a separate line, preferably in the format 'LastName, FirstName MI'"); this.toolTip1.SetToolTip(this.txtEditors,"Put each editor on a separate line, preferably in the format 'LastName, FirstName MI'"); this.toolTip1.SetToolTip(this.txtSubjects,"Put each subject on a separate line"); _bookId = bookId; }
/// <summary> /// Sets the title bar text based on the mode the current window is in /// </summary> /// <param name="libMode"></param> public void SetTitleBar(Constants.LibraryMode libMode, string optionalValue) { MainForm parent = this.MdiParent as MainForm; BaseInfo info = (new BaseInfoDAO(parent.CurrentDatabase.FullName)).GetBaseInfo(); switch (libMode) { case Constants.LibraryMode.LIBRARY: this.Text = "Viewing " + Utils.GetPossessive(info.Owner) + " Library"; break; case Constants.LibraryMode.LOANEDBOOKS: this.Text = "Viewing " + Utils.GetPossessive(info.Owner) + " Loaned Out Books"; break; case Constants.LibraryMode.WISHLIST: this.Text = "Viewing " + Utils.GetPossessive(info.Owner) + " Wishlist"; break; case Constants.LibraryMode.LOANHISTORY: this.Text = "Viewing Loan History of " + optionalValue; break; } }
/// <summary> /// Dynamically builds the query for a search on the book_data view /// </summary> /// <param name="libMode"></param> /// <param name="searchMode"></param> /// <param name="value"></param> /// <returns></returns> public DataSet SearchBooks(Constants.LibraryMode libMode, Constants.SearchMode searchMode, string value) { string baseQuery = ""; switch (libMode) { case Constants.LibraryMode.LIBRARY: baseQuery = SQL.Book.SELECT_LIBRARY; break; case Constants.LibraryMode.LOANEDBOOKS: baseQuery = SQL.Book.SELECT_LOANED_BOOKS; break; case Constants.LibraryMode.WISHLIST: baseQuery = SQL.Book.SELECT_WISHLIST; break; case Constants.LibraryMode.LOANHISTORY: baseQuery = SQL.Book.SELECT_LOAN_RECORDS; break; } switch (searchMode) { case Constants.SearchMode.NONE: //DO NOTHING break; case Constants.SearchMode.AUTHOR_LAST: baseQuery += this.like("last_name", value); break; case Constants.SearchMode.AUTHOR_FIRST: baseQuery += this.like("first_name", value); break; case Constants.SearchMode.TITLE: baseQuery += this.like("short_title", value); break; case Constants.SearchMode.ISBN: baseQuery += this.like("isbn", value); break; case Constants.SearchMode.SUBJECT: baseQuery += this.like("subject", value); break; case Constants.SearchMode.PUBLISHER: baseQuery += this.like("publisher_info", value); break; case Constants.SearchMode.BOOK_ID: baseQuery += this.equal("id", value); break; } switch (searchMode) { case Constants.SearchMode.SUBJECT: //no group by clause break; case Constants.SearchMode.BOOK_ID: //book_id is only used when getting loan records baseQuery += " GROUP BY loan_id"; break; default: baseQuery += " GROUP BY id"; break; } return this.ExecuteQuery(baseQuery, null); }
public Item(string name, Constants.SearchMode value) { _name = name; _value = value; }
public BatchAddByISBNForm(int numBooks, Constants.LibraryMode mode) { InitializeComponent(); _textboxes = new TextBox[numBooks]; _resultLabels = new Label[numBooks]; _textboxes[0] = this.txtISBN0; _resultLabels[0] = this.lblResult0; _mode = mode; int txty = this.txtISBN0.Location.Y; int resulty = this.lblResult0.Location.Y; int rowy = this.lblRow0.Location.Y; int txtx = this.txtISBN0.Location.X; int rowx = this.lblRow0.Location.X; int resultx = this.lblResult0.Location.X; for (int i = 1; i < numBooks; i++) { txty += 30; rowy += 30; resulty += 30; if (i == 10) { txtx = this.txtISBN0.Location.X + 270; rowx = this.lblRow0.Location.X + 270; resultx = this.lblResult0.Location.X + 270; txty = this.txtISBN0.Location.Y; resulty = this.lblResult0.Location.Y; rowy = this.lblRow0.Location.Y; } TextBox t = new TextBox(); t.Name = "txtISBN" + i; t.Location = new System.Drawing.Point(txtx, txty); t.Size = new System.Drawing.Size(124, 20); t.TabIndex = i; t.CharacterCasing = CharacterCasing.Upper; _textboxes[i] = t; Label l = new Label(); l.Location = new System.Drawing.Point(resultx, resulty); l.Name = "lblResult" + i; l.Size = new System.Drawing.Size(35, 13); l.Text = "lbl"; l.Visible = false; l.AutoSize = true; l.Font = new Font(l.Font, FontStyle.Bold); _resultLabels[i] = l; Label l2 = new Label(); l2.Location = new System.Drawing.Point(rowx, rowy); l2.Name = "lblRow" + i; l2.Size = new System.Drawing.Size(35, 13); l2.Text = "" + (i + 1) + ". "; this.groupBox1.Controls.Add(t); this.groupBox1.Controls.Add(l); this.groupBox1.Controls.Add(l2); } }
/// <summary> /// This calls on the dao to get the results depending on the mode we are currently in /// </summary> /// <param name="mode"></param> /// <param name="value"></param> public void Search(Constants.SearchMode mode, string value) { MainForm main = (MainForm)this.ParentForm.MdiParent; BookDAO dao = new BookDAO(main.CurrentDatabase.FullName); this.gridBooks.DataSource = dao.SearchBooks(_mode, mode, value).Tables[0]; }