-
Notifications
You must be signed in to change notification settings - Fork 0
/
RemoveApplication.aspx.cs
99 lines (82 loc) · 3.38 KB
/
RemoveApplication.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
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace HDFC_Loans
{
public partial class RemoveApplication : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string connectionstring = "Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=\"E:\\Web With ASP.Net By PJT\\Project1\\HDFC_Loans\\App_Data\\HDFC-Loans.mdf\";Integrated Security=True";
SqlConnection cn = new SqlConnection(connectionstring);
cn.Open();
if (!string.IsNullOrEmpty(TextBox9.Text))
{
string deleteQuery = "DELETE FROM [Loan] WHERE LoanNo=@LoanNo";
SqlCommand deleteCmd = new SqlCommand(deleteQuery, cn);
deleteCmd.Parameters.AddWithValue("@LoanNo", TextBox9.Text);
deleteCmd.ExecuteNonQuery();
Label10.Text = "Loan application removed successfully!";
TextBox1.Text = "";
TextBox2.Text = "";
DropDownList1.SelectedIndex = 0;
DropDownList2.SelectedIndex = 0;
TextBox5.Text = "";
TextBox6.Text = "";
TextBox7.Text = "";
TextBox8.Text = "";
TextBox9.Text = "";
}
else
{
Label10.Text = "Please enter a valid Loan No.";
}
cn.Close();
}
protected void Button3_Click(object sender, EventArgs e)
{
string connectionstring = "Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=\"E:\\Web With ASP.Net By PJT\\Project1\\HDFC_Loans\\App_Data\\HDFC-Loans.mdf\";Integrated Security=True";
SqlConnection cn = new SqlConnection(connectionstring);
cn.Open();
string query = "SELECT * FROM [Loan] WHERE LoanNo = @LoanNo";
SqlCommand cmd = new SqlCommand(query, cn);
cmd.Parameters.AddWithValue("@LoanNo", TextBox9.Text);
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
adapter.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
DataRow row = ds.Tables[0].Rows[0];
TextBox1.Text = row["AccountNo"].ToString();
TextBox2.Text = row["HolderName"].ToString();
DropDownList1.SelectedValue = row["LoanCategory"].ToString();
DropDownList2.SelectedValue = row["LoanType"].ToString();
TextBox5.Text = row["IssueDate"].ToString();
TextBox6.Text = row["Amount"].ToString();
TextBox7.Text = row["CurrentAddress"].ToString();
TextBox8.Text = row["LoanRemarks"].ToString();
}
else
{
Label10.Text = "Loan not found.";
TextBox1.Text = "";
TextBox2.Text = "";
DropDownList1.SelectedIndex = 0;
DropDownList2.SelectedIndex = 0;
TextBox5.Text = "";
TextBox6.Text = "";
TextBox7.Text = "";
TextBox8.Text = "";
}
cn.Close();
}
}
}