Example #1
0
        /// <summary>
        /// get an instance of object
        /// </summary>
        /// <param name="myID"></param>
        public s_bomba getObjects_bomba(System.Int32 myID)
        {
            s_bomba mys_bomba = new s_bomba();
            CnxBase myBase    = new CnxBase();
            string  reqSQL    = "SELECT id_especialidad,id_sector,prioridad,contacto,id_central FROM s_bomba 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_bomba.id_especialidad = Convert.ToInt32(myReader[0]);
                    mys_bomba.id_sector       = Convert.ToInt32(myReader[1]);
                    mys_bomba.prioridad       = Convert.ToInt32(myReader[2]);
                    mys_bomba.contacto        = myReader[3].ToString();
                    mys_bomba.id_central      = Convert.ToInt32(myReader[4]);
                }
                myBase.CloseConnection(myConn);
            }
            catch (Exception myErr)
            {
                throw(new Exception(myErr.ToString() + reqSQL));
            }
            return(mys_bomba);
        }
Example #2
0
        /// <summary>
        /// modify a record
        /// </summary>
        public void Update(s_bomba mys_bomba)
        {
            CnxBase myBase = new CnxBase();
            string  reqSQL = "UPDATE s_bomba SET id_especialidad=" + mys_bomba.id_especialidad + ",id_sector=" + mys_bomba.id_sector + ",prioridad=" + mys_bomba.prioridad + ",contacto='" + mys_bomba.contacto + "',id_central=" + mys_bomba.id_central + " WHERE (id_especialidad=" + mys_bomba.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));
            }
        }
Example #3
0
        /// <summary>
        /// add a record
        /// </summary>
        /// <param name="myID"></param>
        public void Insert(s_bomba mys_bomba)
        {
            CnxBase myBase = new CnxBase();
            string  reqSQL = "INSERT INTO s_bomba (id_especialidad,id_sector,prioridad,contacto,id_central) VALUES (" + mys_bomba.id_especialidad + "," + mys_bomba.id_sector + "," + mys_bomba.prioridad + ",'" + mys_bomba.contacto + "'," + mys_bomba.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));
            }
        }