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

📄 unprtmsrval.pas

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

interface

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

type
  TPrt_MsrVal_Frm = class(TForm)
    Panel2: TPanel;
    Bevel1: TBevel;
    CheckBox3: TCheckBox;
    Cbx_Dept: TComboBox;
    CheckBox2: TCheckBox;
    CheckBox1: TCheckBox;
    edt_name: TEdit;
    CheckBox4: TCheckBox;
    Cbx_eupet: TComboBox;
    CheckBox7: TCheckBox;
    Date_Djrq: TDateTimePicker;
    Cbx_No: TComboBox;
    CheckBox5: TCheckBox;
    Edt_ib: TEdit;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    Date_Djrq1: TDateTimePicker;
    Panel3: TPanel;
    MonthCalendar1: TMonthCalendar;
    DateTimePicker1: TDateTimePicker;
    Button2: TButton;
    Button1: TButton;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure BitBtn2Click(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Cbx_NoEnter(Sender: TObject);
  private
    { Private declarations }
    function ControlFind():Boolean;
  public
    { Public declarations }
  end;

var
  Prt_MsrVal_Frm: TPrt_MsrVal_Frm;

implementation

uses Undm, ADODB, DB, StdConvs;

{$R *.dfm}
var
  ls_eupetnno:TStringList;
  Yssj:Boolean;
procedure TPrt_MsrVal_Frm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action:=caFree;
  Prt_MsrVal_Frm:=nil;
end;

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

procedure TPrt_MsrVal_Frm.BitBtn1Click(Sender: TObject);
var
  sql,Find_curPlan:string;
  stmp,stmp1,stmp2,stmp3: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_No.Text<>'' then                 //人员stmp2
    stmp2:=copy(Cbx_No.Text,1,4);
  if checkbox2.Checked then
    sql:=' no='+quotedstr(stmp2);

  if CheckBox3.Checked then
  begin
    if sql='' then
      sql:='deptno='+quotedstr(stmp)
    else
      sql:=sql+' and deptno='+quotedstr(stmp);
  end;
  if CheckBox4.Checked then
  begin
    if sql='' then
      sql:='eupetnno='+quotedstr(stmp1)
    else
      sql:=sql+' and eupetnno='+quotedstr(stmp1);
  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;

  Yssj:=CheckBox1.Checked;
  if Yssj then
  begin
      if sql='' then
        sql:=sql + ' (msrvalue<dwv or msrvalue>uwv)'
      else
        sql:=sql+'and (msrvalue<dwv or msrvalue>uwv)';
  end;
  //if CheckBox8.Checked then
  //  Find_curPlan:='view_sbdjvalue_PerAddPlan'
  //else
    Find_curPlan:='view_Newsbdjvalue_per';
  if sql='' then
    sql:='select * from '+Find_curPlan //view_sbdjvalue_Per'
  else
    sql:='select * from '+Find_curPlan+' where '+sql;
    DM.AQ20.SQL.Text:=SQL;
    DM.AQ20.Prepared:=True;
    DM.AQ20.Open;
    DM.RvP.ProjectFile:='DJREP.rav';
    DM.RvP.SelectReport('MsrnoValue',True);
    DM.RvP.Execute;
end;

function TPrt_MsrVal_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 CheckBox2.Checked then
  begin
    If Cbx_No.Text='' then
    begin
      Result:=False;
      Application.MessageBox('请选择人员编号','提示',MB_OK);
      Cbx_No.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 TPrt_MsrVal_Frm.FormCreate(Sender: TObject);
var
  adotmp:TADOQuery;
begin
  Cbx_Dept.Clear;    height:=299;  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 ls_eupetnno:=TStringList.Create;
    while not eof do
    begin
      Cbx_eupet.Items.Add(fieldbyname('eupetno').AsString+'-'+fieldbyname('eupetname').AsString);
      ls_eupetnno.Add(fieldbyname('eupetnno').AsString);
      Next;
    end;
    Free;
  end;
  except
    adotmp.Free;
  end;
  Date_Djrq.Date:=date-1;
  Date_Djrq1.Date:=Date;
end;

procedure TPrt_MsrVal_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;

end.

⌨️ 快捷键说明

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