Best way to manage headers and tables

I'm trying to find a way where a user can have multiple subtitles to create a table. For example, a user can use this type of workflow.

Section header 
--Table Heading
   ---Table

OR

Section header 
--Table Heading
  --Table Subheading (optional) 
     ---Table

OR

  Section header 
    --Table Heading
      ---Table Subheading (*optional*, if user has more sub-sub heading, they might need more one more subheading)
         ----Table Sub-subheading
            -----Table

What is the best way to determine if the user will need this subtitle and then allow them to enter the information in a table?

8 – The selection of tables with the new response return does not work

I am a beginner in Drupal and I want to create a contact list with a dynamic search on ajax. I want to ajax load my tableselect. So I use returns a new answer (render ($ form)); where the form is tableselect. I use this to only return the form without a header, footer, and so on. But the tableselect shows no data in the table.

If I use it as a normal table, it works. You can see on the photo. That's what I want, but with checkboxes.

enter the description of the image here
With tables, select the return table without entries. Can I implement a checkbox in a normal table? Where can I return only the table differently?

My code:

        select('civicrm_contact', 'c');
    $select->join('civicrm_email', 'e', 'c.id = e.contact_id');
    $select->join('civicrm_phone', 'p', 'c.id = p.contact_id');
    $select->addField('c', 'display_name' );
    $select->addField('e', 'email');
    $select->addField('p', 'phone');
    $select->addField('c', 'id');
    $select = $select->extend('DrupalCoreDatabaseQueryTableSortExtender');
    $select = $select->orderByHeader($header);
    $select = $select->extend('DrupalCoreDatabaseQueryPagerSelectExtender')->limit(20);
    $entries = $select->execute()->fetchAll(PDO::FETCH_ASSOC);
    return $entries;
  }

  public function buildForm(array $form, FormStateInterface $form_state) {
    $header = array(
      'name' => array('data' => t('Name'), 'field' => 'c.display_name'),
      'email' => array('data' => t('Email'), 'field' => 'e.email'),
      'phone' => array('data' => t('Phone'), 'field' => 'p.phone',  'sort' => 'DESC'),
    );

    foreach ($entries = $this->load($header) as $entry) {
      $name = array('data' => $entry('display_name'), 'class' => 'link', 'id' => $entry('id'));
      $email = array('data' => $entry('email'), 'class' => 'link', 'id' => $entry('id'));
      $phone = array('data' => $entry('phone'), 'class' => 'link', 'id' => $entry('id'));
      $profile = array('data' => t(""), 'colspan' => '3');
      $loading = array('data' => t("LOADING"), 'colspan' => '3');
      $attributes = array('class' => array('content'));
      $profile_id = 'profile_' . $entry('id');
      $loading_id = 'loading_' . $entry('id');

      $rows($entry('id')) = array(
        'name' => $name,
        'email' => $email,
        'phone' => $phone,
        '#attributes' => $attributes
      );   // row with basic info
      $rows($profile_id) = array(
        'name' => $profile,
        '#attributes' => array('class' => array('profile', $profile_id))
      );   // profile row, hidden in default
      $rows($loading_id) = array(
        'name' => $loading,
        '#attributes' => array('class' => array('loading', $loading_id))
      );   // loading row hidden in default
    }

    $form('table') = array(
      '#id'    => 'select-attendees',
      '#type' => '**tableselect**',
      '#header' => $header,
      '#options' => $rows,
      '#empty' => t('No entries available.'),
    );
    // do not cache this page.
    $form('$cache')('max-age') = 0;
    $form('pager') = array(
      '#type' => 'pager'
    );
    $form('submit') = array(
      '#type' => 'submit',
      '#value' => t('submit'),
    );

    **return new Response(render($form));**
  }
  public function validateForm(array &$form, FormStateInterface $form_state) {

  }
  public function submitForm(array &$form, FormStateInterface $form_state) {
    drupal_set_message(t('The form is working.'));
  }

  public function processTable(&$element, FormStateInterface $form_state, &$complete_form) {


  }


}

And I want to load the table with ajax like this:

  $('.control-label').mousedown(function(event) {
    $.ajax({
      type: "post",
      url: 'contacts',
      data: "somedata",
      cache: false,
      success: function(html) {
        $('#contact_table').html(html);
      }
    });
  });

How to delete tables not belonging to a database in a TreeView? c # Windows Forms, Microsoft SQL Server

It turns out that I have a TreeView that shows me all the databases that exist with their respective tables. The problem, as you will see, is that I see tables that belong to a database but that also appear in others, which is false.

enter the description of the image here

And what I want is to show me only the tables to which the database belongs only.

       TreeNode node;
    TreeNode hijo;
    private void Form1_Load(object sender, EventArgs e)
    {
        DataTable tabla = new DataTable();
        DataTable tablas = new DataTable();

        ReglasDeNegocios.OperacionesBD operaciones = new ReglasDeNegocios.OperacionesBD();
        if (operaciones.BaseDatos(sUsuario, sPassword, ref tabla))
        {


            foreach (DataRow dr in tabla.Rows)
            {
                node = new TreeNode(dr("name").ToString());
                string hijos = Convert.ToString(dr("name").ToString());
                if (operaciones.BaseDatos(sUsuario, sPassword, hijos, ref tablas))
                {
                    foreach (DataRow dr2 in tablas.Rows)
                    {

                        hijo = new TreeNode(dr2("Tabla").ToString());
                        node.Nodes.Add(hijo);
                    }
                    treeView1.Nodes.Add(node);
                }

            }




        }
        else
        {

            MessageBox.Show("Ocurrio un error: " + operaciones.sLastError);
        }
    }

I therefore call the database:

  public Boolean BaseDatos(String sUsuario, String sPassword, String BD, ref DataTable Tabla)
    {
        Boolean bAllOk = false;
        using (SqlConnection conexion = new SqlConnection())
        {
            try
            {

                conexion.ConnectionString = $"Server=ROBERTODIAZ; User Id={sUsuario}; Password={sPassword}";
                conexion.Open();
                SqlCommand comando = new SqlCommand($"use {BD} select sc.name+'.'+tb.name AS Tabla from sys.tables tb inner join sys.schemas sc on tb.schema_id = sc.schema_id order by Tabla ASC", conexion);
                SqlDataAdapter adapter = new SqlDataAdapter(comando);
                adapter.Fill(Tabla);


                bAllOk = true;

            }
            catch (Exception ex)
            {
                sLastError = ex.Message;
            }
            finally
            {
                conexion.Close();
            }
        }
        return bAllOk;
    }

How would you settle that?

Combine two tables with 2 PKs – Table 1 contains the column (id12) that contains the data in column 2 (sub_obje_id).

SELECT COUNT (id12) AS PROG_AREA
FROM (dbo). (Header_record)
INNER JOIN dbo.header_record.id12 = dbo.object.sub_obje_id
SURE
(TO SELECT
pool_id AS & # 39; Pool & # 39;
CASE
WHEN sub_obje_id = 4104 THEN & # 39; Script TV & # 39;
WHEN sub_obje_id = 4105 THEN & # 39; TV order of passage & # 39;
WHEN sub_obje_id = 4152 THEN & # 39; Script radio & # 39;
WHEN sub_obje_id = 4158 THEN & # 39; Radio operation order & # 39;
END AS "Type",
COUNT (*) AS '# Records & # 39;

FROM (dbo). (Object)
WHERE pool_id <> 0 AND sub_obje_id IN (4104,4105,4152,4158)
GROUP BY pool_id, sub_obje_id)
–ORDER BY ob.sob_obje_id ASC

database – Is it allowed to calculate derived attributes directly using the attributes of other tables?

A problem that I see with the approach to calculate the totalPayment on the fly this way, is if the Driver.baseRate or Vehicle.hourRate would be modified later, the previously calculated value could not be reproduced.

I would prefer to keep track of the totalPayment in another table, or store it as an attribute manifested in the Booking table. To fill in the data in this table, you can still use the calculated values ​​from one SELECT statement, but these are valid only in conjunction with a particular moment in which they were calculated.

You must keep in mind that all these values ​​(especially totalPayment) would affect the accounting and what is (eventually) paid to the drivers.
The accounting and what has been paid to the drivers must be (and stay) consistent at all times.

java – List of the last 3 elements (or all if less than 3) in a list of tables

Write a code to return the last 3 elements of a list, if the list contains 3 or more elements, otherwise return all the elements of the list.

But the code seems really bad.
What is the best way to write the same code?

   public void test_arrayListItems() {
        ArrayList arrayList = new ArrayList<>();
        arrayList.add("item1");
        arrayList.add("item2");
        arrayList.add("item3");
        arrayList.add("item4");
        arrayList.add("item5");
        arrayList.add("item6");
        arrayList.add("item7");
        arrayList.add("item8");

        String items = "";
        int j = 0;
        int k = 0;

        if (arrayList.size() <= 2) {
            j = arrayList.size() - 1;
        } else if (arrayList.size() > 2) {
            j = arrayList.size() - 1;
            k = arrayList.size() - 3;
        }
        for (int i = k; i <= j; i++) {
            items = items + "- " + arrayList.get(i) + " ";
        }
        logger.info(items);
    }

Thank you

rstudio – R Markdown prints blank tables made with kable ()

Since I had to uninstall and reinstall R and R studio on my PC, I have trouble seeing the tables created with the kable () function in R Markdown.

When I run the block, it does not give me an error with the construction of the array, but in the notebook output, the elements of the array appear in white, with the exception of the titles, and with the exception. white background that appears by default, I do not see the contents of the table unless you select the text with the cursor. However, the table is correctly displayed in the viewer. When I knit HTML, the table also appears correctly with all visible elements. The only problem is that in the same output of the block, I can not correctly view the tables that I could see in the past.

This is problematic because I am a student and I have to be able to visualize correctly the result of my paintings to be able to continue working on my deliveries, because I have to use kable () yes or yes and it is too laborious to know the visualizer or to knit in HTML format to see if my table is done correctly.

I currently have R studio 1.2.5001 and R 3.6.1. I had the most recent version of R studio, but I do not remember the version of R that I had installed, but this one was not up to date and I was not there. had no problem viewing the tables in R Markdown.

I hope you can help me with my problem. Thank you very much.

database design – MySQL – The value of the column depends on the values ​​of two different tables

I have a MySQL database that contains these tables (* indicates the primary key):

TableA:

----------------------------------------------
|  *id  |  time  |  price  |  special_price  |
----------------------------------------------

TableB:

-------------------------------------
|  *table_a_id  |  *date  |  price  |
-------------------------------------

SpecialDate:

--------------------------
|  *date  |  description |
--------------------------

The value of TableB.price column of each entry in TableB will be either TableA.price or TableA.special_price correspondent TableA entry, as TableB.date is a special date or not (whether it's TableB.date exists in the SpecialDate table).

This design, in its current form, does not seem appropriate to me, because every time I add a recording to TableB, I have to look for the date of SpecialDate to see if it is a special date or not, look for the corresponding entry in TableA to get the value for the price column. And each time a record of SpecialDate is added or updated, I have to go through each entry in TableB update its price column.

I think the column TableB.price should be removed and calculated when needed, but I do not know how to do that with SQL. I have a lot of points of view that depend on that price column, for example:

TableAFullView:

-----------------------------------------------------------------------------
|  id  |  time  |  count_of_table_b_instances  |  sum_of_table_b_instances  |
-----------------------------------------------------------------------------

Or count_of_table_b_instances is the number of TableB the entries that point to this TableA entrance and sum_of_table_b_instances is the sum of their prices.

With my original design, this view is simple to implement and works well. But if I get rid of the column TableB.price, how could I implement this view? Will the performance take a hit?

Note: Do not hesitate to edit the title because I do not know how to best describe this problem.

Google Sheets: move a graph and always update it from the original data / tables?

Can you move or copy a Google Sheets chart into another EXISTING sheet and let it update from the original data tables?
I know you can move a graph in his own sheet, but I'm trying to move multiple graphics on one sheet so I can easily display them all in one place.
Is it possible to do this while keeping the graph up to date when the original sheet data is updated?

c # – inserts one or more tables, or inserts in the same table that knows how to differentiate the folio numbers

The application must record the information on a 2-story table, floor 1 and floor 2, each with a consecutive folio number depending on the year. For example, if you insert in the same installation the factory info number 1 is 0001/2019 and the second floor is a number of acid folio.

MYSQL

NUM AN NAME WEIGHT AMOUNT FACTORY

1 2019 WATER 10 1 1

2 2019 WATER 5 1 1

1 2019 WATER 20 2 2

2 2019 OIL 30 3 2

MYSQL

CREATE DEFINER=`residuos`@`%` PROCEDURE `prueba`(
_anio year(4),
_ACEITE varchar(200),
_CantidadACEITE int,
_PesoACEITE int,
_AGUAvarchar(200),
_CantidadAGUA int,
_PesoAcGUA int)
BEGIN
if( pesoAGUA!=0 OR pesoACEITE!=0 ) then
       Insert into prueba(Numero,anio,ACEITE,CantidadACEITE,PesoACEITE,AC,CantidadAgua,PesoAgua)
        values (_idnumero,_anio,
        _ACEITE,
_CantidadACEITE,
_PesoACEITE,
_AGUA ,
_CantidadAGU,
_PesoAGUA);
if( pesoAGUA2!=0 OR pesoACEITE2!=0 ) then
       Insert into prueba(Numero,anio,ACEITE,CantidadACEITE,PesoACEITE,AC,CantidadAgua,PesoAgua)
        values (_idnumero2,_anio,
        _ACEITE2,
_CantidadACEITE2,
_PesoACEITE2,
_AGUA2 ,
_CantidadAGUA2,
_PesoAGUA2);
END IF;
END IF;
END 

IN THIS CASE, THE ONE INSERTING AT THE SAME TIME, THERE IS NO PROBLEM, BUT IF I INSERT YOU ON THE FACTORY 1, IT APPEARS THAT THE PARAMETERS OF THE FACTORY 2 N & # 39; 39; HAVE NOT BEEN FILLED AND VICE-VERSA, I NEED TO INSERT IN FACTORY 1 OR FACTORY 2. Both