efendy42
Siteden Atıldı
İtibarı : -50
Offline
Mesaj Sayısı: 0
|
 |
« : Nisan 27, 2008, 08:39:51 ÖÖ » |
|
//Not: Delphi 7.0 için; //Eğer Quick Reports paketini kurmadıysanız Delphi 7.0\Bin dizini altındaki //dclqrt70.bpl dosyasını eklemeniz gerekir. //[Menüde Component\Install Packages...\Add sırasını izleyip]
//Delphi 5.0 - 6.0 için bu işlemi yapmanıza gerek yok.
//Form1 üzerine 1 DBGrid, 1 Table1, 1 DataSource, //1 PrinterSetupDialog, 1 PrintDialog1 ve 1 Button ekleyin.
unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DB, DBTables, Grids, DBGrids, StdCtrls, ComCtrls, ExtCtrls, Mask, QuickRpt, Qrctrls, Printers, QRPrntr, QrExtra;
type TForm1 = class(TForm) DBGrid1: TDBGrid; Table1: TTable; DataSource1: TDataSource; PrinterSetupDialog1: TPrinterSetupDialog; PrintDialog1: TPrintDialog; Button3: TButton; procedure DBGrid1DblClick(Sender: TObject); procedure Button3Click(Sender: TObject); private aReport: TQuickRep; public { Public declarations } end;
var Form1: TForm1;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.DBGrid1DblClick(Sender: TObject); begin if DBGrid1.SelectedRows.Count > 0 then begin with DBGrid1.DataSource.DataSet do begin try Application.CreateForm(TForm2, Form2); if not DBGrid1.Fields[0].IsNull then Form2.QRLabel7.Caption:= DBGrid1.Fields[0].Value; //"if not DBGrid1.Fields[0..n].IsNull then" şeklinde bir kod, programınızın //kırılmasını engelleyecektir. Bu, tüm "Field" aktarımları için geçerli ve sorun //çıkarmayan, çıkmasını kontrol altında tutan bir yöntem olduğu düşüncesindeyim. if not DBGrid1.Fields[1].IsNull then Form2.QRLabel8.Caption:= DBGrid1.Fields[1].Value; if not DBGrid1.Fields[2].IsNull then Form2.QRLabel9.Caption:= DBGrid1.Fields[2].Value; if not DBGrid1.Fields[3].IsNull then Form2.QRLabel10.Caption:= DBGrid1.Fields[3].Value; if not DBGrid1.Fields[4].IsNull then Form2.QRLabel11.Caption:= DBGrid1.Fields[4].Value; if not DBGrid1.Fields[5].IsNull then Form2.QRLabel12.Caption:= DBGrid1.Fields[5].Value; if not DBGrid1.Fields[6].IsNull then Form2.QRLabel13.Caption:= DBGrid1.Fields[6].Value; if not DBGrid1.Fields[7].IsNull then Form2.QRLabel14.Caption:= DBGrid1.Fields[7].Value; if not DBGrid1.Fields[8].IsNull then Form2.QRLabel15.Caption:= DBGrid1.Fields[8].Value; Form2.QR.ShowProgress:= False; aReport:= Form2.QR; Printer.PrinterIndex:= -1; aReport.Preview; finally Form2.Free; end; end; end; end;
procedure TForm1.Button3Click(Sender: TObject); begin Close; end;
end.
Not: DBGrid1.Options dgRowSelect True olmalı.
QR -> Form2 üzerindeki QuickRep1 bileşeni
//////////////////////////////////////////////////////////////////////////////// //Form2 üzerine 1 QuickRep (Bu kodlamaya göre Name = QR), //QuickRep üzerine 2 adet QRBand, //QRBand'lar üzerine listelenmesini istediğiniz Field'lerinizin 2 katı QRLabel ve //başlıklarla dataların birbirine karışmaması için Shape ekleyiniz. //Örnek; // STOK LİSTESİ (QRLabel1) // // Stok No(QRLabel2) Stok Adı(QRL3) Birim(QRL4) Brm.Miktar(QRL5) ......... //-------------------------------------------------------------------------------- Shape1 // StokNo(QRL6 StokAdi(QRL7 Birim(QRL8 BrmMiktar(QRL9 ......... // -SağaDayalı) -SolaDayalı) -Ortalı) -SağaDyalı)
unit Unit2;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, QuickRpt, QRPrntr, QRCtrls, Printers, DB, DBTables, QrExtra;
type TForm2 = class(TForm) QR: TQuickRep; QRBand1: TQRBand; QRLabel1: TQRLabel; QRBand2: TQRBand; QRLabel2: TQRLabel; QRLabel3: TQRLabel; QRLabel4: TQRLabel; QRLabel5: TQRLabel; QRLabel6: TQRLabel; QRShape1: TQRShape; QRLabel7: TQRLabel; QRLabel8: TQRLabel; QRLabel9: TQRLabel; QRLabel10: TQRLabel; QRLabel11: TQRLabel; QRLabel12: TQRLabel; QRLabel13: TQRLabel; QRLabel14: TQRLabel; QRLabel15: TQRLabel; QRLabel16: TQRLabel; QRLabel17: TQRLabel; QRLabel18: TQRLabel; QRLabel19: TQRLabel; private { Private declarations } public { Public declarations } end;
var Form2: TForm2;
implementation
uses Unit1;
{$R *.dfm}
end.
Not: QRLabel7'den QRLabel15'e kadar olan bileşenler QRBand2 üzerinde. QRBand2.BandType "rbSummary" olmalı.
QRBand1.BandType "rbTitle" olmalı.
Form2 üzerindeki QR -> QuickRep1 bileşeni
|