-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStudentInformation.aspx.cs
213 lines (194 loc) · 9.09 KB
/
StudentInformation.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
namespace Student_Management_System
{
public partial class StudentInformation : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Button3.Enabled = false;
Button4.Enabled = false;
Button5.Enabled = false;
Button6.Enabled = false;
TextBox2.Enabled = false;
TextBox3.Enabled = false;
TextBox4.Enabled = false;
}
protected void Button2_Click(object sender, EventArgs e)
{
TextBox1.Enabled = true;
TextBox2.Enabled = true;
TextBox3.Enabled = true;
TextBox4.Enabled = true;
Button1.Enabled = false;
Button2.Enabled = false;
Button3.Enabled = true;
Button6.Enabled = true;
Button1.Enabled = false;
Label2.Text = "New Blank Form Has Been Added.";
Label1.Text = "";
}
protected void Button3_Click(object sender, EventArgs e)
{
string mainconn = ConfigurationManager.ConnectionStrings["Myconnection"].ConnectionString;
SqlConnection sqlconn = new SqlConnection(mainconn);
String query = "insert into [dbo].[StudentInformation] (rollno,sname,fathername,mothername)"+" values(@rollno,@sname,@fathername,@mothername)";
// String mycon = "Data Source=VIKAS-PC\\SQLEXPRESS; Initial Catalog=RegistrationFormData; Integrated Security=true";
// SqlConnection con = new SqlConnection(mycon);
sqlconn.Open();
//cmd.Connection = sqlconn;
SqlCommand sqlcomm = new SqlCommand(query, sqlconn);
sqlcomm.Parameters.AddWithValue("@rollno", TextBox1.Text);
//sqlcomm.Parameters.AddWithValue("@gender", DropDownList1.Text);
sqlcomm.Parameters.AddWithValue("@sname", TextBox2.Text);
sqlcomm.Parameters.AddWithValue("@fathername", TextBox3.Text);
sqlcomm.Parameters.AddWithValue("@mothername", TextBox4.Text);
sqlcomm.ExecuteNonQuery();
Button1.Enabled = true;
Button2.Enabled = true;
Button6.Enabled = false;
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
TextBox2.Enabled = false;
TextBox3.Enabled = false;
TextBox4.Enabled = false;
Label2.Text = "Data Has Been Saved Successfully";
Label1.Text = "";
}
protected void Button4_Click(object sender, EventArgs e)
{
string mainconn = ConfigurationManager.ConnectionStrings["Myconnection"].ConnectionString;
SqlConnection sqlconn = new SqlConnection(mainconn);
String query = "Update [dbo].[StudentInformation] set sname='" + TextBox2.Text + "', fathername='" + TextBox3.Text + "', mothername='" + TextBox4.Text + "' where rollno=" + TextBox1.Text;
// String mycon = "Data Source=VIKAS-PC\\SQLEXPRESS; Initial Catalog=RegistrationFormData; Integrated Security=true";
// SqlConnection con = new SqlConnection(mycon);
sqlconn.Open();
//cmd.Connection = sqlconn;
SqlCommand sqlcomm = new SqlCommand(query, sqlconn);
sqlcomm.Parameters.AddWithValue("@rollno", TextBox1.Text);
//sqlcomm.Parameters.AddWithValue("@gender", DropDownList1.Text);
sqlcomm.Parameters.AddWithValue("@sname", TextBox2.Text);
sqlcomm.Parameters.AddWithValue("@fathername", TextBox3.Text);
sqlcomm.Parameters.AddWithValue("@mothername", TextBox4.Text);
sqlcomm.ExecuteNonQuery();
Label1.Text = "";
Label2.Text = "Particular Record Has Been Updated Successfully : Roll Number " + TextBox1.Text;
Button1.Enabled = true;
Button2.Enabled = true;
Button3.Enabled = false;
Button4.Enabled = false;
Button5.Enabled = false;
Button6.Enabled = false;
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
TextBox2.Enabled = false;
TextBox3.Enabled = false;
TextBox4.Enabled = false;
}
protected void Button5_Click(object sender, EventArgs e)
{
string mainconn = ConfigurationManager.ConnectionStrings["Myconnection"].ConnectionString;
SqlConnection sqlconn = new SqlConnection(mainconn);
String query = "delete from [dbo].[StudentInformation] (rollno,sname,fathername,mothername)"+" values(@rollno,@sname,@fathername,@mothername)";
// String mycon = "Data Source=VIKAS-PC\\SQLEXPRESS; Initial Catalog=RegistrationFormData; Integrated Security=true";
// SqlConnection con = new SqlConnection(mycon);
sqlconn.Open();
//cmd.Connection = sqlconn;
SqlCommand sqlcomm = new SqlCommand(query, sqlconn);
sqlcomm.Parameters.AddWithValue("@rollno", TextBox1.Text);
//sqlcomm.Parameters.AddWithValue("@gender", DropDownList1.Text);
sqlcomm.Parameters.AddWithValue("@sname", TextBox2.Text);
sqlcomm.Parameters.AddWithValue("@fathername", TextBox3.Text);
sqlcomm.Parameters.AddWithValue("@mothername", TextBox4.Text);
sqlcomm.ExecuteNonQuery();
Label1.Text = "";
Label2.Text = "Particular Record Has Been Deleted Successfully : Roll Number " + TextBox1.Text;
Button1.Enabled = true;
Button2.Enabled = true;
Button3.Enabled = false;
Button4.Enabled = false;
Button5.Enabled = false;
Button6.Enabled = false;
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
TextBox2.Enabled = false;
TextBox3.Enabled = false;
TextBox4.Enabled = false;
}
protected void Button6_Click(object sender, EventArgs e)
{
Button1.Enabled = true;
Button2.Enabled = true;
Button3.Enabled = false;
Button4.Enabled = false;
Button5.Enabled = false;
Button6.Enabled = false;
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
TextBox2.Enabled = false;
TextBox3.Enabled = false;
TextBox4.Enabled = false;
Label2.Text = "Operation Has Been Cancelled Successfully";
Label1.Text = "";
}
protected void Button1_Click(object sender, EventArgs e)
{
string mainconn = ConfigurationManager.ConnectionStrings["Myconnection"].ConnectionString;
SqlConnection sqlconn = new SqlConnection(mainconn);
String query = "Select * from [dbo].[StudentInformation]" ;
// String mycon = "Data Source=VIKAS-PC\\SQLEXPRESS; Initial Catalog=RegistrationFormData; Integrated Security=true";
// SqlConnection con = new SqlConnection(mycon);
sqlconn.Open();
//cmd.Connection = sqlconn;
SqlCommand sqlcomm = new SqlCommand(query, sqlconn);
/**
* sqlcomm.Parameters.AddWithValue("@rollno", TextBox1.Text);
//sqlcomm.Parameters.AddWithValue("@gender", DropDownList1.Text);
sqlcomm.Parameters.AddWithValue("@sname", TextBox2.Text);
sqlcomm.Parameters.AddWithValue("@fathername", TextBox3.Text);
sqlcomm.Parameters.AddWithValue("@mothername", TextBox4.Text);
**/
sqlcomm.ExecuteNonQuery();
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = sqlcomm;
DataSet ds = new DataSet();
da.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
Label1.Text = "Roll Number Found Successfully";
Label2.Text = "";
TextBox2.Text = ds.Tables[0].Rows[0]["sname"].ToString();
TextBox3.Text = ds.Tables[0].Rows[0]["fathername"].ToString();
TextBox4.Text = ds.Tables[0].Rows[0]["mothername"].ToString();
Button4.Enabled = true;
Button5.Enabled = true;
Button6.Enabled = true;
TextBox2.Enabled = true;
TextBox3.Enabled = true;
TextBox4.Enabled = true;
Button2.Enabled = false;
}
else
{
Label1.Text = "No Particular Searched Roll Number Found";
Label2.Text = "";
}
sqlconn.Close();
}
}
}