Kod: Tümünü seç
unit uAracRapor;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Buttons, Vcl.ComCtrls, uModule,
frxClass, frxDBSet, Vcl.ExtCtrls, Comobj;
type
TformAracRapor = class(TForm)
GroupBox1: TGroupBox;
BitBtn1: TBitBtn;
dtBasTarih: TDateTimePicker;
dtBitisTarih: TDateTimePicker;
Label1: TLabel;
Label2: TLabel;
cbAracSurucu: TComboBox;
cbGuzergah: TComboBox;
Label3: TLabel;
Label4: TLabel;
cbAracPlaka: TComboBox;
Label5: TLabel;
frxDBDataset1: TfrxDBDataset;
frxReport1: TfrxReport;
Image1: TImage;
cbGSorumlusu: TComboBox;
Label6: TLabel;
bAktar: TBitBtn;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure BitBtn1Click(Sender: TObject);
procedure bAktarClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
formAracRapor: TformAracRapor;
implementation
{$R *.dfm}
procedure TformAracRapor.bAktarClick(Sender: TObject);
var
excel, workbook, sheet:Variant;
i:Integer;
ColumnRange: Variant;
begin
with module.adoAracRapor do
begin
Close;
SQL.Clear;
SQL.Add ('select * from bt_arac_takip_formu where tarih between '+#39+DateToStr(dtBasTarih.Date)+#39);
SQL.Add (' and '+#39+DateToStr(dtBitisTarih.Date)+#39);
SQL.Add (' and arac_surucusu like'+#39+cbAracSurucu.text+#37+#39);
SQL.Add (' and guzergah like'+#39+cbGuzergah.Text+#37+#39);
SQL.Add (' and arac_plaka like'+#39+cbAracPlaka.Text+#37+#39);
SQL.Add (' and guvenlik_sorumlusu like'+#39+cbGSorumlusu.Text+#37+#39);
SQL.Add(' order by tarih');
Open;
try
if module.AdoAracRapor.RecordCount = 0 then
begin
application.messageBox('Aktarılacak kayıt bulunamadı !', 'DİKKAT', MB_OK + MB_ICONEXCLAMATION);
exit;
end;
excel := CreateOleObject('excel.application');
workbook := excel.workbooks.add;
sheet := workbook.worksheets[1];
sheet.cells[1, 1] := 'Araç Sürücüsü';
sheet.cells[1, 2] := 'Güzergah';
sheet.cells[1, 3] := 'Çıkış Tarihi';
sheet.cells[1, 4] := 'Çıkış Saati';
sheet.cells[1, 5] := 'Dönüş Tarihi';
sheet.cells[1, 6] := 'Dönüş Saati';
sheet.cells[1, 7] := 'Görevi Yazan';
sheet.cells[1, 8] := 'Araç Plaka';
sheet.cells[1, 9] := 'Açıklama';
sheet.cells[1, 10] := 'Görev Notu';
i := 1;
module.adoAracRapor.first;
while not module.adoAracRapor.eof do
begin
i := i + 1;
sheet.cells[i, 1] := module.adoAracRapor.FieldByName('arac_surucusu').asstring;
sheet.cells[i, 2] := module.adoAracRapor.FieldByName('guzergah').asstring;
sheet.cells[i, 3] := module.adoAracRapor.FieldByName('tarih').asstring;;
sheet.cells[i, 4] := module.adoAracRapor.FieldByName('saat').asstring;
sheet.cells[i, 5] := module.adoAracRapor.FieldByName('donus_tarihi').asstring;
sheet.cells[i, 6] := module.adoAracRapor.FieldByName('donus_saati').asstring;
sheet.cells[i, 7] := module.adoAracRapor.FieldByName('guvenlik_sorumlusu').asstring;
sheet.cells[i, 8] := module.adoAracRapor.FieldByName('arac_plaka').asstring;
sheet.cells[i, 9] := module.adoAracRapor.FieldByName('gorevli_aciklama').asstring;
sheet.cells[i, 10] := module.adoAracRapor.FieldByName('gorev_notu').asstring;
module.adoAracRapor.Next;
end;
excel.visible := true;
except on e:Exception do
begin
showmessage(e.Message);
close;
end;
end;
end;
end;
procedure TformAracRapor.BitBtn1Click(Sender: TObject);
var
tar1 : String;
begin
tar1:=datetostr(dtBasTarih.Date);
with module.adoAracRapor do
begin
Close;
SQL.Clear;
SQL.Add ('select * from bt_arac_takip_formu where tarih between '+#39+DateToStr(dtBasTarih.Date)+#39);
SQL.Add (' and '+#39+DateToStr(dtBitisTarih.Date)+#39);
SQL.Add (' and arac_surucusu like'+#39+cbAracSurucu.text+#37+#39);
SQL.Add (' and guzergah like'+#39+cbGuzergah.Text+#37+#39);
SQL.Add (' and arac_plaka like'+#39+cbAracPlaka.Text+#37+#39);
SQL.Add (' and guvenlik_sorumlusu like'+#39+cbGSorumlusu.Text+#37+#39);
SQL.Add(' order by tarih');
Open;
frxreport1.ShowReport();
end;
end;
procedure TformAracRapor.FormClose(Sender: TObject; var Action: TCloseAction);
begin
action := cafree;
end;
end.