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

📄 unit3.~pas

📁 这是一个平时无事是编写的一个航空售票管理小系统,与大家分享, 有什么问题大家在这里留言,,大家一起讨论
💻 ~PAS
字号:
unit Unit3;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DB, ADODB, StdCtrls;

type
  TQuanXian = class(TForm)
    GroupBox1: TGroupBox;
    Label1: TLabel;
    ComboBox1: TComboBox;
    Label2: TLabel;
    ListBox1: TListBox;
    GroupBox2: TGroupBox;
    CheckBox1: TCheckBox;
    CheckBox2: TCheckBox;
    CheckBox3: TCheckBox;
    Label3: TLabel;
    Button1: TButton;
    Button2: TButton;
    ADOCommand1: TADOCommand;
    ADOQuery1: TADOQuery;
    ADOQuery2: TADOQuery;
    ADOQuery3: TADOQuery;
    CheckBox4: TCheckBox;
    CheckBox5: TCheckBox;
    procedure Button1Click(Sender: TObject);
    procedure ComboBox1Change(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  QuanXian: TQuanXian;

implementation

{$R *.dfm}

procedure TQuanXian.Button1Click(Sender: TObject);
var
 str,username,usernum,max,maxnum,maxnumber:string;
order:integer;
begin
  if combobox1.Text='' then
 showmessage('您还没有选择用户!')
 else


 begin
username:=combobox1.Text;
adoquery3.Close;
adoquery3.SQL.Text:='select 编号 from 操作员表 where 操作员姓名 ='''+username+'''';
adoquery3.Open;
usernum:=adoquery3.fieldbyname('编号').AsString;
adoquery3.Close;
//////////////////////////////////////////最大值////////////////////////////////
adoquery3.Close;
adoquery3.SQL.Clear;
adoquery3.SQL.Add('select max(权限编号) as maxnum from 权限清单');
adoquery3.Open;
maxnumber:=adoquery3.fieldbyname('maxnum').AsString;
adoquery3.Close;
//'''''''''''删除该用户的所有权限以备下一步修改''''''''''''''''''
adocommand1.CommandText:='delete from 权限清单 where 编号='''+usernum+'''';
adocommand1.Execute;


//'''''''''检查CHECKBOX1状态,判断是否给该用户  "添加航班信息"  的权限
if checkbox1.Checked then
begin
 order:=strtoint(maxnumber)+1;
 //order:=strtoint('select max(权限编号) as maxnum from 权限清单')+1;
 str:=inttostr(order);
 adocommand1.CommandText:='insert into 权限清单([权限编号],[编号],[操作员姓名],[操作员权限]) values('''+str+''','+''''+usernum+''','+''''+username+''','+''''+checkbox1.Caption+''''+')';
 adocommand1.Execute;
end;


//'''''''''检查CHECKBOX2
if checkbox2.Checked then
begin
 order:=strtoint(maxnumber)+2;
 str:=inttostr(order);
 adocommand1.CommandText:='insert into 权限清单([权限编号],[编号],[操作员姓名],[操作员权限]) values('''+str+''','+''''+usernum+''','+''''+username+''','+''''+checkbox2.Caption+''''+')';
 adocommand1.Execute;
end;


//'''''''''检查CHECKBOX3
if checkbox3.Checked then
begin
 order:=strtoint(maxnumber)+3;
 str:=inttostr(order);
 adocommand1.CommandText:='insert into 权限清单([权限编号],[编号],[操作员姓名],[操作员权限]) values('''+str+''','+''''+usernum+''','+''''+username+''','+''''+checkbox3.Caption+''''+')';
 adocommand1.Execute;
end;


//'''''''''检查CHECKBOX4
if checkbox4.Checked then
begin
 order:=strtoint(maxnumber)+4;
 str:=inttostr(order);
 adocommand1.CommandText:='insert into 权限清单([权限编号],[编号],[操作员姓名],[操作员权限]) values('''+str+''','+''''+usernum+''','+''''+username+''','+''''+checkbox4.Caption+''''+')';
 adocommand1.Execute;
end;


////////////检查CHECKBOX5
//'''''''''检查CHECKBOX4
if checkbox5.Checked then
begin
 order:=strtoint(maxnumber)+5;
 str:=inttostr(order);
 adocommand1.CommandText:='insert into 权限清单([权限编号],[编号],[操作员姓名],[操作员权限]) values('''+str+''','+''''+usernum+''','+''''+username+''','+''''+checkbox5.Caption+''''+')';
 adocommand1.Execute;
end;

showmessage('修改成功!');
end;

////////////////根据用户权限的更改同步更新CHECKBOX中的内容''''''''''''''''''''''''''''''''
////////////////判断更新后用户是否拥有CHECK1的权限''''''''''''''''''''''''''''''''''''''
adoquery2.Close;
adoquery2.SQL.Clear;
adoquery2.SQL.Add('select 编号 from 权限清单 where(编号=(select 编号 from 操作员表 where 操作员姓名='''+combobox1.Text+'''))and (操作员权限='''+checkbox1.Caption+''')');
adoquery2.Open;
if adoquery2.FieldByName('编号').AsString<>'' then
checkbox1.Checked:=true
else
checkbox1.Checked:=false;
////////////////判断更新后用户是否拥有CHECK2的权限''''''''''''''''''''''''''''''''''''''
adoquery2.Close;
adoquery2.SQL.Clear;
adoquery2.SQL.Add('select 编号 from 权限清单 where(编号=(select 编号 from 操作员表 where 操作员姓名='''+combobox1.Text+'''))and (操作员权限='''+checkbox2.Caption+''')');
adoquery2.Open;
if adoquery2.FieldByName('编号').AsString<>'' then
checkbox2.Checked:=true
else
checkbox2.Checked:=false;
////////////////判断更新后用户是否拥有CHECK3的权限''''''''''''''''''''''''''''''''''''''
adoquery2.Close;
adoquery2.SQL.Clear;
adoquery2.SQL.Add('select 编号 from 权限清单 where(编号=(select 编号 from 操作员表 where 操作员姓名='''+combobox1.Text+'''))and (操作员权限='''+checkbox3.Caption+''')');
adoquery2.Open;
if adoquery2.FieldByName('编号').AsString<>'' then
checkbox3.Checked:=true
else
checkbox3.Checked:=false;
////////////////判断更新后用户是否拥有CHECK4的权限''''''''''''''''''''''''''''''''''''''
adoquery2.Close;
adoquery2.SQL.Clear;
adoquery2.SQL.Add('select 编号 from 权限清单 where(编号=(select 编号 from 操作员表 where 操作员姓名='''+combobox1.Text+'''))and (操作员权限='''+checkbox4.Caption+''')');
adoquery2.Open;
if adoquery2.FieldByName('编号').AsString<>'' then
checkbox4.Checked:=true
else
checkbox4.Checked:=false;
////////////////判断更新后用户是否拥有CHECK5的权限''''''''''''''''''''''''''''''''''''''
adoquery2.Close;
adoquery2.SQL.Clear;
adoquery2.SQL.Add('select 编号 from 权限清单 where(编号=(select 编号 from 操作员表 where 操作员姓名='''+combobox1.Text+'''))and (操作员权限='''+checkbox5.Caption+''')');
adoquery2.Open;
if adoquery2.FieldByName('编号').AsString<>'' then
checkbox5.Checked:=true
else
checkbox5.Checked:=false;



////////////////////刷新更新后的列表框中的权限清单'''''''''''''''''''''''''''''''''''''''''''''
adoquery2.Close;
adoquery2.SQL.Clear;
adoquery2.SQL.Text:='select distinct 操作员权限 from 权限清单 where 编号=(select 编号 from 操作员表 where 操作员姓名='''+combobox1.Text+''''+')';
adoquery2.Open;
listbox1.Clear;
while not adoquery2.Eof do
begin
  listbox1.Items.Add(adoquery2.fieldbyname('操作员权限').AsString);
  adoquery2.Next;
end;
end;


//////////////////选择用户后显示相应用户的所有权限
procedure TQuanXian.ComboBox1Change(Sender: TObject);
var
 str,temp:string;
begin
adoquery2.Close;
adoquery2.SQL.clear;
adoquery2.SQL.Text:='select 操作员权限 from 权限清单 where 编号=(select 编号 from 操作员表 where 操作员姓名='''+combobox1.Text+''')';
adoquery2.open;
listbox1.clear;
while not adoquery2.eof do
begin
  temp:=adoquery2.fieldbyname('操作员权限').AsString;
  listbox1.Items.Add(temp);
  adoquery2.Next;
end;

//'''''''''''根据用户权限修改CHECKBOX中的内容''''''''''''''''''''''''''''''''''
//'''''''''''判断用户是否拥有  "添加航班信息"  权限'''''''''''''''''''''''''''''''''''''
adoquery2.Close;
adoquery2.SQL.Clear;
adoquery2.SQL.Add('select 权限编号 from 权限清单 where 操作员姓名='''+combobox1.Text+'''and 操作员权限='''+checkbox1.Caption+'''');
adoquery2.Open;
if adoquery2.FieldByName('权限编号').AsString<>''then
checkbox1.Checked:=true
//学习:在IF ,,,ELSE,,,,语句里面ELSE前面的分号不能要,,不然会报错误
else
checkbox1.Checked:=false;

//'''''''''''判断用户是否拥有  "更改航班信息"  权限'''''''''''''''''''''''''''''''''''''
adoquery2.Close;
adoquery2.SQL.Clear;
adoquery2.SQL.Add('select 权限编号 from 权限清单 where 操作员姓名='''+combobox1.Text+'''and 操作员权限='''+checkbox2.Caption+'''');adoquery2.Open;
if adoquery2.FieldByName('权限编号').AsString<>''then
checkbox2.Checked:=true
else
checkbox2.Checked:=false;


//'''''''''''根据用户权限修改CHECKBOX中的内容''''''''''''''''''''''''''''''''''
//'''''''''''判断用户是否拥有  "查询"  权限'''''''''''''''''''''''''''''''''''''

adoquery2.SQL.Clear;
adoquery2.SQL.Add('select 权限编号 from 权限清单 where 操作员姓名='''+combobox1.Text+'''and 操作员权限='''+checkbox3.Caption+'''');adoquery2.Open;
if adoquery2.FieldByName('权限编号').AsString<>''then
checkbox3.Checked:=true
else
checkbox3.Checked:=false;



//'''''''''''根据用户权限修改CHECKBOX中的内容''''''''''''''''''''''''''''''''''
//'''''''''''判断用户是否拥有   "更改用户权限"   权限'''''''''''''''''''''''''''''''''''''
adoquery2.Close;
adoquery2.SQL.Clear;
adoquery2.SQL.Add('select 权限编号 from 权限清单 where 操作员姓名='''+combobox1.Text+'''and 操作员权限='''+checkbox4.Caption+'''');adoquery2.Open;
if adoquery2.FieldByName('权限编号').AsString<>''then
checkbox4.Checked:=true
else
checkbox4.Checked:=false;


//'''''''''''根据用户权限修改CHECKBOX中的内容''''''''''''''''''''''''''''''''''
//'''''''''''判断用户是否拥有   "退票"   权限'''''''''''''''''''''''''''''''''''''
adoquery2.Close;
adoquery2.SQL.Clear;
adoquery2.SQL.Add('select 权限编号 from 权限清单 where 操作员姓名='''+combobox1.Text+'''and 操作员权限='''+checkbox5.Caption+'''');adoquery2.Open;
if adoquery2.FieldByName('权限编号').AsString<>''then
checkbox5.Checked:=true
else
checkbox5.Checked:=false;


//////////////////////////////////////////////////////////////

end;

procedure TQuanXian.FormShow(Sender: TObject);
begin
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Text:='select distinct 操作员姓名 from 操作员表 where 操作员姓名<>''admin''';
adoquery1.Open;
combobox1.Clear;
while not adoquery1.Eof do
begin
 combobox1.Items.Add(adoquery1.fieldbyname('操作员姓名').AsString);
 adoquery1.Next;
end
end;

end.

⌨️ 快捷键说明

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