0% found this document useful (0 votes)
27 views

Addind Record: Using Using Using Using Using Using Using

The document contains code for several C# class files that are part of a student management system. The classes include code for adding student records to a database table, an admin homepage, a login page that directs users to different pages based on their role, retrieving a forgotten password, and a student homepage that displays a personalized welcome message. The code establishes database connections, inserts and selects data from tables, and handles user authentication and redirection between pages.

Uploaded by

bond2007
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

Addind Record: Using Using Using Using Using Using Using

The document contains code for several C# class files that are part of a student management system. The classes include code for adding student records to a database table, an admin homepage, a login page that directs users to different pages based on their role, retrieving a forgotten password, and a student homepage that displays a personalized welcome message. The code establishes database connections, inserts and selects data from tables, and handles user authentication and redirection between pages.

Uploaded by

bond2007
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 5

ADDIND RECORD

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;

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


{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection CON = new SqlConnection("Data Source=LATA-
LAPTOP\\SQLEXPRESS;Initial Catalog=satnam sakshi;Integrated
Security=True;Multipleactiveresultsets=true");
CON.Open();

SqlCommand CMD = new SqlCommand("INSERT INTO ssa1


VALUES(@val,@va,@val1,@val2,@val3,@val4,@val5,@val6,@val7,@val8)", CON);

CMD.Parameters.AddWithValue("@val", TextBox3.Text.ToLower());
CMD.Parameters.AddWithValue("@va", Password1.Value);
CMD.Parameters.AddWithValue("@val1", TextBox10.Text);
CMD.Parameters.AddWithValue("@val2", DropDownList1.Text);
CMD.Parameters.AddWithValue("@val3", TextBox4.Text);
CMD.Parameters.AddWithValue("@val4", TextBox5.Text);
CMD.Parameters.AddWithValue("@val5", TextBox6.Text);
CMD.Parameters.AddWithValue("@val6",TextBox7.Text);
CMD.Parameters.AddWithValue("@val7", TextBox8.Text);
CMD.Parameters.AddWithValue("@val8", TextBox9.Text);

CMD.ExecuteReader();
TextBox7.Enabled = false;
TextBox3.Enabled = false;
TextBox4.Enabled = false;
TextBox5.Enabled = false;
TextBox6.Enabled = false;
TextBox8.Enabled = false;
TextBox9.Enabled = false;
TextBox10.Enabled = false;
//TextBox11.Enabled = false;
//TextBox12.Enabled = false;

SqlCommand CMD1 = new SqlCommand("INSERT INTO ssl2


VALUES(@val1,@val2,@val3,@val4)", CON);
CMD1.Parameters.AddWithValue("@val1", TextBox3.Text);
CMD1.Parameters.AddWithValue("@val2", Password1.Value);
CMD1.Parameters.AddWithValue("@val3", "student");
CMD1.Parameters.AddWithValue("@val4", TextBox10.Text);

CMD1.ExecuteReader();
Label9.Text = "Admission Details Recorded";

}
protected void TextBox8_TextChanged(object sender, EventArgs e)
{

}
}

ADMIN PAGE

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;

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


{

protected void Page_Load(object sender, EventArgs e)


{

}
// protected void Button1_Click(object sender, EventArgs e)
//{
// byte[] file;
//file = FileUpload1.FileBytes;
//File.WriteAllBytes("c:\\java\\"+FileUpload1.FileName, file);
//}
}

LOGIN PAGE

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;

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


{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection CON2 = new SqlConnection("Data Source=LATA-
LAPTOP\\SQLEXPRESS;Initial Catalog=satnam sakshi;Integrated
Security=True;Multipleactiveresultsets=true");
CON2.Open();
SqlDataAdapter da = new SqlDataAdapter("select * from
ssl2",CON2);
DataSet ds = new DataSet();

da.Fill(ds);
foreach (DataRow dr in ds.Tables[0].Rows)
{
if (TextBox1.Text == dr[0].ToString() && Password1.Value==
dr[1].ToString())
{
if (dr[2].ToString().Equals("student"))
{
Session["StudentName"] = dr[0].ToString();
Response.Redirect("~/student home page.aspx");
break;
}
if (dr[2].ToString().Equals("warden"))
{
//Loading_Page load = new Loading_Page();
Response.Redirect("~/warden hm page.aspx");
break;
}
if (dr[2].ToString().Equals("admin"))
{
//Loading_Page load = new Loading_Page();
Response.Redirect("~/admin hm page.aspx");
break;
}

}
else
Label3.Text = "Login Failed";

}
}
protected void TextBox4_TextChanged(object sender, EventArgs e)
{

}
protected void TextBox1_TextChanged(object sender, EventArgs e)
{

}
}

RETRIEVE PASSWORD

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;

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


{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection CON = new SqlConnection("Data Source=LATA-
LAPTOP\\SQLEXPRESS;Initial Catalog=satnam sakshi;Integrated
Security=True;Multipleactiveresultsets=true");
CON.Open();

SqlCommand CMD = new SqlCommand("Select password from ssl2 where


[user name]=@val1 ", CON);
CMD.Parameters.AddWithValue("@val1", TextBox1.Text);
SqlDataReader dr = CMD.ExecuteReader();
dr.Read();
Label3.Text="PASSWORD IS :" + dr[0];

}
}

STUDENT HP

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

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


{
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = "Welcome : "+Session["StudentName"].ToString();
}

protected void Button1_Click(object sender, EventArgs e)


{

}
protected void Calendar1_SelectionChanged(object sender, EventArgs
e)
{

}
}

You might also like