Hi all,
Adam,
Your code is working.
But...
If your Memo contains at least one space, the command will not work.
I would recommend additionally using the Trim() function.
If Trim(Form1.MemKeyNotes01.text) ...
My Visual Database → Posts by sparrow
Hi all,
Adam,
Your code is working.
But...
If your Memo contains at least one space, the command will not work.
I would recommend additionally using the Trim() function.
If Trim(Form1.MemKeyNotes01.text) ...
Cancel := True;
Hi Jean,
Now I can fully answer your first question.
Calculation of annuity and differentiated payments.
Calculations are made:
- SQLite recursive
- Recursive script function
- Loop in script procedure
The script contains commented code for working directly with TableGrid with a brief description.
Ability to output results to a report or Excel.
myvalue := Report.TableGrid1.Cell[1,viii].AsInteger;
or
myvalue := StrToInt(Report.TableGrid1.Cells[1,viii]);
There's nothing unusual there.
For ... loop that automatically changes the value to 1 until it reaches the condition value.
While ... loop while the condition is true. How much to change the value and when to do it depends on the user.
Used for increments other than 1 and other conditions.
In your example, there is no increment until the correct cell value is entered.
Repeat ... until - a cycle similar to the previous one but backwards.
The difference between the last two is that “Repeat ... until” will be executed at least once.
Therefore, in your case, the choice fell on WHILE.
In Konstantin's example there are essentially two "Repeat ... until" loops inside a "For".
Hi Derek,
Try this solution:
+ added exit via Cancel.
procedure Form1_Button1_OnClick (Sender: TObject; var Cancel: boolean);
var vi: integer; vs: string;
begin
vi := 0;
While vi <= form1.tablegrid1.RowCount-1 do
begin
form1.tablegrid1.SelectedRow := vi;
if inputquery('Candidate: ' + form1.tablegrid1.cells[1,vi] + ' ' + form1.tablegrid1.cells[0,vi], 'Review:', vs) then
begin
if not (vs in ['a','d','A','D']) then
begin
showmessage('Invalid Input');
end else
begin
if (vs in ['a','A']) then vs := 'APPROVED' else if (vs in ['d','D']) then vs := 'DENIED';
sqlexecute('update candidates set outcome = "'+uppercase(vs)+'" where id = "'+inttostr(form1.tablegrid1.row[vi].id)+'"');
vi := vi + 1;
end;
form1.tablegrid1.dbupdate;
vs := '';
end else Exit;
end;
end;
Проверьте правильность имени события OnChange в свойствах таблицы.
P.S.
What BeginUpdate do?
This call prevent NextGrid from drawing EACH new or changed Cell until operation is finished. Also all complicated calculations needed for drawing Cell is skiped too. This can speed up your code a lot!
We will draw this rows ONLY after we finish with operation, and ONLY we will draw visible Cells on screen. After you finish with adding rows, ALLWAYS call EndUpdate.
Hi Jean,
The calculation formula has been changed to A=P*(r(1+r)^n)/((1+r)^n-1)
Hi Jean,
A little higher in the post I posted the amorti-m1.zip version.
Here is the direct link. https://myvisualdatabase.com/forum/misc … download=1
Everything there is already tied to the EditBox where you can set your values.
Indicate your final formula and I will add it instead of mine. Yesterday I looked at calculators online and they all calculated using your formula.
But there is still a discrepancy.
Hi Adam
I don't understand what algorithm you are trying to achieve.
Why then StartDate, StartTime? Why are the signs of message or sound output automatically removed immediately after one trigger? No more reminders needed? Maybe I haven't studied the project well enough?
I'll shorten my question.
You have StartDate, StartTime, DueDate, DueTime. For which Start or Due event should the reminder be triggered?
Right now you are checking (DueDate <= current date) and (message OR sound are 1).
The second part of the test (message OR sound equals 1) is already incorrect. It causes both message output and audio output to be executed even if only one of them is enabled.
Find answers to the questions for yourself and adjust the condition check.
Hi,
936.64 in my first attached file is for a loan of 100,000, rate 10, period 240 months. with the date of issue 01/01/2010.
According to your formula with such data, the payment is 965.02.
Our formulas are different and the calculation of the monthly rate from the annual rate is different. I just gave an example. I'm not saying that my formula is better or the result is more accurate. And different banks may have different calculations. In any case, the most accurate result is the one that the bank will calculate and which will have to be paid))))). Oh, those banks.
As an option, look at a bank calculator (only without various commissions). and compare with our formulas.
As for the formula, I will help you enter your formula.
You should decide what criteria to use to check records in the OnTimer procedure.
You have the following fields StartDate, StartTime, DueDate, DueTime, PlaySound, MsgPopup, taskCompleted. Which fields should be included in the verification and under what conditions. Moreover, checking for messages and sound should be separated separately.
Fixed and optimized SQLite queries.
Supports leap years in calculations.
Examples are linked to the program.
Hi,
both options are possible
Here is an example for SQLite.
Example1 - script query, Example2 - Buttom SQL query.
Replaced SQLite DLL with a new version.
Example of calculation taking into account days in a month.
I would like to draw special attention to the fact that bank calculations may differ.
Rec_Id := SQLExecute('SELECT id FROM reminder WHERE (PlaySound = 1 or MsgPopup = 1) and '
+ '((duedate Is Not Null and Date(duedate) < strftime(''%Y-%m-%d'', ''now'',''localtime'')) or '
+ '(Date(duedate) = strftime(''%Y-%m-%d'', ''now'',''localtime'')))' );
I removed the check for the "datetime" column from the request
Hi Adam
Your "datetime" field in the "Remainder" table is always NULL and I did not find where you should set it. Check the query condition in the procedure OnTimer;:
duedate Is Not Null and datetime Is Not Null and Date(duedate) <= strftime('%Y-%m-%d', 'now','localtime')
...
and strftime('%H:%M', Time(datetime))
You can simply use Date(''now'',''localtime'') instead of strftime(''%Y-%m-%d'', ''now'',''localtime'')
As for the history of this, you can read here:
https://www.timeanddate.com/calendar/da … -week.html
As for SQLite, new versions support both Sunday and Monday as the first day.
%u day of week 1-7 with Monday==1
%w day of week 0-6 with Sunday==0
https://www.sqlite.org/lang_datefunc.html
However, for compatibility with previous versions it is better to use %w
"But even when the moon looks like it’s waning…it’s actually never changing shape. Don’t ever forget that." —Ai Yazawa
Hi Adam, Derek
OR
if form1.CheckBox1.Checked then SetWindowPos(Form1.Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NoMove or SWP_NoSize)
else SetWindowPos(Form1.Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NoMove or SWP_NoSize);
Use both options with caution. Options are set for one form.
Hi Derek,
Thank you.
samtorn, for self-study.
Option for FastReport. Directly for the Memo field on the form.
Create Memo2 next to Memo1 in Derek's example and place the code below.
It looks scary but it's simple.
[IIF(<Report."Employer_Hours.dayofweek">=1,'Mon',
IIF(<Report."Employer_Hours.dayofweek">=2,'Tue',
IIF(<Report."Employer_Hours.dayofweek">=3,'Wed',
IIF(<Report."Employer_Hours.dayofweek">=4,'Thu',
IIF(<Report."Employer_Hours.dayofweek">=5,'Fri',
IIF(<Report."Employer_Hours.dayofweek">=6,'Sat',
'Sun'))))))]
OR
[SQLExecute('SELECT CASE '''+<Report."Employer_Hours.dayofweek">+'''*1 WHEN 1 THEN ''Monday'' END ')]
And a link to the manual to make it work: https://www.fast-report.com/public_down … ual-en.pdf
Any comments?
In the example you indicated:
Update the ChartBar creation code part:
ChartBar := TChart.Create(Form1);
ChartBar.Parent := Form1.PanelBar;
ChartBar.Align := alClient;
ChartBar.AddSeries(TBarSeries.Create(ChartBar));
ChartBar.Series[0].XValues.DateTime := true;
TBarSeries(ChartBar.Series[0]).marks.Style:=smsValue;
Form1.bBarUpdate.Click;
Update procedure Form1_bBarUpdate_OnClick
procedure Form1_bBarUpdate_OnClick (Sender: string; var Cancel: boolean);
var
Results: TDataSet;
DateValue: Double;
QtyValue, Lab: string;
begin
ChartBar.Series[0].Clear;
SQLQuery('SELECT date, qty, CASE strftime(''%d'', date)*1 WHEN 1 THEN ''Jan'' WHEN 2 THEN ''Feb'' ELSE ''Other'' END AS Lab FROM bar_data ORDER BY date DESC', Results);
while not Results.Eof do
begin
DateValue := SQLDateTimeToDateTime( Results.FieldByName('date').asString );
QtyValue := Results.FieldByName('qty').asString;
Lab := Results.FieldByName('Lab').asString;
if ValidInt(QtyValue) then ChartBar.Series[0].AddXY(DateValue, StrToInt(QtyValue), Lab);
Results.Next;
end;
end;
On the X axis we now display months as an example.
You can use a calculated field like
CASE <FIELD Name>
WHEN 0 THEN 'Sunday'
WHEN 1 THEN 'Monday'
WHEN 2 THEN 'Tuesday'
WHEN 3 THEN 'Wednesday'
WHEN 4 THEN 'Thursday'
WHEN 5 THEN 'Friday'
WHEN 6 THEN 'Saturday' END
or in the FastReport script like
begin
case <variable name> of
1: Form1.Edit1.Text := 'Sunday';
2: Form1.Edit1.Text := 'Monday';
3: Form1.Edit1.Text := 'Tuesday';
4: Form1.Edit1.Text := 'Wednesday';
5: Form1.Edit1.Text := 'Thursday';
6: Form1.Edit1.Text := 'Friday';
7: Form1.Edit1.Text := 'Saturday';
end;
end;
In addition, Pascal and SQLite have their own functions for determining the day of the week (day number) by date.
DayOfWeek()
And
strftime('%w', ...).
Hi Derek, Константин
procedure getpiece (Sender: TObject);
begin
if form1.edit1.Value <= form1.edit2.value then
begin
form1.edit3.text := replacestr(form1.edit1.text, decimalseparator, '.');
form1.edit4.text := replacestr(form1.edit2.text, decimalseparator, '.');
end else
begin
form1.edit3.text := replacestr(form1.edit2.text, decimalseparator, '.');
form1.edit4.text := replacestr(form1.edit1.text, decimalseparator, '.');
end;
end;
My Visual Database → Posts by sparrow
Powered by PunBB, supported by Informer Technologies, Inc.
Theme Hydrogen by Kushi