コード例 #1
0
        /// <summary>
        /// get an instance of object
        /// </summary>
        /// <param name="myID"></param>
        public s_puesto_aire getObjects_puesto_aire(System.Int32 myID)
        {
            s_puesto_aire mys_puesto_aire = new s_puesto_aire();
            CnxBase       myBase          = new CnxBase();
            string        reqSQL          = "SELECT id_especialidad,id_sector,prioridad,contacto,id_central FROM s_puesto_aire WHERE (id_especialidad=" + myID + ")";

            try
            {
                NpgsqlConnection myConn    = myBase.OpenConnection(myBase.cnxString);
                NpgsqlCommand    myCommand = new NpgsqlCommand(reqSQL, myConn);
                NpgsqlDataReader myReader  = myCommand.ExecuteReader();
                if (myReader.Read())
                {
                    mys_puesto_aire.id_especialidad = Convert.ToInt32(myReader[0]);
                    mys_puesto_aire.id_sector       = Convert.ToInt32(myReader[1]);
                    mys_puesto_aire.prioridad       = Convert.ToInt32(myReader[2]);
                    mys_puesto_aire.contacto        = myReader[3].ToString();
                    mys_puesto_aire.id_central      = Convert.ToInt32(myReader[4]);
                }
                myBase.CloseConnection(myConn);
            }
            catch (Exception myErr)
            {
                throw(new Exception(myErr.ToString() + reqSQL));
            }
            return(mys_puesto_aire);
        }
コード例 #2
0
        /// <summary>
        /// modify a record
        /// </summary>
        public void modifys_puesto_aire(s_puesto_aire mys_puesto_aire)
        {
            CnxBase myBase = new CnxBase();
            string  reqSQL = "UPDATE s_puesto_aire SET id_especialidad=" + mys_puesto_aire.id_especialidad + ",id_sector=" + mys_puesto_aire.id_sector + ",prioridad=" + mys_puesto_aire.prioridad + ",contacto='" + mys_puesto_aire.contacto + "',id_central=" + mys_puesto_aire.id_central + " WHERE (id_especialidad=" + mys_puesto_aire.id_especialidad + ")";

            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));
            }
        }
コード例 #3
0
        /// <summary>
        /// add a record
        /// </summary>
        /// <param name="myID"></param>
        public void adds_puesto_aire(s_puesto_aire mys_puesto_aire)
        {
            CnxBase myBase = new CnxBase();
            string  reqSQL = "INSERT INTO s_puesto_aire (id_especialidad,id_sector,prioridad,contacto,id_central) VALUES (" + mys_puesto_aire.id_especialidad + "," + mys_puesto_aire.id_sector + "," + mys_puesto_aire.prioridad + ",'" + mys_puesto_aire.contacto + "'," + mys_puesto_aire.id_central + ")";

            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));
            }
        }