qx_unit.pas

来自「delphi进销存管理系统 很不错得进销存管理系统 有很多skin得」· PAS 代码 · 共 395 行

PAS
395
字号
unit Qx_Unit;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, Buttons, CheckLst, Registry, DB, ADODB;

type
  TQx_Form = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    Panel3: TPanel;
    Btn_Ok: TBitBtn;
    Btn_SelectAll: TBitBtn;
    Btn_Quit: TBitBtn;
    CheckListBox1: TCheckListBox;
    ADOQuery1: TADOQuery;
    ListBox1: TListBox;
    BitBtn1: TBitBtn;
    procedure FormShow(Sender: TObject);
    procedure Btn_SelectAllClick(Sender: TObject);
    procedure Btn_QuitClick(Sender: TObject);
    procedure Btn_OkClick(Sender: TObject);
    procedure ListBox1Click(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
  private
    { Private declarations }
    procedure ShowUser;
    procedure SaveQx;
    procedure LoadQx;
  public
    { Public declarations }
  end;

var
  Qx_Form: TQx_Form;

implementation
uses Login_Unit, Main_Unit;

{$R *.dfm}

{ TQx_Form }

procedure TQx_Form.ShowUser;
var
  i: integer;
  MyReg: TRegistry;
  TmpList: TStringList;
begin
  //ListBox1.Items.Clear;
  TmpList := TStringList.Create;
  Myreg := TRegistry.Create;
  MyReg.RootKey := HKEY_LOCAL_MACHINE;
  MyReg.OpenKey('Software\FLy\Login', True);
  MYReg.GetValueNames(TmpList);
  if G_UserName <> '管理员' then
  begin
    ListBox1.Items.Clear;
    ListBox1.Items.Add(G_UserName);
  end
  else
  begin
    ListBox1.Items.Clear;
    for i := 0 to TmpList.Count - 1 do
    begin
      ListBox1.Items.Add(TmpList.Strings[i]);
    end;
  end;
  ListBox1.Refresh;
  Myreg.CloseKey;
  Myreg.Free;
  TmpList.Free;
end;

procedure TQx_Form.FormShow(Sender: TObject);
begin
  ShowUser;
end;

procedure TQx_Form.Btn_SelectAllClick(Sender: TObject);
var
  i: integer;
begin
  for i := 0 to CheckListBox1.Count - 1 do
  begin
    CheckListBox1.Checked[i] := True;
  end;
end;

procedure TQx_Form.Btn_QuitClick(Sender: TObject);
begin
  Self.Close;
end;

procedure TQx_Form.SaveQx; //保存权限
var
  i: integer;
  TmpStr, TmpStr2: string;
  Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, Q10, Q11, Q12, Q13, Q14, Q15, Q16, Q17, Q18, Q19: string;
begin
  TmpStr := ExtractFilePath(Application.ExeName);
  Adoquery1.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=' + TmpStr + 'mdb\jxc.mdb;Persist Security Info=False';
  with Adoquery1 do
  begin
    Close;
    Sql.Clear;
    Sql.Add('select * from Qx');
    try
      Open;
    except
    end;
  end;
  if CheckListBox1.Checked[0] then
  begin
    Q1 := '1';
  end
  else
  begin
    Q1 := '0';
  end;
  if CheckListBox1.Checked[1] then
  begin
    Q2 := '1';
  end
  else
  begin
    Q2 := '0';
  end;
  if CheckListBox1.Checked[2] then
  begin
    Q3 := '1';
  end
  else
  begin
    Q3 := '0';
  end;
  if CheckListBox1.Checked[3] then
  begin
    Q4 := '1';
  end
  else
  begin
    Q4 := '0';
  end;
  if CheckListBox1.Checked[4] then
  begin
    Q5 := '1';
  end
  else
  begin
    Q5 := '0';
  end;
  if CheckListBox1.Checked[5] then
  begin
    Q6 := '1';
  end
  else
  begin
    Q6 := '0';
  end;
  if CheckListBox1.Checked[6] then
  begin
    Q7 := '1';
  end
  else
  begin
    Q7 := '0';
  end;
  if CheckListBox1.Checked[7] then
  begin
    Q8 := '1';
  end
  else
  begin
    Q8 := '0';
  end;
  if CheckListBox1.Checked[8] then
  begin
    Q9 := '1';
  end
  else
  begin
    Q9 := '0';
  end;
  if CheckListBox1.Checked[9] then
  begin
    Q10 := '1';
  end
  else
  begin
    Q10 := '0';
  end;
  if CheckListBox1.Checked[10] then
  begin
    Q11 := '1';
  end
  else
  begin
    Q11 := '0';
  end;
  if CheckListBox1.Checked[11] then
  begin
    Q12 := '1';
  end
  else
  begin
    Q12 := '0';
  end;
  if CheckListBox1.Checked[12] then
  begin
    Q13 := '1';
  end
  else
  begin
    Q13 := '0';
  end;
  if CheckListBox1.Checked[13] then
  begin
    Q14 := '1';
  end
  else
  begin
    Q14 := '0';
  end;
  if CheckListBox1.Checked[14] then
  begin
    Q15 := '1';
  end
  else
  begin
    Q15 := '0';
  end;
  if CheckListBox1.Checked[15] then
  begin
    Q16 := '1';
  end
  else
  begin
    Q16 := '0';
  end;
  if CheckListBox1.Checked[16] then
  begin
    Q17 := '1';
  end
  else
  begin
    Q17 := '0';
  end;
  if CheckListBox1.Checked[17] then
  begin
    Q18 := '1';
  end
  else
  begin
    Q18 := '0';
  end;
  if CheckListBox1.Checked[18] then
  begin
    Q19 := '1';
  end
  else
  begin
    Q19 := '0';
  end;
  for i := 0 to Listbox1.Count - 1 do
  begin
    if ListBox1.Selected[i] then
    begin
      TmpStr2 := Listbox1.Items.Strings[i];
      if Adoquery1.Locate('username', ListBox1.Items.Strings[i], []) then
      begin
        Adoquery1.Edit;
      end
      else
      begin
        Adoquery1.Append;
      end;
      Adoquery1.Fields.Fields[0].AsString := TmpStr2; //登录用户名
      Adoquery1.Fields.Fields[1].AsString := Q1;
      Adoquery1.Fields.Fields[2].AsString := Q2;
      Adoquery1.Fields.Fields[3].AsString := Q3;
      Adoquery1.Fields.Fields[4].AsString := Q4;
      Adoquery1.Fields.Fields[5].AsString := Q5;
      Adoquery1.Fields.Fields[6].AsString := Q6;
      Adoquery1.Fields.Fields[7].AsString := Q7;
      Adoquery1.Fields.Fields[8].AsString := Q8;
      Adoquery1.Fields.Fields[9].AsString := Q9;
      Adoquery1.Fields.Fields[10].AsString := Q10;
      Adoquery1.Fields.Fields[11].AsString := Q11;
      Adoquery1.Fields.Fields[12].AsString := Q12;
      Adoquery1.Fields.Fields[13].AsString := Q13;
      Adoquery1.Fields.Fields[14].AsString := Q14;
      Adoquery1.Fields.Fields[15].AsString := Q15;
      Adoquery1.Fields.Fields[16].AsString := Q16;
      Adoquery1.Fields.Fields[17].AsString := Q17;
      Adoquery1.Fields.Fields[18].AsString := Q18;
      Adoquery1.Fields.Fields[19].AsString := Q19;
      try
        Adoquery1.Post;  
      except
      end;   
    end;
  end; {endfor}
  Application.MessageBox('保存成功!', '提示', Mb_ok or Mb_Iconinformation);
end;

procedure TQx_Form.LoadQx;
var
  i, j: integer;
  TmpStr: string;
begin
  TmpStr := ExtractFilePath(Application.ExeName);
  Adoquery1.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=' + TmpStr + 'mdb\jxc.mdb;Persist Security Info=False';
  with Adoquery1 do
  begin
    Close;
    Sql.Clear;
    Sql.Add('select * from Qx');
    try
      Open;
    except
    end;
  end;
  for i := 0 to ListBox1.Count - 1 do
  begin
    if ListBox1.Selected[i] then
    begin
      if Adoquery1.Locate('username', ListBox1.Items.Strings[i], []) then
      begin
        for j := 0 to CheckListBox1.Count - 1 do
        begin
          if Adoquery1.Fields.Fields[j + 1].AsString = '1' then
          begin
            CheckListBox1.Checked[j] := True;
          end;
          if Adoquery1.Fields.Fields[j + 1].AsString = '0' then
          begin
            CheckListBox1.Checked[j] := False;
          end;
        end; {endfor j}
      end;
    end;
  end;
end;

procedure TQx_Form.Btn_OkClick(Sender: TObject);
begin
  SaveQx;   
end;

procedure TQx_Form.ListBox1Click(Sender: TObject);
var
  i: integer;
begin
  for i := 0 to CheckListBox1.Count - 1 do
  begin
    CheckListBox1.Checked[i] := False;
  end;
  LoadQx;
end;

procedure TQx_Form.BitBtn1Click(Sender: TObject);
var
  i: integer;
begin
  for i := 0 to CheckListBox1.Count - 1 do
  begin
    CheckListBox1.Checked[i] := False;
  end;
end;

end.



//此源码由程序太平洋收集整理发布,任何人都可自由转载,但需保留本站信息
//╭⌒╮┅~ ¤ 欢迎光临程序太平洋╭⌒╮
//╭⌒╭⌒╮╭⌒╮~╭⌒╮  ︶  ,︶︶
//,︶︶︶︶,''︶~~ ,''~︶︶  ,''
//╔ ╱◥███◣═╬╬╬╬╬╬╬╬╬╗
//╬ ︱田︱田 田 ︱          ╬
//╬       http://www.5ivb.net ╬
//╬  ╭○╮●                     ╬
//╬  /■\/■\                    ╬
//╬   <| ||    有希望,就有成功! ╬
//╬                 ╬
//╚╬╬╬╬╬╬╬╬╬╬╗  ╔╬╬╬╬╝
//
//说明:
//专业提供VB、.NET、Delphi、ASP、PB源码下载
//包括:程序源码,控件,商业源码,系统方案,开发工具,书籍教程,技术文档

⌨️ 快捷键说明

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