/** * stores an operation record in history */ public void SaveRegisto(Registo reg) { if (reg == null) return; SqlConnection con = new SqlConnection(connectionString); con.Open(); SqlCommand query = new SqlCommand(string.Format( "INSERT INTO historico (op_id, op_type, old_bundle_id, new_bundle_id, old_file_id, new_file_id, tag, etiqueta) " + "Values ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', getdate())", reg.op_id, reg.op_type, reg.old_bundle_id, reg.new_bundle_id, reg.old_file_id, reg.new_file_id, reg.tag), con); query.ExecuteNonQuery(); con.Close(); }
/** * retrieves an operation record from history */ public Registo GetRegisto(string op_id) { if (string.IsNullOrEmpty(op_id)) return null; Registo reg = new Registo(); SqlConnection con = new SqlConnection(connectionString); con.Open(); SqlCommand query = new SqlCommand(string.Format("SELECT * FROM historico WHERE op_id = '{0}'", op_id), con); SqlDataReader reader = query.ExecuteReader(); while (reader.Read()) { reg = new Registo(op_id, reader.GetDateTime(7), reader.GetString(1), reader.GetString(2), reader.GetString(3), reader.GetString(4), reader.GetString(5), reader.GetString(6)); } reader.Close(); con.Close(); return reg; }