Topic: Несколько вопросов 5
Уважаемый Дмитрий!
На форме Fond имеется DateTimePicker1 и 2, Button1, TGrid, ostatok (TextBox), omad (TextBox), raft (TextBox), favt (TextBox) и mond (TextBox).
Есть такая вот процедура.
procedure Fond_Button1_OnClick (Sender: string; var Cancel: boolean);
var
i1, i2, i3, i4: integer;
begin
i1:= SQLExecute('Select Count(numberTB) from Base where incomeDate < '+Fond.DateTimePicker1.sqlDateTime+' and outcomeDate Between '+Fond.DateTimePicker1.sqlDateTime +' and '+Fond.DateTimePicker2.sqlDateTime +'');
Fond.ostatok.Value:= i1;
i2:= SQLExecute('Select Count(numberTB) from Base where incomeDate Between '+Fond.DateTimePicker1.sqlDateTime+' and '+Fond.DateTimePicker2.sqlDateTime +'');
Fond.omad.Value:= i2;
i3:= SQLExecute('Select Count(numberTB) from Base where outcomeDate Between '+Fond.DateTimePicker1.sqlDateTime+' and '+Fond.DateTimePicker2.sqlDateTime +'');
Fond.raft.Value:= i3;
i4:= SQLExecute('Select Count(numberTB) from Base where outcomeDate Between '+Fond.DateTimePicker1.sqlDateTime+' and '+Fond.DateTimePicker2.sqlDateTime +' and Base.id_endoftreatment=2');
Fond.favt.Value:= i4;
i5:= i1 + i2 - i3;
Fond.mond.Value:= i5;
end;
Теперь при указании даты в пикерах 1 и 2 все работает отлично. Например я указываю 01.01.2017 и 31.01.17 и в указанных текстбоксах все калькулируется нормально но с учетом всего месяца.
Как мне сделать чтобы в грид добавилась строка и показывались i1, i2, i3, i4 и i5 на каждый день. Т.е. я указываю 01.01.2017 и 31.01.17 и в грид показывается типа вот так:
01.01.17 i1 i2 i3 i4 i5
02.01.17 i1 i2 i3 i4 i5
03.01.17 i1 i2 i3 i4 i5
...
31.01.17 i1 i2 i3 i4 i5
Надо подчеркнуть что i5 сегодняшнего дня всегда равняется i1 следующего дня. Т.е. если привести примеры в виде цифр то должно получится типа вот так:
i1 i2 i3 i4 i5
01.01.17 4 2 3 2 3
02.01.17 3 2 1 3 4
03.01.17 4 1 0 1 5
...
31.01.17 2 2 1 0 3
Помогите с реализацией пожалуйста.