/// <summary> /// get an instance of object /// </summary> /// <param name="myID"></param> public z_dos_6 getObjectz_dos_6(System.Int32 myID) { z_dos_6 myz_dos_6 = new z_dos_6(); CnxBase myBase = new CnxBase(); string reqSQL = "SELECT id_dos_6,id_despacho,id_carro FROM z_dos_6 WHERE (id_despacho=" + myID + ")"; try { NpgsqlConnection myConn = myBase.OpenConnection(myBase.cnxString); NpgsqlCommand myCommand = new NpgsqlCommand(reqSQL, myConn); NpgsqlDataReader myReader = myCommand.ExecuteReader(); if (myReader.Read()) { myz_dos_6.id_dos_6 = Convert.ToInt32(myReader[0]); myz_dos_6.id_despacho = Convert.ToInt32(myReader[1]); myz_dos_6.id_carro = Convert.ToInt32(myReader[2]); } myBase.CloseConnection(myConn); } catch (Exception myErr) { throw(new Exception(myErr.ToString() + reqSQL)); } return(myz_dos_6); }
/// <summary> /// add a record /// </summary> /// <param name="myID"></param> public void addz_dos_6(z_dos_6 myz_dos_6) { CnxBase myBase = new CnxBase(); string reqSQL = "INSERT INTO z_dos_6 (id_despacho,id_carro) VALUES (" + myz_dos_6.id_despacho + "," + myz_dos_6.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)); } }
/// <summary> /// modify a record /// </summary> public void modifyz_dos_6(z_dos_6 myz_dos_6) { CnxBase myBase = new CnxBase(); string reqSQL = "UPDATE z_dos_6 SET id_dos_6=" + myz_dos_6.id_dos_6 + ",id_despacho=" + myz_dos_6.id_despacho + ",id_carro=" + myz_dos_6.id_carro + " WHERE (id_dos_6=" + myz_dos_6.id_dos_6 + ")"; 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)); } }