Top Banner
9

OGS_Snaps

Apr 08, 2018

Download

Documents

Harish Kr Singh
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: OGS_Snaps

8/7/2019 OGS_Snaps

http://slidepdf.com/reader/full/ogssnaps 1/9

Page 2: OGS_Snaps

8/7/2019 OGS_Snaps

http://slidepdf.com/reader/full/ogssnaps 2/9

Page 3: OGS_Snaps

8/7/2019 OGS_Snaps

http://slidepdf.com/reader/full/ogssnaps 3/9

Page 4: OGS_Snaps

8/7/2019 OGS_Snaps

http://slidepdf.com/reader/full/ogssnaps 4/9

Page 5: OGS_Snaps

8/7/2019 OGS_Snaps

http://slidepdf.com/reader/full/ogssnaps 5/9

Page 6: OGS_Snaps

8/7/2019 OGS_Snaps

http://slidepdf.com/reader/full/ogssnaps 6/9

REGISTER.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.Data.SqlClient;

using System.Xml.Linq;

public partial class Services_NewCustomer :System.Web.UI. Page{

protected void Page_Load( object sender, EventArgs e){

} protected void SubmitButton_Click( object sender,

EventArgs e){

try{

//retrieve customer name from session objectSession[ "CustomerName" ] = NameTextBox.Text;

//connection string for locating database SqlConnection con = new SqlConnection ( "Data

Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\Smart\\Documents\\Visual Studio 2008\\WebSites\\Online GasService\\App_Data\\OGS.mdf;Integrated Security=True;UserInstance=True" );

//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 + "')" );

Page 7: OGS_Snaps

8/7/2019 OGS_Snaps

http://slidepdf.com/reader/full/ogssnaps 7/9

//creating connection object con

cmd.Connection = con; //opening Database connection

con.Open(); int rows = cmd.ExecuteNonQuery();

//redirecting to contratulation page aftersuccessful registration

Response.Redirect( "~/Services/frmRegOut.aspx" , false );

} catch ( Exception ex)

{

//redirecting any error catched by try-catcheblock

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;

public partial class Home : System.Web.UI. Page{

Page 8: OGS_Snaps

8/7/2019 OGS_Snaps

http://slidepdf.com/reader/full/ogssnaps 8/9

protected void Page_Load( object sender, EventArgs e){

TimestampLabel.Text = DateTime .Now.ToString();

//to display the current date and time.

}

protected void LoginButton_Click( object sender,EventArgs e)

{

try{

Session[ "UserId" ] = UserIdTextBox.Text;

//creating SqlConection Object con SqlConnection con = new

System.Data.SqlClient. SqlConnection (); DataSet ds1 = new DataSet ();

//connecting Database using data source

connectionStringcon.ConnectionString = "Data

Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\Smart\\Documents\\Visual Studio 2008\\WebSites\\Online GasService\\App_Data\\OGS.mdf;Integrated Security=True;UserInstance=True" ;

//opening Database connectioncon.Open();

string sql = "SELECT * from Customer WHERE(Customer_Id=' " +UserIdTextBox.Text+ "' andCustomer_Pwd='" +PasswordTextBox.Text+ "')" ;

//SqlDataAdapter make bridge between database

and temp data storage user using datafill SqlDataAdapter da = new

System.Data.SqlClient. SqlDataAdapter (sql, con); //storing rows in temp variable user

da.Fill(ds1, "user" );

int status = ds1.Tables[ "user" ].Rows.Count;

if (status == 1){

DataRow drow = ds1.Tables[ "user" ].Rows[0];

Page 9: OGS_Snaps

8/7/2019 OGS_Snaps

http://slidepdf.com/reader/full/ogssnaps 9/9

//session for retrieving customerinformation

Session[ "CustomerInfo" ] = drow;

//redirecting the user to main Customerwindow for performing different operation after successfullylogin

Response.Redirect( "~/Services/MainCustomer.aspx" , false );

} else

{ // display the error for wrong password or

user idInvalidLoginLabel.Text = "User Id or

Password do not match" ;}

} catch ( Exception ex)

{ //redirecting the exception error catched by

try-catche blockSession[ "Error" ] = ex.Message;Response.Redirect( "~/frmError.aspx" , false );

}

}}