unit Main;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, RzPanel, RzButton, ExtCtrls, RzStatus, Menus, ImgList, StdActns,
  ActnList, RzCommon, StdCtrls, shellapi;

type
  TMainFrm = class(TForm)
    RzStatusBar1: TRzStatusBar;
    RzToolbar1: TRzToolbar;
    RzToolButton3: TRzToolButton;
    RzToolButton4: TRzToolButton;
    RzToolButton5: TRzToolButton;
    RzToolButton6: TRzToolButton;
    RzStatusPane1: TRzStatusPane;
    RzStatusPane2: TRzStatusPane;
    RzStatusPane3: TRzStatusPane;
    RzStatusPane4: TRzStatusPane;
    RzStatusPane5: TRzStatusPane;
    MainMenu1: TMainMenu;
    RzMenuController1: TRzMenuController;
    ActionList2: TActionList;
    actCascade: TWindowCascade;
    actTileHorizontal: TWindowTileHorizontal;
    actTileVertical: TWindowTileVertical;
    actMinimizeAll: TWindowMinimizeAll;
    ActionList1: TActionList;
    SetUser: TAction;
    ChangePassword: TAction;
    ExitSystem: TAction;
    ImageIn: TAction;
    InDate: TAction;
    SeekFk: TAction;
    Seektj: TAction;
    SeekCx: TAction;
    ImageList1: TImageList;
    N1: TMenuItem;
    N2: TMenuItem;
    N3: TMenuItem;
    N4: TMenuItem;
    N5: TMenuItem;
    btnSetUser: TRzToolButton;
    RzToolButton7: TRzToolButton;
    RzToolButton8: TRzToolButton;
    btnLimit: TRzToolButton;
    RzToolButton10: TRzToolButton;
    N6: TMenuItem;
    N8: TMenuItem;
    N9: TMenuItem;
    N10: TMenuItem;
    N12: TMenuItem;
    N15: TMenuItem;
    N18: TMenuItem;
    N19: TMenuItem;
    N20: TMenuItem;
    C1: TMenuItem;
    M1: TMenuItem;
    H1: TMenuItem;
    T1: TMenuItem;
    Image1: TImage;
    RzStatusPane6: TRzStatusPane;
    Label1: TLabel;
    N21: TMenuItem;
    N22: TMenuItem;
    Label4: TLabel;
    lbl3: TLabel;
    lbl1: TLabel;
    act_CarType: TAction;
    act_CarColor: TAction;
    act_Limit: TAction;
    act_Rule: TAction;
    N23: TMenuItem;
    N24: TMenuItem;
    N25: TMenuItem;
    N26: TMenuItem;
    act_Help: TAction;
    act_About: TAction;
    RzClockStatus1: TRzClockStatus;
    RzStatusPane7: TRzStatusPane;
    procedure ExitSystemExecute(Sender: TObject);
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure FormShow(Sender: TObject);
    procedure ChangePasswordExecute(Sender: TObject);
    procedure act_CarTypeExecute(Sender: TObject);
    procedure act_CarColorExecute(Sender: TObject);
    procedure act_LimitExecute(Sender: TObject);
    procedure act_RuleExecute(Sender: TObject);
    procedure SetUserExecute(Sender: TObject);
    procedure act_AboutExecute(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    SFKSC: Boolean;
    procedure SetQX;
  end;

var
  MainFrm: TMainFrm;

implementation

uses PasswordFrm, LoadConFig, AboutUnit, DataModuleU,
  U_CheXingDaiHao, U_LeiBeiWeiHu, U_Limit, U_RuleManager, Unit_User,
      U_LimitConst;
{$R *.dfm}

procedure TMainFrm.ExitSystemExecute(Sender: TObject);
begin
  Close;
end;

procedure TMainFrm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
  CanClose := False;
  if MessageBox(Handle, '您确实要退出系统吗?', '提示', MB_YESNO + MB_ICONINFORMATION) = IDYES then
  begin
    CanClose := True;
  end
  else
  begin
    Exit;
  end;
end;

procedure TMainFrm.FormShow(Sender: TObject);
begin
  SetQX;
  try
    Image1.Picture.LoadFromFile(DmFrm.GetPath + 'AppPro\mainShow.jpg');
    Image1.Update;
  except
  end;
  RzStatusPane2.Caption := DmFrm.LogUser;
  RzStatusPane4.Caption := '打开正常';
  Label4.Caption := '注册到: ' + ConfigValue.SYDWXX;
end;

procedure TMainFrm.ChangePasswordExecute(Sender: TObject);
begin
  if CpassFrm = nil then
    CpassFrm := TCpassFrm.Create(Self);
  CpassFrm.ShowModal;
end;

procedure TMainFrm.act_CarTypeExecute(Sender: TObject);
begin
  Frm_CarType := TFrm_CarType.Create(Self);
  try
    Frm_CarType.ShowModal;
  finally
    FreeAndNil(Frm_CarType);
  end;
end;

procedure TMainFrm.act_CarColorExecute(Sender: TObject);
begin
  Frm_CarColor := TFrm_CarColor.Create(Self);
  try
    Frm_CarColor.ShowModal;
  finally
    FreeAndNil(Frm_CarColor);
  end;
end;

procedure TMainFrm.act_LimitExecute(Sender: TObject);
begin
  frm_Limit := Tfrm_Limit.Create(nil);
  try

    frm_Limit.ShowModal;
  finally
    FreeAndNil(frm_Limit);
  end;
end;

procedure TMainFrm.act_RuleExecute(Sender: TObject);
begin
  frm_RuleManager := Tfrm_RuleManager.Create(nil);
  try
    frm_RuleManager.ShowModal;
  finally
    FreeAndNil(frm_RuleManager);
  end;
end;

procedure TMainFrm.SetUserExecute(Sender: TObject);
begin
  Frm_User := TFrm_User.Create(Self);
  try
    Frm_User.ShowModal;
  finally
    FreeAndNil(Frm_User);
  end;
end;

procedure TMainFrm.SetQX;
var
  b_Enable :Boolean;
begin
  b_Enable := DmFrm.LogUserID = 1;
  SetUser.Enabled := b_Enable;
  ChangePassword.Enabled := b_Enable;
  act_CarType.Enabled := b_Enable;
  act_CarColor.Enabled := b_Enable;
  act_Rule.Enabled := b_Enable;
  act_Limit.Enabled := b_Enable;
  InDate.Enabled := b_Enable;
  ImageIn.Enabled := b_Enable;
  SeekCx.Enabled := b_Enable;
  SeekTj.Enabled := b_Enable;
  SeekFk.Enabled := b_Enable;
end;

procedure TMainFrm.act_AboutExecute(Sender: TObject);
begin
  AboutFrm := TAboutFrm.Create(Self);
  try
    AboutFrm.ShowModal;
  finally
    FreeAndNil(AboutFrm);
  end;  
end;

procedure TMainFrm.FormCreate(Sender: TObject);
begin
  Self.DoubleBuffered := True;
end;

end.