UnitUserList.pas
资源名称:东之源.rar [点击查看]
上传用户:zexin0769
上传日期:2010-01-19
资源大小:443k
文件大小:4k
源码类别:
百货/超市行业
开发平台:
Delphi
- unit UnitUserList;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, ExtCtrls, DB, ADODB, Grids, DBGrids, StdCtrls, Buttons, Mask,
- DBCtrls;
- type
- TFrameUserList = class(TFrame)
- Image1: TImage;
- DBGrid1: TDBGrid;
- DataSource1: TDataSource;
- GroupBox1: TGroupBox;
- Label1: TLabel;
- Label2: TLabel;
- Image2: TImage;
- Image3: TImage;
- Image4: TImage;
- DBEdit1: TDBEdit;
- DBEdit2: TDBEdit;
- Label3: TLabel;
- Image5: TImage;
- DBComboBox1: TDBComboBox;
- ADOQuery1: TADOQuery;
- Image6: TImage;
- procedure Image4Click(Sender: TObject);
- procedure Image5Click(Sender: TObject);
- procedure Image3Click(Sender: TObject);
- procedure Image2Click(Sender: TObject);
- procedure Image6Click(Sender: TObject);
- procedure GoEditState();
- procedure DBEdit1KeyPress(Sender: TObject; var Key: Char);
- procedure DBEdit2KeyPress(Sender: TObject; var Key: Char);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- implementation
- uses UnitLogin, UnitMain;
- {$R *.dfm}
- procedure TFrameUserList.Image4Click(Sender: TObject);
- begin
- {修改用户}
- GoEditState();
- ADOQuery1.Edit;
- end;
- procedure TFrameUserList.Image5Click(Sender: TObject);
- var
- i: integer;
- begin
- {提交数据}
- if (DBEdit1.Text<>'') and (DBEdit2.Text<>'') and (DBComboBox1.Text<>'') then
- ADOQuery1.Post
- else
- if messagebox(handle,'您的输入不正确(空值),放弃输入?','检查输入',mb_iconquestion+mb_yesno)=IDyes then
- ADOQuery1.Cancel
- else
- exit;
- Image2.Enabled := True;
- Image3.Enabled := True;
- Image4.Enabled := True;
- DBEdit1.Color := $00FFF0DC;
- DBEdit2.Color := $00FFF0DC;
- DBComboBox1.Color := $00FFF0DC;
- DBEdit1.Enabled := False;
- DBEdit2.Enabled := False;
- DBComboBox1.Enabled := False;
- Image5.Visible := False;
- Image6.Visible := False;
- end;
- procedure TFrameUserList.Image3Click(Sender: TObject);
- begin
- if ADOQuery1.FieldByName('user_name').AsString=UserName then
- begin
- messagebox(handle,'自己不能删除自己!','删除错误',mb_iconwarning+mb_ok);
- exit;
- end;
- if messagebox(handle,'删除的用户不能被恢复,是否删除?','确认删除',mb_iconquestion+mb_yesno)=IDyes then ADOQuery1.Delete;
- end;
- procedure TFrameUserList.Image2Click(Sender: TObject);
- var
- i: integer;
- begin
- {添加用户}
- GoEditState();
- ADOQuery1.Append;
- end;
- procedure TFrameUserList.Image6Click(Sender: TObject);
- begin
- {放弃提交}
- ADOQuery1.Cancel;
- Image2.Enabled := True;
- Image3.Enabled := True;
- Image4.Enabled := True;
- DBEdit1.Color := $00FFF0DC;
- DBEdit2.Color := $00FFF0DC;
- DBComboBox1.Color := $00FFF0DC;
- DBEdit1.Enabled := False;
- DBEdit2.Enabled := False;
- DBComboBox1.Enabled := False;
- Image5.Visible := False;
- Image6.Visible := False;
- end;
- procedure TFrameUserList.GoEditState();
- begin
- {进入编辑状态}
- Image2.Enabled := False;
- Image3.Enabled := False;
- Image4.Enabled := False;
- DBEdit1.Color := clWhite;
- DBEdit2.Color := clWhite;
- DBComboBox1.Color := clWhite;
- DBEdit1.Enabled := True;
- DBEdit2.Enabled := True;
- DBComboBox1.Enabled := True;
- Image5.Visible := True;
- Image6.Visible := True;
- DBEdit1.SetFocus;
- end;
- procedure TFrameUserList.DBEdit1KeyPress(Sender: TObject; var Key: Char);
- begin
- if Key=#13 then DBEdit2.SetFocus;
- end;
- procedure TFrameUserList.DBEdit2KeyPress(Sender: TObject; var Key: Char);
- begin
- if Key=#13 then DBComboBox1.SetFocus;
- end;
- end.