Example #1
0
        /// <summary>
        /// get an instance of object
        /// </summary>
        /// <param name="myID"></param>
        public e_carros_usados getObjecte_carros_usados(System.Int32 myID)
        {
            e_carros_usados mye_carros_usados = new e_carros_usados();
            CnxBase         myBase            = new CnxBase();
            string          reqSQL            = "SELECT id_expediente,id_carro,id_voluntario,num_voluntarios, seis, preinforme, en_jurisdiccion FROM e_carros_usados WHERE (id_carro=" + myID + ")";

            try
            {
                NpgsqlConnection myConn    = myBase.OpenConnection(myBase.cnxString);
                NpgsqlCommand    myCommand = new NpgsqlCommand(reqSQL, myConn);
                NpgsqlDataReader myReader  = myCommand.ExecuteReader();
                if (myReader.Read())
                {
                    mye_carros_usados.id_expediente   = Convert.ToInt32(myReader[0]);
                    mye_carros_usados.id_carro        = Convert.ToInt32(myReader[1]);
                    mye_carros_usados.id_voluntario   = Convert.ToInt32(myReader[2]);
                    mye_carros_usados.num_voluntarios = Convert.ToInt32(myReader[3]);
                    mye_carros_usados.seis            = Convert.ToString(myReader[4]);
                    mye_carros_usados.preinforme      = myReader[5].ToString();
                    mye_carros_usados.en_jurisdiccion = Convert.ToBoolean(myReader[6]);
                }
                myBase.CloseConnection(myConn);
            }
            catch (Exception myErr)
            {
                throw (new Exception(myErr.ToString() + reqSQL));
            }
            return(mye_carros_usados);
        }
Example #2
0
        /// <summary>
        /// modify a record
        /// </summary>
        public void Update(e_carros_usados mye_carros_usados)
        {
            CnxBase myBase = new CnxBase();
            string  reqSQL = "UPDATE e_carros_usados SET id_expediente=" + mye_carros_usados.id_expediente + ",id_carro=" + mye_carros_usados.id_carro + ",id_voluntario=" + mye_carros_usados.id_voluntario + ",num_voluntarios=" + mye_carros_usados.num_voluntarios + ", seis='" + mye_carros_usados.seis + "', preinforme='" + mye_carros_usados.preinforme + "', en_jurisdiccion=" + mye_carros_usados.en_jurisdiccion + " WHERE (id_carro=" + mye_carros_usados.id_carro + ")";

            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(e_carros_usados mye_carros_usados)
        {
            CnxBase myBase = new CnxBase();
            string  reqSQL = "INSERT INTO e_carros_usados (id_expediente,id_carro,id_voluntario,num_voluntarios,seis) VALUES (" + mye_carros_usados.id_expediente + "," + mye_carros_usados.id_carro + "," + mye_carros_usados.id_voluntario + "," + mye_carros_usados.num_voluntarios + ",'" + mye_carros_usados.seis + "')";

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