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

📄 unit2.pas

📁 program kehuji uses Forms, Unit1 in ..zxcUnit1.pas {Form1}, Unit2 in ..zxcUnit2.pas {Form2
💻 PAS
📖 第 1 页 / 共 3 页
字号:
unit Unit2;

interface

uses
  DB, ADODB, Grids, DBGrids,  StdCtrls, Menus, Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs,inifiles, ComCtrls,unit3, ExtCtrls,unit4;

type
  TForm2 = class(TForm)
    Button1: TButton;
    Button3: TButton;
    MainMenu1: TMainMenu;
    N1: TMenuItem;
    GroupBox1: TGroupBox;
    GroupBox2: TGroupBox;
    GroupBox3: TGroupBox;
    DBGrid1: TDBGrid;
    DBGrid2: TDBGrid;
    DBGrid3: TDBGrid;
    DataSource1: TDataSource;
    DataSource2: TDataSource;
    DataSource3: TDataSource;
    ADOQuery1: TADOQuery;
    ADOQuery2: TADOQuery;
    ADOQuery3: TADOQuery;
    GroupBox4: TGroupBox;
    StaticText1: TStaticText;
    StaticText2: TStaticText;
    StaticText3: TStaticText;
    StaticText4: TStaticText;
    DateTimePicker1: TDateTimePicker;
    DateTimePicker2: TDateTimePicker;
    StaticText5: TStaticText;
    ComboBox2: TComboBox;
    ComboBox3: TComboBox;
    ADOTable1: TADOTable;
    CheckBox1: TCheckBox;
    CheckBox2: TCheckBox;
    ComboBox1: TComboBox;
    CheckBox3: TCheckBox;
    CheckBox4: TCheckBox;
    CheckBox5: TCheckBox;
    StaticText12: TStaticText;
    StaticText13: TStaticText;
    StaticText14: TStaticText;
    StaticText15: TStaticText;
    StaticText16: TStaticText;
    StaticText17: TStaticText;
    Timer1: TTimer;
    ADOQuery4: TADOQuery;
    StaticText6: TStaticText;
    StaticText7: TStaticText;
    StaticText8: TStaticText;
    StaticText9: TStaticText;
    StaticText10: TStaticText;
    StaticText11: TStaticText;
    Label1: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure ComboBox2Change(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure CheckBox1Click(Sender: TObject);
    procedure N1Click(Sender: TObject);
    procedure CheckBox5Click(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;
  jian:boolean =false;

implementation

{$R *.dfm}

uses  unit1;

procedure TForm2.FormCreate(Sender: TObject);
var
strsql:string;
count :integer;
o:integer;
p:integer;
temp:string;
tag:boolean;
i:integer;

begin
label1.Color:=clwhite;
label1.Width:=45;
label1.Height:=45;

adoquery1.Connection:=g_Connection;
adoquery2.Connection:=g_Connection;
adoquery3.Connection:=g_Connection;
adoquery4.Connection:=g_Connection;
adotable1.Connection:=g_Connection;


adotable1.TableName:='info';
{
adoquery1.TableName:='shui';
adoquery2.TableName:='dian';
adotable3.TableName:='mei';    }
strsql:='select 户主编号,楼栋,户号,度数,采集时间 from shui,info where shui.户主编号=info.编号';
{
dbgrid1.Columns[0]:='户主编号';
dbgrid1.Columns[1]:='楼栋';
dbgrid1.Columns[2]:='户号';
dbgrid1.Columns[3]:='采集日期';
dbgrid1.Columns[4]:='度数';  }
adotable1.Active:=true ;



adoquery1.SQL.Add(strsql);

adoquery1.Active:=true;
strsql:='select 户主编号,楼栋,户号,度数,采集时间 from dian,info where dian.户主编号=info.编号';
adoquery2.SQL.Clear;
adoquery2.SQL.Add(strsql);
adoquery2.Active:=true;
strsql:='select 户主编号,楼栋,户号,度数,采集时间 from mei,info where mei.户主编号=info.编号';
adoquery3.SQL.Clear;
adoquery3.SQL.Add(strsql);
adoquery3.Active:=true;
{
edit1.text:='';
edit2.Text:='';
edit3.Text:='';
 }
  combobox3.Clear;

  count:=adotable1.RecordCount;
  tag:=true;
  for i:=1 to count-1 do
  begin
    temp:=adotable1.FieldByName('编号').AsString;
    p:=combobox1.ItemIndex;
    for o:=-1 to p do
    begin
      combobox1.ItemIndex:=o;
      if temp = combobox1.Text
      then
      tag:= false;
    end;
    combobox1.ItemIndex:=p;
    if tag=true
    then
    begin
      combobox1.Items.Add(temp);
      combobox1.ItemIndex:=combobox1.ItemIndex+1;
    end;
    adotable1.FindNext;
    tag:=true;
  end;
  temp:=adotable1.FieldByName('编号').AsString;
  p:=combobox1.ItemIndex;
  for o:=-1 to p do
  begin
    combobox1.ItemIndex:=o;
    if temp = combobox1.Text
    then
    tag:= false;
  end;
  combobox1.ItemIndex:=p;
  if tag=true
  then
  combobox1.Items.Add(temp);
  combobox1.ItemIndex:=0;
  adotable1.FindFirst;

  {combobox1.ItemIndex:=0;
  combobox1.Text:=combobox1.Items.GetText;     }


  count:=adotable1.RecordCount;
  tag:=true;
  for i:=1 to count-1 do
  begin
    temp:=adotable1.FieldByName('楼栋').AsString;
    p:=combobox2.ItemIndex;
    for o:=-1 to p do
    begin
      combobox2.ItemIndex:=o;
      if temp = combobox2.Text
      then
      tag:= false;
    end;
    combobox2.ItemIndex:=p;
    if tag=true
    then
    begin
      combobox2.Items.Add(temp);
      combobox2.ItemIndex:=combobox2.ItemIndex+1;
    end;
    adotable1.FindNext;
    tag:=true;
  end;
  temp:=adotable1.FieldByName('楼栋').AsString;
  p:=combobox2.ItemIndex;
  for o:=-1 to p do
  begin
    combobox2.ItemIndex:=o;
    if temp = combobox2.Text
    then
    tag:= false;
  end;
  combobox2.ItemIndex:=p;
  if tag=true
  then
  combobox2.Items.Add(temp);
  combobox2.ItemIndex:=0;
  adotable1.FindFirst;









end;

procedure TForm2.ComboBox2Change(Sender: TObject);
var
p:integer;
i:integer;
temp:string;

begin
  p:=1;
  combobox3.Clear;
  temp:=combobox2.Text;
  temp:=trim(temp);

  if temp='1'
  then
  begin
  p:=3;
  end;

  if temp='2'
  then
  begin
  p:=4;
  end;
  if temp='3'

  then
  begin

  p:=5;


  end;

  for i:=-1 to p-2  do

  begin

  combobox3.ItemIndex:=i;
  combobox3.Items.Add(inttostr(i+2));

  end;




{ count:=adotable1.RecordCount;
  tag:=true;
  for i:=1 to count-1 do
  begin
    temp:=adotable1.FieldByName('户号').AsString;
    p:=combobox3.ItemIndex;
    for o:=-1 to p do
    begin
      combobox3.ItemIndex:=o;
      if temp = combobox3.Text
      then
      tag:= false;
    end;
    combobox3.ItemIndex:=p;
    if tag=true
    then
    begin
      combobox3.Items.Add(temp);
      combobox3.ItemIndex:=combobox3.ItemIndex+1;
    end;
    adotable1.FindNext;
    tag:=true;
  end;
  temp:=adotable1.FieldByName('户号').AsString;
  p:=combobox3.ItemIndex;
  for o:=-1 to p do
  begin
    combobox3.ItemIndex:=o;
    if temp = combobox3.Text
    then
    tag:= false;
  end;
  combobox3.ItemIndex:=p;
  if tag=true
  then
  combobox3.Items.Add(temp);
  combobox3.ItemIndex:=-1;
  adotable1.FindFirst;   }

end;

procedure TForm2.Button1Click(Sender: TObject);
var
time1:string;
time2:string;
temp1:string;
temp2:string;
temp3:string;
temp4:string;
nowtime:string;
timea:Tdatetime;
i:integer;
str:string;
str1:string;

strtemp:string;
start:integer;
final:integer;



 total:integer;
  // i:integer;
   count:integer;
   a:variant;


begin


 adoquery1.Close;
 adoquery1.Filter:='';
 adoquery1.Filtered:=false;
 adoquery1.Open;

 adoquery2.Close;
 adoquery2.Filter:='';
 adoquery2.Filtered:=false;
 adoquery2.Open;

 adoquery3.Close;
 adoquery3.Filter:='';
 adoquery3.Filtered:=false;
 adoquery3.Open;








 timea:=date();

  temp1:=datetimetostr(datetimepicker1.DateTime);
  temp2:=datetimetostr(datetimepicker2.DateTime);
  nowtime:=datetimetostr(timea);

  time1:='';
  time2:='';
  temp3:='';
  temp4:='';

  str:='';

  for i:=1 to 10
  do
  begin
  time1:=time1+temp1[i];
  time2:=time2+temp2[i];
  temp3:=temp3+nowtime[i];
  temp4:=temp4+nowtime[i]


  end;
  time1:=time1+' 0:00:00';
  time2:=time2+' 23:59:59';
  temp3:=temp3+' 0:00:00';
  temp4:=temp4+' 23:59:59';



  if checkbox1.Checked=true
  then
  begin
  str:=str+'1';
  end
  else
  str:=str+'0';

  if checkbox2.Checked=true
  then
  begin
  str:=str+'1';
  end
  else
  str:=str+'0';

   if checkbox3.Checked=true
  then
  begin
  str:=str+'1';
  end
  else
  str:=str+'0';

   if checkbox4.Checked=true
  then
  begin
  str:=str+'1';
  end
  else
  str:=str+'0';



  if str='1000'
  then
  begin
  adoquery1.Filter:='户主编号='''+combobox1.Text+'''';
  adoquery2.Filter:='户主编号='''+combobox1.Text+'''';
  adoquery3.Filter:='户主编号='''+combobox1.Text+'''';
  end;


  if str='1001'
  then
  begin

⌨️ 快捷键说明

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