Exemplo n.º 1
0
        private void borrowButton_Click(object sender, EventArgs e)
        {
            //DateTime BookDueDate;
            //string n = "";
            int noOfDays = int.Parse(noOfDaysTextBox.Text);

            if (noOfDays == 0)
            {
                MessageBox.Show("You should Put The Valid Days For Borrow");
            }
            //if (noOfDays==int.Parse("") )
            //{
            //    MessageBox.Show("You should Put The Days For Borrow");
            //}
            if (noOfDays <= 7)
            {
                DateTime currentDay = DateTime.Now;
                currentDay = currentDay.AddDays(noOfDays);

                dueBackTextBox.Text = currentDay.ToString("yyyy/MM/dd");
            }
            else
            {
                MessageBox.Show("You can't borrow over 7 days");
            }



            BookSelf bookself = new BookSelf();

            bookself.UserId   = userId;
            bookself.BookName = dgvShowBook.CurrentCell.Value.ToString();
            bookself.BackDate = dueBackTextBox.Text;

            dataAccess.AddBookMySelf(bookself);
            MessageBox.Show("Borrow Successfully");

            //switch (noOfDaysTextBox.Text)
            //{
            //    case "0":
            //        BookLoan = 0;
            //        DateTime today = DateTime.Now;
            //        today = today.AddDays(BookLoan);
            //        dueBackTextBox.Text = today.ToString("yyyy/MM/dd");

            //        break;

            //    case "1":
            //        BookLoan = 1;
            //        DateTime today1 = DateTime.Now;
            //        today1 = today1.AddDays(BookLoan);
            //        dueBackTextBox.Text = today1.ToString("yyyy/MM/dd");

            //        break;
            //    case "2":
            //        BookLoan = 2;
            //        DateTime today2 = DateTime.Now;
            //        today2 = today2.AddDays(BookLoan);
            //        dueBackTextBox.Text = today2.ToString("yyyy/MM/dd");

            //        break;
            //    case "3":
            //        BookLoan = 3;
            //        DateTime today3 = DateTime.Now;
            //        today3 = today3.AddDays(BookLoan);
            //        dueBackTextBox.Text = today3.ToString("yyyy/MM/dd");

            //        break;
            //    case "4":
            //        BookLoan = 4;
            //        DateTime today4 = DateTime.Now;
            //        //TimeSpan duration4 = new TimeSpan(BookLoan, 0, 0, 0);
            //        //DateTime answer4 = today4.Add(duration4);
            //        today4 = today4.AddDays(BookLoan);
            //        dueBackTextBox.Text = today4.ToString("yyyy/MM/dd");

            //        break;
            //    case "5":
            //        BookLoan = 5;
            //        DateTime today5 = DateTime.Now;
            //        today5 = today5.AddDays(BookLoan);
            //        dueBackTextBox.Text = today5.ToString("yyyy/MM/dd");

            //        break;
            //    case "6":
            //        BookLoan = 6;
            //        DateTime today6 = DateTime.Now;
            //        today6 = today6.AddDays(BookLoan);
            //        dueBackTextBox.Text = today6.ToString("yyyy/MM/dd");

            //        break;
            //    case "7":
            //        BookLoan = 7;
            //        DateTime today7 = DateTime.Now;
            //        today7 = today7.AddDays(BookLoan);
            //        dueBackTextBox.Text = today7.ToString("yyyy/MM/dd");

            //        break;
            //    default:
            //        break;
            //}
        }