/// <summary> /// get an instance of object /// </summary> /// <param name="myID"></param> public s_cisternas_z getObjects_cisternas_z(System.Int32 myID) { s_cisternas_z mys_cisternas_z = new s_cisternas_z(); CnxBase myBase = new CnxBase(); string reqSQL = "SELECT id_especialidad,id_sector,prioridad,contacto,id_central FROM s_cisternas_z WHERE (id_especialidad=" + myID + ")"; try { NpgsqlConnection myConn = myBase.OpenConnection(myBase.cnxString); NpgsqlCommand myCommand = new NpgsqlCommand(reqSQL, myConn); NpgsqlDataReader myReader = myCommand.ExecuteReader(); if (myReader.Read()) { mys_cisternas_z.id_especialidad = Convert.ToInt32(myReader[0]); mys_cisternas_z.id_sector = Convert.ToInt32(myReader[1]); mys_cisternas_z.prioridad = Convert.ToInt32(myReader[2]); mys_cisternas_z.contacto = myReader[3].ToString(); mys_cisternas_z.id_central = Convert.ToInt32(myReader[4]); } myBase.CloseConnection(myConn); } catch (Exception myErr) { throw(new Exception(myErr.ToString() + reqSQL)); } return(mys_cisternas_z); }
/// <summary> /// modify a record /// </summary> public void modifys_cisternas_z(s_cisternas_z mys_cisternas_z) { CnxBase myBase = new CnxBase(); string reqSQL = "UPDATE s_cisternas_z SET id_especialidad=" + mys_cisternas_z.id_especialidad + ",id_sector=" + mys_cisternas_z.id_sector + ",prioridad=" + mys_cisternas_z.prioridad + ",contacto='" + mys_cisternas_z.contacto + "',id_central=" + mys_cisternas_z.id_central + " WHERE (id_especialidad=" + mys_cisternas_z.id_especialidad + ")"; 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 adds_cisternas_z(s_cisternas_z mys_cisternas_z) { CnxBase myBase = new CnxBase(); string reqSQL = "INSERT INTO s_cisternas_z (id_especialidad,id_sector,prioridad,contacto,id_central) VALUES (" + mys_cisternas_z.id_especialidad + "," + mys_cisternas_z.id_sector + "," + mys_cisternas_z.prioridad + ",'" + mys_cisternas_z.contacto + "'," + mys_cisternas_z.id_central + ")"; 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)); } }