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