public static long SalvarRelatorioId(Relatorio r) { List <object> param = new List <object>(); param = r.GetList(false, true); string sql = "INSERT INTO relatorio " + "(id_paciente, num_relatorio, queixa_clinica, inicio_aval, fim_aval)" + "VALUES ("; for (int i = 0; i < param.Count(); i++) { sql += "@" + (i + 1); if (i < param.Count() - 1) { sql += ", "; } } sql += ") RETURNING id_relatorio;"; Connection.Open(); NpgsqlDataReader dr = Connection.Select(sql, param); dr.Read(); long id = dr.GetInt64(0); Connection.Close(); return(id); }
public static void SalvarRelatorio(Relatorio r) { List <object> param = new List <object>(); param = r.GetList(false, true); string sql = "INSERT INTO relatorio " + "(id_paciente, num_relatorio, queixa_clinica, inicio_aval, fim_aval)" + "VALUES ("; for (int i = 0; i < param.Count(); i++) { sql += "@" + (i + 1); if (i < param.Count() - 1) { sql += ", "; } } sql += ");"; Connection.Open(); Connection.Run(sql, param); Connection.Close(); }
public static void AlterarRelatorio(Relatorio r) { List <object> param = new List <object>(); param = r.GetList(false, false); int i = 1; string sql = "UPDATE public.relatorio " + "SET num_relatorio = @" + (i++) + ", queixa_clinica = @" + (i++) + ", " + "inicio_aval = @" + (i++) + ", fim_aval = @" + (i++) + " " + "WHERE id_relatorio = " + r.Id_Relatorio; Connection.Open(); Connection.Run(sql, param); Connection.Close(); }