Пример #1
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     memcode = int.Parse(TextBox1.Text);
     try
     {
         BorrowBL b = new BorrowBL();
         bookcode = int.Parse(TextBox3.Text);
         TextBox4.Text = ReserveBL.getBooktitle(bookcode);
         if (ReserveBL.checkReservation(bookcode, memcode))
         {
             TextBox5.Enabled = true;
             Button3.Enabled = true;
         }
     }
     catch (Exception ex)
     {
         if (ex is FormatException || ex is OverflowException || ex is ArgumentNullException)
         {
             lbError.Text = ("Wrong book number!");
             lbError.Visible = true;
             return;
         }
         else
         {
             lbError.Text = ("somethings wrong in checkReservation funtion");
             lbError.Visible = true;
         }
     }
     TextBox5.Text = DateTime.Now.ToString("d/M/yyyy");
     Button2.Enabled = false;
     Button1.Enabled = false;
     TextBox3.Enabled = false;
 }
Пример #2
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            try
            {
                memcode = int.Parse(TextBox1.Text);
                BorrowBL b = new BorrowBL();
                if (b.checkMember(memcode))
                {
                    TextBox2.Text = b.showMemberName(memcode);

                }
                else
                {
                    lbError.Text = ("doesn't match with any member ! Please try again.");
                    lbError.Visible = true;
                    return;
                }
            }
            catch (Exception ex)
            {
                if (ex is FormatException || ex is OverflowException || ex is ArgumentNullException)
                {
                    lbError.Text = ("Wrong input");
                    lbError.Visible = true;
                    return;
                }
                else
                {
                    lbError.Text = ("somethings wrong in checkmember funtion" + ex);
                    lbError.Visible = true;
                }
            }
            TextBox1.Enabled = false;
            TextBox3.Enabled = true;
            Button1.Enabled = true;
            DataSet ds = ReserveBL.selectTableReservation(memcode);
            DataView dv = new DataView(ds.Tables[0]);
            GridViewReserved.DataSource = dv;
            GridViewReserved.DataBind();
            Label8.Text = "" + ds.Tables[0].Rows.Count;
            Button2.Enabled = false;
        }
Пример #3
0
        protected void button1_Click(object sender, EventArgs e)
        {
            BorrowBL a = new BorrowBL();
            BorrowDA b = new BorrowDA();
            int code = 0;
            try
            {
                code = int.Parse(textBox1.Text);
            }
            catch (Exception ex)
            {

                Label1.Text = "Please enter a corect book number!";
                Label1.Visible = true;
                return;
            }

            bool test = a.checkMember(code);
            if (!test)
            {
                Label1.Text = "Don't have this member in Database!";
                Label1.Visible = true;
                return;
            }

            else
            {
                DataSet ds = b.SelectDS(code);
                DataView dv = new DataView(ds.Tables[0]);
                textBox2.Text = b.getName(code);
                textBox1.Enabled = false;
                button1.Enabled = false;
                textBox3.Enabled = true;
                button2.Enabled = true;
                Label1.Visible = false;
                FillBorrow(code);
            }
        }
Пример #4
0
        protected void button3_Click(object sender, EventArgs e)
        {
            BorrowBL a = new BorrowBL();
            BorrowDA b = new BorrowDA();
            //DateTime returnDate = new DateTime();

            CirculatedCopy c = new CirculatedCopy();
            try
            {
                c.Id = int.Parse(GridView1.SelectedRow.Cells[1].Text);
                c.CopyNumber = int.Parse(GridView1.SelectedRow.Cells[2].Text);
                c.BorrowerNumber = int.Parse(GridView1.SelectedRow.Cells[3].Text);
                c.DueDate = DateTime.ParseExact(GridView1.SelectedRow.Cells[5].Text, "d/M/yyyy", null);
                c.BorrowedDate = DateTime.ParseExact(GridView1.SelectedRow.Cells[4].Text, "d/M/yyyy", null);
            }
            catch (Exception)
            {
                lbError.Text = "You must select a book !";
                lbError.Visible = true;

                return;
            }

            try
            {
                c.ReturnedDate = DateTime.ParseExact(textBox3.Text, "d/M/yyyy", null);
            }
            catch (Exception ex)
            {

                lbError.Text = (ex.Message);
                lbError.Visible = true;
                return;
            }
            if (c.ReturnedDate.Date < c.BorrowedDate)
            {
                lbError.Text = ("BorrowedDate must less than ReturnedDate !");
                lbError.Visible = true;
                return;
                //MessageBox.Show("BorrowedDate must less than ReturnedDate !");
            }
            TimeSpan dayLater = c.ReturnedDate.Date - c.DueDate;
            double ngay = dayLater.TotalDays;
            if (ngay > 0)
            {
                textBox4.Text = "" + ngay;
            }
            else textBox4.Text = "0";

            GridView1.Enabled = false;
            textBox3.Enabled = false;
            button3.Enabled = false;
            button2.Enabled = true;
        }
Пример #5
0
        protected void button2_Click(object sender, EventArgs e)
        {
            BorrowBL a = new BorrowBL();
            BorrowDA b = new BorrowDA();

            int code = 0;
            try
            {
                code = int.Parse(textBox3.Text);
            }
            catch (Exception ex)
            {
                Label1.Text = "Please enter a corect copy number!";
                Label1.Visible = true;
                return;
            }

            bool test = a.checkCopy(code);
            if (!test)
            {
                Label1.Text = "You can't borrow this copy!";
                Label1.Visible = true;
                return;
            }

            bool test1 = a.checkFive(int.Parse(textBox1.Text));
            if (!test1)
            {
                Label1.Text = "You have borrowed 5 copies!";
                Label1.Visible = true;
                return;
            }

            bool test2 = a.checkReserve1(code);
            if (!test2)
            {
                textBox4.Text = DateTime.Now.ToString("d/M/yyyy");
                textBox3.Enabled = false;
                button2.Enabled = false;
                button3.Enabled = true;
                textBox4.Enabled = true;
                Label1.Visible = false;
            }
            else
            {
                bool test3 = a.checkReserve(code, b.getBoNum(code), int.Parse(textBox1.Text));
                if (!test3)
                {
                    Label1.Text = "This book have resserved by other person!";
                    Label1.Visible = true;
                    return;
                }
                else
                {

                    textBox3.Enabled = false;
                    textBox4.Text = DateTime.Now.ToString("d/M/yyyy");
                    button2.Enabled = false;
                    textBox4.Enabled = true;
                    button3.Enabled = true;
                    Label1.Visible = false;
                }
            }
        }
Пример #6
0
        protected void button3_Click(object sender, EventArgs e)
        {
            BorrowBL a = new BorrowBL();
            BorrowDA b = new BorrowDA();
            DateTime brDate = new DateTime();
            try
            {
                brDate = DateTime.ParseExact(textBox4.Text, "d/M/yyyy", null);
            }
            catch (Exception ex)
            {
                Label1.Text = "Please enter a corect date!";
                Label1.Visible = true;
                return;
            }

            DateTime dueDate = brDate.AddDays(14);
            textBox5.Text = dueDate.ToShortDateString();
            int copyNum = int.Parse(textBox3.Text);
            int brNum = int.Parse(textBox1.Text);
            CirculatedCopy h = new CirculatedCopy();
            a.SetIdMax();
            h.Id = ++a.idMax;
            h.CopyNumber = copyNum;
            h.BorrowerNumber = brNum;
            h.BorrowedDate = brDate;
            h.DueDate = dueDate;
            b.insertBorrow(h);
            b.borrowUpdate(copyNum);
            FillBorrow(brNum);
            bool test2 = a.checkReserve1(copyNum);
            bool test3 = a.checkReserve(copyNum, b.getBoNum(copyNum), int.Parse(textBox1.Text));
            if (test2 && test3)
            {
                b.borrowReUpdate(b.getBoNum(copyNum), int.Parse(textBox1.Text));
            }
            button3.Enabled = false;
            textBox4.Enabled = false;
        }