public DAL_Applicant SelectFromApplicant(string username) { DAL_Applicant DAL_app = new DAL_Applicant(); using (SqlConnection connection = new SqlConnection(connectionString)) { string sql = "Select * From Applicant Where Username = @0"; SqlCommand command = new SqlCommand(sql, connection); command.Parameters.AddWithValue("@0", username); connection.Open(); using (SqlDataReader dataReader = command.ExecuteReader()) { if (dataReader.HasRows) { while (dataReader.Read()) { DAL_app.Id = MyConvertInt(dataReader["Applicant_Id"]); DAL_app.Fname = MyConvertString(dataReader["FName"]); DAL_app.Lname = MyConvertString(dataReader["LName"]); DAL_app.Username = MyConvertString(dataReader["Username"]); DAL_app.Password = MyConvertString(dataReader["Password"]); DAL_app.Age = MyConvertInt(dataReader["Age"]); DAL_app.Phone = MyConvertString(dataReader["Phone"]); DAL_app.ExtraInfo = MyConvertString(dataReader["Extra"]); DAL_app.AddedOn = Convert.ToDateTime(dataReader["ApplyDate"]); } } } connection.Close(); } return(DAL_app); }
public List <DAL_Applicant> GetAllApplicant() { List <DAL_Applicant> DAL_ApplicantList = new List <DAL_Applicant>(); using (SqlConnection connection = new SqlConnection(connectionString)) { connection.Open(); string sql = "Select * From Applicant"; SqlCommand command = new SqlCommand(sql, connection); using (SqlDataReader dataReader = command.ExecuteReader()) { while (dataReader.Read()) { DAL_Applicant DAL_app = new DAL_Applicant(); DAL_app.Id = MyConvertInt(dataReader["Applicant_Id"]); DAL_app.Fname = MyConvertString(dataReader["FName"]); DAL_app.Lname = MyConvertString(dataReader["LName"]); DAL_app.Username = MyConvertString(dataReader["Username"]); DAL_app.Password = MyConvertString(dataReader["Password"]); DAL_app.Age = MyConvertInt(dataReader["Age"]); DAL_app.Phone = MyConvertString(dataReader["Phone"]); DAL_app.ExtraInfo = MyConvertString(dataReader["Extra"]); DAL_app.AddedOn = Convert.ToDateTime(dataReader["ApplyDate"]); DAL_ApplicantList.Add(DAL_app); } } connection.Close(); } return(DAL_ApplicantList); }