/// <summary> /// get an instance of object /// </summary> /// <param name="myID"></param> public z_oficial_cia getObjectz_oficial_cia(System.Int32 myID) { z_oficial_cia myz_oficial_cia = new z_oficial_cia(); CnxBase myBase = new CnxBase(); string reqSQL = "SELECT id_oficial, id_voluntario, general FROM z_oficial_cia WHERE (id_oficial_cia=" + myID + ")"; try { NpgsqlConnection myConn = myBase.OpenConnection(myBase.cnxString); NpgsqlCommand myCommand = new NpgsqlCommand(reqSQL, myConn); NpgsqlDataReader myReader = myCommand.ExecuteReader(); if (myReader.Read()) { myz_oficial_cia.id_oficial_cia = Convert.ToInt32(myReader[0]); myz_oficial_cia.id_oficial = Convert.ToInt32(myReader[1]); myz_oficial_cia.id_voluntario = Convert.ToInt32(myReader[2]); myz_oficial_cia.general = Convert.ToBoolean(myReader[3]); } myBase.CloseConnection(myConn); } catch (Exception myErr) { throw (new Exception(myErr.ToString() + reqSQL)); } return(myz_oficial_cia); }
/// <summary> /// add a record /// </summary> /// <param name="myID"></param> public void addz_oficial_cia(z_oficial_cia myz_oficial_cia) { CnxBase myBase = new CnxBase(); string reqSQL = "INSERT INTO z_oficial_cia (id_oficial, id_voluntario, general) VALUES (" + myz_oficial_cia.id_oficial + "," + myz_oficial_cia.id_voluntario + "," + myz_oficial_cia.general + ")"; 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)); } }
/// <summary> /// modify a record /// </summary> public void modifyz_oficial_cia(z_oficial_cia myz_oficial_cia) { CnxBase myBase = new CnxBase(); string reqSQL = "UPDATE z_oficial_cia SET id_oficial=" + myz_oficial_cia.id_oficial + ",id_voluntario=" + myz_oficial_cia.id_voluntario + ",general=" + myz_oficial_cia.general + " WHERE (id_oficial=" + myz_oficial_cia.id_oficial + ")"; 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)); } }