-
Notifications
You must be signed in to change notification settings - Fork 8
/
UpdateBusFee.aspx.cs
89 lines (72 loc) · 2.45 KB
/
UpdateBusFee.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
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class UpdateBusFee : System.Web.UI.Page
{
SqlConnection con;
SqlCommand cmd1, cmd2;
SqlDataAdapter da;
DataSet ds;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//TextBox1.Enabled = false;
}
}
protected void btnText_Click(object sender, EventArgs e)
{
con = new SqlConnection();
con.ConnectionString = ConfigurationSettings.AppSettings["conn"].ToString();
da = new SqlDataAdapter("select busfee from studentdetails where rollno ='"+txtID.Text+"' ", con);
ds = new DataSet();
da.Fill(ds);
TextBox1.Text = ds.Tables[0].Rows[0][0].ToString();
}
protected void btnChkAll_Click(object sender, EventArgs e)
{
int bus = 0;
con = new SqlConnection();
con.ConnectionString = ConfigurationSettings.AppSettings["conn"].ToString();
if (con.State == ConnectionState.Closed)
{
con.Open();
}
cmd1 = new SqlCommand();
DataSet ds = new DataSet();
SqlDataAdapter sda = new SqlDataAdapter("Select busfeedue from studentdetails where rollno='" + txtID.Text+"'", con);
sda.Fill(ds);
int busFee = Convert.ToInt32(ds.Tables[0].Rows[0][0].ToString());
if( Convert.ToInt32(TextBox1.Text)> Convert.ToInt32(TextBox3.Text))
{
bus = Convert.ToInt32(TextBox1.Text) - Convert.ToInt32(TextBox3.Text);
int busFeeDue = busFee - Convert.ToInt32(TextBox3.Text);
cmd1 = new SqlCommand("update studentdetails set busfeedue='" + busFeeDue + "' where rollno='" + txtID.Text+"'", con);
int i= cmd1.ExecuteNonQuery();
if (i > 0)
{
lblErr.Text = "Inserted Sucessfully";
}
else
{
lblErr.Text = "Error in inserting";
}
}
else
{
lblErr.Text="Enter Correct Value";
}
}
protected void Button1_Click(object sender, EventArgs e)
{
TextBox1.Enabled = true;
}
}