示例#1
0
        public string getAnios(string dat)
        {
            try
            {
                cnx = new cnx();
                rdr = cnx.ExecuteCommand("PR_OBTIENE_EMS_ANIOS", CommandType.StoredProcedure);


                List <anios> list = new List <anios>();
                if (rdr.HasRows)
                {
                    while (rdr.Read())
                    {
                        anios f = new anios()
                        {
                            anio = rdr["ANIO"].ToString(),
                        };
                        list.Add(f);
                    }
                    rdr.Close();
                    rdr = null;
                    string data = JsonConvert.SerializeObject(list);
                    return(data);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return("");
        }
示例#2
0
        public string getAnios(string modelo, string fuente)
        {
            try
            {
                uti = new UtileriasSQL(int.Parse(modelo));
                SqlParameter[] paramcollection = new SqlParameter[1];
                paramcollection[0] = new SqlParameter("@ID_FUENTE", fuente);
                SqlDataReader reader = uti.ExecuteReader(CommandType.StoredProcedure, "PR_OBTIENE_ANIO", paramcollection);

                List<anios> aniosList = new List<anios>();
                while (reader.Read())
                {
                    anios a = new anios();
                    a.Anio = reader["ANIO"].ToString();
                    a.Actual = reader["ACTUAL"].ToString();
                    aniosList.Add(a);

                }
                string jsonString = JsonConvert.SerializeObject(aniosList);

                reader.Close();
                return jsonString;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }