1 (edited by chartcatuser 2022-06-22 10:05:54)

Topic: TableGrid View

I ask for help there is one Order table in which orders are created and there is another Order2 table in which I record dates using the calendar with a double click. You can add another table in the same form so that when you click on the calendar 2 times, an entry in the order2 table immediately appears. Maybe an Sql query or something else. I just have all the entries displayed sad(

procedure frmOrderProduct_Button3_OnClick (Sender: TObject; var Cancel: boolean);
var
maxID:string;
ID2:string;
sBirthDate: string;
begin
      //combobox
      if (frmOrderProduct.ComboBox1.dbItemID = -1) and (frmOrderProduct.ComboBox1.Text <> '') then
    begin
        if 6 = MessageDlg(' Добавить продукт на  '  +  frmOrderProduct.Edit2.Text, mtConfirmation, mbYes + mbNo, 0) then
        begin
      //Save
       if frmOrderProduct.DateTimePicker1.Checked then
          sBirthDate  := '"' + FormatDateTime('yyyy-MM-DD 00:00:00.000', frmOrderProduct.DateTimePicker1.Date) + '"'
          else sBirthDate := 'NULL';
      maxID := SQLExecute('SELECT MAX(id) FROM ORDERT');
      SQLExecute('INSERT INTO Order2 (Dates, INN, ID_ORDERT,productnamedop) VALUES ('+sBirthDate+', "'+frmOrderProduct.KolTovar.Text+'", "'+maxID+'", "'+frmOrderProduct.ComboBox1.Text+'")');
      frmOrder.TableGrid1.dbUpdate;
      UpdateDatabase('bsm_off');
      frmOrderProduct.ComboBox1.dbItemID := Last_Insert_id;
        end;
     end;
end;