static NewService() { RepairsDataSet = new RepairsDataSet(); serviceTableAdapter daservices = new serviceTableAdapter(); try { daservices.Fill(RepairsDataSet.service); } catch { flag = true; } }
protected void Page_Load(object sender, EventArgs e) { if (!User.Identity.IsAuthenticated) //if not logged in { Response.Redirect("/"); } if (Request.Cookies["ID"] != null) // Request the cookies which contaions the ID Of thr record that was carried over from the index page { Label1.Text = Request.Cookies["ID"].Value; } id = Convert.ToInt32(Request.Cookies["ID"].Value); if (!IsPostBack) { if (id != -1) { try { serviceTableAdapter daservices = new serviceTableAdapter(); daservices.Fill(repairsDataSet.service); DataRow Service = repairsDataSet.service.FindByid(id); // Find the related Record and fill the fields in the page with the data if (Service != null) { this.txtName.Text = Service.ItemArray[1].ToString(); this.txtDescription.Text = Service.ItemArray[2].ToString(); this.txtPrice.Text = Service.ItemArray[3].ToString(); } else { this.Label1.Visible = true; Label1.Text = "Please Try Again"; } } catch { this.Label1.Visible = true; Label1.Text = "❌ Database Eror, Contact System Administrator"; } } else { Servicevalidation(); } } }
protected void Page_Load(object sender, EventArgs e) { if (!User.Identity.IsAuthenticated) //if not logged in { Response.Redirect("/"); } try { //refresh the dataset, so the newly created record is shown in index serviceTableAdapter daservices = new serviceTableAdapter(); daservices.Fill(RepairsDataSet.service); } catch { this.Label1.Text = "Failed to load Data, Please Contact the system administrator"; this.Label1.ForeColor = Color.Red; return; } Session["RepairCriteria"] = null; if (Session["deleteMsg"] != null) { if (Session["deleteMsg"].ToString() == "true") { this.lblDeleteMsg.Visible = true; this.lblDeleteMsg.Text = "✔ Record deleted Successfully"; Session["deleteMsg"] = null; this.pnlDeleteConfirm.Visible = false; } else { this.lblDeleteMsg.Visible = true; this.lblDeleteMsg.Text = "❌ Record not deleted, please check if this service is related to any repairs"; Session["deleteMsg"] = null; this.lblDeleteMsg.ForeColor = Color.Red; this.pnlDeleteConfirm.Visible = false; } } //get records rows = (Session["ServiceCriteria"] != null) ? RepairsDataSet.service.Select(Session["ServiceCriteria"].ToString()) //has criteria : RepairsDataSet.service.Select(); //select all DisplayServiceTable(); }
// Filter Search Btn protected void btnSearch_Click(object sender, EventArgs e) { serviceTableAdapter daservices = new serviceTableAdapter(); daservices.Fill(RepairsDataSet.service); if (RepairsDataSet.service.Count > 0) { string criteria = FilterCriteria(); Session["ServiceCriteria"] = FilterCriteria(); rows = (criteria.Length > 0) ? RepairsDataSet.service.Select(criteria) : RepairsDataSet.service.Select(); // Data satisfying the conditions is saved in rows DisplayServiceTable(); } else { this.Label1.Text = "Database Error, Please Contact The System Administarator"; this.Label1.ForeColor = Color.Red; } }