-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path6ManageHR.aspx.cs
More file actions
73 lines (68 loc) · 2.43 KB
/
6ManageHR.aspx.cs
File metadata and controls
73 lines (68 loc) · 2.43 KB
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
using System;
using System.Data.SqlClient;
using System.Data;
namespace WebApplication06_eVisa
{
public partial class _6ManageHR : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("uid=sa; password=manager@123; database=EVisa; server=7Y27QV3\\SQLEXPRESS");
try
{
SqlDataAdapter aa = new SqlDataAdapter("select * from hr", con);
DataSet ds = new DataSet();
aa.Fill(ds);
gvHRData.DataSource = ds;
gvHRData.DataBind();
}
catch (Exception ex)
{
ClientScript.RegisterStartupScript(this.GetType(), "alert", $"alert('Error: {ex.Message}');", true);
}
finally
{
con.Close();
}
}
protected void BtnDelete_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("uid=sa; password=manager@123; database=EVisa; server=7Y27QV3\\SQLEXPRESS");
try
{
con.Open();
SqlCommand cmd = new SqlCommand("DELETE FROM hr WHERE HRID="+ int.Parse(txtHRID.Text), con);
cmd.ExecuteNonQuery();
ClientScript.RegisterStartupScript(this.GetType(), "alert", $"alert('Deleted HRID: {int.Parse(txtHRID.Text)}');", true);
}
catch (Exception ex)
{
ClientScript.RegisterStartupScript(this.GetType(), "alert", $"alert('Error: {ex.Message}');", true);
}
finally
{
con.Close();
}
}
protected void BtnView_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("uid=sa; password=manager@123; database=EVisa; server=7Y27QV3\\SQLEXPRESS");
try
{
SqlDataAdapter aa = new SqlDataAdapter("select * from hr", con);
DataSet ds = new DataSet();
aa.Fill(ds);
gvHRData.DataSource = ds;
gvHRData.DataBind();
}
catch (Exception ex)
{
ClientScript.RegisterStartupScript(this.GetType(), "alert", $"alert('Error: {ex.Message}');", true);
}
finally
{
con.Close();
}
}
}
}