⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 search.~pas

📁 家用理财软件beta版
💻 ~PAS
📖 第 1 页 / 共 3 页
字号:
  dtp2:=datetimetostr(rzdatetimepicker4.Date);
  with ADOquery2 do
  begin
     close;
     sql.Clear;
     sql.Add('select * from incometable');
     if xpedit3.Text<> '' then
     begin
        sql.Add('where ( income_name='''+xpedit3.Text+''')');
        firstone:=false;
     end;
     if xpcheckbox2.Checked then
     begin
      if firstone then
       begin
        sqlstr:='where ( income_date >= (:dtp1) and income_date<= (:dtp2) )';
        sql.Add(sqlstr);
        Parameters.ParamByName('dtp1').Value:=formatdatetime('yyyy-m-d hh:mm:ss',rzdatetimepicker3.DateTime);
        Parameters.ParamByName('dtp2').Value:=formatdatetime('yyyy-m-d hh:mm:ss',rzdatetimepicker4.DateTime);
        firstone:=false;
       end
      else
       begin
        sqlstr:='where ( income_date >= :dtp1 and income_date<= :dtp2 )';
        sql.Add(sqlstr);
        Parameters.ParamByName('dtp1').Value:=formatdatetime('yyyy-m-d hh:mm:ss',rzdatetimepicker3.DateTime);
        Parameters.ParamByName('dtp2').Value:=formatdatetime('yyyy-m-d hh:mm:ss',rzdatetimepicker4.DateTime);
       end;
     end;
     if xpcombobox1.Text<>'' then
     begin
      if firstone then
       begin
        sql.Add('where ( income_source='''+xpcombobox1.Text+''')');
       end
      else
      sql.Add('and ( income_source='''+xpcombobox1.Text+''')');
      end;
      Open;
  end;
  for i:=0 to 5 do
  begin
    rzDBGrid1.Columns[i].Alignment:=taCenter;
    rzDBGrid1.Columns[i].Title.Alignment:=taCenter;
  end;
  rzdbgrid1.Columns.Items[0].Title.caption:='编号';
  rzdbgrid1.Columns.Items[1].Title.caption:='收入人';
  rzdbgrid1.Columns.Items[2].Title.caption:='收入金额';
  rzdbgrid1.Columns.Items[3].Title.caption:='收入日期';
  rzdbgrid1.Columns.Items[4].Title.caption:='收入来源';
  rzdbgrid1.Columns.Items[5].Title.caption:='填写日期';
end;

function monthday(amonth:integer;ayear:integer):Tdatetime;
begin
   case amonth of
   1,3,5,7,8,10,12:
      result:=strtodatetime(inttostr(ayear)+'-'+inttostr(amonth)+'-31 23:59:59');
   4,6,9,11:
      result:=strtodatetime(inttostr(ayear)+'-'+inttostr(amonth)+'-30 23:59:59');
   2:
      begin
        if (ayear mod 400=0) then
          begin
            result:=strtodatetime(inttostr(ayear)+'-'+inttostr(amonth)+'-29 23:59:59');
          end
        else
          begin
          if (ayear mod 4 = 0) then
           result:=strtodatetime(inttostr(ayear)+'-'+inttostr(amonth)+'-29 23:59:59')
          else
           result:=strtodatetime(inttostr(ayear)+'-'+inttostr(amonth)+'-28 23:59:59');
          end;
      end;
   else
     result:=now;
   end;
end;


function zero_gain_month():boolean;
var i:integer;
begin
   for i:=1 to 12 do
   begin
      gain_month[i][1]:=0;
      gain_month[i][2]:=0;
   end;
end;

procedure tForm2.get_total();
var i:integer;
begin
  total_gain:=0;
  total_income:=0;
  total_payout:=0;
  for i:=1 to 12 do
  begin
     total_income:=gain_month[i][1]+total_income;
     total_payout:=gain_month[i][2]+total_payout;
  end;
  total_gain:=total_income-total_payout;
  xpedit6.Text:=floattostr(total_income);
  xpedit7.Text:=floattostr(total_payout);
  xpedit8.Text:=floattostr(total_gain);
end;

function pay_out(month_num:integer;ADOQuery4: TADOQuery):boolean;
var month1,month2: string;
i,j:integer;
begin
  for j:=1 to month_num do
  begin
   with adoquery4 do
   begin
     close;
     sql.Clear;
     sql.Add('select * From payouttable where (payout_date >= :month2 and payout_date <= :month1)');
     Parameters.ParamByName('month1').Value:=formatdatetime('yyyy-m-d',incday(now,-0-(j-1)*30));
     Parameters.ParamByName('month2').Value:=formatdatetime('yyyy-m-d',incday(now,-30-(j-1)*30));
     open;
     first;
     for i:=1 to adoquery4.RecordCount do
     begin
      gain_month[j][2]:=gain_month[j][2]+strtofloat(adoquery4.FieldValues['payout_money']);
      next;
     end;
   end;
  end;
  result:=true;
end;


procedure TForm2.xpBitBtn5Click(Sender: TObject);
var month1,month2: string;
i,j:integer;
    cmonth,cyear,cday:word;
    cur_month:integer;
    cur_year:integer;
begin
  zero_gain_month();
  listview1.Clear;
  decodedate(date,cyear,cmonth,cday);
  cur_month:=strtoint(inttostr(cmonth));
  cur_year:=strtoint(inttostr(cyear));
  for j:=1 to 3 do
  begin
   with ADOQUERY3 do
   begin
     close;
     sql.Clear;
     sql.Add('select * From incometable where (income_date <= :month2 and income_date >= :month1)');
     Parameters.ParamByName('month1').Value:=formatdatetime('yyyy-m-d hh:mm:ss',strtodatetime(inttostr(cur_year)+'-'+inttostr(cur_month)+'-1 00:00:00'));
     Parameters.ParamByName('month2').Value:=formatdatetime('yyyy-m-d hh:mm:ss',monthday(cur_month,cur_year));
     cur_month:=cur_month-1;
     if cur_month=0 then
     begin
      cur_month:=12;
      cur_year:=cyear-1;
     end;
     open;
     first;
     for i:=1 to adoquery3.RecordCount do
     begin
      gain_month[j][1]:=gain_month[j][1]+strtofloat(adoquery3.FieldValues['income_money']);
      next;
     end;
   end;
  end;
  pay_out(3,adoquery4);
  cur_year:=strtoint(inttostr(cyear));
  cur_month:=strtoint(inttostr(cmonth));
   for i:=1 to 3 do
   with listview1.Items.Add do
   begin
      caption:=inttostr(cur_year)+'年'+inttostr(cur_month)+'月收支情况:';
      subitems.Add(floattostr(gain_month[i][1]));
      subitems.Add(floattostr(gain_month[i][2]));
      subitems.Add(floattostr(gain_month[i][1]-gain_month[i][2]));
      cur_month:=cur_month-1;
      if cur_month=0 then
       begin
         cur_month:=12;
         cur_year:=cur_year-1;
       end;
   end;
   get_total;
end;

procedure TForm2.xpBitBtn6Click(Sender: TObject);
var month1,month2: string;
    i,j:integer;
    cmonth,cyear,cday:word;
    cur_month:integer;
    cur_year:integer;
begin
  zero_gain_month();
  listview1.clear;
  decodedate(date,cyear,cmonth,cday);
  cur_month:=strtoint(inttostr(cmonth));
  cur_year:=strtoint(inttostr(cyear));
  for j:=1 to 1 do
  begin
   with ADOQUERY3 do
   begin
     close;
     sql.Clear;
     sql.Add('select * From incometable where (income_date <= :month2 and income_date >= :month1)');
     Parameters.ParamByName('month1').Value:=formatdatetime('yyyy-m-d hh:mm:ss',strtodatetime(inttostr(cur_year)+'-'+inttostr(cur_month)+'-1 00:00:00'));
     Parameters.ParamByName('month2').Value:=formatdatetime('yyyy-m-d hh:mm:ss',monthday(cur_month,cur_year));
     open;
     first;
     for i:=1 to adoquery3.RecordCount do
     begin
      gain_month[j][1]:=gain_month[j][1]+strtofloat(adoquery3.FieldValues['income_money']);
      next;
     end;
   end;
  end;
  pay_out(1,ADOQuery4);
   for i:=1 to 1 do
   with listview1.Items.Add do
   begin
      caption:=inttostr(cyear)+'年'+inttostr(cmonth)+'月收支情况:';
      subitems.Add(floattostr(gain_month[i][1]));
      subitems.Add(floattostr(gain_month[i][2]));
      subitems.Add(floattostr(gain_month[i][1]-gain_month[i][2]));
   end;
   get_total;
end;

procedure TForm2.xpBitBtn7Click(Sender: TObject);
var month1,month2: string;
i,j:integer;
    cmonth,cyear,cday:word;
    cur_month:integer;
    cur_year:integer;
begin
  zero_gain_month();
  listview1.Clear;
  decodedate(date,cyear,cmonth,cday);
  cur_month:=strtoint(inttostr(cmonth));
  cur_year:=strtoint(inttostr(cyear));
  for j:=1 to 4 do
  begin
   with ADOQUERY3 do
   begin
     close;
     sql.Clear;
     sql.Add('select * From incometable where (income_date <= :month2 and income_date >= :month1)');
     Parameters.ParamByName('month1').Value:=formatdatetime('yyyy-m-d hh:mm:ss',strtodatetime(inttostr(cur_year)+'-'+inttostr(cur_month)+'-1 00:00:00'));
     Parameters.ParamByName('month2').Value:=formatdatetime('yyyy-m-d hh:mm:ss',monthday(cur_month,cur_year));
     cur_month:=cur_month-1;
     if cur_month=0 then
     begin
      cur_month:=12;
      cur_year:=cyear-1;
     end;
     open;
     first;
     for i:=1 to adoquery3.RecordCount do
     begin
      gain_month[j][1]:=gain_month[j][1]+strtofloat(adoquery3.FieldValues['income_money']);
      next;
     end;
   end;
  end;
  pay_out(4,adoquery4);
  cur_year:=strtoint(inttostr(cyear));
  cur_month:=strtoint(inttostr(cmonth));
   for i:=1 to 4 do
   with listview1.Items.Add do
   begin
      caption:=inttostr(cur_year)+'年'+inttostr(cur_month)+'月收支情况:';
      subitems.Add(floattostr(gain_month[i][1]));
      subitems.Add(floattostr(gain_month[i][2]));
      subitems.Add(floattostr(gain_month[i][1]-gain_month[i][2]));
      cur_month:=cur_month-1;
      if cur_month=0 then
       begin
         cur_month:=12;
         cur_year:=cur_year-1;
       end;
   end;
   get_total;
end;

procedure TForm2.xpBitBtn8Click(Sender: TObject);
var month1,month2: string;
i,j:integer;
    cmonth,cyear,cday:word;
    cur_month:integer;
    cur_year:integer;
begin
  zero_gain_month();
  listview1.Clear;
  decodedate(date,cyear,cmonth,cday);
  cur_month:=strtoint(inttostr(cmonth));
  cur_year:=strtoint(inttostr(cyear));
  for j:=1 to 6 do
  begin
   with ADOQUERY3 do
   begin
     close;
     sql.Clear;
     sql.Add('select * From incometable where (income_date <= :month2 and income_date >= :month1)');

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -