Exemplo n.º 1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            LibraryEntity context = new LibraryEntity();

            try
            {
                Member m = context.Member.Where(x => x.NRIC == tbNRIC.Text).First();
                if (tbName.Text != "" && tbContact.Text != "" && tbEmail.Text != "" && m.Address != "")
                {
                    m.MemberName = tbName.Text;
                    m.Phone      = tbContact.Text;
                    m.Email      = tbEmail.Text;
                    m.Address    = tbAddress.Text;
                    context.SaveChanges();
                    MessageBox.Show("Update successfully!");
                }
                else
                {
                    MessageBox.Show("Fill in the all the details");
                }
            }
            catch (System.Data.Entity.Infrastructure.DbUpdateException)
            {
                MessageBox.Show("Fill in the all the details");
            }
            catch (System.InvalidOperationException)
            {
                MessageBox.Show("Invalid NRIC");
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Quotq plus 1
        /// </summary>
        private void AddQuota()
        {
            LibraryEntity context = new LibraryEntity();
            Member        mem     = context.Member.Where(x => x.NRIC == txtNRIC.Text).First();

            mem.Quota = mem.Quota + 1;
            context.SaveChanges();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Total stock plus 1
        /// </summary>
        private void Addtotalstock()
        {
            LibraryEntity context = new LibraryEntity();
            string        BokID   = dvwBooks.CurrentRow.Cells["BookID"].Value.ToString();
            int           BookID  = Convert.ToInt32(BokID);
            Books         bok     = context.Books.Where(x => x.BookID == BookID).First();

            bok.TotalStock = (short)(bok.TotalStock + 1);
            context.SaveChanges();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Set status to 'in'
        /// </summary>
        private void BookReturn()
        {
            LibraryEntity context = new LibraryEntity();
            string        TranID  = dvwBooks.CurrentRow.Cells["TransactionID"].Value.ToString();
            int           TransID = Convert.ToInt32(TranID);
            Borrow        bor     = context.Borrow.Where(x => x.TransactionID == TransID).First();

            bor.RentalStatus     = "in";
            bor.DateActualReturn = DateTime.Now;
            context.SaveChanges();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Total stock in book table minus 1
        /// </summary>
        private void TotalStockminus()
        {
            LibraryEntity context = new LibraryEntity();
            int           bookID  = Convert.ToInt32(txtBookID.Text);

            try
            {
                Books bok = context.Books.Where(x => x.BookID == bookID).First();
                bok.TotalStock = (short)(bok.TotalStock - 1);
                context.SaveChanges();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
Exemplo n.º 6
0
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     try
     {
         int   booksID = Convert.ToInt32(tbBooksID.Text);
         Books books   = context.Books.Where(x => x.BookID == booksID).First();
         books.Title      = tbTitle.Text;
         books.Author     = tbAuthor.Text;
         books.CallNumber = tbCallNumber.Text;
         books.Genre      = cmbGenre.Text;
         context.SaveChanges();
         MessageBox.Show("Update successfully");
     }
     catch (Exception)
     {
         MessageBox.Show("fill in the all the details");
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// Insert a record into borrow table
        /// </summary>
        private void Borrow()
        {
            LibraryEntity context = new LibraryEntity();
            Borrow        bo      = new Borrow();
            Member        me      = context.Member.Where(x => x.NRIC == txtNRIC.Text).First();
            int           bookID  = Convert.ToInt32(txtBookID.Text);
            Books         bok     = context.Books.Where(x => x.BookID == bookID).First();

            bo.Member       = me;
            bo.Books        = bok;
            bo.BookID       = bok.BookID;
            bo.NRIC         = me.NRIC;
            bo.RentalStatus = "out";
            bo.DateIssue    = dtpDOI.Value;
            bo.DateDue      = dtpDueDate.Value;
            bo.Remarks      = txtRemarks.Text;
            context.Borrow.Add(bo);
            context.SaveChanges();
        }
Exemplo n.º 8
0
        /// <summary>
        /// Delete the member
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDelete_Click(object sender, EventArgs e)
        {
            LibraryEntity context = new LibraryEntity();

            try
            {
                Member member = context.Member.Where(x => x.NRIC == tbNRIC.Text).First();
                context.Member.Remove(member);
                context.SaveChanges();
                MessageBox.Show("successful");
                tbNRIC.Text    = null;
                tbName.Text    = null;
                tbEmail.Text   = null;
                tbContact.Text = null;
                tbAddress.Text = null;
            }
            catch (Exception)
            {
                MessageBox.Show("Invalid NRIC");
            }
        }
Exemplo n.º 9
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            LibraryEntity context = new LibraryEntity();
            Books         b       = new Books();

            try
            {
                b.Title      = tbTitle.Text;
                b.Author     = tbAuthor.Text;
                b.TotalStock = Convert.ToInt16(tbTotalStock.Text);
                b.Genre      = cmbGenre.SelectedItem.ToString();
                b.CallNumber = tbCallNumber.Text;
                context.Books.Add(b);
                context.SaveChanges();
                MessageBox.Show("Update successfull");
                this.Close();
            }
            catch (System.Data.Entity.Infrastructure.DbUpdateException)
            {
                MessageBox.Show("fill in the all the details");
            }
        }
Exemplo n.º 10
0
 private void btnSignup_Click(object sender, EventArgs e)
 {
     LibraryEntity context = new LibraryEntity();
     Member m = new Member();
     try
     {
         m.NRIC = tbNRIC.Text;
         m.MemberName = tbName.Text;
         m.Phone = tbContact.Text;
         m.Email = tbEmail.Text;
         m.Address = tbAddress.Text;
         ///
         ///The quota for every new member is 4
         ///
         m.Quota = 4;
         context.Member.Add(m);
         context.SaveChanges();
     }
     catch (System.Data.Entity.Infrastructure.DbUpdateException)
     {
         MessageBox.Show("fill in the all the details");
     }
 }