コード例 #1
0
        /// <summary>
        /// get an instance of object
        /// </summary>
        /// <param name="myID"></param>
        public a_agenda_cat getObjecta_agenda_cat(System.Int32 myID)
        {
            a_agenda_cat mya_agenda_cat = new a_agenda_cat();
            CnxBase      myBase         = new CnxBase();
            string       reqSQL         = "SELECT id_cat,nombre,ref_espacial,tabla,orden FROM a_agenda_cat WHERE (id_cat=" + myID + ")";

            try
            {
                NpgsqlConnection myConn    = myBase.OpenConnection(myBase.cnxString);
                NpgsqlCommand    myCommand = new NpgsqlCommand(reqSQL, myConn);
                NpgsqlDataReader myReader  = myCommand.ExecuteReader();
                if (myReader.Read())
                {
                    mya_agenda_cat.id_cat       = Convert.ToInt32(myReader[0]);
                    mya_agenda_cat.nombre       = myReader[1].ToString();
                    mya_agenda_cat.ref_espacial = Convert.ToBoolean(myReader[2]);
                    mya_agenda_cat.tabla        = myReader[3].ToString();
                    mya_agenda_cat.orden        = Convert.ToInt32(myReader[4]);
                }
                myBase.CloseConnection(myConn);
            }
            catch (Exception myErr)
            {
                throw (new Exception(myErr.ToString() + reqSQL));
            }
            return(mya_agenda_cat);
        }
コード例 #2
0
        /// <summary>
        /// modify a record
        /// </summary>
        public void Update(a_agenda_cat mya_agenda_cat)
        {
            CnxBase myBase = new CnxBase();
            string  reqSQL = "UPDATE a_agenda_cat SET id_cat=" + mya_agenda_cat.id_cat + ",nombre='" + mya_agenda_cat.nombre + "',ref_espacial=" + mya_agenda_cat.ref_espacial + ",tabla='" + mya_agenda_cat.tabla + "',orden=" + mya_agenda_cat.orden + " WHERE (id_cat=" + mya_agenda_cat.id_cat + ")";

            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));
            }
        }
コード例 #3
0
        /// <summary>
        /// add a record
        /// </summary>
        /// <param name="myID"></param>
        public void Insert(a_agenda_cat mya_agenda_cat)
        {
            CnxBase myBase = new CnxBase();
            string  reqSQL = "INSERT INTO a_agenda_cat (nombre,ref_espacial,tabla,orden) VALUES ('" + mya_agenda_cat.nombre + "'," + mya_agenda_cat.ref_espacial + ",'" + mya_agenda_cat.tabla + "'," + mya_agenda_cat.orden + ")";

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