-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAddStaff.aspx.cs
63 lines (59 loc) · 2.05 KB
/
AddStaff.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
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace ClassManageApp
{
public partial class WebForm11 : System.Web.UI.Page
{
string constr = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Clear();
}
}
protected void SaveStaffDetails_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(constr);
string spname = "SpManageStaffDetails";
con.Open();
SqlCommand cmd = new SqlCommand(spname, con)
{
CommandType = System.Data.CommandType.StoredProcedure
};
cmd.Parameters.AddWithValue("@ACTION", "CREATE");
cmd.Parameters.AddWithValue("@FirstName", StaffFname.Text);
cmd.Parameters.AddWithValue("@LastName", StaffLname.Text);
cmd.Parameters.AddWithValue("@Contact", StaffNumber.Text);
cmd.Parameters.AddWithValue("@Email", StaffEmail.Text);
cmd.Parameters.AddWithValue("@Qualification", DdlQualification.SelectedValue);
cmd.Parameters.AddWithValue("@TeachingSubject", TeachingSubject.Text);
int i = cmd.ExecuteNonQuery();
if (i == 1)
{
Response.Write("<script>alert('One more Staff added!') </script>");
Clear();
}
else
{
Response.Write("<script>alert('Sorry! Something went wrong...') </script>");
}
con.Close();
}
private void Clear()
{
StaffFname.Text = "";
StaffLname.Text = "";
StaffNumber.Text = "";
StaffEmail.Text = "";
DdlQualification.SelectedValue = "";
TeachingSubject.Text = "";
}
}
}