Coding > Index page

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Data;

using System.Web.UI.WebControls;

public partial class Index : System.Web.UI.Page

{

BusinessLogic obj_business = new BusinessLogic();

DataContext obj_datacontext = new DataContext();

protected void Page_Load(object sender, EventArgs e)

{

if (!IsPostBack)

{

DataTable dt = obj_business.getitemtypes();

datalisttypes.DataSource = dt;

datalisttypes.DataBind();

}

}

protected void btnsubmit_Click(object sender, EventArgs e)

{

string query = "select* from tbl_usermaster where username = '"+txtUsername.Text.ToString()+"'";

DataTable dt = obj_datacontext.getdataTable(query);

int refid = Convert.ToInt32(dt.Rows[0]["i_autoid"].ToString());

string query1 = "select * from tbl_userdetails where ref_id = '"+refid+"'";

DataTable dt1 = obj_datacontext.getdataTable(query1);

if (dt.Rows.Count > 0)

{

Session["username"] = dt.Rows[0]["username"].ToString();

Session["userid"] = Convert.ToInt32(dt.Rows[0]["i_autoid"].ToString());

if(dt.Rows[0]["username"].ToString() == Session["username"].ToString() && dt.Rows[0]["password"].ToString()==txtpwd.Text.ToString())

{

if (dt1.Rows[0]["user_type"].ToString() == "vendor")

{

Response.Redirect("myaccountvendor.aspx?userid=" + Session["userid"].ToString());

}

else if (dt1.Rows[0]["user_type"].ToString() == "both")

{

Response.Redirect("myaccountboth.aspx?userid=" + Session["userid"].ToString());

}

else if (dt1.Rows[0]["user_type"].ToString() == "customer")

{

Response.Redirect("myaccountcustomer.aspx?userid=" + Session["userid"].ToString());

}

}

}

}

protected void btnsignup_Click(object sender, EventArgs e)

{

Response.Redirect("registration.aspx");

}

public string getSRC(object imgSRC)

{

DataRowView dRView = (DataRowView)imgSRC;

string ImageName = dRView["typeimage"].ToString();

if (ImageName == "NoImage")

{

return ResolveUrl(@"~/UserImage/missing.jpg");

}

else

{

return ResolveUrl(ImageName);

}

}

public string itemtype(object sURL)

{

DataRowView dRView = (DataRowView)sURL;

string heading = dRView["typename"].ToString();

return heading;

}

protected void btnforgot_Click(object sender, EventArgs e)

{

Response.Redirect("PasswordRecovery.aspx");

}

}