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

📄 unxfind.pas

📁 设备巡检操作系统 本程序是专门为某电厂开发的设备巡检系统
💻 PAS
字号:
unit UnXfind;

interface

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

type
  TXfind_frm = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    CheckBox3: TCheckBox;
    Cbx_Dept: TComboBox;
    CheckBox2: TCheckBox;
    edt_name: TEdit;
    CheckBox4: TCheckBox;
    Cbx_eupet: TComboBox;
    CheckBox6: TCheckBox;
    Cbx_cp: TComboBox;
    CheckBox7: TCheckBox;
    Date_Djrq: TDateTimePicker;
    Cbx_No: TComboBox;
    CheckBox5: TCheckBox;
    Edt_ib: TEdit;
    Button3: TButton;
    Button4: TButton;
    Label2: TLabel;
    Label1: TLabel;
    Date_Djrq1: TDateTimePicker;
    Bevel1: TBevel;
    Panel4: TPanel;
    RB1: TRadioButton;
    Rb2: TRadioButton;
    edt_1: TEdit;
    Button1: TButton;
    Bevel2: TBevel;
    edt_2: TEdit;
    Button2: TButton;
    CheckBox9: TCheckBox;
    Cbx_Part: TComboBox;
    BitBtn2: TBitBtn;
    BitBtn1: TBitBtn;
    CheckBox8: TCheckBox;
    CheckBox1: TCheckBox;
    BitBtn3: TBitBtn;
    RB3: TRadioButton;
    Button5: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Cbx_NoEnter(Sender: TObject);
    procedure Cbx_cpEnter(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure BitBtn2Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure edt_1DblClick(Sender: TObject);
    procedure edt_2DblClick(Sender: TObject);
    procedure Cbx_eupetClick(Sender: TObject);
    procedure BitBtn3Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure Cbx_PartClick(Sender: TObject);
  private
    { Private declarations }
    function ControlFind():Boolean;
    procedure Findout(const strsql:string);
  public
    { Public declarations }
  end;

var
  Xfind_frm: TXfind_frm;

implementation

uses Undm, Math, UnFindoutPt, Undate;

{$R *.dfm}
var
  ls_eupetnno,Ls_NPartno:TStrings;
  Yssj:Boolean;
procedure TXfind_frm.FormCreate(Sender: TObject);
var
  adotmp:TADOQuery;
begin
  Left:=10;Top:=10;Height:=176;Width:=605; 
  Cbx_Dept.Clear;     Yssj:=False;
  adotmp:=TADOQuery.Create(self);
  try
  with adotmp do
  begin
    Connection:=DM.AdoConn;
    SQL.Text:='select * from T_dept order by deptno';
    Open;
    while not eof do
    begin
      Cbx_Dept.Items.Add(fieldbyname('deptno').AsString+'-'+fieldbyname('deptname').AsString);
      Next;
    end; Close;
    SQL.Text:='select * from T_eupet order by eupetno';
    Open;
    if not eof then begin
    ls_eupetnno:=TStringList.Create;
    Ls_NPartno:=TStringList.Create;
    end;
    while not eof do
    begin
      Cbx_eupet.Items.Add(fieldbyname('eupetno').AsString+'-'+fieldbyname('eupetname').AsString);
      ls_eupetnno.Add(fieldbyname('eupetnno').AsString);
      Next;
    end;

    SQL.Text:='select * from T_CHECKPT order by msrno';
    Open;
    while not eof do
    begin
      Cbx_cp.Items.Add(fieldbyname('msrno').AsString+'-'+fieldbyname('msrname').AsString);
      Next;
    end;
    Free;
  end;
  except
    adotmp.Free;
  end;
  edt_1.Text:=FormatDateTime('yyyy-mm-dd hh:mm:ss',now-1);
  edt_2.Text:=FormatDateTime('yyyy-mm-dd hh:mm:ss',now);
end;

procedure TXfind_frm.Cbx_NoEnter(Sender: TObject);
var
  adotmp:TADOQuery;
begin
  Cbx_No.Clear;
  adotmp:=TADOQuery.Create(self);
  try
  with adotmp do
  begin
    Connection:=DM.AdoConn;
    Close;
    if Cbx_Dept.Text<>'' then
      SQL.Text:='select * from T_employee where deptno='+quotedstr(copy(Cbx_Dept.Text,1,2))
    else
      SQL.Text:='select * from T_employee order by no';
    Open;
    while not eof do
    begin
      Cbx_no.Items.Add(fieldbyname('no').AsString+'-'+fieldbyname('username').AsString);
      Next;
    end;
    Free;
  end;
  except
    adotmp.Free;
  end;
end;

procedure TXfind_frm.Cbx_cpEnter(Sender: TObject);
var
  adotmp:TADOQuery;
begin
  Cbx_cp.Clear;
  adotmp:=TADOQuery.Create(self);
  try
  with adotmp do
  begin
    Connection:=DM.AdoConn;
    Close;
    if Cbx_eupet.ItemIndex<>-1 then
      SQL.Text:='select * from T_checkpt where eupetnno='+quotedstr(ls_eupetnno[Cbx_eupet.ItemIndex])
    else
      SQL.Text:='select * from T_checkpt';
    Open;
    while not eof do
    begin
      Cbx_cp.Items.Add(fieldbyname('msrno').AsString+'-'+fieldbyname('msrname').AsString);
      Next;
    end;
    Free;
  end;
  except
    adotmp.Free;
  end;
end;

procedure TXfind_frm.FormDestroy(Sender: TObject);
begin
  if Assigned(ls_eupetnno) then
    ls_eupetnno.Free;
  if Assigned(Ls_NPartno) then
    Ls_NPartno.Free;
end;

function TXfind_frm.ControlFind: Boolean;
begin
  Result:=True;
  if CheckBox3.Checked then
  begin
    If Cbx_Dept.Text='' then
    begin
      Result:=False;
      Application.MessageBox('请选择部门','提示',MB_OK);
      Cbx_Dept.SetFocus;
      Exit;
    end;
  end;

  if CheckBox4.Checked then
  begin
    If Cbx_eupet.Text='' then
    begin
      Result:=False;
      Application.MessageBox('请选择机组','提示',MB_OK);
      Cbx_eupet.SetFocus;
      Exit;
    end;
  end;
  if CheckBox9.Checked then
  begin
    If Cbx_eupet.Text='' then
    begin
      Result:=False;
      Application.MessageBox('请选择设备','提示',MB_OK);
      Cbx_Part.SetFocus;
      Exit;
    end;
  end;

  if CheckBox2.Checked then
  begin
    If Cbx_No.Text='' then
    begin
      Result:=False;
      Application.MessageBox('请选择人员编号','提示',MB_OK);
      Cbx_No.SetFocus;
      Exit;
    end;
  end;

  if CheckBox6.Checked then
  begin
    If Cbx_cp.Text='' then
    begin
      Result:=False;
      Application.MessageBox('请选择测点编号','提示',MB_OK);
      Cbx_cp.SetFocus;
      Exit;
    end;
  end;

{  if CheckBox1.Checked then
  begin
    If edt_name.Text='' then
    begin
      Result:=False;
      Application.MessageBox('请输入姓名','提示',MB_OK);
      edt_name.SetFocus;
      Exit;
    end;
  end;
 }
  if CheckBox5.Checked then
  begin
    If Edt_ib.Text='' then
    begin
      Result:=False;
      Application.MessageBox('请输入信息钮!','提示',MB_OK);
      Edt_ib.SetFocus;
      Exit;
    end;
  end;

end;

procedure TXfind_frm.Findout(const strsql: string);
begin
  with DM.AQ7 do
  begin
    if not Yssj then
      SQL.Text:=strsql
    else begin                             
      if Pos('where',strsql)<=0 then
        SQL.Text:=strsql + ' where ((msrvalue<dwv or msrvalue>uwv) or (msrvalue<-9999)) and (msrvalue<>-10002)'
      else
        SQL.Text:=strsql+' and (msrvalue<dwv or msrvalue>uwv)';
    end;
    Prepared:=True;
    Open;
    label1.Caption:=IntToStr(Recordset.RecordCount);
    Button4.Visible:=not eof;
    if not eof then begin
      if findout_frm=nil then
      findout_frm:=Tfindout_frm.Create(self);
      findout_frm.Show;
      Xfind_frm.Close;
    end
  end;
 // Panel1.Visible:=True;
 { if Panel2.Visible then
    Height:=176+186+80
  else
    Height:=176+80;   }
 // panel1.Align:=alClient;
  
end;

procedure TXfind_frm.BitBtn1Click(Sender: TObject);
const  Stand_date='yyyy-mm-dd hh24:mi:ss';
var
  strsql,sql,Find_curPlan:string;
  tmp_str:string;
  stmp,stmp1,stmp2,stmp3,stmp4:string;
begin
  If not ControlFind then Exit;
  sql:='';
  stmp1:='';stmp:='';stmp2:='';stmp3:='';
  if Cbx_Dept.Text<>'' then
    stmp:=copy(Cbx_Dept.Text,1,2);        //部门stmp
  if Cbx_eupet.ItemIndex<>-1 then          //机组stmp1
    stmp1:=ls_eupetnno[Cbx_eupet.ItemIndex];
  if Cbx_Part.ItemIndex<>-1 then          //设备stmp4
    stmp4:=Ls_NPartno[Cbx_Part.ItemIndex];
  if Cbx_No.Text<>'' then                 //人员stmp2
    stmp2:=copy(Cbx_No.Text,1,4);
  if Cbx_cp.Text<>'' then                 //测点tmp3
    stmp3:=copy(Cbx_cp.Text,1,pos('-',Cbx_cp.Text)-1);
  if Panel2.Visible then
  if (checkbox2.Checked) then begin
    sql:=' 人员编号='+quotedstr(stmp2);
  end;
  if Panel2.Visible then
  if (CheckBox3.Checked) then
  begin
    if sql='' then
      sql:='部门编号='+quotedstr(stmp)
    else
      sql:=sql+' and 部门编号='+quotedstr(stmp);
  end;
  if Panel2.Visible then
  if CheckBox4.Checked then
  begin
    if sql='' then
      sql:='eupetnno='+quotedstr(stmp1)
    else
      sql:=sql+' and eupetnno='+quotedstr(stmp1);
  end;
  if Panel2.Visible then
  if CheckBox9.Checked then
  begin
    if sql='' then
      sql:='npartno='+quotedstr(stmp4)
    else
      sql:=sql+' and npartno='+quotedstr(stmp4);
  end;
  if Panel2.Visible then
  if CheckBox6.Checked then
  begin
    if sql='' then
      sql:='msrno='+quotedstr(stmp3)
    else
      sql:=sql+' and msrno='+quotedstr(stmp3);
  end;
  {if CheckBox7.Checked then
  begin
    if sql='' then
      sql:='udate>='+quotedstr(datetostr(Date_Djrq.Date))+' and udate<='+ quotedstr(datetostr(Date_Djrq1.Date))
    else
      sql:=sql+' and udate>='+quotedstr(datetostr(Date_Djrq.Date))+' and udate<='+ quotedstr(datetostr(Date_Djrq1.Date));
  end; }



  IF not RB3.Checked THEN
  BEGIN
    if RB1.Checked then
       tmp_str:='udate'
     else
      tmp_str:='cdate';
    IF sql='' THEN
      sql:=tmp_str+'>=to_date(' +
        quotedstr(edt_1.text)+','+quotedstr('yyyy-mm-dd hh24:mi:ss') +')'
          +' and '+tmp_str+'<=to_date('+quotedstr(edt_2.text)+','+quotedstr(Stand_date) +')'
    else
      sql:=sql+' and '+tmp_str+'>=to_date(' +
        quotedstr(edt_1.text)+','+quotedstr('yyyy-mm-dd hh24:mi:ss') +')'
          +' and '+tmp_str+'<=to_date('+quotedstr(edt_2.text)+','+quotedstr('yyyy-mm-dd hh24:mi:ss') +')';
  END;
  if Panel2.Visible then
  if CheckBox5.Checked then
  begin
    if sql='' then
      sql:='ib='+quotedstr(Edt_ib.Text)
    else
      sql:=sql+' and ib='+quotedstr(Edt_ib.Text);
  end;
  Yssj:=(CheckBox1.Checked) and (Panel2.Visible);

  if CheckBox8.Checked  then
    Find_curPlan:='view_sbdjvalue_PerAddPlan'
  else
    Find_curPlan:='view_sbdjvalue_per';
  if sql='' then
    sql:='select * from '+Find_curPlan //view_sbdjvalue_Per'
  else
    sql:='select * from '+Find_curPlan+' where '+sql;
    edt_name.text:=sql;
  //Findout(sql);

 strsql:=sql;
  with DM.AQ7 do
  begin
    if not Yssj then
      SQL.Text:=strsql +' order by cdate desc,ib'
    else begin                             
      if Pos('where',strsql)<=0 then
        SQL.Text:=strsql + ' where ((msrvalue<dwv or msrvalue>uwv) or (msrvalue<-9999)) and (msrvalue<>-10002)'+' order by cdate desc,ib'
      else
        SQL.Text:=strsql+' and (msrvalue<dwv or msrvalue>uwv)'+' order by cdate desc,ib';
    end;
    Prepared:=True;
    Open;
    label1.Caption:=IntToStr(Recordset.RecordCount);
    Button4.Visible:=not eof;
    //if not eof then begin
    if findout_frm=nil then
      findout_frm:=Tfindout_frm.Create(nil);
      findout_frm.Show;
//      Xfind_frm.Close;
    //end
  end;
  Close;


end;

procedure TXfind_frm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action:=cafree;  Xfind_frm:=nil;
end;

procedure TXfind_frm.BitBtn2Click(Sender: TObject);
begin
  Close;
end;

procedure TXfind_frm.Button4Click(Sender: TObject);
begin
  findout_frm:=Tfindout_frm.Create(self);
  findout_frm.Show;
end;

procedure TXfind_frm.Button1Click(Sender: TObject);
var
  pt:TPoint;
begin
  if date_frm=nil then
    date_frm:=Tdate_frm.Create(Application);
    date_frm.x:=edt_1.Handle;
    date_frm.Show;
   // SetWindowPos(date_frm.Handle,HWND_TOPMOST,date_frm.Left,date_frm.Top,date_frm.Width,date_frm.Height,0) ;
    pt.X:= edt_1.Left+Panel4.Left;  pt.Y:=edt_1.Top+edt_1.Height+Panel4.Top;
    pt:=ClientToScreen(pt);
    date_frm.Left:=pt.X;
    date_frm.Top:=pt.Y;
end;

procedure TXfind_frm.Button2Click(Sender: TObject);
var
  pt:TPoint;
begin
  if date_frm=nil then
    date_frm:=Tdate_frm.Create(Application);
    date_frm.x:=edt_2.Handle;
    date_frm.Show;
   // SetWindowPos(date_frm.Handle,HWND_TOPMOST,date_frm.Left,date_frm.Top,date_frm.Width,date_frm.Height,0) ;
    pt.X:= edt_2.Left+Panel4.Left;  pt.Y:=edt_2.Top+edt_2.Height+Panel4.Top;
    pt:=ClientToScreen(pt);
    date_frm.Left:=pt.X;
    date_frm.Top:=pt.Y;
end;

procedure TXfind_frm.edt_1DblClick(Sender: TObject);
begin
  edt_1.Text:=FormatDateTime('yyyy-mm-dd hh:mm:ss',now);
end;

procedure TXfind_frm.edt_2DblClick(Sender: TObject);
begin
  edt_2.Text:=FormatDateTime('yyyy-mm-dd hh:mm:ss',now);
end;

procedure TXfind_frm.Cbx_eupetClick(Sender: TObject);
var
  adotmp:TADOQuery;
  stmp1:string;
begin

  Cbx_Part.Clear;
  Ls_NPartno.Clear;
  adotmp:=TADOQuery.Create(self);
    if Cbx_eupet.ItemIndex<>-1 then          //机组stmp1
  stmp1:=ls_eupetnno[Cbx_eupet.ItemIndex];
  try
  with adotmp do
  begin
    Connection:=DM.AdoConn;
    Close;
    SQL.Text:='select * from T_Part where eupetnno='+quotedstr(stmp1)+' order by Partno';
    Open;
    while not eof do
    begin
      Cbx_Part.Items.Add(fieldbyname('Partno').AsString+'-'+fieldbyname('partname').AsString);
      Ls_NPartno.Add(fieldbyname('npartno').AsString);
      Next;
    end;

    SQL.Text:='select * from T_CHECKPT where eupetnno='+quotedstr(stmp1)+' order by msrno';
    Open;
    while not eof do
    begin
      Cbx_cp.Items.Add(fieldbyname('msrno').AsString+'-'+fieldbyname('msrname').AsString);
      Next;
    end;

    Free;
  end;
  except
    adotmp.Free;
  end;
end;

procedure TXfind_frm.BitBtn3Click(Sender: TObject);
begin
  Panel2.Visible:=not Panel2.Visible;
  if Panel2.Visible then Height:=Height+186
  else Height:=Height-186;
end;

procedure TXfind_frm.Button5Click(Sender: TObject);
begin
  showmessage(IntToStr(Height)) ;
end;

procedure TXfind_frm.Cbx_PartClick(Sender: TObject);
var
  adotmp:TADOQuery;
  stmp4,stmp1:string;
begin
  adotmp:=TADOQuery.Create(self);
    if Cbx_eupet.ItemIndex<>-1 then          //机组stmp1
  stmp1:=ls_eupetnno[Cbx_eupet.ItemIndex] else stmp1:='';
    if Cbx_Part.ItemIndex<>-1 then          //设备stmp4
  stmp4:=Ls_NPartno[Cbx_Part.ItemIndex] else stmp4:='';
  try
  with adotmp do
  begin
    Connection:=DM.AdoConn;
    Close;
    SQL.Text:='select * from T_CHECKPT where eupetnno='+quotedstr(stmp1)
    +' and Npartno='+quotedstr(stmp4)+' order by msrno' ;
    Open;
    while not eof do
    begin
      Cbx_cp.Items.Add(fieldbyname('msrno').AsString+'-'+fieldbyname('msrname').AsString);
      Next;
    end;
    Free;
  end;
  except
    adotmp.Free;
  end;
end;

end.

⌨️ 快捷键说明

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