mainunit.pas

来自「这是为工商所开发的工商收费簿套打软件,借初学者学习」· PAS 代码 · 共 489 行 · 第 1/2 页

PAS
489
字号
unit mainUnit;

interface

uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs, DB, ADODB, Grids, DBGridEh, LbSpeedButton, ExtCtrls, AAFont,
    AACtrls, jpeg, StdCtrls, LbButton, ComCtrls, Menus;

type
    TForm1 = class(TForm)
        Panel1: TPanel;
        Panel2: TPanel;
        LbSpeedButton1: TLbSpeedButton;
        DBGridEh1: TDBGridEh;
        DataSource1: TDataSource;
        AALabel1: TAALabel;
        LbSpeedButton2: TLbSpeedButton;
        LbSpeedButton4: TLbSpeedButton;
        LbSpeedButton5: TLbSpeedButton;
        ADOQuery1: TADOQuery;
        Panel3: TPanel;
        LbButton1: TLbButton;
        LbButton2: TLbButton;
        LbButton3: TLbButton;
        LbButton4: TLbButton;
        LbButton5: TLbButton;
        LbButton6: TLbButton;
        LbButton7: TLbButton;
        LbButton8: TLbButton;
        LbButton9: TLbButton;
        LbButton10: TLbButton;
        LbButton11: TLbButton;
        LbButton12: TLbButton;
        LbButton14: TLbButton;
        LbButton15: TLbButton;
        LbButton16: TLbButton;
        LbButton17: TLbButton;
        Image1: TImage;
        Label1: TLabel;
        AALabel2: TAALabel;
        LbSpeedButton3: TLbSpeedButton;
        LbButton13: TLbButton;
        LbSpeedButton6: TLbSpeedButton;
    AAText1: TAAText;
    LbSpeedButton7: TLbSpeedButton;
    LbButton18: TLbButton;
    Image2: TImage;
    AALabel4: TAALabel;
    AALabel9: TAALabel;
    Image3: TImage;
    StatusBar1: TStatusBar;
    MainMenu1: TMainMenu;
    N1: TMenuItem;
    N2: TMenuItem;
    N3: TMenuItem;
        procedure LbSpeedButton1Click(Sender: TObject);
        procedure ADOTable1AfterOpen(DataSet: TDataSet);
        procedure LbSpeedButton5Click(Sender: TObject);
        procedure LbSpeedButton2Click(Sender: TObject);
        procedure DBGridEh1CellClick(Column: TColumnEh);
        procedure LbSpeedButton3Click(Sender: TObject);
        procedure LbSpeedButton4Click(Sender: TObject);
        procedure FormCreate(Sender: TObject);
        procedure LbButton1Click(Sender: TObject);
        procedure LbSpeedButton6Click(Sender: TObject);
    procedure LbSpeedButton7Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure N3Click(Sender: TObject);
    procedure N1Click(Sender: TObject);
    procedure N4Click(Sender: TObject);
    procedure N5Click(Sender: TObject);
    private
    { Private declarations }
        procedure FlashREC;
        procedure DelAnotherTable(Sid: string);
        procedure AppendMB2005(SID:string);
    public
    { Public declarations }
    end;

var
    Form1: TForm1;



implementation
uses DM, EDITMAIN, Unit100s, Unit101s, Unit102s, Unit103s,
    Unit104s, Unit105s, Unit106s, unit107s, Unit108s, unit109s,
    unit110s, Unit1111213s, Unit114s, Unit115s, Unit1617s,
    Unit18_24s,UNITF3,  UnitPreview, UnitAbout, UnitSet;
{$R *.dfm}

procedure TForm1.LbSpeedButton1Click(Sender: TObject);
begin
//    FlashREC;
SetForm.ShowModal;
end;

procedure TForm1.ADOTable1AfterOpen(DataSet: TDataSet);
begin
    AALabel1.Caption := '共有' + IntToStr(ADOQuery1.RecordCount) + '条记录。';
end;

procedure TForm1.LbSpeedButton5Click(Sender: TObject);
begin
 if  Application.MessageBox('是否真的退出“嘉俊工商表格套打系统”?','询问'
  ,MB_YESNO+MB_ICONQUESTION )=IDYES then
  Application.Terminate ;
end;

procedure TForm1.LbSpeedButton2Click(Sender: TObject);
begin
    ADOQuery1.Append;
    IDForm := TIDForm.Create(SELF);
    IDForm.bAppend := true;
    IDForm.ShowModal;
    FlashREC; //刷新
end;

procedure TForm1.FlashREC;
var
    currrec: Integer;
begin
    if ADOQuery1.Active then
        currrec := adoquery1.RecNo
    else
        currrec := 0;
    ADOquery1.CLOSE;
    ADOquery1.SQL.Text :=
        'select TID.合同编号,T0.出卖人,T0.买受人 FROM TID,T0 WHERE TID.合同编号=T0.合同编号 and TID.合同编号<>''MD2005''';
    ADOQuery1.Open;
    Panel3.Visible := (adoquery1.RecordCount > 0);
    AALabel1.Caption := '共有' + inttostr(ADOQuery1.recordcount) + '条记录。';
    if ADOQuery1.RecordCount = 0 then
        Exit
    else if currrec > ADOQuery1.RecordCount then
        ADOQuery1.Last
    else if currrec < 1 then
        adoquery1.First
    else
        adoquery1.RecNo := currrec;

end;

procedure TForm1.DBGridEh1CellClick(Column: TColumnEh);
begin
    Panel3.Visible := (adoquery1.RecordCount > 0);
end;

procedure TForm1.LbSpeedButton3Click(Sender: TObject);
begin
{    ADOQuery1.edit;
    IDForm := TIDForm.Create(SELF);
    IDForm.bAppend := false;
    IDForm.ShowModal;
    FlashREC; //刷新 }
    AboutForm.ShowModal;
end;

procedure TForm1.LbSpeedButton4Click(Sender: TObject);
begin
    if Application.MessageBox('删除选定合同后将无法恢复,是否真的删除记录?',
        '询问', MB_YESNO or MB_ICONQUESTION) = idyes then begin
        DelAnotherTable(ADOQuery1.fieldbyname('合同编号').AsString);

        FlashREC;
    end;
end;

procedure TForm1.DelAnotherTable(Sid: string);
var
    I: Integer;
    ADOQ: TADOQUERY;

begin
    ADOQ := TADOQUERY.Create(SELF);
    with ADOQ do begin
        CONNECTION := dm.DataModule2.ADOConnection1;
        dm.DataModule2.ADOConnection1.BeginTrans;
        try
            for I := sTablename.Count - 1 downto 0 do begin
                SQL.Text := 'delete  from ' + sTablename[I] +
                    ' where  合同编号=''' + sid + '''';
                ExecSQL;

            end;
            DM.DataModule2.ADOConnection1.CommitTrans;
        except
            DM.DataModule2.ADOConnection1.RollbackTrans;
        end;
        free;
    end;

end;

procedure TForm1.FormCreate(Sender: TObject);
var
devmode:tDevicemode;
Const
Orignwidth=1024;
Orignheight=768;       
begin
    FlashREC;
{'强制改变分辨率
if screen.width<>orignwidth then
begin
    if EnumDisplaySettings(nil,0,devmode) then
    begin
      devmode.dmfields:=dm_pelswidth OR dm_pelsheight ;
      devmode.dmpelswidth:=orignwidth;    {宽度}
      //devmode.dmpelsheight:=orignheight;{高度}
     // ChangeDisplaySettings(devmode,0); {更改设置}
    //end;

//自适应
{scaled:=true;
if (screen.width<>orignwidth) then
begin
  height:=longint(height)*longint
  (screen.height) div orignheight;
  width:=longint(width)*longint
  (screen.width) div orignwidth;
  scaleby(screen.width , orignwidth);
end; }
       
end;

procedure TForm1.LbButton1Click(Sender: TObject);
begin

    case TLbButton(Sender).Tag of
        200: begin
                sID := adoquery1.fieldbyname('合同编号').Text;
                PreviewForm := TPreviewForm.Create(SELF);
                PreviewForm.ShowModal;
            end;
        100: begin
                sSQL := 'select * from T0 where 合同编号=''' +
                    adoquery1.fieldbyname('合同编号').Text + '''';
                sID := adoquery1.fieldbyname('合同编号').Text;
                form100s := TFORM100S.Create(SELF);
                Form100S.ShowModal;
            end;
        101: begin

⌨️ 快捷键说明

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