Beispiel #1
0
        /// <summary>
        /// add a record
        /// </summary>
        /// <param name="myID"></param>
        public void addz_companias(z_companias myz_companias)
        {
            CnxBase myBase = new CnxBase();
            string  reqSQL = "INSERT INTO z_companias (id_compania,email) VALUES (" + myz_companias.id_compania + ",'" + myz_companias.email + "')";

            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 #2
0
        /// <summary>
        /// modify a record
        /// </summary>
        public void modifyz_companias(z_companias myz_companias)
        {
            CnxBase myBase = new CnxBase();
            string  reqSQL = "UPDATE z_companias SET id_compania=" + myz_companias.id_compania + ",email='" + myz_companias.email + "' WHERE (id_compania=" + myz_companias.id_compania + ")";

            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>
        /// get an instance of object
        /// </summary>
        /// <param name="myID"></param>
        public z_companias getObjectz_companias(System.Int32 myID)
        {
            z_companias myz_companias = new z_companias();
            CnxBase     myBase        = new CnxBase();
            string      reqSQL        = "SELECT id_compania,email FROM z_companias WHERE (id_compania=" + myID + ")";

            try
            {
                NpgsqlConnection myConn    = myBase.OpenConnection(myBase.cnxString);
                NpgsqlCommand    myCommand = new NpgsqlCommand(reqSQL, myConn);
                NpgsqlDataReader myReader  = myCommand.ExecuteReader();
                if (myReader.Read())
                {
                    myz_companias.id_compania = Convert.ToInt32(myReader[0]);
                    myz_companias.email       = myReader[1].ToString();
                }
                myBase.CloseConnection(myConn);
            }
            catch (Exception myErr)
            {
                throw(new Exception(myErr.ToString() + reqSQL));
            }
            return(myz_companias);
        }