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

📄 unreportinfo.pas

📁 本产品是开发LISTVIEW相关功能的可定制产品
💻 PAS
字号:
unit UnReportInfo;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons,DB,DBTables;

type
  TFrmReportInfo = class(TForm)
    GroupBox1: TGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    Label6: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    ComboBox1: TComboBox;
    ComboBox2: TComboBox;
    Label3: TLabel;
    btnOk: TBitBtn;
    btnCancek: TBitBtn;
    procedure BitBtn1Click(Sender: TObject);
    procedure ComboBox1KeyPress(Sender: TObject; var Key: Char);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
    WhichType,nWidth:Integer;
    OldReportTitle,OldReportName,OldDiscription,OldFormName:String;
    ReportID,PrintModal,FormCaption,ReportName,Discription:String;
    bSure:boolean;
  public
    { Public declarations }
    procedure IniInfo(Width,WhichOper,PrintType:Integer;ReportTitle,ReportName,Discription:String);
    property  sReportID:String read ReportID;
    property  sPrintType:String read PrintModal;
    property  sFormCaption:String read FormCaption;
    property  sReportName:String read ReportName;
    property  sDiscription:String read Discription;
    property  bbSure:Boolean read bSure;
  end;

var
  FrmReportInfo: TFrmReportInfo;

implementation

uses unCDM;

{$R *.dfm}

procedure TFrmReportInfo.IniInfo(Width,WhichOper,PrintType:Integer;ReportTitle,ReportName,Discription:String);
var qQryDB:TQuery;
    i:integer;
begin
   bSure:=False;
   nWidth:=Width;
   WhichType:=WhichOper;
   OldReportTitle:=ReportTitle;
   OldReportName:=ReportName;
   OldDiscription:=Discription;
   qQryDB:=TQuery.Create(nil);
   qQryDB.DatabaseName:=CDM.dbData.DatabaseName;
   qQryDB.SessionName:=CDM.dbData.SessionName;
   with qQryDB do
   begin
      Close;
      SQL.Clear;
      SQL.Add('SELECT FORMCAPTION FROM SFRJREPORTNAME GROUP BY FORMCAPTION');
      Open;
      First;
      ComBoBox1.Items.Clear;
      While not eof do
      begin
          ComBoBox1.Items.Add(FieldByName('FORMCAPTION').AsString);
          next;
      end;
      qQryDB.Close;
      qQryDB.Free;
      qQryDB:=nil;
   end;

   if WhichOper=0 then  //添加
   begin
       Caption:='请输入需要定制报表的内容';
       ComBoBox2.ItemIndex:=0;
   end;
   if WhichOper=1 then  //修改
   begin
       Caption:='请修改定制报表的内容';
       ComboBox1.Text:=ReportTitle;
       ComboBox1.Enabled:=FALSE;
       Edit1.Text:=ReportName;
       Edit2.Text:=Discription;
       ComboBox2.ItemIndex:=PrintType;
       PrintModal:=ComboBox2.Text;
   end;
   if WhichOper=2 then  //删除
   begin
       Caption:='请确认删除定制报表的内容';
       ComboBox1.Text:=ReportTitle;
       Edit1.Text:=ReportName;
       Edit2.Text:=Discription;
       ComboBox1.Enabled:=FALSE;
       Edit1.Enabled:=FALSE;
       Edit2.Enabled:=FALSE;
       ComboBox2.ItemIndex:=PrintType;
       ComboBox2.Enabled:=FALSE;
   end;
end;

procedure TFrmReportInfo.BitBtn1Click(Sender: TObject);
var qQryDB:TQuery;
    i:integer;
    Str:String;
begin
   if((ComboBox1.Text='') or (ComboBox2.Text='') or (Edit1.Text=''))then
   begin
     Application.MessageBox('   输入信息不全,请确保窗体被选择且名称被输入','系统信息管理窗',0);
     exit;
   end;
   qQryDB:=TQuery.Create(nil);
   qQryDB.DatabaseName:=CDM.dbData.DatabaseName;
   qQryDB.SessionName:=CDM.dbData.SessionName;
   if WhichType=0 then  //添加
   begin
      qQryDB.close;
      qQryDB.sql.Clear;
      qQryDB.sql.Add('SELECT Count(*) WW FROM SFRJREPORTNAME WHERE FORMCAPTION='''+Edit2.Text+''' AND REPORTNAME='''+Edit1.Text+'''');
      qQryDB.Open;
      qQryDB.First;
      If(qQryDB.FieldByName('WW').AsInteger=1)then
      begin
         Application.MessageBox('   你要添加的报表名称在数据库中已经存在,请检查是否重复!','系统信息管理窗',0);
         qQryDB.Close;
         qQryDB.Free;
         qQryDB:=nil;
         exit;
      end;
      qQryDB.close;
      qQryDB.sql.Clear;
      qQryDB.sql.Add('SELECT FORMNAME FROM SFRJREPORTNAME WHERE FORMCAPTION='''+Combobox1.Text+'''');
      qQryDB.Open;
      qQryDB.First;
      OldFormName:=qQryDB.FieldByName('FORMNAME').AsString;
      qQryDB.Close;
      qQryDB.SQL.Clear;
      qQryDB.sql.Add('INSERT INTO SFRJREPORTNAME(FORMNAME,REPORTNAME,FORMCAPTION,DISCRIPTION,PRINTTYPE) VALUES('''+OldFormName+''','''+Edit1.Text+''','''+Combobox1.Text+''','''+Edit2.Text+''','+IntToStr(ComBoBox2.ItemIndex)+')');
      qQryDB.ExecSql;
      bSure:=True;
      qQryDB.Close;
      qQryDB.SQL.Clear;
      qQryDB.sql.Add('SELECT SFRJREPORTNAME_SEQ.CURRVAL WW FROM DUAL');
      qQryDB.Open;
      qQryDB.First;
      ReportID:=qQryDB.FieldByName('WW').AsString;
      qQryDB.Close;
      qQryDB.Sql.Clear;
      qQryDB.sql.Add('COMMIT');
      qQryDB.ExecSQL;
      qQryDB.Close;
      qQryDB.Free;
      qQryDB:=nil;
      PrintModal:=ComboBox2.Text;
      FormCaption:=ComboBox1.Text;
      ReportName:=Edit1.Text;
      Discription:=Edit2.Text;
   end;
   if WhichType=1 then  //修改
   begin
      if((ComboBox2.Text=PrintModal) and (ComboBox1.Text=OldReportTitle) and (Edit1.Text=OldReportName)and(Edit2.Text=OldDiscription))then
          btnCancek.Click
      else
      begin
          if ((nWidth>718) And (ComboBox2.ItemIndex=0))then
          begin
             MessageDlg('   你所修改报表的总宽度已经达到'+IntToStr(nWidth)+'个像素,而A4竖打只支持最大718个像素;因此你不能更改‘纸张打印方式的设置’!',mtWarning,[mbYes],0);
             Exit;
          end;
          qQryDB.close;
          qQryDB.sql.Clear;
          qQryDB.sql.Add('SELECT Count(*) WW FROM SFRJREPORTNAME WHERE FORMCAPTION='''+Edit2.Text+''' AND REPORTNAME='''+Edit1.Text+'''');
          qQryDB.Open;
          qQryDB.First;
          If(((qQryDB.FieldByName('WW').AsInteger)=1) and (Edit1.Text<>OldReportName))then
          begin
             Application.MessageBox('   你修改的报表名称在数据库中已经存在,请检查是否重复!','系统信息管理窗',0);
             qQryDB.Close;
             qQryDB.Free;
             qQryDB:=nil;
             exit;
          end;
          qQryDB.Close;
          qQryDB.sql.Clear;
          qQryDB.sql.Add('UPDATE SFRJREPORTNAME SET REPORTNAME='''+Edit1.Text+''', DISCRIPTION='''+Edit2.Text+''',PRINTTYPE='+IntToStr(Combobox2.ItemIndex)+' WHERE FORMCAPTION='''+OldReportTitle+''' AND REPORTNAME='''+OldReportName+'''');
          qQryDB.ExecSql;
          bSure:=True;          
          qQryDB.Close;
          qQryDB.Free;
          qQryDB:=nil;
          PrintModal:=ComboBox2.Text;
          FormCaption:=ComboBox1.Text;
          ReportName:=Edit1.Text;
          Discription:=Edit2.Text;
      end;
   end;
   if WhichType=2 then  //删除
   begin
          qQryDB.Close;
          qQryDB.sql.Clear;
          qQryDB.sql.Add('SELECT COUNT(*) XX FROM SFRJREPORTNAME WHERE FORMCAPTION='''+OldReportTitle+'''');
          qQryDB.OPEN;
          qQryDB.First;
          If qQryDB.FieldByName('XX').AsInteger=1 then
          begin
              ShowMessage('   系统已仅剩下最后一条打印方案,不允许再删除!');
              qQryDB.Close;
              qQryDB.Free;
              qQryDB:=nil;
              Exit;
          end;

          qQryDB.Close;
          qQryDB.sql.Clear;
          qQryDB.sql.Add('SELECT REPORTID,FORMCAPTION FROM SFRJREPORTNAME WHERE FORMCAPTION='''+OldReportTitle+''' AND REPORTNAME='''+OldReportName+'''');
          qQryDB.OPEN;
          qQryDB.First;
          Str:= qQryDB.FieldByName('REPORTID').AsString;
          qQryDB.Close;
          qQryDB.Sql.Clear;
          qQryDB.sql.Add('DELETE SFRJPRINTDETAIL WHERE REPORTID='+Str);
          qQryDB.ExecSql;
          qQryDB.Close;
          qQryDB.Sql.Clear;
          qQryDB.sql.Add('DELETE SFRJREPORTNAME WHERE FORMCAPTION='''+OldReportTitle+''' AND REPORTNAME='''+OldReportName+'''');
          qQryDB.ExecSql;
          qQryDB.Close;
          qQryDB.Free;
          qQryDB:=nil;
          bSure:=True;
   End;
   Close;
end;

procedure TFrmReportInfo.ComboBox1KeyPress(Sender: TObject; var Key: Char);
begin
  if (Key <> Char(VK_UP))and(Key <> Char(VK_DOWN))then
      key := Char(0); //禁止用户键盘输入信息
end;

procedure TFrmReportInfo.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
      Action:=CaFree;
end;

end.

⌨️ 快捷键说明

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