protected void ButtonBookSubmit_Click(object sender, EventArgs e) { string day = this.TextboxBookDate.Text; string time = this.TextboxBookTime.Text; int id = (int)Session["id"]; //needed : check if this is booked WebApplication1.scripts.AppointmentDAO dao = new scripts.AppointmentDAO(); WebApplication1.scripts.Appointment app = new scripts.Appointment(); List <WebApplication1.scripts.Appointment> list = new List <scripts.Appointment>(); list = dao.searchByDay(day); bool booked = false; for (int i = 0; i < list.Count; i++) { if (list[i].getTime() == time) { booked = true; } } if (!booked) { int fees = 100; app.setDay(day); app.setTime(time); app.setId(id); dao.setAppointment(app); //after booking the bill inserted to bills table WebApplication1.scripts.bill Bill = new scripts.bill(); Bill.setID(id); Bill.setBDate(day); Bill.setValue(fees); Bill.setPaid(false); WebApplication1.scripts.billDAO bDao = new scripts.billDAO(); bDao.insertBill(Bill); //redirect to bills Response.Redirect(Page.ResolveClientUrl("../bill/bill.aspx")); } else { ClientScriptManager cs = Page.ClientScript; Type cstype = this.GetType(); String alert = "alert('this time is booked');"; cs.RegisterStartupScript(cstype, "PopupScript", alert, true); } }
protected void Page_Load(object sender, EventArgs e) { if ((int)Session["id"] == 0) { Response.Redirect(Page.ResolveClientUrl("../../index.aspx")); } else { WebApplication1.scripts.billDAO dao = new scripts.billDAO(); int id = (int)Session["id"]; List <WebApplication1.scripts.bill> bills = new List <scripts.bill>(); bills = dao.getBillByID(id); for (int i = 0; i < bills.Count; i++) { TableRow row = new TableRow(); TableCell billNumerCell = new TableCell(); TableCell dateCell = new TableCell(); TableCell valueCell = new TableCell(); TableCell paidCell = new TableCell(); billNumerCell.Text = bills[i].getBillNumber().ToString(); dateCell.Text = bills[i].getBDate(); valueCell.Text = bills[i].getValue().ToString(); if (bills[i].getPaid()) { paidCell.Text = "Paid"; } else { paidCell.Text = "Not Paid"; } row.Cells.Add(billNumerCell); row.Cells.Add(dateCell); row.Cells.Add(valueCell); row.Cells.Add(paidCell); tableBill.Rows.Add(row); } } }