cgqmainfrm.pas

来自「一个仓库管理中的子系统--采购子系统」· PAS 代码 · 共 303 行

PAS
303
字号
unit cgqmainFrm;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Menus, Grids, DBGrids, Db, DBTables, Buttons, StdCtrls, ExtCtrls, ImgList,
  ComCtrls,mmsystem;

type
  TmainForm = class(TForm)
    MainMenu1: TMainMenu;
    cgsqblr: TMenuItem;
    scsqb: TMenuItem;
    cgsqbcx: TMenuItem;
    cxsqb: TMenuItem;
    N2: TMenuItem;
    N1: TMenuItem;
    ImageList1: TImageList;
    N3: TMenuItem;
    StatusBar1: TStatusBar;
    Bevel1: TBevel;
    SpeedButton4: TSpeedButton;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    SpeedButton3: TSpeedButton;
    SpeedButton5: TSpeedButton;
    SpeedButton6: TSpeedButton;
    N4: TMenuItem;
    N5: TMenuItem;
    Bevel2: TBevel;
    Label1: TLabel;
    procedure scsqbClick(Sender: TObject);
    procedure cxsqbClick(Sender: TObject);
    procedure N2Click(Sender: TObject);
    procedure N1Click(Sender: TObject);
    procedure N3Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure SpeedButton6Click(Sender: TObject);
    procedure SpeedButton4MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure N4Click(Sender: TObject);
    procedure N5Click(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormClick(Sender: TObject);
    procedure FormDblClick(Sender: TObject);
  private
  function gethelpinformation(b:tspeedbutton):string;
  function ismainitem(name:string):boolean;
    { Private declarations }
  public
  function initdb:boolean;
    { Public declarations }
  end;

var
  mainForm: TmainForm;

implementation
uses sqbinput,sqquery,datamodule, jhydl, sccgssb, cghzbcx, htglmk, NeoForm;
{$R *.DFM}

var
  active_color:tcolor=clblue;
  inactive_color:tcolor=clGreen;

procedure OpenMidi;
begin
  MCISendString('OPEN music2.MID TYPE SEQUENCER ALIAS NN',nil,0,0);
  MCISendString('PLAY NN FROM 0',nil,0,0);
  MCISendString('CLOSE ANIMATION',nil,0,0);
end;

procedure CloseMidi;
begin
   MCISendString('OPEN music2.MID TYPE SEQUENCER ALIAS NN',nil,0,0);
   MCISendString('STOP NN',nil,0,0);
   MCISendString('CLOSE ANIMATION',nil,0,0);
end;

function TmainForm.ismainitem(name:string):boolean;
begin
if (name='SpeedButton1') or
   (name='SpeedButton2') or
   (name='SpeedButton3') or
   (name='SpeedButton4') or
   (name='SpeedButton5') or
   (name='SpeedButton6') then
   result:=true
else result:=false;
end;

function TmainForm.gethelpinformation(b:tspeedbutton):string;
begin
if b<>nil then result:=b.hint
else result:='亚星公司 武汉 湖北 2001 版权所有';
end;

function TmainForm.initdb:boolean;
begin
result:=true;
with datamodule1 do
  begin
  try
    //showinitinfo('请稍后 正连接数据库。。。');
    dbase709.close;
    dbase709.Open;
    //showinitinfo('请稍后 正统计库存信息。。。');
    //cal_10kc;
{    showinitinfo('请稍后 正打开字典表。。。');
    zdobject:=tzdobject.create;}
  except
    result:=false;
    dbase709.Close;
  end;
  end;
end;

procedure TmainForm.scsqbClick(Sender: TObject);
begin
    sqinputForm:=TsqinputForm.Create(application);
    hide;
    sqinputform.ShowModal;
    sqinputForm.Free;
    show;
end;

procedure TmainForm.cxsqbClick(Sender: TObject);
begin
    datamodule1.set_flag:=1;
    sqcxForm:=TsqcxForm.Create(Application);
    hide;
    sqcxForm.ShowModal;
    sqcxForm.Free;
    show;
end;

procedure TmainForm.N2Click(Sender: TObject);
begin
    jhydlForm:=TjhydlForm.Create(Application);
    hide;
    jhydlForm.ShowModal;
    jhydlForm.free;
    show;
end;

procedure TmainForm.N1Click(Sender: TObject);
begin
    jhssForm:=TjhssForm.Create(Application);
    with datamodule1.publicQuery3 do
    begin
    close;
    sql.clear;
    sql.Add('select sqbid From dbo.a_cgsqzb');
    sql.add('where scssb_flag='+''''+'0'+'''');
    prepare;
    open;
    if RecordCount=0 then
    begin
    close;
    showmessage('没有未生成实施表的申请表!');
    jhssForm.Free;
    exit;
    end;
    jhssForm.sqbidCombo.Items.clear;
    while not Eof do
    begin
    jhssForm.sqbidComBo.Items.Add(FieldByName('sqbid').asstring);
    next;
    end;
    jhssForm.sqbidComBo.Text:=jhssForm.sqbidComBo.Items[jhssForm.sqbidComBo.Items.count-1];
    close;
    end;
    hide;
    jhssForm.ShowModal;
    jhssForm.Free;
    show;
end;

procedure TmainForm.N3Click(Sender: TObject);
begin
     cghzbForm:=TcghzbForm.create(Application);
     hide;
     cghzbForm.ShowModal;
     cghzbForm.free;
     show;
end;

procedure TmainForm.FormCreate(Sender: TObject);
var
  count1:integer;
begin
//mainForm.Color:=$00DCB4A0;

  // 提示框为浅灰色小方框
Application.HintColor:=clsilver ;
// 延长停留时间为1 0 秒
Application.HintHidePause:=10000 ;
// 使提示框立即出现
Application.HintPause:=100;
// 显示快捷键信息
Application.HintShortCuts:=True ;
// 使一个提示框出现后,鼠标移动到另一个组件上后,立即显示新的提示框
Application.HintShortPause:=0 ;
for count1:=0 to componentcount-1 do
    if components[count1] is tspeedbutton then
      tspeedbutton(components[count1]).font.color:=active_color;
statusbar1.Panels[1].text:='  '+gethelpinformation(nil);

  if not initdb then
  begin
  application.MessageBox('数据库初始化失败,请重新启动系统。','系统错误',mb_ok+mb_iconerror);
  application.Terminate;
  end;
end;

procedure TmainForm.SpeedButton6Click(Sender: TObject);
begin
close;
end;

procedure TmainForm.SpeedButton4MouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
  var
  count1:integer;
begin
if ismainitem(tspeedbutton(sender).name) then
  begin
  if tspeedbutton(sender).font.color=inactive_color then exit
  else
    begin
    for count1:=0 to componentcount-1 do
      if components[count1] is tspeedbutton then
        tspeedbutton(components[count1]).font.color:=active_color;
    tspeedbutton(sender).font.color:=inactive_color;
    end;
  //notebook1.ActivePage:=tspeedbutton(sender).name;
  statusbar1.Panels[1].text:='  '+gethelpinformation(tspeedbutton(sender));
  end
else
  begin
  if tspeedbutton(sender).font.color=inactive_color then exit;
    for count1:=0 to componentcount-1 do
      if (components[count1] is tspeedbutton) and (not ismainitem(tspeedbutton(components[count1]).name)) then
        tspeedbutton(components[count1]).font.color:=active_color;
    tspeedbutton(sender).font.color:=inactive_color;
    statusbar1.Panels[1].text:='  '+gethelpinformation(tspeedbutton(sender));
  end;
end;

procedure TmainForm.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
var
  count1:integer;
begin
  for count1:=0 to componentcount-1 do
    if components[count1] is tspeedbutton then
      tspeedbutton(components[count1]).font.color:=active_color;
statusbar1.Panels[1].text:='  '+gethelpinformation(nil);
end;

procedure TmainForm.N4Click(Sender: TObject);
begin
    htglForm:=ThtglForm.Create(application);
    hide;
    htglForm.ShowModal;
    htGlForm.free;
    show;
end;

procedure TmainForm.N5Click(Sender: TObject);
begin
    zypNeoForm:=TzypNeoForm.Create(Application);
    zypNeoForm.ShowModal;
    zypNeoForm.free;
end;

procedure TmainForm.FormActivate(Sender: TObject);
begin
   openMidi;
end;

procedure TmainForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
    CloseMidi;
end;

procedure TmainForm.FormClick(Sender: TObject);
begin
   closemidi;
   openmidi;
end;

procedure TmainForm.FormDblClick(Sender: TObject);
begin
    closemidi;
end;

end.

⌨️ 快捷键说明

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