-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDALStudentInfo.cs
143 lines (120 loc) · 4.98 KB
/
DALStudentInfo.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
using System;
using System.Collections.Generic;
using System.Linq;
using System.Data.SqlClient;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using ClassLibraryEntities;
using System.Reflection.Metadata;
namespace ClassLibraryDAL
{
public class DALStudentInfo
{
public static string? Excep { get; set; }
public static void SaveStudentInfo(EntStudentInfo ee)
{
try
{
SqlConnection con = DBHelper.GetConnection();
con.Open();
SqlCommand cmd = new SqlCommand("SP_SaveStudentInfo", con);
cmd.Parameters.AddWithValue("@SID", ee.SID);
cmd.Parameters.AddWithValue("@FirstName", ee.FirstName);
cmd.Parameters.AddWithValue("@FatherName", ee.FatherName);
cmd.Parameters.AddWithValue("@Gender", ee.Gender);
cmd.Parameters.AddWithValue("@CNIC", ee.CNIC);
cmd.Parameters.AddWithValue("@DateOfBirth", ee.DateOfBirth);
cmd.Parameters.AddWithValue("@City", ee.City);
cmd.Parameters.AddWithValue("@Address", ee.Address);
cmd.Parameters.AddWithValue("@StudentMobileNo", ee.StudentMobileNo);
cmd.Parameters.AddWithValue("@Email", ee.Email);
cmd.CommandType = CommandType.StoredProcedure;
cmd.ExecuteNonQuery();
con.Close();
}
catch (Exception ex)
{
Excep = ex.Message.ToString() + ex.StackTrace.ToString();
DalFilter.GetError(Excep);
}
}
public static List<EntStudentInfo> GetStudentInfobyID(string stdid)
{
List<EntStudentInfo> StudentInfoList = new List<EntStudentInfo>();
try
{
SqlConnection con = DBHelper.GetConnection();
con.Open();
SqlCommand cmd = new SqlCommand("U_SP_GetStudentInfobyID", con);
cmd.Parameters.AddWithValue("@StdId", stdid);
cmd.CommandType = CommandType.StoredProcedure;
SqlDataReader sdr = cmd.ExecuteReader();
while (sdr.Read())
{
EntStudentInfo ee = new EntStudentInfo();
ee.SID = sdr["SID"].ToString();
ee.FirstName = sdr["FirstName"].ToString();
ee.FatherName = sdr["FatherName"].ToString();
ee.CNIC = sdr["StdCnic"].ToString();
ee.DateOfBirth = sdr["DateOfBirth"].ToString();
ee.City = sdr["City"].ToString();
ee.Email = sdr["Email"].ToString();
ee.Gender = sdr["Gender"].ToString();
ee.StudentMobileNo = sdr["StdMobileNumber"].ToString();
StudentInfoList.Add(ee);
}
con.Close();
}
catch (Exception ex)
{
Excep = ex.Message.ToString() + ex.StackTrace.ToString();
DalFilter.GetError(Excep);
}
return StudentInfoList;
}
public static void DeleteStudentInfobyID(string id)
{
try
{
SqlConnection con = DBHelper.GetConnection();
con.Open();
SqlCommand cmd = new SqlCommand("U_SP_DeleteStudentInfobyID", con);
cmd.Parameters.AddWithValue("@SID", id);
cmd.CommandType = CommandType.StoredProcedure;
cmd.ExecuteNonQuery();
con.Close();
}
catch (Exception ex)
{
Excep = ex.Message.ToString() + ex.StackTrace.ToString();
DalFilter.GetError(Excep);
}
}
public static void UpdateStudentInfo(EntEducationalInfo ee)
{
try
{
SqlConnection con = DBHelper.GetConnection();
con.Open();
SqlCommand cmd = new SqlCommand("SP_UpdateFSC", con);
cmd.Parameters.AddWithValue("@SID", ee.SID);
cmd.Parameters.AddWithValue("@PassingDSGroup", ee.PassingDSGroup);
cmd.Parameters.AddWithValue("@Board_University", ee.Board_University);
cmd.Parameters.AddWithValue("@ObtainedMarks", ee.ObtainedMarks);
cmd.Parameters.AddWithValue("@TotalMarks", ee.TotalMarks);
cmd.Parameters.AddWithValue("@Percentage", ee.Percentage);
cmd.Parameters.AddWithValue("@PassingYear", ee.PassingYear);
cmd.Parameters.AddWithValue("@Institute", ee.Institute);
cmd.CommandType = CommandType.StoredProcedure;
cmd.ExecuteNonQuery();
con.Close();
}
catch (Exception ex)
{
Excep = ex.Message.ToString() + ex.StackTrace.ToString();
DalFilter.GetError(Excep);
}
}
}
}