private void BorrowBtn_Click(object sender, EventArgs e)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    int  bookcode = Int32.Parse(dataGridView1.CurrentRow.Cells[0].Value.ToString());
                    Book book     = context.Books.Where(x => x.BookCode == bookcode).ToList().First();
                    book.NumberAvaliable -= 1;
                    book.NumberRented    += 1;

                    IssueTran it = new IssueTran();
                    it.CustomerID    = customer.CustomerID;
                    it.BookCode      = bookcode;
                    it.DateIssue     = FromdateTimePicker.Value.Date;
                    it.DateDue       = TodateTimePicker.Value.Date;
                    it.RentailStatus = "OUT";

                    context.IssueTrans.Add(it);
                    context.SaveChanges();
                    MessageBox.Show("Borrw Success!");
                    ts.Complete();

                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Esempio n. 2
0
        private void ExtendLoanBtn_Click(object sender, EventArgs e)
        {
            int       issuetran_id = Int32.Parse(TransactiondataGridView.CurrentRow.Cells[0].Value.ToString());
            string    bookname     = TransactiondataGridView.CurrentRow.Cells[1].Value.ToString();
            IssueTran it           = context.IssueTrans.Where(x => x.TransactionID == issuetran_id).ToList().First();

            new ApplyExtention(it, bookname).ShowDialog();
        }
Esempio n. 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            ea.IsApproved = "True";
            ea.Remarks    = textBox8.Text;
            IssueTran it = ea.IssueTran;

            it.DateDue = it.DateDue.Value.AddDays((double)ea.ExtendDays);
            context.SaveChanges();
            this.Close();
        }
Esempio n. 4
0
 public ManageIssueTran(int primarykey)
 {
     InitializeComponent();
     it                    = context.IssueTrans.Where(x => x.TransactionID == primarykey).ToList().First();
     textBox3.Text         = it.BookCode.ToString();
     textBox2.Text         = it.CustomerID.ToString();
     dateTimePicker1.Value = (DateTime)it.DateIssue;
     dateTimePicker2.Value = (DateTime)it.DateDue;
     dateTimePicker3.Value = (DateTime)it.DateActualReturn;
     textBox8.Text         = it.Remarks;
 }
Esempio n. 5
0
 private void ReturnBookBtn_Click(object sender, EventArgs e)
 {
     if (IssueTranList.Count() == 0)
     {
         MessageBox.Show("You have no book need to be returned!");
     }
     else
     {
         var curent_row = TransactiondataGridView.CurrentRow;
         if (curent_row != null)
         {
             int       issuetran_id = Int32.Parse(TransactiondataGridView.CurrentRow.Cells[0].Value.ToString());
             string    bookname     = TransactiondataGridView.CurrentRow.Cells[1].Value.ToString();
             IssueTran it           = context.IssueTrans.Where(x => x.TransactionID == issuetran_id).ToList().First();
             new ReturnBook(it, bookname).ShowDialog();
             LoadTheDataGridView();
         }
         else
         {
             MessageBox.Show("You must select a book first.");
         }
     }
 }
        private void Delete_Click(object sender, EventArgs e)
        {
            int primarykey;

            if (dataGridView.Rows.Count > 0)
            {
                if (Int32.TryParse(dataGridView.CurrentRow.Cells[0].Value.ToString(), out primarykey))
                {
                    switch (clickedBtn)
                    {
                    case ButtonClicked.BookList:
                    {
                        Book item = context.Books.Where(x => x.BookCode == primarykey).ToList().First();
                        if (ConfirmDelete())
                        {
                            context.Books.Remove(item);
                            context.SaveChanges();
                            MessageBox.Show("Delete success!");
                        }
                        break;
                    }

                    case ButtonClicked.CustomerList:
                    {
                        Customer item = context.Customers.Where(x => x.CustomerID == primarykey).ToList().First();
                        if (ConfirmDelete())
                        {
                            context.Customers.Remove(item);
                            context.SaveChanges();
                            MessageBox.Show("Delete success!");
                        }
                        break;
                    }

                    case ButtonClicked.Extention:
                    {
                        ExtendApplication item = context.ExtendApplications.Where(x => x.ApplicationID == primarykey).ToList().First();
                        if (ConfirmDelete())
                        {
                            context.ExtendApplications.Remove(item);
                            context.SaveChanges();
                            MessageBox.Show("Delete success!");
                        }
                        break;
                    }

                    case ButtonClicked.IssueTran:
                    {
                        IssueTran item = context.IssueTrans.Where(x => x.TransactionID == primarykey).ToList().First();
                        if (ConfirmDelete())
                        {
                            context.IssueTrans.Remove(item);
                            context.SaveChanges();
                            MessageBox.Show("Delete success!");
                        }
                        break;
                    }

                    case ButtonClicked.PaymentTran:
                    {
                        PaymentTran item = context.PaymentTrans.Where(x => x.PaymentID == primarykey).ToList().First();
                        if (ConfirmDelete())
                        {
                            context.PaymentTrans.Remove(item);
                            context.SaveChanges();
                            MessageBox.Show("Delete success!");
                        }
                        break;
                    }

                    case ButtonClicked.AuthorList:
                    {
                        Author item = context.Authors.Where(x => x.AuthorID == primarykey).ToList().First();
                        if (ConfirmDelete())
                        {
                            context.Authors.Remove(item);
                            context.SaveChanges();
                            MessageBox.Show("Delete success!");
                        }
                        break;
                    }

                    case ButtonClicked.PublisherList:
                    {
                        Publisher item = context.Publishers.Where(x => x.PublisherID == primarykey).ToList().First();
                        if (ConfirmDelete())
                        {
                            context.Publishers.Remove(item);
                            context.SaveChanges();
                            MessageBox.Show("Delete success!");
                        }
                        break;
                    }

                    case ButtonClicked.CountryList:
                    {
                        Country item = context.Countries.Where(x => x.CountryCode == primarykey).ToList().First();
                        if (ConfirmDelete())
                        {
                            context.Countries.Remove(item);
                            context.SaveChanges();
                            MessageBox.Show("Delete success!");
                        }
                        break;
                    }
                    }
                }
            }
            else
            {
                MessageBox.Show("No data in the table");
            }
        }
 public ReturnBook(IssueTran it, string bookname)
 {
     InitializeComponent();
     this.it          = context.IssueTrans.Where(x => x.TransactionID == it.TransactionID).ToList().First();
     BookNameBox.Text = bookname;
 }
Esempio n. 8
0
 public ManageIssueTran()
 {
     InitializeComponent();
     it       = new IssueTran();
     IsAddNew = true;
 }
 public ApplyExtention(IssueTran it, string bookname)
 {
     InitializeComponent();
     this.it       = it;
     this.bookname = bookname;
 }