-
Notifications
You must be signed in to change notification settings - Fork 8
/
UpdateLibraryFee.aspx.cs
83 lines (65 loc) · 2.22 KB
/
UpdateLibraryFee.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
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 UpdateLibraryFee : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["conn"].ToString());
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)
{
TextBox1.Enabled = true;
}
protected void btnChkAll_Click(object sender, EventArgs e)
{
if (con.State == ConnectionState.Closed)
{
con.Open();
}
DataSet ds = new DataSet();
SqlDataAdapter sda = new SqlDataAdapter("Select libraryfeedue from studentdetails where rollno='" + txtID.Text+"'", con);
sda.Fill(ds);
int libFee = Convert.ToInt32(ds.Tables[0].Rows[0][0].ToString());
if (Convert.ToInt32(TextBox1.Text) > Convert.ToInt32(TextBox3.Text))
{
int lib = Convert.ToInt32(TextBox1.Text) - Convert.ToInt32(TextBox3.Text);
int libFeeDue = libFee - Convert.ToInt32(TextBox3.Text);
cmd1 = new SqlCommand();
cmd1.Connection = con;
cmd1.CommandType = CommandType.Text;
cmd1.CommandText = "update studentdetails set libraryfeedue='" + libFeeDue + "' where rollno='" + txtID.Text + "'";
int i = cmd1.ExecuteNonQuery();
if (i > 0)
{
lblErr.Text = "updated sucessfully";
}
}
else
{
lblErr.Text = "Enter Correct Value";
}
}
protected void Button1_Click(object sender, EventArgs e)
{
da = new SqlDataAdapter("SELECT libraryfee FROM studentdetails WHERE rollno='" + txtID.Text+"' " , con);
ds = new DataSet();
da.Fill(ds);
TextBox1.Text = ds.Tables[0].Rows[0][0].ToString();
}
}