//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "MlekaraMain.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "cxClasses"
#pragma link "cxControls"
#pragma link "cxCustomData"
#pragma link "cxData"
#pragma link "cxDataStorage"
#pragma link "cxDBData"
#pragma link "cxEdit"
#pragma link "cxFilter"
#pragma link "cxGraphics"
#pragma link "cxGrid"
#pragma link "cxGridCustomTableView"
#pragma link "cxGridCustomView"
#pragma link "cxGridDBTableView"
#pragma link "cxGridLevel"
#pragma link "cxGridTableView"
#pragma link "cxLookAndFeelPainters"
#pragma link "cxLookAndFeels"
#pragma link "cxNavigator"
#pragma link "cxStyles"
#pragma link "dxSkinBlack"
#pragma link "dxSkinBlue"
#pragma link "dxSkinBlueprint"
#pragma link "dxSkinCaramel"
#pragma link "dxSkinCoffee"
#pragma link "dxSkinDarkRoom"
#pragma link "dxSkinDarkSide"
#pragma link "dxSkinDevExpressDarkStyle"
#pragma link "dxSkinDevExpressStyle"
#pragma link "dxSkinFoggy"
#pragma link "dxSkinGlassOceans"
#pragma link "dxSkinHighContrast"
#pragma link "dxSkiniMaginary"
#pragma link "dxSkinLilian"
#pragma link "dxSkinLiquidSky"
#pragma link "dxSkinLondonLiquidSky"
#pragma link "dxSkinMcSkin"
#pragma link "dxSkinMoneyTwins"
#pragma link "dxSkinOffice2007Black"
#pragma link "dxSkinOffice2007Blue"
#pragma link "dxSkinOffice2007Green"
#pragma link "dxSkinOffice2007Pink"
#pragma link "dxSkinOffice2007Silver"
#pragma link "dxSkinOffice2010Black"
#pragma link "dxSkinOffice2010Blue"
#pragma link "dxSkinOffice2010Silver"
#pragma link "dxSkinOffice2013White"
#pragma link "dxSkinPumpkin"
#pragma link "dxSkinsCore"
#pragma link "dxSkinscxPCPainter"
#pragma link "dxSkinsDefaultPainters"
#pragma link "dxSkinSeven"
#pragma link "dxSkinSevenClassic"
#pragma link "dxSkinSharp"
#pragma link "dxSkinSharpPlus"
#pragma link "dxSkinSilver"
#pragma link "dxSkinSpringTime"
#pragma link "dxSkinStardust"
#pragma link "dxSkinSummer2008"
#pragma link "dxSkinTheAsphaltWorld"
#pragma link "dxSkinValentine"
#pragma link "dxSkinVS2010"
#pragma link "dxSkinWhiteprint"
#pragma link "dxSkinXmas2008Blue"
#pragma link "cxGridChartView"
#pragma link "cxGridDBChartView"
#pragma link "cxContainer"
#pragma link "cxGridCardView"
#pragma link "cxGridCustomLayoutView"
#pragma link "cxGridDBCardView"
#pragma link "cxGroupBox"
#pragma link "cxPC"
#pragma link "cxPCdxBarPopupMenu"
#pragma link "frxClass"
#pragma link "cxCalendar"
#pragma link "cxDBEdit"
#pragma link "cxDropDownEdit"
#pragma link "cxLabel"
#pragma link "cxMaskEdit"
#pragma link "cxTextEdit"
#pragma link "cxButtons"
#pragma link "AdvDateTimePicker"
#pragma link "cxDBLookupComboBox"
#pragma link "cxDBLookupEdit"
#pragma link "cxLookupEdit"
#pragma link "frxDBSet"
#pragma link "cxDrawTextUtils"
#pragma link "dxBkgnd"
#pragma link "dxPrnDev"
#pragma link "dxPrnPg"
#pragma link "dxPSCompsProvider"
#pragma link "dxPSCore"
#pragma link "dxPScxCommon"
#pragma link "dxPScxEditorProducers"
#pragma link "dxPScxExtEditorProducers"
#pragma link "dxPScxGridLayoutViewLnk"
#pragma link "dxPScxGridLnk"
#pragma link "dxPScxPageControlProducer"
#pragma link "dxPSEdgePatterns"
#pragma link "dxPSEngn"
#pragma link "dxPSFillPatterns"
#pragma link "dxPSGlbl"
#pragma link "dxPSPDFExport"
#pragma link "dxPSPDFExportCore"
#pragma link "dxPSPrVwAdv"
#pragma link "dxPSPrVwRibbon"
#pragma link "dxPSPrVwStd"
#pragma link "dxPSUtl"
#pragma link "dxSkinsdxBarPainter"
#pragma link "dxSkinsdxRibbonPainter"
#pragma link "dxWrap"
#pragma link "dxPSContainerLnk"
#pragma resource "*.dfm"
TMainForm *MainForm;
//---------------------------------------------------------------------------
__fastcall TMainForm::TMainForm(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------


void __fastcall TMainForm::btNewClick(TObject *Sender)
{
	db->cdsArtikli->Append();
	AdvDateTimePicker1->DateTime = Now();
	AdvDateTimePicker2->DateTime = Now();
	db->cdsArtikli->FieldByName("od")->AsDateTime = Now();
	db->cdsArtikli->FieldByName("do")->AsDateTime = Now();
}
//---------------------------------------------------------------------------


void __fastcall TMainForm::btSaveClick(TObject *Sender)
{
	db->cdsArtikli->Post();
}
//---------------------------------------------------------------------------


void __fastcall TMainForm::FormShow(TObject *Sender)
{
	db->openArtikliCds();
	db->cdsUredjaj->Active = false;
	db->cdsUredjaj->Active = true;
	db->dsArtikli->OnDataChange = &ArtikliDataChange;

}
//---------------------------------------------------------------------------
void __fastcall TMainForm::ArtikliDataChange(TObject *Sender, TField *Field)
{
	if (Field == NULL) {

		db->cdsStampa->Active = false;
		db->sdsStampa->ParamByName("ID")->AsInteger = db->cdsArtikli->FieldByName("id_uredjaja")->AsInteger;
		db->sdsStampa->ParamByName("D1")->AsDateTime = db->cdsArtikli->FieldByName("OD")->AsDateTime;
		db->sdsStampa->ParamByName("D2")->AsDateTime = db->cdsArtikli->FieldByName("DO")->AsDateTime;
		db->cdsStampa->Active = true;
		cxGrid7DBChartView1->Title->Text = "Vreme merenje u satima za posudu "+IntToStr(db->cdsArtikli->FieldByName("id_uredjaja")->AsInteger);


		AdvDateTimePicker1->DateTime = db->cdsArtikli->FieldByName("od")->AsDateTime;
		AdvDateTimePicker2->DateTime = db->cdsArtikli->FieldByName("do")->AsDateTime;
		cxLabel6->Caption = db->cdsArtikli->FieldByName("Artikal")->AsString;
		cxLabel16->Caption = db->cdsArtikli->FieldByName("Kolicina")->AsString;
		cxLabel15->Caption = db->cdsArtikli->FieldByName("od")->AsString;
		cxLabel14->Caption = db->cdsArtikli->FieldByName("do")->AsString;
		cxLabel13->Caption = 200;
		cxLabel11->Caption = db->cdsArtikli->FieldByName("zadata_temperatura")->AsString;
	}
}
void __fastcall TMainForm::AdvDateTimePicker1Change(TObject *Sender)
{
	db->cdsArtikli->FieldByName("od")->AsDateTime = AdvDateTimePicker1->DateTime;
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::AdvDateTimePicker2Change(TObject *Sender)
{
	db->cdsArtikli->FieldByName("do")->AsDateTime = AdvDateTimePicker2->DateTime;
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::cxButton1Click(TObject *Sender)
{
	cxGroupBox8->Visible = false;
	dxComponentPrinter1->RebuildReport();
	dxComponentPrinter1->Print(false,NULL,NULL);
	cxGroupBox8->Visible = true;
}
//---------------------------------------------------------------------------

