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

📄 manmanage.~pas

📁 四川大学图书管理系统!sql+c++实现
💻 ~PAS
字号:
unit ManManage;

interface

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

type
  TManManageForm = class(TForm)
    Label1: TLabel;
    DBGrid1: TDBGrid;
    GroupBox1: TGroupBox;
    Label2: TLabel;
    Edit1: TEdit;
    Label3: TLabel;
    Edit2: TEdit;
    ComboBox1: TComboBox;
    Button1: TButton;
    Button2: TButton;
    Label4: TLabel;
    CheckBox1: TCheckBox;
    procedure Button1Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure CheckBox1Click(Sender: TObject);
    procedure ComboBox1Change(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  ManManageForm: TManManageForm;
  UseId, Types, Tables, List1, List2, UserTypes:String;
  UserId, Passwd :Integer;

implementation

uses Login,Main,Data;

{$R *.dfm}

procedure TManManageForm.Button1Click(Sender: TObject);
begin
  if Edit1.Text='' then
    begin
      Application.MessageBox('编号不能为空','错误信息',MB_OK+MB_ICONEXCLAMATION);
    end
  else
    begin
  with Data.DataModule.ManManage do
    begin
      if Main.Choose=1 then //增加
        begin
          if CheckBox1.Checked=False then
            begin
              Close;
              SQL.Clear;
              SQL.Add('insert into');
              SQL.Add(Tables);
              SQL.Add('(');
              SQL.Add(List1);
              SQL.Add(',');
              SQL.Add(List2);
              SQL.Add(',密码');
              SQL.Add(')');
              SQL.Add('VALUES(');
              SQL.Add(Edit1.Text);
              SQL.Add(',');
              SQL.Add(UserTypes);
              SQL.Add(',''8888''');
              SQL.Add(')');
              ExecSQL;
              Close;
              SQL.Clear;
              SQL.Add('select ');
              SQL.Add(List1);
              SQL.Add(',姓名,性别,出生年月,所在单位,联系地址,邮政编码,电话1,电话2,备注');
              SQL.Add('from');
              SQL.Add(Tables);
              SQL.Add('where');
              SQL.Add(List2);
              SQL.Add('=');
              SQL.Add(UserTypes);
              Open;
            end
          else //批量,没做
            begin
            end;
        end
      else if Main.Choose=2 then //修改
        begin
          if CheckBox1.Checked=False then
            begin
              Close;
              SQL.Clear;
              SQL.Add('update ');
              SQL.Add(Tables);
              SQL.Add('set ');
              SQL.Add(List2);
              SQL.Add('=');
              SQL.Add(UserTypes);
              SQL.Add('where ');
              SQL.Add(List1);
              SQL.Add('= ');
              SQL.Add(Edit1.Text);
              ExecSQL;
              Close;
              SQL.Clear;
              SQL.Add('select ');
              SQL.Add(List1);
              SQL.Add(',姓名,性别,出生年月,所在单位,联系地址,邮政编码,电话1,电话2,备注');
              SQL.Add('from');
              SQL.Add(Tables);
              SQL.Add('where');
              SQL.Add(List2);
              SQL.Add('=');
              SQL.Add(UserTypes);
              Open;
            end
          else //批量
            begin
            end;
        end
      else if Main.Choose=3 then //删除
        begin
          if CheckBox1.Checked=False then
            begin
              Close;
              SQL.Clear;
              SQL.Add('delete from');
              SQL.Add(Tables);
              SQL.Add('where');
              SQL.Add(List1);
              SQL.Add('=');
              SQL.Add(Edit1.Text);
              ExecSQL;
              Close;
              SQL.Clear;
              SQL.Add('select ');
              SQL.Add(List1);
              SQL.Add(',姓名,性别,出生年月,所在单位,联系地址,邮政编码,电话1,电话2,备注');
              SQL.Add('from');
              SQL.Add(Tables);
              SQL.Add('where');
              SQL.Add(List2);
              SQL.Add('=');
              SQL.Add(UserTypes);
              Open;
            end
          else //批量
            begin
            end;
        end;
      end
    end;
  //更新读者表,初始化已借数量为0
  if (ComboBox1.Text='学生') or (ComboBox1.Text='老师') or (ComboBox1.Text='其他') then
    begin
      with Data.DataModule.manInit do
        begin
          Close;
          SQL.Clear;
          SQL.Add('update 读者 set 已借数量=0 where 读者证号=''' + Edit1.Text + '''');
          ExecSQL;
        end
    end;
  Edit1.Clear;
end;

procedure TManManageForm.FormShow(Sender: TObject);
begin
  UseId := Login.UseId;
  Types := Login.Types;
  //根据权限设置类型的可选项
  with Data.DataModule.ManManage do
    begin
      if Main.Purview[1]<>0 then
        begin
          ComboBox1.Items.Add('超级管理员');
          ComboBox1.Items.Add('图书管理员(入库)');
          ComboBox1.Items.Add('图书管理员(删除)');
          ComboBox1.Items.Add('借阅管理员');
          ComboBox1.Items.Add('归还管理员');
          ComboBox1.Items.Add('人事管理员');
          ComboBox1.Items.Add('读者管理员');
        end;
      if Main.Purview[2]<>0 then
        begin
          ComboBox1.Items.Add('老师');
          ComboBox1.Items.Add('学生');
          ComboBox1.Items.Add('其他');
        end;
      //设置组合框显示第一个选项
      ComboBox1.ItemIndex := 0;
      //根据设置CheckBox的是否选择来确定是否是批量操作
      if CheckBox1.Checked=False then
        begin
          Edit2.Enabled := False;
          Edit2.Color := clScrollBar;
        end
    end
end;

procedure TManManageForm.CheckBox1Click(Sender: TObject);
begin
  if CheckBox1.Checked=False then
    begin
      Edit2.Enabled := False;
      Edit2.Color := clScrollBar;
    end
  else
    begin
      Edit2.Enabled := True;
      Edit2.Color := clWindow;
    end
end;

procedure TManManageForm.ComboBox1Change(Sender: TObject);
begin
  //确定要查询的表和列名、及管理类型
  if ComboBox1.Text='学生' then
    begin
      UserTypes := '6';
      Tables := '读者';
      List1 := '读者证号';
      List2 := '读者类型';
    end
  else if ComboBox1.Text='老师' then
    begin
      UserTypes := '8';
      Tables := '读者';
      List1 := '读者证号';
      List2 := '读者类型';
    end
  else if ComboBox1.Text='其他' then
    begin
      UserTypes := '4';
      Tables := '读者';
      List1 := '读者证号';
      List2 := '读者类型';
    end
  else if ComboBox1.Text='借阅管理员' then
    begin
      UserTypes := '16';
      Tables := '管理员';
      List1 := '工作编号';
      List2 := '管理员类型';
    end
  else if ComboBox1.Text='归还管理员' then
    begin
      UserTypes := '18';
      Tables := '管理员';
      List1 := '工作编号';
      List2 := '管理员类型';
    end
  else if ComboBox1.Text='人事管理员' then
    begin
      UserTypes := '20';
      Tables := '管理员';
      List1 := '工作编号';
      List2 := '管理员类型';
    end
  else if ComboBox1.Text='读者管理员' then
    begin
      UserTypes := '22';
      Tables := '管理员';
      List1 := '工作编号';
      List2 := '管理员类型';
    end
  else if ComboBox1.Text='图书管理员(入库)' then
    begin
      UserTypes := '12';
      Tables := '管理员';
      List1 := '工作编号';
      List2 := '管理员类型';
    end
  else if ComboBox1.Text='图书管理员(删除)' then
    begin
      UserTypes := '14';
      Tables := '管理员';
      List1 := '工作编号';
      List2 := '管理员类型';
    end
  else if ComboBox1.Text='超级管理员' then
    begin
      UserTypes := '99';
      Tables := '管理员';
      List1 := '工作编号';
      List2 := '管理员类型';
    end;
  //查询
  DBGrid1.DataSource := Data.DataModule.ManManageDS;
  with Data.DataModule.ManManage do
    begin
      Close;
      SQL.Clear;
      SQL.Add('select ');
      SQL.Add(List1);
      SQL.Add(',姓名,性别,出生年月,所在单位,联系地址,邮政编码,电话1,电话2,备注');
      SQL.Add('from');
      SQL.Add(Tables);
      SQL.Add('where');
      SQL.Add(List2);
      SQL.Add('=');
      SQL.Add(UserTypes);
      Open;
    end;
end;

procedure TManManageForm.Button2Click(Sender: TObject);
begin
  ComboBox1.Items.Clear;
  ManManageForm.Close;
end;

procedure TManManageForm.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  ComboBox1.Items.Clear;
end;

end.

⌨️ 快捷键说明

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