コード例 #1
0
        /// <summary>
        /// get an instance of object
        /// </summary>
        /// <param name="myID"></param>
        public z_preinforme getObjectz_preinforme(System.Int32 myID)
        {
            z_preinforme myz_preinforme = new z_preinforme();
            CnxBase      myBase         = new CnxBase();
            string       reqSQL         = "SELECT id_preinforme,codigo_llamado,preinforme FROM z_preinforme WHERE (id_preinforme=" + myID + ")";

            try
            {
                NpgsqlConnection myConn    = myBase.OpenConnection(myBase.cnxString);
                NpgsqlCommand    myCommand = new NpgsqlCommand(reqSQL, myConn);
                NpgsqlDataReader myReader  = myCommand.ExecuteReader();
                if (myReader.Read())
                {
                    myz_preinforme.id_preinforme  = Convert.ToInt32(myReader[0]);
                    myz_preinforme.codigo_llamado = Convert.ToInt32(myReader[1]);
                    myz_preinforme.preinforme     = myReader[2].ToString();
                }
                myBase.CloseConnection(myConn);
            }
            catch (Exception myErr)
            {
                throw(new Exception(myErr.ToString() + reqSQL));
            }
            return(myz_preinforme);
        }
コード例 #2
0
        /// <summary>
        /// add a record
        /// </summary>
        /// <param name="myID"></param>
        public void addz_preinforme(z_preinforme myz_preinforme)
        {
            CnxBase myBase = new CnxBase();
            string  reqSQL = "INSERT INTO z_preinforme (codigo_llamado,preinforme) VALUES (" + myz_preinforme.codigo_llamado + ",'" + myz_preinforme.preinforme + "')";

            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>
        /// modify a record
        /// </summary>
        public void modifyz_preinforme(z_preinforme myz_preinforme)
        {
            CnxBase myBase = new CnxBase();
            string  reqSQL = "UPDATE z_preinforme SET id_preinforme=" + myz_preinforme.id_preinforme + ",codigo_llamado=" + myz_preinforme.codigo_llamado + ",preinforme='" + myz_preinforme.preinforme + "' WHERE (id_preinforme=" + myz_preinforme.id_preinforme + ")";

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