/// <summary> /// get an instance of object /// </summary> /// <param name="myID"></param> public z_orden getObjectz_orden(System.Int32 myID) { z_orden myz_orden = new z_orden(); CnxBase myBase = new CnxBase(); string reqSQL = "SELECT id_orden,codigo_llamado,orden_numero,id_tipo_carro FROM z_orden WHERE (id_orden=" + myID + ")"; try { NpgsqlConnection myConn = myBase.OpenConnection(myBase.cnxString); NpgsqlCommand myCommand = new NpgsqlCommand(reqSQL, myConn); NpgsqlDataReader myReader = myCommand.ExecuteReader(); if (myReader.Read()) { myz_orden.id_orden = Convert.ToInt32(myReader[0]); myz_orden.codigo_llamado = Convert.ToInt32(myReader[1]); myz_orden.orden_numero = Convert.ToInt32(myReader[2]); myz_orden.id_tipo_carro = Convert.ToInt32(myReader[3]); } myBase.CloseConnection(myConn); } catch (Exception myErr) { throw (new Exception(myErr.ToString() + reqSQL)); } return(myz_orden); }
/// <summary> /// modify a record /// </summary> public void modifyz_orden(z_orden myz_orden) { CnxBase myBase = new CnxBase(); string reqSQL = "UPDATE z_orden SET id_orden=" + myz_orden.id_orden + ",codigo_llamado=" + myz_orden.codigo_llamado + ",orden_numero=" + myz_orden.orden_numero + ",id_tipo_carro=" + myz_orden.id_tipo_carro + " WHERE (id_orden=" + myz_orden.id_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)); } }
/// <summary> /// add a record /// </summary> /// <param name="myID"></param> public void addz_orden(z_orden myz_orden) { CnxBase myBase = new CnxBase(); string reqSQL = "INSERT INTO z_orden (id_orden,codigo_llamado,orden_numero,id_tipo_carro) VALUES (" + myz_orden.id_orden + "," + myz_orden.codigo_llamado + "," + myz_orden.orden_numero + "," + myz_orden.id_tipo_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)); } }