Beispiel #1
0
        public PhanHoi GetQuestion(int id)
        {
            string  sql       = string.Format("SELECT * FROM CAUHOI WHERE MACAUHOI = {0}", id);
            PhanHoi phanHoi   = new PhanHoi();
            var     dataTable = dataProvider.ExecuteQuery(sql);

            foreach (DataRow row in dataTable.Rows)
            {
                phanHoi.MaCauHoi  = Int32.Parse(row["MaCauHoi"].ToString());
                phanHoi.TenCauHoi = row["TenCauHoi"].ToString();
                phanHoi.NoiDung   = row["NoiDung"].ToString();
            }
            sql = string.Format("SELECT * FROM CAUTRALOI WHERE MACAUHOI = {0}", id);
            var dataTableTraLoi = dataProvider.ExecuteQuery(sql);

            foreach (DataRow row in dataTableTraLoi.Rows)
            {
                CauTraLoi cauTraLoi = new CauTraLoi();
                cauTraLoi.MaCauHoi    = Int32.Parse(row["MaCauHoi"].ToString());
                cauTraLoi.MaCauTraLoi = Int32.Parse(row["MaCauTraLoi"].ToString());
                cauTraLoi.TraLoi      = row["TraLoi"].ToString();
                cauTraLoi.NgayGui     = Convert.ToDateTime(row["NgayGui"].ToString());
                cauTraLoi.HoTen       = row["HoTen"].ToString();
                phanHoi.ListCauTraLoi.Add(cauTraLoi);
            }
            return(phanHoi);
        }
 public PhanHoi GetQuestion(int id)
 {
     string sql = string.Format("SELECT * FROM CAUHOI WHERE MACAUHOI = {0}", id);
     PhanHoi phanHoi = new PhanHoi();
     var dataTable = dataProvider.ExecuteQuery(sql);
     foreach (DataRow row in dataTable.Rows)
     {
         phanHoi.MaCauHoi = Int32.Parse(row["MaCauHoi"].ToString());
         phanHoi.TenCauHoi = row["TenCauHoi"].ToString();
         phanHoi.NoiDung = row["NoiDung"].ToString();
     }
     sql = string.Format("SELECT * FROM CAUTRALOI WHERE MACAUHOI = {0}", id);
     var dataTableTraLoi = dataProvider.ExecuteQuery(sql);
     foreach (DataRow row in dataTableTraLoi.Rows)
     {
         CauTraLoi cauTraLoi = new CauTraLoi();
         cauTraLoi.MaCauHoi = Int32.Parse(row["MaCauHoi"].ToString());
         cauTraLoi.MaCauTraLoi = Int32.Parse(row["MaCauTraLoi"].ToString());
         cauTraLoi.TraLoi = row["TraLoi"].ToString();
         cauTraLoi.NgayGui = Convert.ToDateTime(row["NgayGui"].ToString());
         cauTraLoi.HoTen = row["HoTen"].ToString();
         phanHoi.ListCauTraLoi.Add(cauTraLoi);
     }
     return phanHoi;
 }