Delphi query date data

Source: Internet
Author: User

1. Define the display status of the time control when the form is displayed.
DateTimePicker1.Date: = Date-30;
DateTimePicker2.Date: = Date
2. query turnover
Query1.close;
Query1. SQL. clear;
Query1. SQL. add ('select * from monthly settlement expense where date>: A and date <=: B ');
Query1. SQL. add ('order by checkout No. asc ');
Query1.ParamByName ('A'). AsDateTime: = DateTimePicker1.DateTime;
Query1.ParamByName ('B'). AsDateTime: = DateTimePicker2.DateTime;
Query1.open;
Query2.close;
Query2. SQL. clear;
Query2. SQL. add ('select sum (cost) from monthly settlement fee information table where date> = A and date <=: B ');
Query2.ParamByName ('A'). AsDateTime: = DateTimePicker1.DateTime;
Query2.ParamByName ('B'). AsDateTime: = DateTimePicker2.DateTime;
Query2.open;
Lable1.caption: = Query2.Fields [0]. AsString;
Lable2.caption: = IntToStr (Query1.RecordCount );
Query2.close;

3. query the world
Query1. SQL. add ('select * from warehouse receiving where date =: ');
Query1.ParamByName ('A'). AsDateTime: = Date;

4. Comprehensive query statistics
Var
Str_date, str_date1: string;
Begin
If chk_rkrq.Checked then
Begin
DateTimeToString (str_date, 'yyyymmdd', dtp_ksrq.date );
DateTimeToString (str_date1, 'yyyymmdd', dtp_jsrq.date );
Dy_ksrq: = Copy (Trim (str_date), 1, 4) + 'Year' + Copy (Trim (str_date), 5, 2) +
'Month' + Copy (Trim (str_date), 7, 2) + 'day ';
Dy_jsrq: = Copy (Trim (str_date1), 1, 4) + 'Year' + Copy (Trim (str_date1), 5, 2) +
'Month' + Copy (Trim (str_date1), 7, 2) + 'day ';
With qry_jhxx do
Begin
Close;
SQL. Clear;
SQL. add ('select. jhdh,. ghsmc,. hwzje, B. czyxm from j_jhzdxxb a, j_xtczyb B where. czydm = B. czyid and. jhdh like ''' % '+ trim (edt_jhdh.Text) +' % ''');
SQL. Add (and a. ghsmc like ''% '+ trim (cbb_ghsmc.Text) +
'% ''And substring (jhdh, 3, 8) between ''' + str_date + ''' and ''' +
Str_date1 + '''');
Open;
End;
End
Else
If chk_rkrq.Checked = False then
Begin
With qry_jhxx do
Begin
Close;
SQL. Clear;
SQL. add ('select. jhdh,. ghsmc,. hwzje, B. czyxm from j_jhzdxxb a, j_xtczyb B where. czydm = B. czyid and. jhdh like ''' % '+ trim (edt_jhdh.Text) +' % ''');
SQL. Add (and a. ghsmc like ''' % '+ trim (cbb_ghsmc.Text) +' % ''');
Open;
End;
End;
Stat_jhcx.Panels [0]. Text: = 'number of query information records: '+ inttostr (qry_jhxx.RecordCount)
+ 'Entries. ';

5. Check the records. If not, forget it.
If ds_xx.DataSet.State = dsinactive then
Begin
Exit;
End;
If ds_xx.DataSet.RecordCount = 0 then
Begin
Exit;
End;
Jxxxw. showmodal;

6. Leave the field 0 in the table.
If trim (dbgrd_czy.Columns.Grid.Fields [0]. AsString) <> ''then
Begin
Edt_bh.Text: = Trim (dbgrd_czy.performance.dataset.fieldvalues ['czyid']);
Edt_xm.Text: = Trim (dbgrd_czy.performance.dataset.fieldvalues ['czyxm ']);
Edt_bh.Enabled: = False;
Edt_xm.Enabled: = false;
Edt_qrmm.Enabled: = false;
End;

7.
If length (edt_bh.text) <> 5 then
Begin
Application. MessageBox ('number must be a 5-digit integer. Please enter it again! ', 'Operator number', MB_ OK
+ MB_ICONWarning );
Edt_bh.SetFocus;
Exit;
End;
If Trim (edt_xm.Text) = ''then
Begin
Application. MessageBox ('name cannot be blank. Please enter it again! ', 'Operator name', MB_ OK +
MB_ICONWarning );
Edt_xm.SetFocus;
Exit;
End;
If Trim (edt_mm.Text) = ''then
Begin
Application. MessageBox ('the password cannot be blank. Please try again! ', 'Operator password', MB_ OK +
MB_ICONWarning );
Edt_mm.SetFocus;
Exit;
End;
If Trim (edt_mm.Text) <> Trim (edt_qrmm.Text) then
Begin
Application. MessageBox ('different passwords are entered twice. Please try again! ', 'Operator password', MB_ OK
+ MB_ICONWarning );
Edt_mm.SetFocus;
Exit;
End;
If edt_bh.Enabled = True then
Begin
If MessageBox (0,
PChar ('Are you sure you have entered the correct information? Click "yes", and then click "no "! '),
'Confirm new information', MB_ICONQUESTION or MB_YESNO) = IDNO then
Exit;
With qry_czy do
Begin
Close;
SQL. Clear;
SQL. Add ('insert into j_xtczyb (czyid, czyxm, czymm, czyzt, czyqx, czsj, czydm )');
SQL. Add ('values (''' + trim (edt_bh.Text) + ''', ''' + trim (edt_xm.Text) +
'''');
SQL. Add (', ''' + Encrypt (trim (edt_mm.Text), 66) +
''', ''0'', ''000000'', CURRENT_TIMESTAMP, ''' + d1_z
+ ''')');
// Inputbox (SQL. text, SQL. Text, SQL. text );
ExecSQL;
End;
With jmainw. qry_xtrz do
Begin
Close;
SQL. clear;
SQL. add ('insert into j_syslog values (''' + d1_z + ''', ''' + dlxmz +
''', CURRENT_TIMESTAMP, ''add operator '')');
Execsql;
End;
Application. MessageBox ('operator added successfully! ',' Add', MB_ OK +
MB_ICONINFORMATION );
Jczyglw. FormActivate (nil );
Btn_clear.Click;
Exit;
End
Else
If edt_qrmm.Enabled = True then
Begin
If (Trim (edt_mm.Text) <> '') and (Trim (edt_qrmm.text) <>'') then
Begin
If MessageBox (0, PChar ('Confirm modify' + trim (edt_xm.Text) +
'Password? Click "yes", and then click "no "! '), 'Confirm password information ',
MB_ICONQUESTION or MB_YESNO) = IDNO then
Exit;
With qry_czy do
Begin
Close;
SQL. Clear;
SQL. Add ('Update j_xtczyb set czymm = ''' + Encrypt (trim (edt_mm.Text), 66)
+ '''');
SQL. Add (', czsj = CURRENT_TIMESTAMP, czydm = ''' + d1_z +
'''Where czyid = ''' + trim (edt_bh.Text) + '''');
ExecSQL;
End;
End;
With jmainw. qry_xtrz do
Begin
Close;
SQL. clear;
SQL. add ('insert into j_syslog values (''' + d1_z + ''', ''' + dlxmz +
''', CURRENT_TIMESTAMP, ''change operator password '')');
Execsql;
End;
Application. MessageBox ('operator password modified successfully! ', 'Change password', MB_ OK +
MB_ICONINFORMATION );
Jczyglw. FormActivate (nil );
Btn_clear.Click;
Exit;
End;
End;

8.
With qry_ylxx do
Begin
Close;
SQL. Clear;
SQL. Add ('Update ylcf set name = ''' + trim (edt_ylmc.Text) + ''', zjm = ''' +
Trim (edt_zjm.Text) + '''');
SQL. Add (', yylb_id = ''' + trim (yllb_idz) + ''' where code = ''' +
Trim (edt_ylbh.Text) + '''');
ExecSQL;
End;
Except
Exit;
End;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.