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

📄 u_czy.~pas

📁 学习资料
💻 ~PAS
字号:
unit U_czy;

interface

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

type
  Tfrm_gly = class(TForm)
    CoolBar1: TCoolBar;
    ToolBar1: TToolBar;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    SpeedButton3: TSpeedButton;
    ToolButton1: TToolButton;
    SpeedButton6: TSpeedButton;
    Panel1: TPanel;
    DataSource1: TDataSource;
    DBGrid1: TDBGrid;
    Panel2: TPanel;
    Label1: TLabel;
    Edit1: TEdit;
    Label2: TLabel;
    Edit2: TEdit;
    procedure SpeedButton6Click(Sender: TObject);
    procedure SpeedButton3Click(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure DBGrid1CellClick(Column: TColumn);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frm_gly: Tfrm_gly;

implementation

uses U_data;

{$R *.dfm}

procedure Tfrm_gly.SpeedButton6Click(Sender: TObject);
begin
close;
end;

procedure Tfrm_gly.SpeedButton3Click(Sender: TObject);
begin
if messagebox(self.Handle,'确定要删除吗?','提示',mb_yesno+mb_iconquestion)=idyes then
data1.ADOlogin.Delete;
edit1.Clear;
edit2.Clear;
end;

procedure Tfrm_gly.SpeedButton1Click(Sender: TObject);
begin
if edit1.Text='' then
application.MessageBox('请输入操作员名称','提示',64)
else
if edit2.Text='' then
   application.MessageBox('请输入操作员密码','提示',64)
else
begin
with data1.ADOlogin do
   begin
      close;
      sql.Clear;
      sql.Add('select * from 操作员信息表 where 操作员名称=:a');
      parameters.ParamByName('a').Value:=trim(edit1.Text);
      open;
   end;
if data1.ADOlogin.RecordCount>0 then
   begin
   application.MessageBox('操作员已经存在!','提示',64);
   edit1.Clear;
   edit2.Clear;
   edit1.SetFocus;
   end
else
try
with data1.ADOlogin do
begin
   close;
   sql.Clear;
   sql.Add('insert 操作员信息表 values (:a,:b)');
   parameters.ParamByName('a').Value:=trim(edit1.Text);
   parameters.ParamByName('b').Value:=trim(edit2.Text);
   execsql
end;
self.OnShow(sender);
application.MessageBox('添加成功','提示',64);
edit1.Clear;
edit2.Clear;
except
   application.MessageBox('添加失败','提示',64);
end;
end;
end;

procedure Tfrm_gly.SpeedButton2Click(Sender: TObject);
begin
with data1.ADOlogin do
   begin
   edit;
   FieldByName ('操作员名称').Value:=trim(edit1.Text);
   fieldbyname ('操作员密码').Value:=trim(edit2.Text);
   post;
   end;
   application.MessageBox('修改成功','提示',64);
   edit1.Clear;
   edit2.Clear;
end;

procedure Tfrm_gly.FormShow(Sender: TObject);
begin
with data1.ADOlogin do
   begin
      close;
      sql.Clear;
      sql.Add('select * from 操作员信息表');
      open;
   end;
   data1.ADOlogin.Active:=true;
   end;

procedure Tfrm_gly.DBGrid1CellClick(Column: TColumn);
begin
If DBGrid1.DataSource.DataSet<> Nil then
    if DBGrid1.DataSource.DataSet.RecordCount>0 then
      edit1.Text:=data1.ADOlogin.FieldByName('操作员名称').Value;
      edit2.Text:=data1.ADOlogin.FieldByName('操作员密码').Value;
end;

end.

⌨️ 快捷键说明

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