diff --git a/Code/DBProject/Doctor/Bill.aspx.cs b/Code/DBProject/Doctor/Bill.aspx.cs index 477527c..cf00b17 100644 --- a/Code/DBProject/Doctor/Bill.aspx.cs +++ b/Code/DBProject/Doctor/Bill.aspx.cs @@ -1,59 +1,76 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; +using System; +using System.Data; using System.Web.UI; -using System.Web.UI.WebControls; using DBProject.DAL; -using System.Data; namespace doctor { - public partial class bill : System.Web.UI.Page + public partial class bill : Page { protected void Page_Load(object sender, EventArgs e) { - - myDAL objmyDAL = new myDAL(); - DataTable dt = new DataTable(); - int found; - - int did = (int)Session["idoriginal"]; - - found = objmyDAL.generate_bill_DAL(did, ref dt); - - if (found != 1) - { Response.Write(""); } - else + if (!IsPostBack) { - Label1.Text = dt.Rows[0][0].ToString(); + try + { + int did = (int)Session["idoriginal"]; + myDAL objmyDAL = new myDAL(); + DataTable dt = new DataTable(); + int found = objmyDAL.generate_bill_DAL(did, ref dt); + + if (found != 1 || dt.Rows.Count == 0) + { + Label1.Text = "Error generating bill"; + Response.Write(""); + } + else + { + Label1.Text = dt.Rows[0][0].ToString(); + } + } + catch (Exception ex) + { + Response.Write($""); + } } } - public void bill_paid(object sender, EventArgs e) { - myDAL objmyDAL = new myDAL(); - - int did = (int)Session["idoriginal"]; - int appoint = (int)Session["appointid"]; - objmyDAL.paid_bill_DAL(did,appoint); - - Response.BufferOutput = false; - Response.Redirect("patienthistory.aspx"); - } + try + { + int did = (int)Session["idoriginal"]; + int appoint = (int)Session["appointid"]; + myDAL objmyDAL = new myDAL(); + objmyDAL.paid_bill_DAL(did, appoint); + + Response.BufferOutput = false; + Response.Redirect("patienthistory.aspx"); + } + catch (Exception ex) + { + Response.Write($""); + } + } public void bill_Unpaid(object sender, EventArgs e) { - myDAL objmyDAL = new myDAL(); + try + { + int did = (int)Session["idoriginal"]; + int appoint = (int)Session["appointid"]; - int did = (int)Session["idoriginal"]; - int appoint = (int)Session["appointid"]; - objmyDAL.Unpaid_bill_DAL(did, appoint); + myDAL objmyDAL = new myDAL(); + objmyDAL.Unpaid_bill_DAL(did, appoint); - Response.BufferOutput = false; - Response.Redirect("patienthistory.aspx"); + Response.BufferOutput = false; + Response.Redirect("patienthistory.aspx"); + } + catch (Exception ex) + { + Response.Write($""); + } } } -} \ No newline at end of file +}