unit maliyetyerleriraporu_;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, glWizardHeader, cxStyles, cxCustomData, cxGraphics,
  cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, StdCtrls,
  cxGridLevel, cxClasses, cxControls, cxGridCustomView,
  cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGrid, Menus,
  dxCore, dxButtons, mySQLDbTables, unit1, unitgenel, RxMemDS, pr_Common,
  pr_Classes,ComObj, ShellApi;

type
  Tmaliyetyerleriraporu = class(TForm)
    glWizardHeader1: TglWizardHeader;
    Panel1: TPanel;
    Panel2: TPanel;
    cxGrid1: TcxGrid;
    cxGrid1DBTableView1: TcxGridDBTableView;
    cxGrid1Level1: TcxGridLevel;
    GroupBox1: TGroupBox;
    dxButton1: TdxButton;
    dxButton2: TdxButton;
    dxButton3: TdxButton;
    dxButton4: TdxButton;
    PopupMenu1: TPopupMenu;
    Listele1: TMenuItem;
    Yazdr1: TMenuItem;
    Excell1: TMenuItem;
    k1: TMenuItem;
    FormDizayn1: TMenuItem;
    GroupBox2: TGroupBox;
    Label8: TLabel;
    GroupBox3: TGroupBox;
    Edit1: TEdit;
    Edit2: TEdit;
    Genelgider: TmySQLQuery;
    DataSource1: TDataSource;
    GenelgiderSIRKOD: TStringField;
    GenelgiderKODU: TFloatField;
    GenelgiderDONEM: TFloatField;
    GenelgiderADI: TStringField;
    GenelgiderYASITMAMUHASEBEKODU: TStringField;
    GenelgiderBUTCEFARKIMUHASEBEKODU: TStringField;
    GenelgiderKAPASITEFARKIMUHASEBEKODU: TStringField;
    GenelgiderVERIMLILIKMUHASEBEKODU: TStringField;
    GenelgiderYASITMAMASRAF: TStringField;
    GenelgiderBUTCEMASRAF: TStringField;
    GenelgiderKAPASITEMASRAF: TStringField;
    GenelgiderVERIMLILIKMASRAF: TStringField;
    cxGrid1DBTableView1KODU: TcxGridDBColumn;
    cxGrid1DBTableView1ADI: TcxGridDBColumn;
    cxGrid1DBTableView1YASITMAMUHASEBEKODU: TcxGridDBColumn;
    cxGrid1DBTableView1BUTCEFARKIMUHASEBEKODU: TcxGridDBColumn;
    cxGrid1DBTableView1KAPASITEFARKIMUHASEBEKODU: TcxGridDBColumn;
    cxGrid1DBTableView1VERIMLILIKMUHASEBEKODU: TcxGridDBColumn;
    raporozeti: TRxMemoryData;
    raporozetiSIRKET: TStringField;
    raporozetiDONEM: TStringField;
    prReport1: TprReport;
    procedure dxButton4Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure Edit1KeyPress(Sender: TObject; var Key: Char);
    procedure Edit1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure Edit1KeyUp(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure Edit2KeyUp(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure Edit2KeyPress(Sender: TObject; var Key: Char);
    procedure dxButton1Click(Sender: TObject);
    procedure Edit2KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure FormDizayn1Click(Sender: TObject);
    procedure dxButton2Click(Sender: TObject);
    procedure dxButton3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  maliyetyerleriraporu: Tmaliyetyerleriraporu;

implementation

uses genelgiderlistesi_;

{$R *.dfm}

procedure Tmaliyetyerleriraporu.dxButton4Click(Sender: TObject);
begin
close;

end;

procedure Tmaliyetyerleriraporu.FormShow(Sender: TObject);
begin
edit1.SetFocus;
end;

procedure Tmaliyetyerleriraporu.Edit1KeyPress(Sender: TObject;
  var Key: Char);
begin
UGEditKeyPress(Sender,Key);
end;

procedure Tmaliyetyerleriraporu.Edit1KeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
UGEditKeyDown(Sender,Key,Shift);
if key=13 then edit2.SetFocus;
end;

procedure Tmaliyetyerleriraporu.Edit1KeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if key=13  then edit2.SetFocus;
  if key=122 then
    begin
      Application.CreateForm(Tgenelgiderlistesi, genelgiderlistesi);
      if (genelgiderlistesi.ShowModal=mrok) then
        begin
          edit1.Text:=genelgiderlistesi.genelgiderkartiKODU.text;
          genelgiderlistesi.Free;
        end;
        edit1.SetFocus;
    end;
end;

procedure Tmaliyetyerleriraporu.Edit2KeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if key=13  then dxButton1.SetFocus;
  if key=122 then
    begin
      Application.CreateForm(Tgenelgiderlistesi, genelgiderlistesi);
      if (genelgiderlistesi.ShowModal=mrok) then
        begin
          edit2.Text:=genelgiderlistesi.genelgiderkartiKODU.text;
          genelgiderlistesi.Free;
        end;
        edit2.SetFocus;
    end;
end;

procedure Tmaliyetyerleriraporu.Edit2KeyPress(Sender: TObject;
  var Key: Char);
begin
UGEditKeyPress(Sender,Key);
if key=#13 then dxButton1.SetFocus;
end;

procedure Tmaliyetyerleriraporu.dxButton1Click(Sender: TObject);
begin
///////STOK KODU////////
     if Edit1.Text='' then
       Edit1.Text:='0';
     if Edit2.Text='' then
       Edit2.Text:='99999999';
     raporozeti.Edit;
     raporozetiSIRKET.Value:=sb.SirketAdi;
     raporozetiDONEM.Text:=datetostr(sb.balangictarihi)+'--'+ datetostr(sb.bitistarihi);
     raporozeti.Post;

     Genelgider.Close;
     Genelgider.ParamByName('XSIRKOD').Value:=sb.SirKod;
     Genelgider.ParamByName('XDONEM').Value:=sb.donem;
     Genelgider.ParamByName('XBKODU').Text:=edit1.Text;
     Genelgider.ParamByName('XSKODU').Text:=edit2.Text;
     Genelgider.ExecSQL;
     Genelgider.Open;
     if Genelgider.IsEmpty then
       begin
       showmessage('Belirtilen Aralıkta Bilgi Bulunamadı');
       edit1.SetFocus;
       exit;
       end;






end;

procedure Tmaliyetyerleriraporu.Edit2KeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
UGEditKeyDown(Sender,Key,Shift);
end;

procedure Tmaliyetyerleriraporu.FormDizayn1Click(Sender: TObject);
var
path:string;
begin
  Path := ExtractFilePath(ParamStr(0));
  prReport1.LoadTemplateFromFile(path+'WRAPOR\Genelgiderkartlari.prt',false);
  prReport1.DesignReport(false);
end;

procedure Tmaliyetyerleriraporu.dxButton2Click(Sender: TObject);
var
sayi:string;
path:string;
begin
  if Genelgider.IsEmpty then
    begin
    showmessage('Ekranda Yazdırılacak Bilgi Yok');
    exit;
    end;

  Path := ExtractFilePath(ParamStr(0));
  prReport1.LoadTemplateFromFile(path+'WRAPOR\Genelgiderkartlari.prt',false);
  prReport1.PrepareReport;
  prReport1.PreviewPreparedReport(false);
end;
procedure Tmaliyetyerleriraporu.dxButton3Click(Sender: TObject);
begin

 if Genelgider.IsEmpty then
   begin
   showmessage('Ekranda Aktarılacak Bilgi Yok');
   exit;
   end;
 if Kaynak.save.Execute then DBGridToExcell(Kaynak.save,cxGrid1DBTableView1,Kaynak.save.FileName );

end;

end.
