public List <LopHoc> GetList(string TenLopHoc, byte MonHocID, string NhanHocVien, byte Khoi, string username) { SqlConnection con = db.getConnection(); List <LopHoc> l_LopHoc = new List <LopHoc>(); try { SqlCommand cmd = new SqlCommand("LopHoc_timkiem"); cmd.Connection = con; con.Open(); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@TenLopHoc", TenLopHoc)); cmd.Parameters.Add(new SqlParameter("@MonHocID", MonHocID)); cmd.Parameters.Add(new SqlParameter("@NhanHocVien", NhanHocVien)); cmd.Parameters.Add(new SqlParameter("@Khoi", Khoi)); SqlDataReader reader = cmd.ExecuteReader(); SmartDataReader smartReader = new SmartDataReader(reader); while (smartReader.Read()) { LopHoc lh = new LopHoc(); lh.ID = smartReader.GetInt16("ID"); lh.TenLopHoc = smartReader.GetString("TenLopHoc"); lh.SoLuong = smartReader.GetInt16("SoLuong"); lh.NgayNhan = smartReader.GetString("NgayNhan"); lh.HanChot = smartReader.GetString("HanChot"); lh.NgayNhapHoc = smartReader.GetString("NgayNhapHoc"); lh.TenMonHoc = smartReader.GetString("TenMonHoc"); lh.HocPhi = smartReader.GetDecimal("HocPhi"); lh.LichHoc = smartReader.GetString("LichHoc"); lh.NhanHocVien = smartReader.GetBoolean("NhanHocVien"); lh.LoaiHocPhiID = smartReader.GetByte("LoaiHocPhiID"); lh.Khoi = smartReader.GetByte("Khoi"); lh.DangKy = CheckDangKy(username, lh.ID); l_LopHoc.Add(lh); } smartReader.disposeReader(reader); } catch (Exception ex) { throw ex; } finally { db.closeConnection(con); } return(l_LopHoc); }
public LopHoc FindByID(short ID) { LopHoc lh = new LopHoc(); SqlConnection con = db.getConnection(); try { SqlCommand cmd = new SqlCommand("LopHoc_chitiet"); cmd.Connection = con; con.Open(); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@ID", ID)); SqlDataReader reader = cmd.ExecuteReader(); SmartDataReader smartReader = new SmartDataReader(reader); while (smartReader.Read()) { lh.ID = smartReader.GetInt16("ID"); lh.TenLopHoc = smartReader.GetString("TenLopHoc"); lh.SoLuong = smartReader.GetInt16("SoLuong"); lh.NgayNhan = smartReader.GetString("NgayNhan"); lh.HanChot = smartReader.GetString("HanChot"); lh.NgayNhapHoc = smartReader.GetString("NgayNhapHoc"); lh.MonHocID = smartReader.GetByte("MonHocID"); lh.HocPhi = smartReader.GetDecimal("HocPhi"); lh.LichHoc = smartReader.GetString("LichHoc"); lh.MoTa = smartReader.GetString("MoTa"); lh.NhanHocVien = smartReader.GetBoolean("NhanHocVien"); lh.LoaiHocPhiID = smartReader.GetByte("LoaiHocPhiID"); lh.Khoi = smartReader.GetByte("Khoi"); } smartReader.disposeReader(reader); } catch (Exception ex) { throw ex; } finally { db.closeConnection(con); } return(lh); }