Example #1
0
        protected void Button3_Click(object sender, EventArgs e)
        {
            DropDownList3.Visible = true;
            Button6.Visible       = true;
            Database1Entities22 db = new Database1Entities22();
            Penalty             p  = new Penalty();

            p.user_id         = Label4.Text;
            p.penalty_subject = TextBox4.Text;
            p.penalty_descrip = TextBox5.Text;
            p.penalty_money   = Int32.Parse(TextBox6.Text);
            p.penalty_date    = DateTime.Today;
            p.penalty_status  = "unpaid";
            db.Penalties.Add(p);
            db.SaveChanges();
            Label9.Text      = "Successfully Inserted";
            Label9.ForeColor = System.Drawing.Color.ForestGreen;
            GridView2.DataBind();
        }
Example #2
0
        protected void Button4_Click(object sender, EventArgs e)
        {
            Database1Entities22 db = new Database1Entities22();
            int    bid             = Int32.Parse(TextBox3.Text);
            string uid             = TextBox4.Text;
            Take   tk = db.Takes.Where(s => (s.user_id).Equals(uid) && s.book_id == bid).FirstOrDefault <Take>();

            if (tk == null)
            {
                Label5.Text      = "No such Book issued";
                Label5.ForeColor = System.Drawing.Color.ForestGreen;
                return;
            }
            DateTime dt = DateTime.Now;

            if (tk.due_date < dt)
            {
                int days = (int)(dt - tk.due_date).TotalDays;
                Label6.Text      = "You are" + days + "days late penalty will be charged";
                Label6.ForeColor = System.Drawing.Color.ForestGreen;
                Penalty p = new Penalty();
                p.penalty_subject = "Book Submission";
                p.penalty_descrip = "You are" + days + "days late for book submission";
                p.penalty_money   = 10 * days;
                p.user_id         = uid;
                p.penalty_date    = DateTime.Now;
                db.Penalties.Add(p);
                db.SaveChanges();
            }
            tk.issue_date = DateTime.Now;
            tk.due_date   = DateTime.Now.AddDays(21);
            db.SaveChanges();
            Label5.Text = "Book successfully Renewed";
            GridView1.DataBind();
            GridView3.DataBind();
            TextBox3.Text = "";
            TextBox4.Text = "";
        }