Ejemplo n.º 1
0
        public List<GetAllQuanHuyenViewModels> GetAllQuanHuyen()
        {
            HtmlHelperGeneral.openConnection();
            SqlCommand sqlCommand = new SqlCommand();
            sqlCommand.CommandText = "GetAllQuanHuyen";
            sqlCommand.CommandType = CommandType.StoredProcedure;

            sqlCommand.Connection = HtmlHelperGeneral.con;
            SqlDataReader reader = sqlCommand.ExecuteReader();
            List<GetAllQuanHuyenViewModels> acDetails = new List<GetAllQuanHuyenViewModels>();
            while (reader.Read())
            {
                GetAllQuanHuyenViewModels h = new GetAllQuanHuyenViewModels();
                h.quanID = reader.GetInt32NullCheck(0);
                h.maQuanHuyen = reader.GetStringNullCheck(1);
                h.tenQuanHuyen = reader.GetStringNullCheck(2);
                acDetails.Add(h);
            }
            HtmlHelperGeneral.Close();
            return acDetails;
        }
Ejemplo n.º 2
0
        public List<GetAllQuanHuyenViewModels> GetAllQuanHuyen()
        {
            SqlConnection sqlConnection = new SqlConnection();
            sqlConnection.ConnectionString = MyConnectionString1;
            SqlCommand sqlCommand = new SqlCommand();
            sqlCommand.CommandText = "GetAllQuanHuyen";
            sqlCommand.CommandType = CommandType.StoredProcedure;

            sqlCommand.Connection = sqlConnection;
            sqlConnection.Open();
            SqlDataReader reader = sqlCommand.ExecuteReader();
            List<GetAllQuanHuyenViewModels> acDetails = new List<GetAllQuanHuyenViewModels>();
            while (reader.Read())
            {
                GetAllQuanHuyenViewModels h = new GetAllQuanHuyenViewModels();
                h.quanID = reader.GetInt32NullCheck(0);
                h.maQuanHuyen = reader.GetStringNullCheck(1);
                h.tenQuanHuyen = reader.GetStringNullCheck(2);
                acDetails.Add(h);
            }
            return acDetails;
        }