unsystpublic.~pas

来自「一个图书批发商的通用软件」· ~PAS 代码 · 共 91 行

~PAS
91
字号
unit unSystPublic;

interface
uses  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs,StdCtrls;
const
  ACCESS_DB_PASSWORD ='123456';
  Title ='图书软件';
  StartSaleId='1000000';
var
  CurrentUserId:string;//当前用户编号
  CurrentUserName:string;//当前用户名
  function GetConnectionString(sSource: string): string;
  function ConctionDataBase(filename:string):boolean;
  procedure GetPH(var cb:tcombobox);
  procedure ChildrenShow(FormClass:TFormClass; var fm; AOwner: TComponent);
implementation

uses Data, Main;
function GetConnectionString(sSource: string): string;
begin
  Result := '';
  if sSource <> '' then
  Result := 'Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;' +
  'Data Source=' + sSource + ';User ID=Admin;Jet OLEDB:Database Password=' +
  ACCESS_DB_PASSWORD;
end;
function ConctionDataBase(filename:string):boolean;
begin
  result:=true;
  try
    dmData.adcDatabase.Close;
    dmData.adcDatabase.ConnectionString:= GetConnectionString(ExtractFilePath(ParamStr(0))+filename);
    dmData.adcDatabase.Open;
  except
    result :=false;
  end;
end;
procedure ChildrenShow(FormClass:TFormClass; var fm; AOwner: TComponent);
var  i: integer;  Child: TForm;
begin
  for i := 0 to Screen.FormCount - 1 do
  begin
    if screen.Forms[i] = Aowner then//.Owner
    begin
      Continue;
    end
    else
    begin
      if Screen.Forms[i].ClassType=FormClass then
      begin
        Child := Screen.Forms[i];
        if Child.WindowState = wsMinimized then
        ShowWindow(Child.handle, SW_SHOWNORMAL)
        else ShowWindow(Child.handle, SW_SHOWNA);
        if (not Child.Visible) then Child.Visible := True;
        Child.BringToFront;
        Child.Setfocus;
        TForm(fm) := Child;
        exit;
      end;
    end;
  end;
  Child := TForm(FormClass.NewInstance);
  TForm(fm) := Child;
  Child.Create(AOwner);
  Child.Left :=2;
  child.Top :=2;
  Child.Width :=frmMain.ClientWidth-10;
  Child.Height :=frmMain.ClientHeight-76;

end;
procedure GetPH(var cb:tcombobox);
var nowyear,nowmonth:integer;
begin
  cb.Items.Clear;
  nowyear :=strtoint(FormatDateTime('yyyy',now));
  nowmonth :=strtoint(FormatDateTime('mm',now));
  cb.Items.Add(inttostr(nowyear-1)+'A');
  cb.Items.Add(inttostr(nowyear-1)+'B');
  cb.Items.Add(inttostr(nowyear)+'A');
  cb.Items.Add(inttostr(nowyear)+'B');
  cb.Items.Add(inttostr(nowyear+1)+'A');
  cb.Items.Add(inttostr(nowyear+1)+'B');
  if nowmonth>6 then
  cb.ItemIndex :=cb.Items.IndexOf(inttostr(nowyear)+'B')
  else
  cb.ItemIndex :=cb.Items.IndexOf(inttostr(nowyear)+'A');
end;
end.
 

⌨️ 快捷键说明

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