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

📄 userguide.pas

📁 彩票销售系统
💻 PAS
字号:
unit UserGuide;

interface

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

type
  TUserGuideFrm = class(TForm)
    Image1: TImage;
    Bevel1: TBevel;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    procedure Button3Click(Sender: TObject);
    Procedure FollowStep1(Sender: TObject);
    Procedure FollowStep2(Sender: TObject);
    Procedure Finish(Sender: TObject);
    Procedure BackStep2(Sender: TObject);
    Procedure BackStep3(Sender: TObject);
    Procedure OnKeyDown(Sender: TObject; var Key: Word;
                Shift: TShiftState);
    procedure FormActivate(Sender: TObject);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
    { Private declarations }
    PageNum: integer;    
    Procedure SetPage1;
    Procedure SetPage2;
    Procedure SetPage3;
  public
    { Public declarations }
    PassWord, ConfirmPassWord: string;
    ManagerName, ManagerFullName, ManagerInfor, ManagerLevel: string;
    Label1, Label2, Label3, Label4, Label5: TLabel;
    Edit1, Edit2, Edit3: TEdit;
    RadioButton1, RadioButton2, RadioButton3: TRadioButton;
  end;

  TDirection = (dForward, dBackward);
var
  UserGuideFrm: TUserGuideFrm;

implementation

uses UserAndPassWord;

{$R *.DFM}

//**********************************************************************

procedure TUserGuideFrm.Button3Click(Sender: TObject);
begin
  UserAndPassWord.UserAndPassWordFrm.ListView1.SetFocus;
  UserGuideFrm.Hide;
  //Close;
end;

procedure TUserGuideFrm.FollowStep1(Sender: TObject);
begin
  if Edit1.Text = '' then begin
     MessageDlg('用户名不能为空!', mtError, [mbOK], 0);
     Edit1.SetFocus;
     Exit;
  end;
  if not UserAndPassWord.UserAndPassWordFrm.ManagerTable.Active then UserAndPassWordFrm.ManagerTable.Open;
  try
    if UserAndPassWord.UserAndPassWordFrm.ManagerTable.Locate('FUserName', Edit1.Text, []) then begin
       MessageDlg('同名用户已经存在,你可以重新设置该用户的权限!', mtError, [mbOK], 0);
       Edit1.SetFocus;
       Exit;
    end;
  finally
    UserAndPassWord.UserAndPassWordFrm.ManagerTable.Open;
  end;  
  ManagerName := Edit1.Text;
  SetPage2;
end;

procedure TUserGuideFrm.FollowStep2(Sender: TObject);
begin
  if Edit1.Text = '' then begin
     MessageDlg('密码不能为空!',mtError,[mbOk],0);
     Edit1.SetFocus;
     Exit;
  end;
  if Edit1.Text <> Edit2.Text then begin
     MessageDlg('你键入的密码不匹配,请在两个文本框内键入该用户的密码。',mtError,[mbOk],0);
     Edit2.SetFocus;
     Exit;
  end;
  PassWord := Edit1.Text;
  ConfirmPassWord := Edit2.Text;
  SetPage3;
end;

Procedure TUserGuideFrm.BackStep2(Sender: TObject);
begin
  SetPage1;
  Edit1.Text := ManagerName;
end;

Procedure TUserGuideFrm.BackStep3(Sender: TObject);
begin
  SetPage2;
  Edit1.Text := PassWord;
  Edit2.Text := ConfirmPassWord;
end;

//用户设置进入数据库
procedure TUserGuideFrm.Finish(Sender: TObject);
var
  i: integer;
begin
  if RadioButton1.Checked then
    ManagerLevel := '普通用户'
  else
    if RadioButton2.Checked then
      ManagerLevel := '高级用户'
    else
      ManagerLevel := '超级用户';

  with UserAndPassWord.UserAndPassWordFrm.ManagerTable do
  begin
    try
      if not Active then Open;
      Append;
      FieldByName('FUserName').AsString := ManagerName;
      FieldByName('FUserPassWord').AsString := PassWord;
      FieldByName('FUserPower').AsString := ManagerLevel;
      Post;
    finally
      UserGuideFrm.Close;
    end;

  end;

  UserAndPassWord.UserAndPassWordFrm.ManagerInsertListView1;
  with UserAndPassWord.UserAndPassWordFrm do
  begin
    for i:=0 to ListView1.Items.Count-1 do
      if (ListView1.Items.Item[i].Caption = ManagerName)
           and (ListView1.Items.Item[i].SubItems[0] = ManagerLevel) then
       begin
         ListView1.SetFocus;
         ListView1.Selected := ListView1.Items.Item[i];
         OldItem := ListView1.Items.Item[i];
         GroupBox1.Caption := ManagerName +' 的密码';
         Label3.Caption := '要更改 '+ManagerName+' 的密码,请单击<设置密码>。';
         ListView1.SetFocus;
         BitBtn1.Enabled := True;
         Break;
       end;  
  end;

  UserGuideFrm.Close;
end;

procedure TUserGuideFrm.FormActivate(Sender: TObject);
begin
  Label1 := TLabel.Create(Self);
  Label1.Parent := UserGuideFrm;
  Label1.Font.Name := '宋体';
  Label1.Font.Size := 9;
  Label1.Visible := True;  

  Label2 := TLabel.Create(Self);
  Label2.Parent := UserGuideFrm;
  Label2.Font.Name := '宋体';
  Label2.Font.Size := 9;
  Label2.Visible := True;

  Label3 := TLabel.Create(Self);
  Label3.Parent := UserGuideFrm;
  Label3.Font.Name := '宋体';
  Label3.Font.Size := 9;
  Label3.Visible := True;

  Label4 := TLabel.Create(Self);
  Label4.Parent := UserGuideFrm;
  Label4.Font.Name := '宋体';
  Label4.Font.Size := 9;
  Label4.Visible := True;

  Label5 := TLabel.Create(Self);
  Label5.Parent := UserGuideFrm;
  Label5.Font.Name := '宋体';
  Label5.Font.Size := 9;
  Label5.Visible := True;

  Edit1 := TEdit.Create(Self);
  Edit1.Parent := UserGuideFrm;
  Edit1.Tag := 1;
  Edit1.Font.Name := '宋体';
  Edit1.OnKeyDown := OnKeyDown;
  Edit1.Visible := True;

  Edit2 := TEdit.Create(Self);
  Edit2.Parent := UserGuideFrm;
  Edit2.Tag := 2;
  Edit2.Font.Name := '宋体';
  Edit2.OnKeyDown := OnKeyDown;
  Edit2.Visible := True;

  Edit3 := TEdit.Create(Self);
  Edit3.Parent := UserGuideFrm;
  Edit3.Tag := 3;
  Edit3.Font.Name := '宋体';
  Edit3.OnKeyDown := OnKeyDown;
  Edit3.Visible := True;

  RadioButton1 := TRadioButton.Create(Self);
  RadioButton1.Parent := UserGuideFrm;
  RadioButton1.Tag := 1;
  RadioButton1.Checked := True;
  RadioButton1.Font.Name := '宋体';
  RadioButton1.Font.Size := 10;
  RadioButton1.Font.Style := [fsBold];
  RadioButton1.OnKeyDown := OnKeyDown;

  RadioButton2 := TRadioButton.Create(Self);
  RadioButton2.Parent := UserGuideFrm;
  RadioButton2.Tag := 2;
  RadioButton2.Checked := False;
  RadioButton2.Font.Name := '宋体';
  RadioButton2.Font.Size := 10;
  RadioButton2.Font.Style := [fsBold];
  RadioButton2.OnKeyDown := OnKeyDown;

  RadioButton3 := TRadioButton.Create(Self);
  RadioButton3.Parent := UserGuideFrm;
  RadioButton3.Tag := 3;
  RadioButton3.Checked := False;
  RadioButton3.Font.Name := '宋体';
  RadioButton3.Font.Size := 10;
  RadioButton3.Font.Style := [fsBold];
  RadioButton3.OnKeyDown := OnKeyDown;

  PassWord := '';
  ConfirmPassWord := '';
  ManagerName := '';
  ManagerFullName := '';
  ManagerInfor := '';
  ManagerLevel := '';

  SetPage1;
end;

procedure TUserGuideFrm.SetPage1;
begin

  Label1.Caption := '请输入新用户的基本信息。';
  Label1.Left  := 150;
  Label1.Top := 15;
  Label1.Height := 14;
  Label1.Width := 150;

  Label2.Caption := '用户名:';
  Label2.Left  := 150;
  Label2.Top := 45;
  Label2.Height := 14;
  Label2.Width := 50;

  Label3.Caption := '全名:';
  Label3.Left  := 150;
  Label3.Top := 75;
  Label3.Height := 14;
  Label3.Width := 100;

  Label4.Caption := '说明:';
  Label4.Left  := 150;
  Label4.Top := 105;
  Label4.Height := 14;
  Label4.Width := 100;

  Label5.Caption := '输入用户名后单击<下一步>继续。';
  Label5.Left  := 150;
  Label5.Top := 160;
  Label5.Height := 14;
  Label5.Width := 200;

  Edit1.PasswordChar := #0;
  Edit1.Left  := 200;
  Edit1.Top := 38;
  Edit1.Width := 210;
  Edit1.Height := 22;

  Edit2.PasswordChar := #0;  
  Edit2.Left  := 200;
  Edit2.Top := 70;
  Edit2.Height := 22;
  Edit2.Width := 210;

  Edit3.Left  := 200;
  Edit3.Top := 100;
  Edit3.Height := 22;
  Edit3.Width := 210;

  Button1.Enabled := False;
  RadioButton1.Visible := False;
  RadioButton2.Visible := False;
  RadioButton3.Visible := False;

  Button2.OnClick := FollowStep1;
  Edit1.SetFocus;

  Edit1.Text := ManagerName;
  Edit2.Text := ManagerFullName;
  Edit3.Text := ManagerInfor;

  PageNum := 1;
end;

procedure TUserGuideFrm.SetPage2;
begin
  Label1.Visible := True;
  Label2.Visible := True;
  Label3.Visible := True;
  Label5.Visible := True;
  Edit1.Visible  := True;
  Edit2.Visible  := True;

  Label1.Caption := '键入并确认该用户的密码。';

  Label2.Caption := '密码:';
  Label2.Left  := 150;
  Label2.Top := 45;
  Label2.Height := 14;
  Label2.Width := 50;

  Label3.Caption := '确认密码:';
  Label3.Left  := 150;
  Label3.Top := 75;
  Label3.Height := 14;
  Label3.Width := 100;

  Label5.Caption := '输入密码后单击<下一步>继续。';
  Label5.Left  := 150;
  Label5.Top := 160;
  Label5.Height := 14;
  Label5.Width := 200;

  Edit1.PasswordChar := '*';
  Edit1.Left  := 200;
  Edit1.Width :=200;
  Edit2.PasswordChar := '*';
  Edit2.Left  := 200;
  Edit2.Width :=200;

  Edit3.Visible := False;
  Label4.Visible := False;
  RadioButton1.Visible := False;
  RadioButton2.Visible := False;
  RadioButton3.Visible := False;

  Button1.Enabled := True;
  Button1.OnClick := BackStep2;
  Edit1.SetFocus;
  Button2.Caption := '下一步 >';
  Button2.OnClick := FollowStep2;

  Edit1.Text := PassWord;
  Edit2.Text := ConfirmPassWord;

  PageNum := 2;
end;

procedure TUserGuideFrm.SetPage3;
begin
  RadioButton1.Caption := '普通用户';
  RadioButton1.Left := 150;
  RadioButton1.Top := 45;
  RadioButton1.Width:=80;
  RadioButton1.Visible := True;

  RadioButton2.Caption := '高级用户';
  RadioButton2.Left := 150;
  RadioButton2.Top := 100;
  RadioButton2.Width:=80;
  RadioButton2.Visible := True;

  RadioButton3.Caption := '超级用户';
  RadioButton3.Left := 150;
  RadioButton3.Top := 155;
  RadioButton3.Visible := True;
  RadioButton3.Width:=80;
  edit1.Visible:=false;
  edit2.Visible:=false;
  edit3.Visible:=false;
  if ManagerLevel = '普通用户' then
     RadioButton1.Checked := True
  else if ManagerLevel = '高级用户' then
      RadioButton2.Checked := True
  else if ManagerLevel = '超级用户' then
      RadioButton3.Checked := True
  else
     RadioButton1.Checked := True;
      
  Label1.Caption := '想授予该用户何种级别的访问权限?';

  Label2.Left := 170;
  Label2.Top  := 65;
  Label2.Caption := '可以使用系统,但不能进行系统的'#13#10'设置与管理';

  Label3.Left := 170;
  Label3.Top  := 120;
  Label3.Caption := '可以使用除用户和密码管理的一切功能';

  Label4.Left := 170;
  Label4.Top  := 185;
  Label4.Caption := '可以使用系统的一切功能';

  Label1.Visible := True;
  Label2.Visible := True;
  Label3.Visible := True;
  Label4.Visible := True;
  RadioButton1.Visible := True;
  RadioButton2.Visible := True;
  RadioButton3.Visible := True;
  RadioButton3.Checked := True;
  Label5.Visible := False;
  Edit1.Visible := False;
  Edit2.Visible := False;
  Edit3.Visible := False;

  Button2.Caption :='完   成';
  Button1.OnClick := BackStep3;
  Button2.OnClick := Finish;

  RadioButton1.SetFocus;
  PageNum := 3;
end;

Procedure TUserGuideFrm.OnKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  case PageNum of
     1: begin
          if Sender is TEdit then begin
             with Sender as TEdit do begin
               case Tag of
                 1: begin
                      case Key of
                        VK_DOWN: Edit2.SetFocus;
                          VK_UP: Edit3.SetFocus;
                      VK_RETURN: Button2.Click;
                      end;
                    end;
                 2: begin
                      case Key of
                        VK_DOWN: Edit3.SetFocus;
                          VK_UP: Edit1.SetFocus;
                      VK_RETURN: Button2.Click;
                      end;
                    end;
                 3: begin
                      case Key of
                        VK_DOWN: Edit1.SetFocus;
                          VK_UP: Edit2.SetFocus;
                      VK_RETURN: Button2.Click;
                      end;
                    end;
               end;
             end;
          end;

        end;

     2: begin
          if Sender is TEdit then begin
             with Sender as TEdit do begin
               case Tag of
                 1: begin
                      case Key of
                        VK_DOWN: Edit2.SetFocus;
                          VK_UP: Edit2.SetFocus;
                      VK_RETURN: Edit2.SetFocus;
                      end;
                    end;
                 2: begin
                      case Key of
                        VK_DOWN: Edit1.SetFocus;
                          VK_UP: Edit1.SetFocus;
                      VK_RETURN: Button2.Click;
                      end;
                    end;
               end;
             end;
          end;

        end;

     3: begin
          if Sender is TRadioButton then begin
             with Sender as TRadioButton do begin
                  if Key = VK_RETURN then Button2.Click;
             end;
          end;

        end;

  end;
end;

procedure TUserGuideFrm.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Key = VK_ESCAPE then Button3.Click;
end;


end.

⌨️ 快捷键说明

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