Exemple #1
0
        public ModeloNegocio.Tema getTemaId(int tema_id)
        {
            Cmd            = new SqlCommand();
            Cmd.Connection = Conn;
            ModeloNegocio.Tema tema = new ModeloNegocio.Tema();

            try
            {
                Cmd.CommandType = CommandType.StoredProcedure;
                Cmd.CommandText = "PA_GET_TEMA_ID";
                Cmd.Parameters.Add("@tema_id", SqlDbType.Int).Value = tema_id;

                Dtr = Cmd.ExecuteReader();

                while (Dtr.Read())
                {
                    tema.Id = Convert.ToInt32(Dtr["id"]);

                    tema.Name  = Dtr["tema"].ToString();
                    tema.Grade = Dtr["grade"].ToString();

                    // if (DBNull.Value.Equals(Dtr["created_at"])) sesion.Created_at = DateTime.Now; else sesion.Created_at = DateTime.Parse(Dtr["created_at"].ToString());
                    // if (DBNull.Value.Equals(Dtr["updated_at"])) sesion.Updated_at = DateTime.Now; else sesion.Updated_at = DateTime.Parse(Dtr["updated_at"].ToString());
                }
                Conn.Close();

                return(tema);
            }
            catch (Exception e)
            {
                Console.WriteLine("{0} Exception caught.", e);
                return(tema);
            }
        }
Exemple #2
0
        public ModeloNegocio.Tema getTemaId(int tema_id)
        {
            Cmd = new SqlCommand();
            Cmd.Connection = Conn;
            ModeloNegocio.Tema tema = new ModeloNegocio.Tema();

            try
            {

                Cmd.CommandType = CommandType.StoredProcedure;
                Cmd.CommandText = "PA_GET_TEMA_ID";
                Cmd.Parameters.Add("@tema_id", SqlDbType.Int).Value = tema_id;

                Dtr = Cmd.ExecuteReader();

                while (Dtr.Read())
                {

                    tema.Id = Convert.ToInt32(Dtr["id"]);

                    tema.Name = Dtr["tema"].ToString();
                    tema.Grade = Dtr["grade"].ToString();

                    // if (DBNull.Value.Equals(Dtr["created_at"])) sesion.Created_at = DateTime.Now; else sesion.Created_at = DateTime.Parse(Dtr["created_at"].ToString());
                    // if (DBNull.Value.Equals(Dtr["updated_at"])) sesion.Updated_at = DateTime.Now; else sesion.Updated_at = DateTime.Parse(Dtr["updated_at"].ToString());
                }
                Conn.Close();

                return tema;
            }
            catch (Exception e)
            {
                Console.WriteLine("{0} Exception caught.", e);
                return tema;
            }
        }