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

📄 accountmain.pas

📁 档案信息管理系统
💻 PAS
字号:
//帐户管理窗体
unit AccountMain;

interface

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

type
  TAccountMainForm = class(TForm)
    Splitter1: TSplitter;
    GroupBox1: TGroupBox;
    DBGrid1: TDBGrid;
    GroupBox2: TGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    edAccountName: TEdit;
    edPassword: TEdit;
    gbOpRight: TComboBox;
    btAddAccount: TBitBtn;
    btAccountModify: TBitBtn;
    btAccountDel: TBitBtn;
    btAccountReset: TBitBtn;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure btAddAccountClick(Sender: TObject);
    procedure btAccountResetClick(Sender: TObject);
    procedure btAccountModifyClick(Sender: TObject);
    procedure btAccountDelClick(Sender: TObject);
    procedure DBGrid1CellClick(Column: TColumn);
  private
    { Private declarations }
public
     procedure SetControlEnable();
  end;
var
  AccountMainForm: TAccountMainForm;
implementation
uses ArchDataModule,ArchDataClass,MainForm;
{$R *.dfm}

procedure TAccountMainForm.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  AccountMainForm.Release;
  ArchMainForm.AccountMenu.Enabled :=true;
end;
//新建帐户
procedure TAccountMainForm.btAddAccountClick(Sender: TObject);
  var
  //管理帐户输入信息
    AccountInput: UserAccount;
  //管理帐户入库
    AccountManager: AccountDBManager;
  begin
      AccountInput :=UserAccount.Create;
      AccountManager :=AccountDBManager.Create;
      AccountInput.SetUserAccount;//将输入框中的信息保存到AccountInput类中
       if AccountInput.ValidCheck then //检查帐户的合法性
      begin
        if AccountManager.IsExist(AccountInput.UserName)<>0 then
           Application.MessageBox('帐户名重复,请重新输入','重复的帐户名',MB_OK)
        else
           if Application.MessageBox('确认要添加该记录吗','确认操作',MB_OKCANCEL)=1 then
               AccountManager.AddNewAccount(AccountInput)
      end
      else
        Application.MessageBox('上述信息不能为空,请重新输入','输入错误',MB_OK);
//清空帐户输入框
      AccountInput.ZeroAccountInput;
      edAccountName.SetFocus;
      AccountInput.Free;
      AccountManager.Free;
      MainDataModule.AccountTable.First;
  end;

//重置帐户输入框
procedure TAccountMainForm.btAccountResetClick(Sender: TObject);
  var
    AccountInput: UserAccount;
begin
    AccountInput :=UserAccount.Create;
    AccountInput.ZeroAccountInput;
    AccountInput.Free;
    SetControlEnable;
end;

//修改帐户信息
procedure TAccountMainForm.btAccountModifyClick(Sender: TObject);
  var
    AccountInput: UserAccount;
    AccountManager: AccountDBManager;
  begin
      AccountInput :=UserAccount.Create;
      AccountManager :=AccountDBManager.Create;
      AccountInput.SetUserAccount;
      if AccountInput.ValidCheck then
      begin
        if AccountManager.IsExist(AccountInput.UserName)=2 then
           Application.MessageBox('帐户名重复,请重新输入','重复的帐户名',MB_OK)
        else
           if Application.MessageBox('确认修改当前记录吗','确认操作',MB_OKCANCEL)=1 then
                  AccountManager.ModifyAccount(AccountInput)
      end
      else
      Application.MessageBox('上述信息不能为空,请重新输入','输入错误',MB_OK);
      AccountInput.ZeroAccountInput;
      edAccountName.SetFocus;
      AccountInput.Free;
      AccountManager.Free;
      SetControlEnable;
      MainDataModule.AccountTable.First;
  end;

//删除指定帐户
procedure TAccountMainForm.btAccountDelClick(Sender: TObject);
  var
    AccountManager: AccountDBManager;
    AccountInput : UserAccount;
begin
    AccountManager := AccountDBManager.Create;
    AccountInput :=UserAccount.Create;

    if Application.MessageBox('确认要删除当前记录吗','确认操作',MB_OKCANCEL)=1 then
        AccountManager.DeleteAccount;


    AccountInput.ZeroAccountInput;
    MainDataModule.AccountTable.First;

    edAccountName.SetFocus;

    AccountManager.Free;
    AccountInput.Free;
    SetControlEnable;
end;

//设置窗体中相关按钮的活动属性
procedure TAccountMainForm.SetControlEnable;
begin
    btAddAccount.Enabled :=true;
    btAccountModify.Enabled :=false;
    btAccountDel.Enabled :=false;
    btAccountReset.Enabled :=true;
end;

//将在记录列表中选中记录信息加载到输入框中
procedure TAccountMainForm.DBGrid1CellClick(Column: TColumn);
var
    AccountInput: UserAccount;
//    AccountManager :AccountDBManager;
  begin
    AccountInput :=UserAccount.Create;
//    AccountManager :=AccountDBManager.Create;

    if MainDataModule.AccountTable.RecordCount<>0 then
    begin
      btAddAccount.Enabled :=false;
      btAccountModify.Enabled :=true;
      btAccountDel.Enabled :=true;
      AccountInput.LoadAccountInput;//将记录信息加载到输入框中
    end;
    AccountInput.Free;
  end;

end.










⌨️ 快捷键说明

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