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

📄 main.pas

📁 一款不错的商务程序商品管理系统,有简易的窗体皮肤
💻 PAS
字号:
unit Main;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Menus, ComCtrls, ToolWin, DB, ADODB,StrUtils, WinSkinData,
  ImgList, jpeg, ExtCtrls, StdCtrls,Theme;

type
  TFrm_Main = class(TBaseForm)
    MainMenu1: TMainMenu;
    N1: TMenuItem;
    p1: TMenuItem;
    N2: TMenuItem;
    N3: TMenuItem;
    N20: TMenuItem;
    N6: TMenuItem;
    N7: TMenuItem;
    N10: TMenuItem;
    N11: TMenuItem;
    N12: TMenuItem;
    N13: TMenuItem;
    N14: TMenuItem;
    CoolBar1: TCoolBar;
    ToolBar1: TToolBar;
    ToolButton1: TToolButton;
    ToolButton2: TToolButton;
    ToolButton3: TToolButton;
    StatusBar1: TStatusBar;
    N15: TMenuItem;
    N16: TMenuItem;
    N17: TMenuItem;
    ToolButton4: TToolButton;
    ToolButton5: TToolButton;
    ToolButton6: TToolButton;
    ToolButton7: TToolButton;
    ToolButton8: TToolButton;
    ToolButton9: TToolButton;
    ToolButton10: TToolButton;
    OpenDialog1: TOpenDialog;
    SaveDialog1: TSaveDialog;
    ImageList1: TImageList;
    N8: TMenuItem;
    N9: TMenuItem;
    N18: TMenuItem;
    N19: TMenuItem;
    N21: TMenuItem;
    N22: TMenuItem;
    N23: TMenuItem;
    N24: TMenuItem;
    N25: TMenuItem;
    Image1: TImage;
    procedure N11Click(Sender: TObject);
    procedure N12Click(Sender: TObject);
    procedure N13Click(Sender: TObject);
    procedure N14Click(Sender: TObject);
    procedure N15Click(Sender: TObject);
    procedure N16Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure N6Click(Sender: TObject);
    procedure N17Click(Sender: TObject);
    procedure N7Click(Sender: TObject);
    procedure N10Click(Sender: TObject);
    procedure ToolButton10Click(Sender: TObject);
    procedure N20Click(Sender: TObject);
    procedure N4Click(Sender: TObject);
    procedure N5Click(Sender: TObject);
    procedure N9Click(Sender: TObject);
    procedure N18Click(Sender: TObject);
    procedure N19Click(Sender: TObject);
    procedure N21Click(Sender: TObject);
    procedure N22Click(Sender: TObject);
    procedure N23Click(Sender: TObject);
    procedure ToolButton4Click(Sender: TObject);
  private
    { Private declarations }
    procedure ActiveFrom( PPageActive:Integer);
    function IsShowForm(FormName:string):Boolean;
    function DataBaseBack:Boolean;
    function DataBaseRestore:Boolean;
  public
    { Public declarations }
  end;

var
  Frm_Main: TFrm_Main;
  ActiveForm:TForm;
  Operator:string;
  UName:string;
  IsLogin:Boolean;


implementation
uses BaseInfo,Arrange,Buyers,Charts,SetTree,
    Popedom,Login, DM,MailSend,InCept,SelMail,
    chararea,LinkMain,LocateMail;
{$R *.dfm}

procedure TFrm_Main.ActiveFrom(PPageActive: Integer);
begin
  if Assigned(ActiveForm) then
  begin
    ActiveForm.Close;
  end;
  PageActive:=PPageActive;
  ActiveForm:=TFrm_Base.Create(Self);
  
end;

procedure TFrm_Main.N11Click(Sender: TObject);
begin
  if not IsShowForm('产品资料') then
  begin
    Application.MessageBox('您没有操作权限!','明日科技');
    Exit;
  end;
  ActiveFrom(0);
end;

procedure TFrm_Main.N12Click(Sender: TObject);
begin
  if not IsShowForm('客户类型设置') then
  begin
    Application.MessageBox('您没有操作权限!','明日科技');
    Exit;
  end;
  ActiveFrom(1);
end;

procedure TFrm_Main.N13Click(Sender: TObject);
begin
  if not IsShowForm('客户来源设置') then
  begin
    Application.MessageBox('您没有操作权限!','明日科技');
    Exit;
  end;
  ActiveFrom(2);
end;

procedure TFrm_Main.N14Click(Sender: TObject);
begin
  if not IsShowForm('部门设置') then
  begin
    Application.MessageBox('您没有操作权限!','明日科技');
    Exit;
  end;
  ActiveFrom(3);
end;

procedure TFrm_Main.N15Click(Sender: TObject);
begin
  if not IsShowForm('区域设置') then
  begin
    Application.MessageBox('您没有操作权限!','明日科技');
    Exit;
  end;
  ActiveFrom(4);
end;

procedure TFrm_Main.N16Click(Sender: TObject);
begin
  if not IsShowForm('联系方式') then
  begin
    Application.MessageBox('您没有操作权限!','明日科技');
    Exit;
  end;
  ActiveFrom(5);
end;

procedure TFrm_Main.FormShow(Sender: TObject);
begin
  IsLogin:=False;
  Frm_Login:=TFrm_Login.Create(Application);
  Frm_Login.ShowModal;
  if not IsLogin then
    PostMessage(Handle, WM_CLOSE, 0, 0);
  Operator:=UName;
  Frm_Login.Free;
end;

procedure TFrm_Main.N6Click(Sender: TObject);
begin
  if not IsShowForm('日程管理') then
  begin
    Application.MessageBox('您没有操作权限!','明日科技');
    Exit;
  end;
  if Assigned(ActiveForm) then
  begin
    ActiveForm.Close;
  end;

  ActiveForm:=TFrm_Arrange.Create(Self);
end;

procedure TFrm_Main.N17Click(Sender: TObject);
begin
  if not IsShowForm('职务设置') then
  begin
    Application.MessageBox('您没有操作权限!','明日科技');
    Exit;
  end;
  ActiveFrom(6);
end;

procedure TFrm_Main.N7Click(Sender: TObject);
begin
  if not IsShowForm('客户管理') then
  begin
    Application.MessageBox('您没有操作权限!','明日科技');
    Exit;
  end;
  if Assigned(ActiveForm) then
  begin
    ActiveForm.Close;
  end;

  ActiveForm:=TFrm_Buyers.Create(Self);
end;

procedure TFrm_Main.N10Click(Sender: TObject);
begin
  if not IsShowForm('图表分析A') then
  begin
    Application.MessageBox('您没有操作权限!','明日科技');
    Exit;
  end;
  if Assigned(ActiveForm) then
  begin
    ActiveForm.Close;
  end;

  ActiveForm:=TFrm_Chart.Create(Self);
end;

procedure TFrm_Main.ToolButton10Click(Sender: TObject);
begin
  Close;
end;

procedure TFrm_Main.N20Click(Sender: TObject);
begin
  if not IsShowForm('权限管理') then
  begin
    Application.MessageBox('您没有操作权限!','明日科技');
    Exit;
  end;
  Frm_Popedom.ShowModal;
end;


function TFrm_Main.IsShowForm(FormName: string): Boolean;
var
  ADOQ:TADODataSet;
begin
  ADOQ:=TADODataSet.Create(nil);
  ADOQ.Connection:=FDM.ADOConnection1;
  ADOQ.CommandText:='Select P.IsUse From MR_User_Tab U,MR_Popedom_Tab P '+
                    'where U.MR_Group=P.MR_Name and U.MR_Login='+QuotedStr(UName)+
                    ' and P.MR_FormName='+QuotedStr(FormName);
  ADOQ.Open;
  if ADOQ.RecordCount=0 then
    Result := False
  else
    Result := ADOQ.Fields[0].AsBoolean;
end;

function TFrm_Main.DataBaseBack: Boolean;
var
  FileName:string;
  ADOQ:TADOQuery;
begin
  ADOQ:=TADOQuery.Create(nil);
  ADOQ.Connection:=FDM.ADOConnection1;

  try
   if Application.MessageBox('是否要备份数据库?', '明日科技', MB_OKCANCEL) =
     IDOK then
   begin
      if SaveDialog1.Execute then
      FileName:=SaveDialog1.FileName;
      ADOQ.SQL.Text:='use master BACKUP DATABASE MR_Buyer to Disk ='''+FileName+''' use MR_Buyer';
      ADOQ.ExecSQL;
      Application.MessageBox('数据备份成功!','明日科技');
   end;
    Result := True;
  except
    Application.MessageBox('数据备份失败!','明日科技');
    Result := False;
  end;
end;

procedure TFrm_Main.N4Click(Sender: TObject);
begin
  DataBaseBack;
end;

function TFrm_Main.DataBaseRestore: Boolean;
var
  SQLStr:string;
  ADOQ:TADOQuery;
begin
    ADOQ:=TADOQuery.Create(nil);
    ADOQ.Connection:=FDM.ADOConnection1;
    try
     if Application.MessageBox('是否要还原数据库?', '明日科技', MB_OKCANCEL) =
       IDOK then
     begin
        if OpenDialog1.Execute then
        begin
          SQLStr:=
          ' use master '+
          ' RESTORE DATABASE MR_Buyer FROM Disk = '+QuotedStr(OpenDialog1.FileName)+
          ' use MR_Buyer';
          ADOQ.SQL.Text:=SQLStr;
          ADOQ.ExecSQL;
          //FDM.ADOCon.Execute('use master BACKUP DATABASE '+DataName+' to Disk ='''+GetCurrentDir+'\Back\'+DateTostr(Now)+'''');
          Application.MessageBox('数据还原成功!','明日科技');

        end;
     end;
     Result := True;
    except
      Application.MessageBox('数据还原失败!','明日科技');
      Result := False;
    end;
end;

procedure TFrm_Main.N5Click(Sender: TObject);
begin
  DataBaseRestore;
end;

procedure TFrm_Main.N9Click(Sender: TObject);
begin
  if not IsShowForm('邮件发送') then
  begin
    Application.MessageBox('您没有操作权限!','明日科技');
    Exit;
  end;
  Frm_Send.ShowModal;
end;

procedure TFrm_Main.N18Click(Sender: TObject);
begin
  if not IsShowForm('邮件接收') then
  begin
    Application.MessageBox('您没有操作权限!','明日科技');
    Exit;
  end;
  Frm_Incept.ShowModal;
end;

procedure TFrm_Main.N19Click(Sender: TObject);
begin
  if not IsShowForm('邮件查询') then
  begin
    Application.MessageBox('您没有操作权限!','明日科技');
    Exit;
  end;
  Frm_SelMail.ShowModal;
end;

procedure TFrm_Main.N21Click(Sender: TObject);
begin
  if not IsShowForm('地区邮件分析') then
  begin
    Application.MessageBox('您没有操作权限!','明日科技');
    Exit;
  end;
  Frm_Mailchart.ShowModal;
end;

procedure TFrm_Main.N22Click(Sender: TObject);
begin
  if not IsShowForm('联系人') then
  begin
    Application.MessageBox('您没有操作权限!','明日科技');
    Exit;
  end;
  Frm_LinkMain.ShowModal;
end;

procedure TFrm_Main.N23Click(Sender: TObject);
begin
  if not IsShowForm('邮件服务设置') then
  begin
    Application.MessageBox('您没有操作权限!','明日科技');
    Exit;
  end;
  Frm_Setup.ShowModal;
end;

procedure TFrm_Main.ToolButton4Click(Sender: TObject);
begin
  inherited;
  if not IsShowForm('基础信息') then
  begin
    Application.MessageBox('您没有操作权限!','明日科技');
    Exit;
  end;
  ActiveFrom(0);
end;

end.

⌨️ 快捷键说明

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