|
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Common.Helpers.DataAccess;
using Common.Helpers.ExceptionHandling;
using System.Data.SqlClient;
namespace HelpersTestWeb
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GridView1.Visible = false;
TextBox1.Visible = false;
}
}
protected void btnScenario1_Click(object sender, EventArgs e)
{
try
{
DataTable dt = MyClass.GetCustomersList();
GridView1.DataSource = dt;
GridView1.DataBind();
GridView1.Visible = true;
}
catch (Exception ex)
{
TextBox1.Visible = true;
TextBox1.Text = ex.Message.ToString();
}
}
protected void btnScenario2_Click(object sender, EventArgs e)
{
try
{
object ret = MyClass.InsertCustomer("ABC", "ABC INC");
}
catch (Exception ex)
{
TextBox1.Visible = true;
TextBox1.Text = ex.Message.ToString();
}
}
protected void btnScenario3_Click(object sender, EventArgs e)
{
try
{
DataTable dt = MyClass.GetCustomerData("");
GridView1.DataSource = dt;
GridView1.DataBind();
GridView1.Visible = true;
}
catch (Exception ex)
{
TextBox1.Visible = true;
TextBox1.Text = ex.Message.ToString();
}
}
protected void btnScenario4_Click(object sender, EventArgs e)
{
try
{
int result = MyClass.DoSomeCalculation(10, 0);
TextBox1.Visible = true;
TextBox1.Text = "Calculation performed successfully. Result is " + result.ToString();
}
catch (Exception ex)
{
TextBox1.Visible = true;
TextBox1.Text = ex.Message.ToString();
}
}
protected void btnScenario5_Click(object sender, EventArgs e)
{
try
{
MyClass.SaveInvoice("ABC", 1200);
TextBox1.Visible = true;
TextBox1.Text = "Invoice saved successfully";
}
catch (Exception ex)
{
TextBox1.Visible = true;
TextBox1.Text = ex.Message.ToString();
}
}
protected void btnScenario6_Click(object sender, EventArgs e)
{
try
{
//intentially raising Divide by Zero exception
int a, b, c;
a = 20;
b = 0;
c = a / b;
TextBox1.Visible = true;
TextBox1.Text = "Divided Successfully. Result is " + c.ToString();
}
catch (Exception ex)
{
bool rethrow = false;
rethrow = UserInterfaceExceptionHandler.HandleExcetion(ref ex);
TextBox1.Visible = true;
TextBox1.Text = ex.Message.ToString();
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.