Unit12.pas
上传用户:szyozho
上传日期:2013-04-13
资源大小:3688k
文件大小:3k
- unit Unit12;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls, Buttons, DBCtrls, Grids, DBGrids, ExtCtrls, jpeg, Mask,
- DB, DBTables;
- type
- Tusermanage = class(TForm)
- Panel1: TPanel;
- BitBtn1: TBitBtn;
- Image1: TImage;
- Bevel1: TBevel;
- Label1: TLabel;
- Label3: TLabel;
- Label4: TLabel;
- DBEdit1: TDBEdit;
- DBEdit2: TDBEdit;
- DBComboBox1: TDBComboBox;
- Label2: TLabel;
- Label5: TLabel;
- Label6: TLabel;
- Label7: TLabel;
- DBNavigator1: TDBNavigator;
- DBGrid1: TDBGrid;
- Query1: TQuery;
- Query1ID: TStringField;
- Query1mi: TStringField;
- Query1qx: TStringField;
- BitBtn2: TBitBtn;
- BitBtn3: TBitBtn;
- DataSource1: TDataSource;
- // procedure BitBtn2Click(Sender: TObject);
- // procedure BitBtn3Click(Sender: TObject);
- procedure DBNavigator1Click(Sender: TObject; Button: TNavigateBtn);
- procedure FormCreate(Sender: TObject);
- procedure BitBtn1Click(Sender: TObject);
- procedure DBEdit1Change(Sender: TObject);
- procedure BitBtn2Click(Sender: TObject);
- procedure DBEdit1MouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- // procedure DBNavigator1Click(Sender: TObject; Button: TNavigateBtn);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- usermanage: Tusermanage;
- // havechange:boolean;
- implementation
- uses Unit4, Unit3;
- {$R *.dfm}
- procedure Tusermanage.DBNavigator1Click(Sender: TObject;
- Button: TNavigateBtn);
- begin
- case button of
- nbInsert :
- begin
- DBGrid1.Enabled:=false;
- end;
- end;
- case button of
- nbPost:
- begin
- DataModule4.Table_u.Close;
- DataModule4.Table_u.Open;
- end;
- end;
- case button of
- nbFirst,nbPrior,nbNext,nbLast,nbDelete,nbPost,nbCancel: DBGrid1.Enabled:=true;
- end;
- end;
- procedure Tusermanage.FormCreate(Sender: TObject);
- begin
- //havechange:=false;
- //Form3.Active:=false;
- end;
- procedure Tusermanage.BitBtn1Click(Sender: TObject);
- begin
- //form3.Active:=true;
- //usermanage.Close;
- end;
- procedure Tusermanage.DBEdit1Change(Sender: TObject);
- begin
- //havechange:=true;
- end;
- procedure Tusermanage.BitBtn2Click(Sender: TObject);
- begin
- if DBEdit1.Text='' then
- showmessage('用户名不能为空!')
- else if DBEdit2.Text='' then
- showmessage('密码不能为空!')
- else if DBComboBox1.Text='' then
- showmessage('请选择用户权限:管理员用a表示,一般用户用b表示!')
- else
- begin
- query1.Close;
- query1.SQL.Clear;
- query1.SQL.Add('select * from u where ID='''+DBEdit1.Text+'''') ;
- query1.Open;
- if query1.RecordCount<1 then
- begin
- DataModule4.Table_u.Post;
- DataModule4.Table_u.Close;
- DataModule4.Table_u.Open;
- showmessage('新用户添加成功!');
- end
- else
- begin
- showmessage('该用户已经存在!');
- DataModule4.Table_u.Close;
- DataModule4.Table_u.Open;
- end;
- end;
- end;
- procedure Tusermanage.DBEdit1MouseDown(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- //DBEdit1.DataSource.Enabled:=false;
- // DBEdit2.DataSource.Enabled:=false;
- //DBComboBox1.DataSource.Enabled:=false;
- end;
- end.