PDA

نسخه کامل مشاهده نسخه کامل : کد های سی شارپ



spring_sky
17-09-2008, 14:04
سلام
من یه تکه کد به زبان سی شارپ دارم . اگر امکان دارد توضیح بدهید که هر خط چه کارایی دارد ؟
سپاسگزارم


public partial class _Default : System.Web.UI.Page
{
string a, b;
protected void Page_Load(object sender, EventArgs e)
{



}

protected void LinkButton1_Click(object sender, EventArgs e)
{
Response.Redirect("main.aspx");
TextBox1.Text = "";
TextBox2.Text = "";
Label3.Text = "";
}
protected void Button1_Click(object sender, EventArgs e)
{

}
protected void Button1_Click1(object sender, EventArgs e)
{
if (TextBox1.Text.Equals("") || TextBox2.Text.Equals(""))
return;


SqlConnection cn = new SqlConnection();
SqlCommand cmd = new SqlCommand();
SqlDataReader dr;
cn.ConnectionString = "Data Source=.;Initial Catalog=maskandb;Integrated Security=True";
cmd.Connection = cn;
cmd.CommandText = "select * from identify where user1='" + TextBox1.Text + "'and pass='" + TextBox2.Text + "'";
cn.Open();
dr = cmd.ExecuteReader();
while (dr.Read())
{
a = dr["user1"].ToString().Trim();
b = dr["pass"].ToString().Trim();
Session["name"] = dr["name"];
Session["fam"] = dr["famil"];
Session["tel"] = dr["tel"];
Session["cust_id"] = dr["code"];
}
if ((TextBox1.Text.Trim() == a) && (TextBox2.Text.Trim() == b))
{