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

📄 uprsettle.~pas

📁 DELPHI编程入门篇.从基础入手,浅显易懂,一定物有所值.
💻 ~PAS
字号:
unit Uprsettle;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Buttons, Grids, ComCtrls, StdCtrls, ExtCtrls,DateUtils, DB,
  ADODB, RpCon, RpRender, RpRenderText, RpDefine, RpRave,RvCsRpt,RVProj,
  RVClass,RVCsStd, RpConDS;

type
  Tfrmprsettle = class(TForm)
    Panel1: TPanel;
    Label1: TLabel;
    Label2: TLabel;
    Edit1: TEdit;
    ComboBox1: TComboBox;
    CheckBox1: TCheckBox;
    DatePicker: TDateTimePicker;
    StringGrid1: TStringGrid;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    SpeedButton3: TSpeedButton;
    SpeedButton4: TSpeedButton;
    ADOQuery1: TADOQuery;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    RvProject1: TRvProject;
    provideConnection1: TRvDataSetConnection;
    procedure FormCreate(Sender: TObject);
    procedure CheckBox1Click(Sender: TObject);
    procedure ComboBox1Select(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure SpeedButton4Click(Sender: TObject);
    procedure SpeedButton3Click(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmprsettle: Tfrmprsettle;

implementation

uses Udatamodule, Usettlepay;

{$R *.dfm}

procedure Tfrmprsettle.FormCreate(Sender: TObject);
var
  sdate,syear,smonth:word;
begin
  decodedate(date,syear,smonth,sdate);
  if smonth > 1 then dec(smonth)
  else begin
    smonth:=12;
    dec(syear);
  end;
  datepicker.Date:=encodedate(syear,smonth,sdate);
  checkbox1.Checked:=false;
  datepicker.Enabled:=false;
  adoquery1.SQL.Text:='select provname from provinfo';
  adoquery1.Open;
  while not adoquery1.Eof do
  begin
    combobox1.Items.Add(adoquery1.fields[0].AsString);
    adoquery1.Next;
  end;
  adoquery1.Close;
  combobox1.ItemIndex:=-1;
  stringgrid1.Cells[0,0]:='业务日期';
  stringgrid1.Cells[1,0]:='业务类型';
  stringgrid1.Cells[2,0]:='单号';
  stringgrid1.Cells[3,0]:='经手人';
  stringgrid1.Cells[4,0]:='应付金额';
  stringgrid1.Cells[5,0]:='已付金额';
end;

procedure Tfrmprsettle.CheckBox1Click(Sender: TObject);
begin
  if datepicker.Enabled then
    datepicker.Enabled:=false
  else
    datepicker.Enabled:=true;
end;

procedure Tfrmprsettle.ComboBox1Select(Sender: TObject);
begin
  adoquery1.SQL.Text:='select provid from provinfo where provname = '''+combobox1.Text+'''';
  adoquery1.Open;
  edit1.Text:=adoquery1.Fields[0].AsString;
  adoquery1.Close;
end;

procedure Tfrmprsettle.SpeedButton1Click(Sender: TObject);
var
  i,arow:integer;
  allpay,allpayed:real;
begin
  if edit1.Text = '' then
  begin
    showmessage('请选择供应商!');
    exit;
  end;
  for i:=1 to stringgrid1.RowCount-1 do
  stringgrid1.Rows[i].Clear;
  stringgrid1.RowCount:=2;
  adoquery1.SQL.Text:='select stockdate,stockid,handleman,accounts from '
  +'stockin where provid = '''+edit1.Text+'''';
  if datepicker.Enabled then
  adoquery1.SQL.Add('and stockdate >=#'+datetostr(datepicker.Date)+'#');
  adoquery1.Open;
  if adoquery1.RecordCount > 0 then
  begin
    arow:=1;
    stringgrid1.RowCount:=adoquery1.RecordCount+1;
    while not adoquery1.Eof do
    begin
      stringgrid1.Cells[0,arow]:=adoquery1.Fields[0].AsString;
      stringgrid1.Cells[1,arow]:='入库';
      stringgrid1.Cells[2,arow]:=adoquery1.Fields[1].AsString;
      stringgrid1.Cells[3,arow]:=adoquery1.Fields[2].AsString;
      stringgrid1.Cells[4,arow]:=adoquery1.Fields[3].AsString;
      stringgrid1.Cells[5,arow]:='0';
      adoquery1.Next;
      inc(arow);
    end;
  end;
  adoquery1.Close;
  adoquery1.SQL.Text:='select refudate,refid,handleman,accounts '
  +'from refund where provid = '''+edit1.Text+'''';
  if not datepicker.Enabled then
    adoquery1.SQL.Add('and refudate >=#'+datetostr(datepicker.Date)+'#');
  adoquery1.Open;
  if adoquery1.RecordCount > 0 then
  begin
    while not adoquery1.Eof do
    begin
      if stringgrid1.Cells[0,stringgrid1.RowCount-1] <> '' then
        stringgrid1.RowCount:=stringgrid1.RowCount+1;
      arow:=stringgrid1.RowCount-1;
      stringgrid1.Cells[0,arow]:=adoquery1.Fields[0].AsString;
      stringgrid1.Cells[1,arow]:='退货';
      stringgrid1.Cells[2,arow]:=adoquery1.Fields[1].AsString;
      stringgrid1.Cells[3,arow]:=adoquery1.Fields[2].AsString;
      stringgrid1.Cells[4,arow]:='-'+adoquery1.Fields[3].AsString;
      stringgrid1.Cells[5,arow]:='0';
      adoquery1.Next;
    end;
  end;
  adoquery1.Close;
  adoquery1.SQL.Text:='select settledate,settleid,handleman,payed from'
  +' prsettle where provid = '''+edit1.Text+'''';
  if datepicker.enabled then
    adoquery1.SQL.add('and settledate >=#'+datetostr(datepicker.Date)+'#');
  adoquery1.Open;
  if adoquery1.RecordCount > 0 then
  begin
    while not adoquery1.Eof do
    begin
      if stringgrid1.Cells[0,stringgrid1.RowCount-1] <> '' then
        stringgrid1.RowCount:=stringgrid1.RowCount+1;
      arow:=stringgrid1.RowCount-1;
      stringgrid1.Cells[0,arow]:=adoquery1.Fields[0].AsString;
      stringgrid1.Cells[1,arow]:='结算';
      stringgrid1.Cells[2,arow]:=adoquery1.Fields[1].AsString;
      stringgrid1.Cells[3,arow]:=adoquery1.Fields[2].AsString;
      stringgrid1.Cells[4,arow]:='0';
      stringgrid1.Cells[5,arow]:=adoquery1.Fields[3].AsString;
      adoquery1.Next;
    end;
  end;
  adoquery1.Close;
  allpay:=0;
  allpayed:=0;
  for i:=1 to stringgrid1.RowCount-1 do
  begin
    allpay:=allpay+strtocurr(stringgrid1.Cells[4,i]);
    allpayed:=allpayed+strtocurr(stringgrid1.Cells[5,i]);
  end;
  label5.Caption:=floattostr(allpay)+'  ';
  label6.Caption:=floattostr(allpayed)+'  ';
end;

procedure Tfrmprsettle.SpeedButton4Click(Sender: TObject);
begin
  modalresult:=mrcancel;
end;

procedure Tfrmprsettle.SpeedButton3Click(Sender: TObject);
begin
  Application.CreateForm(Tfrmsettlepay, frmsettlepay);
  frmsettlepay.ShowModal;
  frmsettlepay.Release;
end;

procedure Tfrmprsettle.SpeedButton2Click(Sender: TObject);
var
  i:integer;
  mypage:travepage;
  mytext:travetext;
begin
  rvproject1.Open;
  with rvproject1.ProjMan do
  begin
    mypage:=findravecomponent('report1.page1',nil) as travepage;
    mytext:=findravecomponent('text3',mypage) as travetext;
    mytext.Text:=combobox1.Text;
    mytext:=findravecomponent('text12',mypage) as travetext;
    mytext.Text:=label5.Caption;
    mytext:=findravecomponent('text13',mypage) as travetext;
    mytext.Text:=label6.Caption;
  end;  
  if stringgrid1.Cells[0,1] <> '' then
  try
    adoquery1.SQL.Text:='create table tbprovidset (operdate date not null,'+
    'operkind char(20),tabid char(12),handleman char(20),shpay float,payed float)';
    adoquery1.ExecSQL;
    adoquery1.Close;
    for i:=1 to stringgrid1.RowCount-1 do
    begin
      adoquery1.SQL.Text:='insert into tbprovidset values(#'+stringgrid1.Cells[0,i]+
      '#,'''+stringgrid1.Cells[1,i]+''','''+stringgrid1.Cells[2,i]+''','''+
      stringgrid1.Cells[3,i]+''','+stringgrid1.Cells[4,i]+','+stringgrid1.Cells[5,i]+')';
      adoquery1.ExecSQL;
      adoquery1.Close;
    end;
    adoquery1.SQL.Text:='select * from tbprovidset';
    adoquery1.Open;
    rvproject1.Execute;
  finally
    rvproject1.Close;
    adoquery1.Close;
    adoquery1.SQL.Text:='drop table tbprovidset';
    adoquery1.ExecSQL;
    adoquery1.Close;
  end
  else
    showmessage('请先查询数据');
end;

end.

⌨️ 快捷键说明

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