-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmployee Source Code.txt
More file actions
79 lines (36 loc) · 1.8 KB
/
Employee Source Code.txt
File metadata and controls
79 lines (36 loc) · 1.8 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
74
75
76
77
78
79
void BindData(){
SqlCommand cnn = new SqlCommand("Select * from emptab", con);
SqlDataAdapter da = new SqlDataAdapter(cnn);
DataTable table = new DataTable();
da.Fill(table);
dataGridView1.DataSource = table;
}
Add Code
con.Open();
SqlCommand cnn = new SqlCommand("Insert into emptab(id,employeename,age,email,salary,dob,benefit) Values(@id,@employeename,@age,@email,@salary,@dob,@benefit)", con);
cnn.Parameters.AddWithValue("@Id", int.Parse(textBox1.Text));
cnn.Parameters.AddWithValue("@EmployeeName", textBox2.Text);
cnn.Parameters.AddWithValue("@Age", int.Parse(textBox3.Text));
cnn.Parameters.AddWithValue("@Email", textBox4.Text);
cnn.Parameters.AddWithValue("@Salary", int.Parse(textBox5.Text));
cnn.Parameters.AddWithValue("@Dob", DateTime.Parse(textBox6.Text));
cnn.Parameters.AddWithValue("@Benefit", textBox7.Text);
cnn.ExecuteNonQuery();
con.Close();
BindData();
New Code
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
textBox5.Text = "";
textBox6.Text = "";
textBox7.Text = "";
Delete Code
SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-ADG77QL\SQLEXPRESS;Initial Catalog=employeedb;Integrated Security=True");
con.Open();
SqlCommand cnn = new SqlCommand("Delete emptab where id=@id", con);
cnn.Parameters.AddWithValue("@Id", int.Parse(textBox1.Text));
cnn.ExecuteNonQuery();
con.Close();
MessageBox.Show("Data Deleted");