Esempio n. 1
0
        protected void button2_Click(object sender, EventArgs e)
        {
            ReturnDA k = new ReturnDA();

            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;
                //MessageBox.Show("BorrowedDate must less than ReturnedDate !");
                return;
            }
            TimeSpan dayLater = c.ReturnedDate.Date - c.DueDate;
            double ngay = dayLater.TotalDays;
            if (ngay > 0)
            {
                c.FineAmount = (int)ngay;
            }
            else c.FineAmount = 0;
            k.returnUpdate(c.CopyNumber);
            k.cirUpdate(c);
            button2.Enabled = false;
            DataSet ds = k.SelectDS(c.CopyNumber);
            DataView dv = new DataView(ds.Tables[0]);
            GridView1.DataSource = dv;
            GridView1.DataBind();
            Label4.Text = "" + ds.Tables[0].Rows.Count;
            lbError.Text = ("Return Successfully !");
            lbError.Visible = true;
        }
Esempio n. 2
0
        protected void button1_Click(object sender, EventArgs e)
        {
            ReturnDA b = new ReturnDA();

            ReturnBL a = new ReturnBL();
            int code = 0;
            try
            {
                code = int.Parse(textBox1.Text);
            }
            catch (Exception ex)
            {
                lbError.Text = ex.Message;
                lbError.Visible = true;
                return;
            }

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

            else
            {
                DataSet ds = b.SelectDS(code);
                DataView dv = new DataView(ds.Tables[0]);
                GridView1.DataSource = dv;

                GridView1.DataBind();
                Label4.Text = "" + ds.Tables[0].Rows.Count;
                textBox2.Text = b.getName(code);
                textBox3.Enabled = true;
                textBox3.Text = DateTime.Now.ToString("dd/M/yyyy");
                button3.Enabled = true;
                textBox1.Enabled = false;
                button1.Enabled = false;
            }
        }