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

#include <vcl.h>
#pragma hdrstop

#include "HR_SpecialForm.h"
#include "Keyboard_Form.h"
#include "Common_PC.h"
#include "Environment.h"
#include "InspectionSetup_Form.h"
//#include "ComputerSystemSetting_Form.h"

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "TntExtCtrls"
#pragma link "TntStdCtrls"
#pragma resource "*.dfm"

THR_SpecialInsForm *HR_SpecialInsForm;
//---------------------------------------------------------------------------
__fastcall THR_SpecialInsForm::THR_SpecialInsForm(TComponent* Owner)
	: TForm(Owner)
{
	TntLabel1->Caption = "분배기 당 정제 수량을 입력 하세요.";
    TntLabel3->Caption = "전체 분배기 통 갯수를 입력 하세요.";

    TntLabel1->Width = 353;
    TntLabel2->Width = 105;
	TntLabel3->Width = 353;
    TntLabel5->Width = 160;
}
//---------------------------------------------------------------------------
void __fastcall THR_SpecialInsForm::FormCreate(TObject *Sender)
{
  TProductData tempProductData;

  AnsiString fileName = GetProductDataFileName(ProductData.ProductCode);
  ReadProductData(fileName, tempProductData, MachineParams, MachineSetupData);

  HrSpecialCount1->Text = IntToStr(ProductData.SpecialInsCount[0]);
  HrSpecialCount2->Text = IntToStr(ProductData.SpecialInsCount[1]);
  if(ProductData.SpecialInsCount[2] == 1)
  {
  		LotCheckBox1->Checked = true;
  }
  else
  {
        LotCheckBox1->Checked = false;
  }



  TntLabel1->Width = 353;
  TntLabel2->Width = 105;
  TntLabel3->Width = 353;
  TntLabel5->Width = 160;

  TntLabel2->Height = 25;
}
//---------------------------------------------------------------------------
void __fastcall THR_SpecialInsForm::HrSpecialCount1Click(TObject *Sender)
{
	TTntEdit *theEdit = (TTntEdit *) Sender;

	KeyboardForm->Text = theEdit->Text;
    if (KeyboardForm->ShowKeypad() == mrOk)
    {
		theEdit->Text = KeyboardForm->Text;
    }
}
//---------------------------------------------------------------------------
void __fastcall THR_SpecialInsForm::HrSpecialCount2Click(TObject *Sender)
{
	TTntEdit *theEdit = (TTntEdit *) Sender;

	KeyboardForm->Text = theEdit->Text;
    if (KeyboardForm->ShowKeypad() == mrOk)
    {
		theEdit->Text = KeyboardForm->Text;
    }  
}
//---------------------------------------------------------------------------
void __fastcall THR_SpecialInsForm::HROKBtnClick(TObject *Sender)
{
  	ProductData.SpecialInsCount[0] = StrToInt(HrSpecialCount1->Text);
    ProductData.SpecialInsCount[1] = StrToInt(HrSpecialCount2->Text);
    if(LotCheckBox1->Checked)
    {
    	ProductData.SpecialInsCount[2] = 1;
    }
    else
    {
       ProductData.SpecialInsCount[2] = 0;
    }
    ProductData.SpecialInsCount[3] = 0;
    ProductData.SpecialInsCount[4] = 0;
    ProductData.SpecialInsCount[5] = 0;

    AnsiString fileName = GetProductDataFileName(ProductData.ProductCode);
	  WriteProductData(fileName, ProductData);

    this->Close();
}
//---------------------------------------------------------------------------
void __fastcall THR_SpecialInsForm::HRCancelBtnClick(TObject *Sender)
{
	this->Close();
}
//---------------------------------------------------------------------------

void __fastcall THR_SpecialInsForm::FormActivate(TObject *Sender)
{
  TProductData tempProductData;

  AnsiString fileName = GetProductDataFileName(ProductData.ProductCode);
  ReadProductData(fileName, tempProductData, MachineParams, MachineSetupData);

  HrSpecialCount1->Text = IntToStr(tempProductData.SpecialInsCount[0]);
  HrSpecialCount2->Text = IntToStr(tempProductData.SpecialInsCount[1]);
  if(tempProductData.SpecialInsCount[2] == 1)
  {
  		LotCheckBox1->Checked = true;
  }
  else
  {
        LotCheckBox1->Checked = false;
  }
}
//---------------------------------------------------------------------------

