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

📄 rsgl1.pas

📁 数据库编程 人事档案管理
💻 PAS
字号:
unit rsgl1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, DBCtrls, Mask, Grids, DBGrids, DB, DBTables;

type
  TForm2 = class(TForm)
    Label1: TLabel;
    Panel1: TPanel;
    Button8: TButton;
    Rg: TRadioGroup;
    Edit1: TEdit;
    DBGrid1: TDBGrid;
    Query1: TQuery;
    DataSource1: TDataSource;
    Button1: TButton;
    procedure Button8Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation
uses dm;
{$R *.dfm}

procedure TForm2.Button8Click(Sender: TObject);
var
temp:string;
mysql:string;
begin
case rg.ItemIndex of
0:begin
   if length(trim(edit1.Text ))=0 then
   begin
   messagedlg('没有输入人员编号,重新输入',mterror,[mbok],0);
   edit1.SetFocus ;
   exit;
   end;
   with query1 do
   begin
   close;
   sql.Clear ;
   sql.Add('select * from ''basicinfo''');
   sql.Add('where id=:id');
   parambyname('id').AsString :=trim(edit1.Text );
   open;
   if recordcount>0 then
   dbgrid1.Enabled :=true
   else
   begin
   messagedlg('所要查找的人员并不存在,请您重新核对',mtinformation,[mbok],0);
   dbgrid1.Enabled :=false;
   end;
   end;
   end;

1:begin
   if length(trim(edit1.Text ))=0 then
   begin
   messagedlg('没有输入人员姓名,重新输入',mterror,[mbok],0);
   edit1.SetFocus ;
   exit;
   end;
   temp:='%'+trim(edit1.Text )+'%';
   mysql:=format('select * from ''basicinfo'' where name like ''%s''',[temp]);
   with query1 do
   begin
   close;
   sql.Clear ;
   sql.Text :=mysql;
   open;
   if recordcount>0 then
   dbgrid1.Enabled :=true
   else
   begin
   messagedlg('所要查找的人员并不存在,请您重新核对',mtinformation,[mbok],0);
   dbgrid1.Enabled :=false;
   end;
   end;
   end;

2:begin
 if length(trim(edit1.Text ))=0 then
   begin
   messagedlg('没有输入人员性别,重新输入',mterror,[mbok],0);
   edit1.SetFocus ;
   exit;
   end;
   with query1 do
   begin
   close;
   sql.Clear ;
   sql.Add('select * from ''basicinfo''');
   sql.Add('where sex=:temp');
   if edit1.text='男' then temp:='1' else temp:='2';
   parambyname('temp').AsString :=temp;
   open;
   if recordcount>0 then
   dbgrid1.Enabled :=true
   else
   begin
   messagedlg('所要查找的人员并不存在,请您重新核对',mtinformation,[mbok],0);
   dbgrid1.Enabled :=false;
   end;
   end;
   end;
   end;
end;

end.

⌨️ 快捷键说明

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