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

📄 uform_advice.pas

📁 这是在SQL数据库下编写的一个源代码
💻 PAS
字号:
unit Uform_advice;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ImgList, DB, ADODB, StdCtrls, Buttons, ComCtrls, ExtCtrls;

type
  Tform_advice = class(TForm)
    Panel1: TPanel;
    Image1: TImage;
    Label2: TLabel;
    Label1: TLabel;
    Bevel1: TBevel;
    Image2: TImage;
    Label23: TLabel;
    Label24: TLabel;
    Panel2: TPanel;
    ListView1: TListView;
    Panel3: TPanel;
    Panel4: TPanel;
    BitBtn3: TBitBtn;
    BitBtn2: TBitBtn;
    BitBtn1: TBitBtn;
    recordset_temp: TADOQuery;
    ImageList1: TImageList;
    recordset_temp2: TADOQuery;
    Label3: TLabel;
    Label4: TLabel;
    procedure BitBtn3Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    sdate:tdate;
    edate:tdate;
  end;

var
  form_advice: Tform_advice;

implementation

uses Uform_fw_limit, Uform_advice_inf;

{$R *.dfm}

procedure Tform_advice.BitBtn3Click(Sender: TObject);
begin
   close;
end;

procedure Tform_advice.FormShow(Sender: TObject);
var
   i:integer;
   ListItem: TListItem;
   p:^integer;
   intcount:integer;
begin
   sdate:=now;
   edate:=now;
   listview1.Items.Clear ;
   label4.Caption :='未限定';

   recordset_temp.SQL.Clear ;
   recordset_temp.SQL.Add('select * from [APART]');
   recordset_temp.Open ;
   intCount:=recordset_temp.RecordCount ;
   Label24.Caption :=inttostr(intCount) + '个部门';
   for i:=1 to recordset_temp.RecordCount do
   begin
      listitem:=listview1.Items.Add ;
      listitem.Caption :=recordset_temp.Fields[1].AsString ;
      listitem.ImageIndex :=0;

      listitem.SubItems.Add('0');
      listitem.SubItems.Add('0');
      listitem.SubItems.Add('0');
      listitem.SubItems.Add('0');

      new(p);
      p^ := recordset_temp.Fields[0].AsInteger ;
      listitem.Data :=p;
      recordset_temp.Next;
   end;
   recordset_temp.Close;
end;

procedure Tform_advice.BitBtn2Click(Sender: TObject);
var
   i:integer;
   ListItem: TListItem;
   p:^integer;
   intcount:integer;
   c1:integer;
   c2:integer;
   c3:integer;
begin
   form_fw_limit.ShowModal ;
   if form_fw_limit.yesno =false then
   begin
      exit;
   end;

   sdate:=form_fw_limit.sdate;
   edate:=form_fw_limit.edate;

   
   listview1.Items.Clear ;
   label4.Caption :=datetostr(sdate) + ' - ' + datetostr(edate);

   recordset_temp.SQL.Clear ;
   recordset_temp.SQL.Add('select * from [APART]');
   recordset_temp.Open ;
   intCount:=recordset_temp.RecordCount ;
   Label24.Caption :=inttostr(intCount) + '个部门';
   for i:=1 to recordset_temp.RecordCount do
   begin
      listitem:=listview1.Items.Add ;
      listitem.Caption :=recordset_temp.Fields[1].AsString ;
      listitem.ImageIndex :=0;

      recordset_temp2.SQL.Clear ;
      recordset_temp2.SQL.Add('select count([PJ_ID]) from [PJ] where [PJ_APART_ID]='
        + inttostr(recordset_temp.Fields[0].asinteger)
        + 'and [PJ_OK]=0 and [PJ_DATE]>=#' + datetostr(sdate) + '# and [PJ_DATE]<=#' + datetostr(edate+1) +'#');
      recordset_temp2.Open ;
      if recordset_temp2.RecordCount <>0 then
      begin
         c1:=recordset_temp2.Fields[0].AsInteger ;
      end
      else
      begin
         c1:=0
      end;
      recordset_temp2.Close;

      recordset_temp2.SQL.Clear ;
      recordset_temp2.SQL.Add('select count([PJ_ID]) from [PJ] where [PJ_APART_ID]='
        + inttostr(recordset_temp.Fields[0].asinteger)
        + 'and [PJ_OK]=1 and [PJ_DATE]>=#' + datetostr(sdate) + '# and [PJ_DATE]<=#' + datetostr(edate+1) +'#');
      recordset_temp2.Open ;
      if recordset_temp2.RecordCount <>0 then
      begin
         c2:=recordset_temp2.Fields[0].AsInteger ;
      end
      else
      begin
         c2:=0
      end;
      recordset_temp2.Close;

      recordset_temp2.SQL.Clear ;
      recordset_temp2.SQL.Add('select count([PJ_ID]) from [PJ] where [PJ_APART_ID]='
        + inttostr(recordset_temp.Fields[0].asinteger)
        + 'and [PJ_OK]=2 and [PJ_DATE]>=#' + datetostr(sdate) + '# and [PJ_DATE]<=#' + datetostr(edate+1) +'#');
      recordset_temp2.Open ;
      if recordset_temp2.RecordCount <>0 then
      begin
         c3:=recordset_temp2.Fields[0].AsInteger ;
      end
      else
      begin
         c3:=0
      end;
      recordset_temp2.Close;



      listitem.SubItems.Add(inttostr(c1));
      listitem.SubItems.Add(inttostr(c2));
      listitem.SubItems.Add(inttostr(c3));
      listitem.SubItems.Add(inttostr(c1+ c3 + c2));

      new(p);
      p^ := recordset_temp.Fields[0].AsInteger ;
      listitem.Data :=p;
      recordset_temp.Next;
   end;
   recordset_temp.Close;
end;

procedure Tform_advice.BitBtn1Click(Sender: TObject);
var
   p:^integer;
begin
   if listview1.Selected=nil then
   begin
      exit;
   end;

   p:=listview1.Selected.Data;
   form_advice_inf.partid :=p^;
   form_advice_inf.partname :=listview1.Selected.Caption ;
   form_advice_inf.sdate :=sdate;
   form_advice_inf.edate :=edate;

   form_advice_inf.ShowModal ;
end;

end.

⌨️ 快捷键说明

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