//---------------------------------------------------------------------------
// For SELMA200, 20180223, moon, 예정
// 다국어 작업 필요
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "SpecialIns_Form.h"
#include "Keyboard_Form.h"
#include "Common_PC.h"
#include "Environment.h"
#include "InspectionSetup_Form.h"
//#define DAEHWAPROGRAM
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "TntExtCtrls"
#pragma link "TntStdCtrls"
#pragma resource "*.dfm"
TSpecialInsForm *SpecialInsForm;
//---------------------------------------------------------------------------
__fastcall TSpecialInsForm::TSpecialInsForm(TComponent* Owner)
  : TForm(Owner)
{
  TntStaticText7->Caption = "차례로 입력한 순서대로 선별 됩니다." ;
}
//---------------------------------------------------------------------------
void __fastcall TSpecialInsForm::SpecialCount1Click(TObject *Sender)
{
	TTntEdit *theEdit = (TTntEdit *) Sender;

	KeyboardForm->Text = theEdit->Text;
  if (KeyboardForm->ShowKeypad() == mrOk)
  {
		theEdit->Text = KeyboardForm->Text;
  }
}
//---------------------------------------------------------------------------

void __fastcall TSpecialInsForm::SpecialCount2Click(TObject *Sender)
{
	TTntEdit *theEdit = (TTntEdit *) Sender;

	KeyboardForm->Text = theEdit->Text;
  if (KeyboardForm->ShowKeypad() == mrOk)
  {
		theEdit->Text = KeyboardForm->Text;
  }
}
//---------------------------------------------------------------------------

void __fastcall TSpecialInsForm::SpecialCount3Click(TObject *Sender)
{
	TTntEdit *theEdit = (TTntEdit *) Sender;

	KeyboardForm->Text = theEdit->Text;
  if (KeyboardForm->ShowKeypad() == mrOk)
  {
		theEdit->Text = KeyboardForm->Text;
  }
}
//---------------------------------------------------------------------------

void __fastcall TSpecialInsForm::SpecialCount4Click(TObject *Sender)
{
	TTntEdit *theEdit = (TTntEdit *) Sender;

	KeyboardForm->Text = theEdit->Text;
  if (KeyboardForm->ShowKeypad() == mrOk)
  {
		theEdit->Text = KeyboardForm->Text;
  }
}
//---------------------------------------------------------------------------

void __fastcall TSpecialInsForm::SpecialCount5Click(TObject *Sender)
{
	TTntEdit *theEdit = (TTntEdit *) Sender;

	KeyboardForm->Text = theEdit->Text;
  if (KeyboardForm->ShowKeypad() == mrOk)
  {
		theEdit->Text = KeyboardForm->Text;
  }
}
//---------------------------------------------------------------------------

void __fastcall TSpecialInsForm::SpecialCount6Click(TObject *Sender)
{
	TTntEdit *theEdit = (TTntEdit *) Sender;

	KeyboardForm->Text = theEdit->Text;
  if (KeyboardForm->ShowKeypad() == mrOk)
  {
		theEdit->Text = KeyboardForm->Text;
  }
}
//---------------------------------------------------------------------------

void __fastcall TSpecialInsForm::OKBtnClick(TObject *Sender)
{
  ProductData.SpecialInsCount[0] = StrToInt(SpecialCount1->Text);
  ProductData.SpecialInsCount[1] = StrToInt(SpecialCount2->Text);
  ProductData.SpecialInsCount[2] = StrToInt(SpecialCount3->Text);
  ProductData.SpecialInsCount[3] = StrToInt(SpecialCount4->Text);
  ProductData.SpecialInsCount[4] = StrToInt(SpecialCount5->Text);
  ProductData.SpecialInsCount[5] = StrToInt(SpecialCount6->Text);
  AnsiString fileName = GetProductDataFileName(ProductData.ProductCode);
	WriteProductData(fileName, ProductData);
}
//---------------------------------------------------------------------------

void __fastcall TSpecialInsForm::FormCreate(TObject *Sender)
{
  TProductData tempProductData;
  AnsiString fileName = GetProductDataFileName(ProductData.ProductCode);
	ReadProductData(fileName, tempProductData, MachineParams, MachineSetupData);

  SpecialCount1->Text = IntToStr(ProductData.SpecialInsCount[0]);
  SpecialCount2->Text = IntToStr(ProductData.SpecialInsCount[1]);
  SpecialCount3->Text = IntToStr(ProductData.SpecialInsCount[2]);
  SpecialCount4->Text = IntToStr(ProductData.SpecialInsCount[3]);
  SpecialCount5->Text = IntToStr(ProductData.SpecialInsCount[4]);
  SpecialCount6->Text = IntToStr(ProductData.SpecialInsCount[5]);
}
//---------------------------------------------------------------------------

