Professional Documents
Culture Documents
CS
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.Data.SqlClient;
using System.Xml.Linq;
}
protected void SubmitButton_Click(object sender,
EventArgs e)
{
try
{
//retrieve customer name from session object
Session["CustomerName"] = NameTextBox.Text;
//sql query
SqlCommand cmd = new SqlCommand("insert into
Customer values(' " + CustomerIdTextBox.Text + "','" +
PasswordTextBox.Text + "','" + NameTextBox.Text + "','" +
DateTextBox.Text +
"','" + SexTextBox.Text + "','" +
DOBTextBox.Text + "','" + AddressTextBox.Text + "'," +
PhoneTextBox.Text + ",'" + EmailTextBox.Text + "')");
//creating connection object con
cmd.Connection = con;
Response.Redirect("~/Services/frmRegOut.aspx",false);
}
catch (Exception ex)
{
//redirecting any error catched by try-catche
block
Session["Error"] = ex.Message;
Response.Redirect("~/frmError.aspx",false);
}
}
HOME.ASPX.CS
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 System.Data.SqlClient;
using System.Data.Sql;
try
{
Session["UserId"] = UserIdTextBox.Text;
if (status == 1)
{
DataRow drow = ds1.Tables["user"].Rows[0];
//session for retrieving customer
information
Session["CustomerInfo"] = drow;
Response.Redirect("~/Services/MainCustomer.aspx", false);
}
else
{
// display the error for wrong password or
user id
InvalidLoginLabel.Text = "User Id or
Password do not match";
}
}
catch (Exception ex)
{
//redirecting the exception error catched by
try-catche block
Session["Error"] = ex.Message;
Response.Redirect("~/frmError.aspx", false);
}
}
}