Exemplo n.º 1
0
        /// <summary>
        /// get an instance of object
        /// </summary>
        /// <param name="myID"></param>
        public p_interes getObjectp_interes(System.Int32 myID)
        {
            p_interes myp_interes = new p_interes();
            CnxBase   myBase      = new CnxBase();
            string    reqSQL      = "SELECT id_puntos,radio_text,label1,combo1,label2,tabla FROM p_interes WHERE (id_puntos=" + myID + ")";

            try
            {
                NpgsqlConnection myConn    = myBase.OpenConnection(myBase.cnxString);
                NpgsqlCommand    myCommand = new NpgsqlCommand(reqSQL, myConn);
                NpgsqlDataReader myReader  = myCommand.ExecuteReader();
                if (myReader.Read())
                {
                    myp_interes.id_puntos  = Convert.ToInt32(myReader[0]);
                    myp_interes.radio_text = myReader[1].ToString();
                    myp_interes.label1     = myReader[2].ToString();
                    myp_interes.combo1     = myReader[3].ToString();
                    myp_interes.label2     = myReader[4].ToString();
                    myp_interes.tabla      = myReader[5].ToString();
                }
                myBase.CloseConnection(myConn);
            }
            catch (Exception myErr)
            {
                throw(new Exception(myErr.ToString() + reqSQL));
            }
            return(myp_interes);
        }
Exemplo n.º 2
0
        /// <summary>
        /// modify a record
        /// </summary>
        public void Update(p_interes myp_interes)
        {
            CnxBase myBase = new CnxBase();
            string  reqSQL = "UPDATE p_interes SET id_puntos=" + myp_interes.id_puntos + ",radio_text='" + myp_interes.radio_text + "',label1='" + myp_interes.label1 + "',combo1='" + myp_interes.combo1 + "',label2='" + myp_interes.label2 + "',tabla='" + myp_interes.tabla + "' WHERE (id_puntos=" + myp_interes.id_puntos + ")";

            try
            {
                NpgsqlConnection myConn    = myBase.OpenConnection(myBase.cnxString);
                NpgsqlCommand    myCommand = new NpgsqlCommand(reqSQL, myConn);
                myCommand.ExecuteNonQuery();
                myBase.CloseConnection(myConn);
            }
            catch (Exception myErr)
            {
                throw(new Exception(myErr.ToString() + reqSQL));
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// add a record
        /// </summary>
        /// <param name="myID"></param>
        public void Insert(p_interes myp_interes)
        {
            CnxBase myBase = new CnxBase();
            string  reqSQL = "INSERT INTO p_interes (id_puntos,radio_text,label1,combo1,label2,tabla) VALUES (" + myp_interes.id_puntos + ",'" + myp_interes.radio_text + "','" + myp_interes.label1 + "','" + myp_interes.combo1 + "','" + myp_interes.label2 + "','" + myp_interes.tabla + "')";

            try
            {
                NpgsqlConnection myConn    = myBase.OpenConnection(myBase.cnxString);
                NpgsqlCommand    myCommand = new NpgsqlCommand(reqSQL, myConn);
                myCommand.ExecuteNonQuery();
                myBase.CloseConnection(myConn);
            }
            catch (Exception myErr)
            {
                throw(new Exception(myErr.ToString() + reqSQL));
            }
        }