/// <summary> /// Lấy DS cấp bậc /// Khắc Anh /// Date 6/5/2011 /// </summary> /// <param name="capbatDto"> </param> /// <returns>DataTable dtDSCapBac</returns> public List<CapBac> LayDSCapBac() { List<CapBac> lstDSCapBac = new List<CapBac>(); try { DataTable dtDSCapBac = new DataTable(); dtDSCapBac = SqlDataAccessHelper.ExecuteQuery("spLayDSCapBac"); foreach (DataRow dtRow in dtDSCapBac.Rows) { CapBac CapBac = new CapBac(); CapBac.intMaCapBac = int.Parse(dtRow["MaCapBac"].ToString()); CapBac.strTenCapBac = dtRow["TenCapBac"].ToString(); CapBac.intDiem = int.Parse(dtRow["Diem"].ToString()); CapBac.intTongCauHoi = int.Parse(dtRow["TongCauHoi"].ToString()); CapBac.intTongCauTraLoi = int.Parse(dtRow["TongCauTraLoi"].ToString()); lstDSCapBac.Add(CapBac); } } catch (Exception ex) { throw ex; } return lstDSCapBac; }
/// <summary> /// Lấy cấp bậc theo mã /// Khắc Anh /// Date 6/5/2011 /// Edit: Thu Hà /// </summary> /// <param name="capbatDto"> </param> /// <returns>1: 0</returns> //public int LayCapBacTheoMa() // { // int res = 0; // try // { // // add tham số // List<SqlParameter> lstParam = new List<SqlParameter>(); // lstParam.Add(new SqlParameter("@macapbac", intMaCapBac)); // res = SqlDataAccessHelper.ExecuteNoneQuery("spLayCapBacTheoMa", lstParam); // } // catch (Exception e) // { // res = 0; // throw e; // } // return res; // } public CapBac LayCapBacTheoMa(int maCapBac) { CapBac capBac = new CapBac(); try { // add tham số List<SqlParameter> lstParam = new List<SqlParameter>(); lstParam.Add(new SqlParameter("@macapbac", maCapBac)); DataTable dtCapBac = SqlDataAccessHelper.ExecuteQuery("spLayCapBacTheoMa", lstParam); if (dtCapBac.Rows.Count == 1) { DataRow dtRow = dtCapBac.Rows[0]; capBac.intMaCapBac = int.Parse(dtRow["MaCapBac"].ToString()); capBac.intTongCauHoi = int.Parse(dtRow["TongCauHoi"].ToString()); capBac.intTongCauTraLoi = int.Parse(dtRow["TongCauTraLoi"].ToString()); capBac.strTenCapBac = dtRow["TenCapBac"].ToString(); } } catch (Exception e) { throw e; } return capBac; }