private void btn_Clicked(object sender, EventArgs e) { if (sender == btnSearch) { try { List <ConsumerManagementService.Consumer> list = client.getConsumerID(tbConsumerid.Text).ToList(); lblError.Text = ""; consumerlist.DataSource = list; consumerlist.DataBind(); } catch (FaultException <ConsumerManagementService.ConsumerFault> obj) { lblError.Text = obj.Detail.Error + " : " + obj.Detail.Details; consumerlist.DataSource = null; consumerlist.DataBind(); } catch (SocketException obj) { Session.Abandon(); Response.Redirect("Login.aspx"); } catch (WebException obj) { Session.Abandon(); Response.Redirect("Login.aspx"); } catch (EndpointNotFoundException obj) { Session.Abandon(); Response.Redirect("Login.aspx"); } } }
protected void Page_Load(object sender, EventArgs e) { try { lblUsername.Text = "Hello " + Session["username"]; if (Session["username"].ToString() == "") { throw new Exception(); } } catch (Exception ex) { Response.Redirect("Login.aspx"); } client = (ConsumerManagementService.ConsumerManagementServiceClient) Session["client"]; btnYes.Click += new System.EventHandler(this.btn_Clicked); btnNo.Click += new System.EventHandler(this.btn_Clicked); List <ConsumerManagementService.Consumer> list = client.getConsumerID(Session["consumerId"].ToString()).ToList(); lblConsumerId.Text = list[0].ConsumerID.ToString(); lblFirstName.Text = list[0].FirstName; lblLastName.Text = list[0].LastName; lblCity.Text = list[0].City; lblBillAmount.Text = list[0].BillAmount.ToString(); lblDueDate.Text = list[0].DueDate.ToString(); }
protected void Page_Load(object sender, EventArgs e) { try { lblUsername.Text = "Hello " + Session["username"]; if (Session["username"].ToString() == "") { throw new Exception(); } } catch (Exception ex) { Response.Redirect("Login.aspx"); } client = (ConsumerManagementService.ConsumerManagementServiceClient) Session["client"]; lblConsumerId.ForeColor = System.Drawing.Color.Red; lblFirstName.ForeColor = System.Drawing.Color.Red; lblLastName.ForeColor = System.Drawing.Color.Red; lblCity.ForeColor = System.Drawing.Color.Red; lblBillAmount.ForeColor = System.Drawing.Color.Red; lblDueDate.ForeColor = System.Drawing.Color.Red; btnAdd.Click += new EventHandler(this.btn_Click); btnReset.Click += new EventHandler(this.btn_Click); if (Session["operation"] != null && Session["operation"].Equals("edit")) { List <ConsumerManagementService.Consumer> list = client.getConsumerID(Session["consumerId"].ToString()).ToList(); tbConsumerID.Text = list[0].ConsumerID.ToString(); tbConsumerID.Enabled = false; tbFirstName.Text = list[0].FirstName; tbLastName.Text = list[0].LastName; tbCity.Text = list[0].City; tbBillAmount.Text = list[0].BillAmount.ToString(); tbDueDate.Text = list[0].DueDate.ToString("yyyy-MM-dd"); btnAdd.Text = "Update"; } }