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