Ejemplo n.º 1
0
 public frmBorrowBook()
 {
     InitializeComponent();
     context = new SA45_Team08B_LibraryEntities();
     b       = null;
     m       = null;
 }
Ejemplo n.º 2
0
        private void MemberInfo_UpdateDetails_Load(object sender, EventArgs e)
        {
            statusStrip1.ForeColor = Color.White;
            context = new SA45_Team08B_LibraryEntities();

            lblIDValid.Text = lblAddressValid.Text = lblCityValid.Text = lblEmailValid.Text = lblMemberNameValid.Text
                                                                                                  = lblPostalCodeValid.Text = lblPlaceOfBirthValid.Text = lblPhoneValid.Text = "";
            cbbContactTitle.Text = "MR";
        }
Ejemplo n.º 3
0
 private void frmBookInfo_Load(object sender, EventArgs e)
 {
     context = new SA45_Team08B_LibraryEntities();
     pnlAdmin.Hide();
     EnableButtons(false);
     lblValid.Text      = "";
     lblValid.ForeColor = Color.Red;
     ShowAvailDate(false);
 }
Ejemplo n.º 4
0
        public frmReturn()
        {
            InitializeComponent();
            //timer1.Tick += new EventHandler(timer1_tick);

            context = new SA45_Team08B_LibraryEntities();

            //lblDateReturn.Text = DateTime.Today.ToString(); //shows the time today for return
            MaximizeBox        = false;
            MinimizeBox        = false;
            btnSubmit.Enabled  = false;
            rbMemberID.Checked = true;
        }
Ejemplo n.º 5
0
        private void btnGo_Click(object sender, EventArgs e)
        {
            SA45_Team08B_LibraryEntities context = new SA45_Team08B_LibraryEntities();
            int  id = Convert.ToInt16(txtBook.Text);
            Book b  = new Book();

            b = context.Books.Where(x => x.BookID == id).First();

            txtBookType.Text     = b.BookType;
            txtBookTitle.Text    = b.BookTitle;
            txtPublisher.Text    = b.Publisher;
            txtTotalStock.Text   = b.TotalStock.ToString();
            txtNumberBorrow.Text = b.NumberBorrowed.ToString();
            txtAuthor.Text       = b.Author;
        }
Ejemplo n.º 6
0
        private void MemberInfo_UpdateDetails_Load(object sender, EventArgs e)
        {
            context = new SA45_Team08B_LibraryEntities();
            member  = context.Members.Where(x => x.MemberID == MemberIDSelected).First();

            tbxAddress.Text      = member.Address;
            tbxCity.Text         = member.City;
            tbxMemberID.Text     = member.MemberID;
            cbbContactTitle.Text = member.ContactTitle;
            cbbCountryCode.Text  = member.PlaceOfBirth;
            tbxEmail.Text        = member.EmailAddress;
            //cbbMemberCategory.Text = member.MemberCategory;
            tbxMemberName.Text = member.MemberName;
            tbxPhone.Text      = member.PhoneNumber;
            tbxPostalCode.Text = member.PostalCode;
        }
Ejemplo n.º 7
0
 private void btnSearch_Click(object sender, EventArgs e)
 {
     //context = new LibraryEntities();
     //var qry = from x in context.Members
     //          where txtMemberID.Text == x.MemberID || txtMemberName.Text == x.MemberName select x;
     //dgv.DataSource = qry.ToList();
     using (frmSearchMember f = new frmSearchMember())
     {
         context = new SA45_Team08B_LibraryEntities();
         f.ShowDialog();
         if (f.DialogResult == DialogResult.OK)
         {
             txtMemberID.Text = f.GetID;
             btnGo_Click(sender, e);
         }
     }
 }
Ejemplo n.º 8
0
        private void MemberInfo_UpdateDetails_Load(object sender, EventArgs e)
        {
            statusStrip1.ForeColor = Color.White;
            context = new SA45_Team08B_LibraryEntities();
            member  = context.Members.Where(x => x.MemberID == MemberIDSelected).First();

            lblAddressValid.Text = lblCityValid.Text = lblEmailValid.Text = lblMemberNameValid.Text
                                                                                = lblPostalCodeValid.Text = lblPlaceOfBirthValid.Text = lblPhoneValid.Text = "";
            tbxAddress.Text      = member.Address;
            tbxCity.Text         = member.City;
            tbxMemberID.Text     = member.MemberID;
            cbbContactTitle.Text = member.ContactTitle;
            cbbPlaceOfBirth.Text = member.PlaceOfBirth;
            tbxEmail.Text        = member.EmailAddress;
            //cbbMemberCategory.Text = member.MemberCategory;
            tbxMemberName.Text = member.MemberName;
            tbxPhone.Text      = member.PhoneNumber;
            tbxPostalCode.Text = member.PostalCode;
        }
Ejemplo n.º 9
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            SA45_Team08B_LibraryEntities context = new SA45_Team08B_LibraryEntities();
            DialogResult r = MessageBox.Show("Are you sure to delete the record?", "Confirm", MessageBoxButtons.YesNo);

            if (r == DialogResult.Yes)
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    Book b  = new Book();
                    int  id = Convert.ToInt16(txtBook.Text);
                    var  q  = from x in context.Books where x.BookID == id select x;
                    b = q.First();
                    context.Books.Remove(b);
                    context.SaveChanges();
                    ts.Complete();
                }
                sslDelete.Text = "You have deleted the record successfully.";
            }
        }
Ejemplo n.º 10
0
        private void BookInfo_Update_Load(object sender, EventArgs e)
        {
            statusStrip1.ForeColor = Color.White;
            context = new SA45_Team08B_LibraryEntities();

            lblAuthorValid.Text = lblBookTitleValid.Text = lblBookTypeValid.Text = lblPublisherValid.Text = lblTotalStockValid.Text = "";

            book = context.Books.Where(x => x.BookID == BookIDSelected).First();

            nudTotalStock.Value   = (short)book.TotalStock;
            tbxAuthor.Text        = book.Author;
            tbxBookID.Text        = book.BookID.ToString();
            tbxBookTitle.Text     = book.BookTitle;
            cbbBookType.Text      = book.BookType;
            tbxNumberBorowed.Text = book.NumberBorrowed.ToString();
            tbxPublisher.Text     = book.Publisher;
            //cbbRating.Text = book.Rating;
            //nudTotalStock.Maximum = 20;
            //nudTotalStock.Minimum = 1;
            checkChanges();
        }
Ejemplo n.º 11
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            SA45_Team08B_LibraryEntities context = new SA45_Team08B_LibraryEntities();
            frmSearchBook f = new frmSearchBook();
            DialogResult  r = f.ShowDialog();

            if (r == DialogResult.OK)
            {
                txtBook.Text = f.GetID;
                int  id = Convert.ToInt16(txtBook.Text);
                Book b  = new Book();
                b = context.Books.Where(x => x.BookID == id).First();

                txtBookType.Text     = b.BookType;
                txtBookTitle.Text    = b.BookTitle;
                txtPublisher.Text    = b.Publisher;
                txtTotalStock.Text   = b.TotalStock.ToString();
                txtNumberBorrow.Text = b.NumberBorrowed.ToString();
                txtAuthor.Text       = b.Author;
            }
        }
Ejemplo n.º 12
0
 public frmSearchMember()
 {
     InitializeComponent();
     context = new SA45_Team08B_LibraryEntities();
 }
Ejemplo n.º 13
0
        private void button1_Click(object sender, EventArgs e)
        {
            SA45_Team08B_LibraryEntities context = new SA45_Team08B_LibraryEntities();

            short bkID;
            int   testId;
            short bkStock;
            bool  valid = true;
            Book  b;

            if (!Int16.TryParse(txtBID.Text, out bkID))
            {
                if (int.TryParse(txtBID.Text, out testId))
                {
                    lblErrorID.Text = "Select an ID less than 32768";
                }
                else
                {
                    lblErrorID.Text = "Book ID should only contain numbers";
                }
                valid = false;
            }
            else
            {
                try
                {
                    b = context.Books.Where(x => x.BookID == bkID).First();
                    //no error means book is already inside database
                    lblErrorID.Text = "Book ID in use. Please enter another ID";
                    valid           = false;
                }
                catch (Exception ex)
                {
                    lblErrorID.Text = "";
                }
            }


            if (txtBookTitle.Text == "")
            {
                lblErrorTitle.Text = "Title field cannot be empty";
                valid = false;
            }
            else
            {
                lblErrorTitle.Text = "";
            }

            if (cmbBookType.Text == "")
            {
                lblErrorType.Text = "Please select a book type";
                valid             = false;
            }
            else
            {
                lblErrorType.Text = "";
            }

            if (txtPublisher.Text == "")
            {
                lblErrorPublisher.Text = "Publisher field cannot be empty";
                valid = false;
            }
            else
            {
                lblErrorPublisher.Text = "";
            }
            if (txtAuthor.Text == "")
            {
                lblErrorAuthor.Text = "Author field cannot be empty";
                valid = false;
            }
            else
            {
                lblErrorAuthor.Text = "";
            }
            if (!Int16.TryParse(txtTotalStock.Text, out bkStock))
            {
                lblErrorStock.Text = "Please enter a number";
                valid = false;
            }
            else
            {
                lblErrorStock.Text = "";
            }

            if (valid)
            {
                DialogResult r = MessageBox.Show("Are you sure to add the book?", "Confirm", MessageBoxButtons.YesNo);
                if (r == DialogResult.Yes)
                {
                    using (TransactionScope ts = new TransactionScope())
                    {
                        Book bk = new Book();
                        bk.BookID     = Convert.ToInt16(txtBID.Text);
                        bk.BookTitle  = txtBookTitle.Text;
                        bk.BookType   = cmbBookType.Text;
                        bk.Author     = txtAuthor.Text;
                        bk.Publisher  = txtPublisher.Text;
                        bk.TotalStock = Convert.ToInt16(txtTotalStock.Text);

                        context.Books.Add(bk);

                        context.SaveChanges();

                        ts.Complete();
                        sslAdd.Text = "You have added the book successfully!";
                    }
                }
            }
        }