Ejemplo n.º 1
0
        private void setInfoLabel(string msg)
        {
            Label lbl;

            if (this.chkAutoAdd.Checked == true)
            {
                lbl = this.lblResult;
            }
            else
            {
                lbl = this.lblResult2;
            }

            MainForm parent = (MainForm)this.MdiParent;
            string   title  = _book.ShortTitle.Equals("") ? _book.LongTitle : _book.ShortTitle;

            if (msg == null || msg.Equals(""))
            {
                lbl.Visible = false;
                parent.SetStatusStripText("Enter an ISBN and click Lookup to proceed");
            }
            else if (msg.Equals("Success"))
            {
                lbl.Text      = msg;
                lbl.ForeColor = Color.Green;
                lbl.Visible   = true;
                parent.SetStatusStripText("Book '" + title + "' was successfully added");
            }
            else if (msg.Equals("Processing..."))
            {
                lbl.Text      = msg;
                lbl.ForeColor = Color.Blue;
                lbl.Visible   = true;
            }
            else if (msg.Equals("Failed"))
            {
                lbl.Text      = msg;
                lbl.ForeColor = Color.Red;
                lbl.Visible   = true;
                parent.SetStatusStripText("Adding of book " + title + " failed.");
            }
            else if (msg.Equals("Not Found"))
            {
                lbl.Text      = msg;
                lbl.ForeColor = Color.Red;
                lbl.Visible   = true;
                parent.SetStatusStripText("The ISBN you entered was not found.");
            }
            else if (msg.Equals("View"))
            {
                parent.SetStatusStripText("Viewing Book: " + title);
            }

            Application.DoEvents();
        }
Ejemplo n.º 2
0
        private bool isRequiredFieldsFilled()
        {
            int error = 0;

            if (this.txtShortTitle.Text.Equals("") && this.txtLongTitle.Text.Equals(""))
            {
                this.errorProvider1.SetError(this.txtShortTitle, "You must fill in at least one of the Title fields");
                this.errorProvider1.SetError(this.txtLongTitle, "You must fill in at least one of the Title fields");
                error++;
            }
            else
            {
                this.errorProvider1.SetError(this.txtShortTitle, "");
                this.errorProvider1.SetError(this.txtLongTitle, "");
            }

            if (error > 0)
            {
                MainForm form = (MainForm)this.MdiParent;
                form.SetStatusStripText("Error: Please fill in all required fields.");
                return(false);
            }
            else
            {
                MainForm form = (MainForm)this.MdiParent;
                form.SetStatusStripText("Fill in information and click save when ready.");
                return(true);
            }
        }
        /// <summary>
        /// Called when this method Show() is called
        /// </summary>
        /// <param name="e"></param>
        protected override void OnShown(EventArgs e)
        {
            base.OnShown(e);
            MainForm form = (MainForm)this.MdiParent;

            form.SetStatusStripText("Viewing all available libraries");

            this.refreshGrid();
        }
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            if (!this.checkRequiredFields())
                return;
            
            BookDAO dao = new BookDAO(_topParent.CurrentDatabase.FullName);

            bool success = dao.LoanBook(_bookId, this.txtLoanTo.Text);
            if (!success)
            {
                MessageBox.Show("An unknown error occurred and this book was not updated.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
            else
            {
                _topParent.SetStatusStripText("Book " + this.lblBook.Text + " was successfully loaned to " + this.txtLoanTo.Text);
                this.Close();
            }
        }