//---------------------------------------------------------------------------
// 이력서는 양식은 모든 업체들이 변경에 대하여 민감하므로 충분한 고려와 상의 후 변경이 필요함
// Skip

#include <vcl.h>     
#include <inifiles.hpp>
#pragma hdrstop

#include "PrintInspectionResult_Form.h"
#include "Environment.h"
#include "MultiLanguage.h"
#include "AbstractDB.h"    
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "TntExtCtrls"
#pragma link "TntStdCtrls"
#pragma resource "*.dfm"
TPrintInspectionResultForm *PrintInspectionResultForm;
//---------------------------------------------------------------------------
__fastcall TPrintInspectionResultForm::TPrintInspectionResultForm(TComponent* Owner)
	: TTntForm(Owner)
{
	if (DefaultLCID == 1028 || DefaultLCID == 2052 || DefaultLCID == 3076 || DefaultLCID == 4100)
		ComponentSetFontName(this, "SimSun");
	else if (DefaultLCID == 1041)
		ComponentSetFontName(this, "Meiryo UI");
  else if(DefaultLCID == 3082)
  {
    ComponentSetFontName(this, "Segoe UI");
    ComponentSetMultiLine(this);
  }

  // report custom (영진- YJ)
	TIniFile *iniFile = new TIniFile(ProgramPath.Env + "\\MachineInfor.ini");
  MachineName = iniFile->ReadString("Machine Information","Machine Name","SELMA-200");
  delete iniFile;

	PrintPreviewButton->Caption = V6_REPORT_PRINT_FORM_ADD_04;
	PrinterSetupButton->Caption = V6_REPORT_PRINT_FORM_ADD_05;
	PrintButton->Caption = V6_REPORT_PRINT_FORM_ADD_06;
	CancelButton->Caption = V6_REPORT_PRINT_FORM_ADD_07;
	SelectDefectImageButton->Caption = V6_REPORT_PRINT_FORM_ADD_09;  // "이미지 선택";//    
	DefectImagePrintLabel->Caption = V6_REPORT_PRINT_FORM_ADD_13;  // "이미지 선택";//

	PrintDefectSeriesCheckBox->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_23;
	QRSignatureDone3->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_26;
	QRSignatureDone4->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_26;
	QRSignatureDone6->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_26;

	QRSignatureCheck3->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_27;
	QRSignatureCheck4->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_27;
	QRSignatureCheck6->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_27;

	QRSignatureReview3->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_25;
	QRSignatureReview4->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_25;
	QRSignatureReview6->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_25;

	QRSignatureDate13->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_29;
	QRSignatureDate14->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_29;
	QRSignatureDate23->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_29;
	QRSignatureDate24->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_29;
	QRSignatureDate33->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_29;
	QRSignatureDate34->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_29;
	QRSignatureDate16->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_29;
	QRSignatureDate26->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_29;
	QRSignatureDate36->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_29;

	QRPage2Title->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_24;
	QRChartLabel->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_28;
                                      
	QRDefectNameLabel1->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_30;
	QRDefectNameLabel2->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_30;
	QRDefectNameLabel3->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_30;
	QRDefectNameLabel4->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_30;
	QRDefectNameLabel5->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_30;
	QRDefectNameLabel6->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_30;
	QRDefectSizeLabel1->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_31;
	QRDefectSizeLabel2->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_31;
	QRDefectSizeLabel3->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_31;
	QRDefectSizeLabel4->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_31;
	QRDefectSizeLabel5->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_31;
	QRDefectSizeLabel6->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_31;

	QRInspectionSpeedLabel->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_32;
	QRLabel107->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_33;
	QRLabel108->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_34;

	PageList = new TTntStringList();
	PageList->Add("QuickRep1");

  GroupBox1->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_59;
  PrintGradeAndSizeRadioButton->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_58;
  PrintGradeOnlyRadioButton->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_57;
  GroupBox3->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_64;
  PrintPreviewButton->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_60;
  PrinterSetupButton->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_61;
  PrintButton->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_62;
  CancelButton->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_63;
}
void __fastcall TPrintInspectionResultForm::GetDefalutString()
{
  ///////////////[Title]///////////////
  //Inspection Result Report

  QRLabel1->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_02;
	QRLabel101->Caption =PRINTINSPECTIONRESULTFORM_UNKNOWN_02;
	QRLabel152->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_02;
	QRLabel234->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_02;

  // Ins Info
  QRLabel7->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_04;
  QRLabel40->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_04;
  QRLabel75->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_04;
  QRLabel155->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_04;

  // Product Name
  QRLabel3->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_20;
  QRLabel35->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_20;
  QRLabel46->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_20;
  QRLabel153->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_20;

  // Lot Name
  QRLabel2->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_19;
  QRLabel50->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_19;
  QRLabel78->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_19;
  QRLabel165->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_19;

  // Lot Unit
  QRLabel4->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_18;
  QRLabel51->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_18;
  QRLabel79->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_18;
  QRLabel166->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_18;

  // Ins Start 
  QRLabel5->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_06;
  QRLabel39->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_06;
  QRLabel62->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_06;
  QRLabel154->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_06;

  // Ins End
  QRLabel20->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_07;
	QRLabel60->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_07;
	QRLabel87->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_07;
	QRLabel175->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_07;

  // Operator
  QRLabel6->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_17;
	QRLabel53->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_17;
	QRLabel81->Caption =PRINTINSPECTIONRESULTFORM_UNKNOWN_17;
	QRLabel168->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_17;

  // Confirm
  QRLabel13->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_22;
  QRLabel90->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_22;
  QRLabel118->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_22;
  QRLabel205->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_22;

  ///////////////[Middle]///////////////
  // Ins Grade
  QRLabel49->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_05;
  QRLabel59->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_05;
  QRLabel138->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_05;
  QRLabel174->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_05;

  // Top Ins Grade
  QRLabel54->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_11;
  QRLabel64->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_11;
  QRLabel140->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_11;
  QRLabel179->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_11;

  //"Normal Dark Dirty";
  QRLabel23->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_15;
  QRLabel65->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_15;
  QRLabel94->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_15;
  QRLabel180->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_15;

  //"Carve Dark Dirty";
  QRLabel24->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_01;
  QRLabel66->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_01;
  QRLabel95->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_01;
  QRLabel181->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_01;

  //"Edge Dark Dirty";
  QRLabel25->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_08;
  QRLabel67->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_08;
  QRLabel96->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_08;
  QRLabel182->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_08;

  //"Normal blurred Stain";
  QRLabel26->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_16;
  QRLabel68->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_16;
  QRLabel98->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_16;
  QRLabel183->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_16;

  //"Edge blurred Stain";
  QRLabel37->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_09;
  QRLabel93->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_09;
  QRLabel121->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_09;
  QRLabel208->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_09;

  // "Color Stain"; 2D with 3D
  QRLabel16->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_10;
  QRLabel17->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_10;
  QRLabel91->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_10;
  QRLabel44->Caption  = PRINTINSPECTIONRESULTFORM_UNKNOWN_10;
  QRLabel119->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_10;
  QRLabel144->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_10;
  QRLabel206->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_10;
  QRLabel224->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_10;

  //"Side Ins Grade";
  QRLabel57->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_21;
  QRLabel70->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_21;
  QRLabel141->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_21;
  QRLabel185->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_21;

  //"Side Dark Dirty";
  QRLabel29->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_35;
  QRLabel71->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_35;
  QRLabel102->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_35;
  QRLabel186->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_35;

  //"Side blurred Stain";
  QRLabel30->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_36;
  QRLabel72->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_36;
  QRLabel103->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_36;
  QRLabel187->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_36;

  // Side N Edge Blur or Spot
  QRLabel22->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_37;
	QRLabel12->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_37;
	QRLabel149->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_37;
	QRLabel230->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_37;

  //  Edge Blur or Spot
  SideNLabel1->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_38;
  SideNLabel3->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_38;
  SideNLabel5->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_38;
  SideNLabel7->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_38;

  SideNLabel2->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_39;
  SideNLabel4->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_39;
  SideNLabel6->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_39;
  SideNLabel8->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_39;

  QRLabel31->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_40;
  QRLabel73->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_40;
  QRLabel104->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_40;
  QRLabel188->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_40;

  //other Title
  QRLabel52->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_46;
  QRLabel63->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_46;
  QRLabel139->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_46;
  QRLabel178->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_46;

  //3d
  QRLabel19->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_41;
  QRLabel85->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_41;
  QRLabel113->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_41;
  QRLabel200->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_41;

  // 3D 모서리영역
  QRLabel27->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_42;
  QRLabel69->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_42;
  QRLabel100->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_42;
  QRLabel184->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_42;

  QRLabel34->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_43;
  QRLabel86->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_43;
  QRLabel114->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_43;
  QRLabel201->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_43;

  QRLabel36->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_44;
  QRLabel88->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_44;
  QRLabel116->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_44;
  QRLabel203->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_44;

  QRLabel18->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_45;
  QRLabel97->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_45;
  QRLabel124->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_45;
  QRLabel211->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_45;

  QRLabel8->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_47;
  QRLabel41->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_47;
  QRLabel128->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_47;
  QRLabel156->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_47;

  QRLabel48->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_53;
  QRLabel58->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_53;
  QRLabel137->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_53;
  QRLabel173->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_53;

  QRLabel33->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_48;
  QRLabel55->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_48;
  QRLabel135->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_48;
  QRLabel170->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_48;

  QRLabel9->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_49;
  QRLabel42->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_49;
  QRLabel129->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_49;
  QRLabel157->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_49;

  QRLabel10->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_50;
  QRLabel43->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_50;
  QRLabel130->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_50;
  QRLabel158->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_50;

  QRLabel61->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_51;
  QRLabel83->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_51;
	QRLabel142->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_51;
  QRLabel198->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_51;

  QRLabel47->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_52;
	QRLabel56->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_52;
  QRLabel136->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_52;
  QRLabel171->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_52;

  if(MachineSetupData.CompanyID == INTERNATIONAL_MACHINE1)
  {
    QRQuantityLabelTitle1->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_68;
    QRQuantityLabelTitle2->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_68;
    DefectSeriesLabel3->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_68;
    DefectSeriesLabel33->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_68;
    DefectSeriesLabel6->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_68;
    DefectSeriesLabel66->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_68;
  }
  else
  {
    QRQuantityLabelTitle1->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_53;
    QRQuantityLabelTitle2->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_53;
    DefectSeriesLabel3->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_53;
    DefectSeriesLabel33->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_53;
    DefectSeriesLabel6->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_53;
    DefectSeriesLabel66->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_53;
  }

  QRRateLabelTitle1->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_55;
  QRRateLabelTitle2->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_55;

  QRItemLabelTitle1->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_54;
  QRItemLabelTitle2->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_54;

  /**************************************************************************/
  DefectSeriesLabel1->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_56;
  DefectSeriesLabel11->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_56;

  DefectSeriesLabel2->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_54;
  DefectSeriesLabel22->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_54;
    DefectSeriesLabel5->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_54;
  DefectSeriesLabel55->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_54;

  DefectSeriesLabel7->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_55;
  DefectSeriesLabel77->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_55;
    DefectSeriesLabel4->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_55;
  DefectSeriesLabel44->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_55;

  /**************************************************************************/

}
//---------------------------------------------------------------------------// TTabletInspectReport tabletInspectReport, TTabletInspectGradeData tabletInspectGradeData, int *tempDefectSeriesCount,
void __fastcall TPrintInspectionResultForm::SetReport(WideString productName, WideString lotName,
  NFA_INSPECTION_REPORT_STRUCT REPORT, bool isPrintedTablet,int printModeOption, int threeDHeightOption, bool hIprogram)
{
  GetDefalutString();

  globalIsPrintedTablet = isPrintedTablet;

	SetThroughtputChart(ProductData.ProductCode, lotName);

  ProductName = ProductData.ProductCode;
	LOTName = lotName;

  Report = REPORT;
  memcpy(DefectSeriesCount, Report.DefectSeriesCount.DefectSeriesCount, (MAX_DEFECT_SERIES_COUNT + 1) * sizeof(int));
  
  SetDefectInfoPage2();

	ProductQRLabel1->Caption = productName;
	ProductQRLabel2->Caption = productName;
	ProductQRLabel3->Caption = productName;
	ProductQRLabel4->Caption = productName;

  for (int i = 0; i < 4; ++i)
	{
		const int validWidth = 150;
		if (((TQRLabel*)FindComponent("ProductQRLabel" + IntToStr(i+1)))->Width > validWidth)
		{
			TQRLabel *dstLabel= ((TQRLabel*)FindComponent("ProductQRLabel" + IntToStr(i+1)));
			dstLabel->Caption = "";

			AnsiString tmpStr = AnsiString(productName);
			AnsiString applyText = "";
			int textString = tmpStr.Length();

			char *strBuff = new char[textString + 1];
			memset(strBuff, 0, sizeof(char) * textString + 1);
			strcpy(strBuff, tmpStr.c_str());

			int StringOverflowCount = 0;

			for (int strLength = 0; strLength < textString; strLength++)
			{
				bool Kor = false;
				if (strBuff[strLength] & 0x80)
				{
					applyText += strBuff[strLength];
					applyText += strBuff[strLength + 1];
					Kor = true;
					++strLength;
				}
				else
				{
					applyText += strBuff[strLength];
				}

				dstLabel->Caption = applyText;

				if (dstLabel->Width > validWidth)
				{
					StringOverflowCount++;
					if (StringOverflowCount > 2)
					{
						if (Kor)
							applyText.Delete(applyText.Length() - 1, 2);
						else
							applyText.Delete(applyText.Length(), 1);
						break;
					}

					applyText.Insert("\r\n", (strLength + 2 * (StringOverflowCount - 1)));

				}
			}

			delete strBuff;

			dstLabel->Caption = applyText;
      dstLabel->Left = 10;

		}
		else
		{
			((TQRLabel*)FindComponent("ProductQRLabel" + IntToStr(i+1)))->Alignment = taCenter;
			((TQRLabel*)FindComponent("ProductQRLabel" + IntToStr(i+1)))->Width = 158;
      ((TQRLabel*)FindComponent("ProductQRLabel" + IntToStr(i+1)))->Left = 10;
      ((TQRLabel*)FindComponent("ProductQRLabel" + IntToStr(i+1)))->AutoSize = false;
		}
	}

	QRRichText0->Caption = LOTName;
	QRRichText2->Caption = LOTName;
	QRRichText1->Caption = LOTName;
	QRRichText3->Caption = LOTName;

	for (int i = 0; i < 4; ++i)
	{
		const int validWidth = 80;
		if (((TQRLabel*)FindComponent("QRRichText" + IntToStr(i)))->Width > validWidth)
		{
			TQRLabel *dstLabel = ((TQRLabel*)FindComponent("QRRichText" + IntToStr(i)));
			dstLabel->Caption = "";

			AnsiString tmpStr = AnsiString(lotName);
			AnsiString applyText = "";
			int textString = tmpStr.Length();

			char *strBuff = new char[textString + 1];
			memset(strBuff, 0, sizeof(char) * textString + 1);
			strcpy(strBuff, tmpStr.c_str());

			int StringOverflowCount = 0;

			for (int strLength = 0; strLength < textString; strLength++)
			{
				bool Kor = false;
				if (strBuff[strLength] & 0x80)
				{
					applyText += strBuff[strLength];
					applyText += strBuff[strLength + 1];
					Kor = true;
					++strLength;
				}
				else
				{
					applyText += strBuff[strLength];
				}

				dstLabel->Caption = applyText;

				if (dstLabel->Width > validWidth)
				{
					StringOverflowCount++;
					if (StringOverflowCount > 2)
					{
						if (Kor)
							applyText.Delete(applyText.Length() - 1, 2);
						else
							applyText.Delete(applyText.Length(), 1);
						break;
					}

					applyText.Insert("\r\n", (strLength + 2 * (StringOverflowCount - 1)));

				}
			}

			delete strBuff;

			dstLabel->Caption = applyText;

		}
		else
		{
			((TQRLabel*)FindComponent("QRRichText" + IntToStr(i)))->AutoSize = false;
			((TQRLabel*)FindComponent("QRRichText" + IntToStr(i)))->Alignment = taCenter;
			((TQRLabel*)FindComponent("QRRichText" + IntToStr(i)))->Width = 80;
		}
	}

	TIniFile *iniFile = new TIniFile(ProgramPath.Env + "\\UserInfor.ini");
	bool DHGradeHide = iniFile->ReadInteger("PC Program Option", "DH Grade Hide program", false);
  bool HIprogram = iniFile->ReadInteger("PC Program Option", "HIprogram", false);

  SideEdgeNeighborSizeLabel1->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.Side_Edge_Neighbor_Defect_Size) / 100.0) + " mm";
  SideEdgeNeighborSizeLabel2->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.Side_Edge_Neighbor_Defect_Size) / 100.0) + " mm";

  SideEdgeDarkSizeLabel1->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.Side_Edge_Dark_Defect_Size) / 100.0) + " mm";
  SideEdgeDarkSizeLabel2->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.Side_Edge_Dark_Defect_Size) / 100.0) + " mm";

  SideEdgeBrightSizeLabel1->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.Side_Edge_Bright_Defect_Size) / 100.0) + " mm";
  SideEdgeBrightSizeLabel2->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.Side_Edge_Bright_Defect_Size) / 100.0) + " mm";

  SideEdgeBreakSizeLabel1->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.Side_Edge_Neighbor_Break_Size) / 100.0) + " mm";
  SideEdgeBreakSizeLabel2->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.Side_Edge_Neighbor_Break_Size) / 100.0) + " mm";

  WideString tempString = "";

  if (!DHGradeHide)
  {
    if (DefaultLCID == 1042)
    {
      tempString = " 등급";
    }
    else if(DefaultLCID == 1041)
    {
      tempString = " "+INSPECTIONFORM_STRGRID_CELL_03;
    }
    else
    {
      tempString = " grade";
    }
  }

  SideEdgeNeighborIntensityLabel1->Caption = IntToStr(Report.GradeData.Side_Edge_Neighbor_Intensity) + tempString;
  SideEdgeNeighborIntensityLabel2->Caption = IntToStr(Report.GradeData.Side_Edge_Neighbor_Intensity) + tempString;
  SideEdgeNeighborIntensityLabel3->Caption = IntToStr(Report.GradeData.Side_Edge_Neighbor_Intensity) + tempString;
  SideEdgeNeighborIntensityLabel4->Caption = IntToStr(Report.GradeData.Side_Edge_Neighbor_Intensity) + tempString;

  SideEdgeDarkIntensityLabel1->Caption = IntToStr(Report.GradeData.Side_Edge_Dark_Intensity) + tempString;
  SideEdgeDarkIntensityLabel2->Caption = IntToStr(Report.GradeData.Side_Edge_Dark_Intensity) + tempString;
  SideEdgeDarkIntensityLabel3->Caption = IntToStr(Report.GradeData.Side_Edge_Dark_Intensity) + tempString;
  SideEdgeDarkIntensityLabel4->Caption = IntToStr(Report.GradeData.Side_Edge_Dark_Intensity) + tempString;

  SideEdgeBrightIntensityLabel1->Caption = IntToStr(Report.GradeData.Side_Edge_Bright_Intensity) + tempString;
  SideEdgeBrightIntensityLabel2->Caption = IntToStr(Report.GradeData.Side_Edge_Bright_Intensity) + tempString;
  SideEdgeBrightIntensityLabel3->Caption = IntToStr(Report.GradeData.Side_Edge_Bright_Intensity) + tempString;
  SideEdgeBrightIntensityLabel4->Caption = IntToStr(Report.GradeData.Side_Edge_Bright_Intensity) + tempString;

  SideEdgeBreakIntensityLabel1->Caption = IntToStr(Report.GradeData.Side_Edge_Neighbor_Break_Intensity) + tempString;
  SideEdgeBreakIntensityLabel2->Caption = IntToStr(Report.GradeData.Side_Edge_Neighbor_Break_Intensity) + tempString;
  SideEdgeBreakIntensityLabel3->Caption = IntToStr(Report.GradeData.Side_Edge_Neighbor_Break_Intensity) + tempString;
  SideEdgeBreakIntensityLabel4->Caption = IntToStr(Report.GradeData.Side_Edge_Neighbor_Break_Intensity) + tempString;

  FrontNormalDirtyGradeQRLabel->Caption = IntToStr(Report.GradeData.FrontNormalDirtyGrade) + tempString;
  FrontNormalDirtyGradeQRLabel2->Caption = IntToStr(Report.GradeData.FrontNormalDirtyGrade) + tempString;
  FrontNormalDirtyGradeQRLabel3->Caption = IntToStr(Report.GradeData.FrontNormalDirtyGrade) + tempString;
  FrontNormalDirtyGradeQRLabel4->Caption = IntToStr(Report.GradeData.FrontNormalDirtyGrade) + tempString;

  FrontPrintDirtyGradeQRLabel->Caption = IntToStr(Report.GradeData.FrontPrintDirtyGrade) + tempString;
  FrontPrintDirtyGradeQRLabel2->Caption = IntToStr(Report.GradeData.FrontPrintDirtyGrade) + tempString;
  FrontPrintDirtyGradeQRLabel3->Caption = IntToStr(Report.GradeData.FrontPrintDirtyGrade) + tempString;
  FrontPrintDirtyGradeQRLabel4->Caption = IntToStr(Report.GradeData.FrontPrintDirtyGrade) + tempString;

  FrontEdgeDirtyGradeQRLabel->Caption = IntToStr(Report.GradeData.FrontEdgeDirtyGrade) + tempString;
  FrontEdgeDirtyGradeQRLabel2->Caption = IntToStr(Report.GradeData.FrontEdgeDirtyGrade) + tempString;
  FrontEdgeDirtyGradeQRLabel3->Caption = IntToStr(Report.GradeData.FrontEdgeDirtyGrade) + tempString;
  FrontEdgeDirtyGradeQRLabel4->Caption = IntToStr(Report.GradeData.FrontEdgeDirtyGrade) + tempString;

  FrontStainGradeQRLabel->Caption = IntToStr(Report.GradeData.FrontStainGrade) + tempString;
  FrontStainGradeQRLabel2->Caption = IntToStr(Report.GradeData.FrontStainGrade) + tempString;
  FrontStainGradeQRLabel3->Caption = IntToStr(Report.GradeData.FrontStainGrade) + tempString;
  FrontStainGradeQRLabel4->Caption = IntToStr(Report.GradeData.FrontStainGrade) + tempString;

  FrontEdgeStainGradeQRLabel->Caption = IntToStr(Report.GradeData.FrontEdgeGrade) + tempString;
  FrontEdgeStainGradeQRLabel2->Caption = IntToStr(Report.GradeData.FrontEdgeGrade) + tempString;
  FrontEdgeStainGradeQRLabel3->Caption = IntToStr(Report.GradeData.FrontEdgeGrade) + tempString;
  FrontEdgeStainGradeQRLabel4->Caption = IntToStr(Report.GradeData.FrontEdgeGrade) + tempString;

  SideDirtyGradeQRLabel->Caption = IntToStr(Report.GradeData.SideDirtyGrade) + tempString;
  SideDirtyGradeQRLabel2->Caption = IntToStr(Report.GradeData.SideDirtyGrade) + tempString;
  SideDirtyGradeQRLabel3->Caption = IntToStr(Report.GradeData.SideDirtyGrade) + tempString;
  SideDirtyGradeQRLabel4->Caption = IntToStr(Report.GradeData.SideDirtyGrade) + tempString;

  SideStainGradeQRLabel->Caption = IntToStr(Report.GradeData.SideStainGrade) + tempString;
  SideStainGradeQRLabel2->Caption = IntToStr(Report.GradeData.SideStainGrade) + tempString;
  SideStainGradeQRLabel3->Caption = IntToStr(Report.GradeData.SideStainGrade) + tempString;
  SideStainGradeQRLabel4->Caption = IntToStr(Report.GradeData.SideStainGrade) + tempString;

  ColorGradeQRLabel->Caption = IntToStr(Report.GradeData.ColorGrade) + tempString;
  ColorGradeQRLabel2->Caption = IntToStr(Report.GradeData.ColorGrade) + tempString;
  ColorGradeQRLabel3->Caption = IntToStr(Report.GradeData.ColorGrade) + tempString;
  ColorGradeQRLabel4->Caption = IntToStr(Report.GradeData.ColorGrade) + tempString;

  FrontColorDirtyGradeQRLabel->Caption = IntToStr(Report.GradeData.FrontColorDirtyGrade) + tempString;
  FrontColorDirtyGradeQRLabel2->Caption = IntToStr(Report.GradeData.FrontColorDirtyGrade) + tempString;
  FrontColorDirtyGradeQRLabel3->Caption = IntToStr(Report.GradeData.FrontColorDirtyGrade) + tempString;
  FrontColorDirtyGradeQRLabel4->Caption = IntToStr(Report.GradeData.FrontColorDirtyGrade) + tempString;

  SideColorDirtyGradeQRLabel->Caption = IntToStr(Report.GradeData.SideColorDirtyGrade) + tempString;
  SideColorDirtyGradeQRLabel2->Caption = IntToStr(Report.GradeData.SideColorDirtyGrade) + tempString;
  SideColorDirtyGradeQRLabel3->Caption = IntToStr(Report.GradeData.SideColorDirtyGrade) + tempString;
  SideColorDirtyGradeQRLabel4->Caption = IntToStr(Report.GradeData.SideColorDirtyGrade) + tempString;

  ThreeDHeightGradeQRLabel->Caption = IntToStr((int)((Report.GradeData.ThreeDHeightMinusLimit + Report.GradeData.ThreeDHeightPlusLimit) * 0.03 / 2 * 10) + 1) + tempString;
  ThreeDHeightGradeQRLabel2->Caption = IntToStr((int)((Report.GradeData.ThreeDHeightMinusLimit + Report.GradeData.ThreeDHeightPlusLimit) * 0.03 / 2 * 10) + 1) + tempString;
  ThreeDHeightGradeQRLabel3->Caption = IntToStr((int)((Report.GradeData.ThreeDHeightMinusLimit + Report.GradeData.ThreeDHeightPlusLimit) * 0.03 / 2 * 10) + 1) + tempString;
  ThreeDHeightGradeQRLabel4->Caption = IntToStr((int)((Report.GradeData.ThreeDHeightMinusLimit + Report.GradeData.ThreeDHeightPlusLimit) * 0.03 / 2 * 10) + 1) + tempString;

  if(isPrintedTablet)
  {
    PrintSpreadLabel1->Caption = FloatToStr(DefectSizePixelToMili((Report.GradeData.PrintSpreadGrade + 1) * (Report.GradeData.PrintSpreadGrade)) / 100.0) + " mm";
    PrintSpreadLabel2->Caption = FloatToStr(DefectSizePixelToMili((Report.GradeData.PrintSpreadGrade + 1) * (Report.GradeData.PrintSpreadGrade)) / 100.0) + " mm";
    PrintSpreadLabel3->Caption = FloatToStr(DefectSizePixelToMili((Report.GradeData.PrintSpreadGrade + 1) * (Report.GradeData.PrintSpreadGrade)) / 100.0) + " mm";
    PrintSpreadLabel4->Caption = FloatToStr(DefectSizePixelToMili((Report.GradeData.PrintSpreadGrade + 1) * (Report.GradeData.PrintSpreadGrade)) / 100.0) + " mm";
  }
  else if(!isPrintedTablet)
  {
    PrintSpreadLabel1->Caption = "";//IntToStr(TabletInspectGradeData.EngraveDistinguishGradeFor2D) + tempString;
    PrintSpreadLabel2->Caption = "";//IntToStr(TabletInspectGradeData.EngraveDistinguishGradeFor2D) + tempString;
    PrintSpreadLabel3->Caption = "";//IntToStr(TabletInspectGradeData.EngraveDistinguishGradeFor2D) + tempString;
    PrintSpreadLabel4->Caption = "";//IntToStr(TabletInspectGradeData.EngraveDistinguishGradeFor2D) + tempString;
  }

  if(!HIprogram)
  {
    EngraveDefectCheckGradeTitleLabel1->Caption = "";
    EngraveDefectCheckGradeValueLabel1->Caption = "";
    EngraveDefectCheckGradeTitleLabel2->Caption = "";
    EngraveDefectCheckGradeValueLabel2->Caption = "";
    EngraveDefectCheckGradeTitleLabel3->Caption = "";
    EngraveDefectCheckGradeValueLabel3->Caption = "";
    EngraveDefectCheckGradeTitleLabel4->Caption = "";
    EngraveDefectCheckGradeValueLabel4->Caption = "";
  }
  else
  {
    AnsiString GradeTitle, GradeState;

    if(DefaultLCID == 1042)
    {
      GradeTitle = "각인 위치 불량 검출";

      if(Report.GradeData.EngravePositionDefectCheckSW)
        GradeState = "사용";
      else
        GradeState = "미사용";
    }
    else
    {
      GradeTitle = "Engrave Position Defect";

      if(Report.GradeData.EngravePositionDefectCheckSW)
        GradeState = "Enabled";
      else
        GradeState = "Disabled";
    }

    EngraveDefectCheckGradeTitleLabel1->Caption = GradeTitle;
    EngraveDefectCheckGradeValueLabel1->Caption = GradeState;
    EngraveDefectCheckGradeTitleLabel2->Caption = GradeTitle;
    EngraveDefectCheckGradeValueLabel2->Caption = GradeState;
    EngraveDefectCheckGradeTitleLabel3->Caption = GradeTitle;
    EngraveDefectCheckGradeValueLabel3->Caption = GradeState;
    EngraveDefectCheckGradeTitleLabel4->Caption = GradeTitle;
    EngraveDefectCheckGradeValueLabel4->Caption = GradeState;
  }

	delete iniFile;

  /**************************************************************************/
  if (isPrintedTablet)
  {
    // print erase
    QRLabel32->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_14;
    QRLabel74->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_14;
    QRLabel105->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_14;
    QRLabel189->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_14;

    //print spread
    GradeNameLabel1->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_13;
    GradeNameLabel2->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_13;
    GradeNameLabel3->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_13;
    GradeNameLabel4->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_13;
  }
  else
  {
    //Engrave Erase
    QRLabel32->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_44;
    QRLabel74->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_44;
    QRLabel105->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_44;
    QRLabel189->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_44;

    GradeNameLabel1->Caption = "";//"각인 식별 등급";
    GradeNameLabel2->Caption = "";//"각인 식별 등급";
    GradeNameLabel3->Caption = "";//"각인 식별 등급";
    GradeNameLabel4->Caption = "";//"각인 식별 등급";
  }

	if (DefaultLCID == 1042)
	{
		RefreshDefectsInfo(Report.Data.DefectTabletCount);

		ProductionQRLabel->Caption = Format("%.0n 정", ARRAYOFCONST(((double)Report.Data.ProductionCount)));
		ProductionQRLabel2->Caption = Format("%.0n 정", ARRAYOFCONST(((double)Report.Data.ProductionCount)));
		ProductionQRLabel3->Caption = Format("%.0n 정", ARRAYOFCONST(((double)Report.Data.ProductionCount)));
		ProductionQRLabel4->Caption = Format("%.0n 정", ARRAYOFCONST(((double)Report.Data.ProductionCount)));

		char operName[33];
		strncpy(operName, Report.Data.OperatorName, 32);
		operName[32] = '\0';
		OperatorQRLabel->Caption = AnsiString(operName);
		OperatorQRLabel2->Caption = AnsiString(operName);
		OperatorQRLabel3->Caption = AnsiString(operName);
		OperatorQRLabel4->Caption = AnsiString(operName);

		TDateTime inspectionStartTime = TDateTime(Report.Data.InspectionStartTime);
		StartDateQRLabel->Caption = inspectionStartTime.FormatString("yyyy") + "년 " + inspectionStartTime.FormatString("m") + "월 " + inspectionStartTime.FormatString("d") + "일";
		StartDateQRLabel2->Caption = inspectionStartTime.FormatString("yyyy") + "년 " + inspectionStartTime.FormatString("m") + "월 " + inspectionStartTime.FormatString("d") + "일";
		StartDateQRLabel3->Caption = inspectionStartTime.FormatString("yyyy") + "년 " + inspectionStartTime.FormatString("m") + "월 " + inspectionStartTime.FormatString("d") + "일";
		StartDateQRLabel4->Caption = inspectionStartTime.FormatString("yyyy") + "년 " + inspectionStartTime.FormatString("m") + "월 " + inspectionStartTime.FormatString("d") + "일";

		StartTimeQRLabel->Caption = inspectionStartTime.FormatString("hh") + "시 " + inspectionStartTime.FormatString("nn") + "분";
		StartTimeQRLabel2->Caption = inspectionStartTime.FormatString("hh") + "시 " + inspectionStartTime.FormatString("nn") + "분";
		StartTimeQRLabel3->Caption = inspectionStartTime.FormatString("hh") + "시 " + inspectionStartTime.FormatString("nn") + "분";
		StartTimeQRLabel4->Caption = inspectionStartTime.FormatString("hh") + "시 " + inspectionStartTime.FormatString("nn") + "분";

		TDateTime inspectionEndTime = TDateTime(Report.Data.InspectionEndTime);
		EndDateQRLabel->Caption = inspectionEndTime.FormatString("yyyy") + "년 " + inspectionEndTime.FormatString("m") + "월 " + inspectionEndTime.FormatString("d") + "일";
		EndDateQRLabel2->Caption = inspectionEndTime.FormatString("yyyy") + "년 " + inspectionEndTime.FormatString("m") + "월 " + inspectionEndTime.FormatString("d") + "일";
		EndDateQRLabel3->Caption = inspectionEndTime.FormatString("yyyy") + "년 " + inspectionEndTime.FormatString("m") + "월 " + inspectionEndTime.FormatString("d") + "일";
		EndDateQRLabel4->Caption = inspectionEndTime.FormatString("yyyy") + "년 " + inspectionEndTime.FormatString("m") + "월 " + inspectionEndTime.FormatString("d") + "일";

		EndTimeQRLabel->Caption = inspectionEndTime.FormatString("hh") + "시 " + inspectionEndTime.FormatString("nn") + "분";
		EndTimeQRLabel2->Caption = inspectionEndTime.FormatString("hh") + "시 " + inspectionEndTime.FormatString("nn") + "분";
		EndTimeQRLabel3->Caption = inspectionEndTime.FormatString("hh") + "시 " + inspectionEndTime.FormatString("nn") + "분";
		EndTimeQRLabel4->Caption = inspectionEndTime.FormatString("hh") + "시 " + inspectionEndTime.FormatString("nn") + "분";

		PassCntQRLabel->Caption = Format("%.0n 정", ARRAYOFCONST(((double)Report.Data.GoodTabletCount)));
		PassCntQRLabel2->Caption = Format("%.0n 정", ARRAYOFCONST(((double)Report.Data.GoodTabletCount)));
		PassCntQRLabel3->Caption = Format("%.0n 정", ARRAYOFCONST(((double)Report.Data.GoodTabletCount)));
		PassCntQRLabel4->Caption = Format("%.0n 정", ARRAYOFCONST(((double)Report.Data.GoodTabletCount)));

		DefectCntQRLabel->Caption = Format("%.0n 정", ARRAYOFCONST(((double)Report.Data.DefectTabletCount)));
		DefectCntQRLabel2->Caption = Format("%.0n 정", ARRAYOFCONST(((double)Report.Data.DefectTabletCount)));
		DefectCntQRLabel3->Caption = Format("%.0n 정", ARRAYOFCONST(((double)Report.Data.DefectTabletCount)));
		DefectCntQRLabel4->Caption = Format("%.0n 정", ARRAYOFCONST(((double)Report.Data.DefectTabletCount)));

        if(PCProgramOption.IncludeUnInsTabletCount == true)
        {
			UninsCntQRLabel3->Caption = Format("%.0n 정", ARRAYOFCONST(((double)Report.Data.UnInsTabletCount)));
            UninsCntQRLabel->Caption = Format("%.0n 정", ARRAYOFCONST(((double)Report.Data.UnInsTabletCount)));
            UninsCntQRLabel2->Caption = Format("%.0n 정", ARRAYOFCONST(((double)Report.Data.UnInsTabletCount)));
            UninsCntQRLabel4->Caption = Format("%.0n 정", ARRAYOFCONST(((double)Report.Data.UnInsTabletCount)));

        }

		// 검사 결과
		// 미검 옵션 선택 사항에 따른 계산 변경
		int TotalCnt = 0;
		if (PCProgramOption.IncludeUnInsTabletCount)
			TotalCnt = Report.Data.GoodTabletCount + Report.Data.DefectTabletCount + Report.Data.UnInsTabletCount;
		else
			TotalCnt = Report.Data.GoodTabletCount + Report.Data.DefectTabletCount;

		TotalCntQRLabel->Caption = Format("%.0n 정", ARRAYOFCONST(((double)(TotalCnt))));
		TotalCntQRLabel2->Caption = Format("%.0n 정", ARRAYOFCONST(((double)(TotalCnt))));
		TotalCntQRLabel3->Caption = Format("%.0n 정", ARRAYOFCONST(((double)(TotalCnt))));
		TotalCntQRLabel4->Caption = Format("%.0n 정", ARRAYOFCONST(((double)(TotalCnt))));

		bool ValidCheck = false; // 각 항목에 따른 총 제품 검사 수량이 0보다 큰지 확인
		if (PCProgramOption.IncludeUnInsTabletCount)
			ValidCheck = (Report.Data.GoodTabletCount + Report.Data.DefectTabletCount + Report.Data.UnInsTabletCount > 0) ? true : false;
		else
			ValidCheck = (Report.Data.GoodTabletCount + Report.Data.DefectTabletCount > 0) ? true : false;

		if (ValidCheck)
		{
			//RPassCntQRLabel->Caption = Format("%.2f %%", ARRAYOFCONST(((double)tabletInspectReport.GoodTabletCount * 100 / (tabletInspectReport.TotalTabletCount))));
			//RDefectCntQRLabel->Caption = Format("%.2f %%", ARRAYOFCONST(((double)tabletInspectReport.DefectTabletCount * 100 / (tabletInspectReport.TotalTabletCount))));
			RPassCntQRLabel->Caption = Format("%.2f %%", ARRAYOFCONST(((double)Report.Data.GoodTabletCount * 100 / TotalCnt)));
			RDefectCntQRLabel->Caption = Format("%.2f %%", ARRAYOFCONST(((double)Report.Data.DefectTabletCount * 100 / TotalCnt)));

			//RPassCntQRLabel2->Caption = Format("%.2f %%", ARRAYOFCONST(((double)tabletInspectReport.GoodTabletCount * 100 / (tabletInspectReport.TotalTabletCount))));
			//RDefectCntQRLabel2->Caption = Format("%.2f %%", ARRAYOFCONST(((double)tabletInspectReport.DefectTabletCount * 100 / (tabletInspectReport.TotalTabletCount))));  
			RPassCntQRLabel2->Caption = Format("%.2f %%", ARRAYOFCONST(((double)Report.Data.GoodTabletCount * 100 / TotalCnt)));
			RDefectCntQRLabel2->Caption = Format("%.2f %%", ARRAYOFCONST(((double)Report.Data.DefectTabletCount * 100 / TotalCnt)));

			//RPassCntQRLabel3->Caption = Format("%.2f %%", ARRAYOFCONST(((double)tabletInspectReport.GoodTabletCount * 100 / (tabletInspectReport.TotalTabletCount))));
			//RDefectCntQRLabel3->Caption = Format("%.2f %%", ARRAYOFCONST(((double)tabletInspectReport.DefectTabletCount * 100 / (tabletInspectReport.TotalTabletCount))));
			RPassCntQRLabel3->Caption = Format("%.2f %%", ARRAYOFCONST(((double)Report.Data.GoodTabletCount * 100 / TotalCnt)));
			RDefectCntQRLabel3->Caption = Format("%.2f %%", ARRAYOFCONST(((double)Report.Data.DefectTabletCount * 100 / TotalCnt)));

			//RPassCntQRLabel4->Caption = Format("%.2f %%", ARRAYOFCONST(((double)tabletInspectReport.GoodTabletCount * 100 / (tabletInspectReport.TotalTabletCount))));
			//RDefectCntQRLabel4->Caption = Format("%.2f %%", ARRAYOFCONST(((double)tabletInspectReport.DefectTabletCount * 100 / (tabletInspectReport.TotalTabletCount))));
			RPassCntQRLabel4->Caption = Format("%.2f %%", ARRAYOFCONST(((double)Report.Data.GoodTabletCount * 100 / TotalCnt)));
			RDefectCntQRLabel4->Caption = Format("%.2f %%", ARRAYOFCONST(((double)Report.Data.DefectTabletCount * 100 / TotalCnt)));
		}
		else
		{
			RDefectCntQRLabel->Caption = "0%";
			RPassCntQRLabel->Caption = "0%";

			RDefectCntQRLabel2->Caption = "0%";
			RPassCntQRLabel2->Caption = "0%";

			RDefectCntQRLabel3->Caption = "0%";
			RPassCntQRLabel3->Caption = "0%";

			RDefectCntQRLabel4->Caption = "0%";
			RPassCntQRLabel4->Caption = "0%";
		}


    OptionBreakingGradeQRLabel->Caption = FloatToStr((float)Report.GradeData.OptionBreakingGrade*30.0 / 10.0 / 1000.0) + " mm";
    OptionFrontStickingGradeType1QRLabel->Caption = FloatToStr((float)Report.GradeData.OptionFrontStickingGrade_Type1*30.0 / 10.0 / 1000.0) + " mm";
    OptionFrontStickingGradeType2QRLabel->Caption = FloatToStr((float)Report.GradeData.OptionFrontStickingGrade_Type2*30.0 / 10.0 / 1000.0) + " mm";

    OptionPrintMarkGradeQRLabel->Caption = IntToStr(Report.GradeData.OptionPrintMarkGrade) + " %";
    PrintEraseGradeQRLabel->Caption = FloatToStr(DefectSizePixelToMili((Report.GradeData.PrintEraseGrade + 1) * (Report.GradeData.PrintEraseGrade)) / 100.0) + " mm";
    ThreeDHeightMinusLimitQRLabel->Caption = "-" + FloatToStr((float)Report.GradeData.ThreeDHeightMinusLimit*0.03) + " mm";
    ThreeDHeightPlusLimitQRLabel->Caption = "+" + FloatToStr((float)Report.GradeData.ThreeDHeightPlusLimit*0.03) + " mm";


    OptionBreakingGradeQRLabel2->Caption = FloatToStr((float)Report.GradeData.OptionBreakingGrade*30.0 / 10.0 / 1000.0) + " mm";
    OptionFrontStickingGradeType1QRLabel2->Caption = FloatToStr((float)Report.GradeData.OptionFrontStickingGrade_Type1*30.0 / 10.0 / 1000.0) + " mm";
    OptionFrontStickingGradeType2QRLabel2->Caption = FloatToStr((float)Report.GradeData.OptionFrontStickingGrade_Type2*30.0 / 10.0 / 1000.0) + " mm";

    OptionPrintMarkGradeQRLabel2->Caption = IntToStr(Report.GradeData.OptionPrintMarkGrade) + " %";
    PrintEraseGradeQRLabel2->Caption = FloatToStr(DefectSizePixelToMili((Report.GradeData.PrintEraseGrade + 1) * (Report.GradeData.PrintEraseGrade)) / 100.0) + " mm";
    ThreeDHeightMinusLimitQRLabel2->Caption = "-" + FloatToStr((float)Report.GradeData.ThreeDHeightMinusLimit*0.03) + " mm";
    ThreeDHeightPlusLimitQRLabel2->Caption = "+" + FloatToStr((float)Report.GradeData.ThreeDHeightPlusLimit*0.03) + " mm";
    FrontNormalDirtySizeQRLabel2->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.FrontNormalDirtySize) / 100.0) + " mm";
    FrontEdgeDirtySizeQRLabel2->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.FrontEdgeDirtySize) / 100.0) + " mm";
    FrontStainSizeQRLabel2->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.FrontStainSize) / 100.0) + " mm";
    FrontEdgeSizeQRLabel2->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.FrontEdgeSize) / 100.0) + " mm";
    FrontColorDirtySizeQRLabel2->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.FrontColorDirtySize) / 100.0) + " mm";
    SideDirtySizeQRLabel2->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.SideDirtySize) / 100.0) + " mm";
    SideStainSizeQRLabel2->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.SideStainSize) / 100.0) + " mm";
    OptionBreakingSizeQRLabel2->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.OptionBreakingSize) / 100.0) + " mm";
    OptionFrontStickingSizeType1QRLabel2->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.OptionFrontStickingSize_Type1) / 100.0) + " mm";
    OptionFrontStickingSizeType2QRLabel2->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.OptionFrontStickingSize_Type2) / 100.0) + " mm";

    SideColorDirtySizeQRLabel2->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.SideColorDirtySize) / 100.0) + " mm";
    QRLabel11->Caption = FloatToStr((float)Report.GradeData.EngraveDistinguishGradeFor3D*30.0 / 10.0 / 100.0) + " mm";



		/**************************************************************************/

    OptionBreakingGradeQRLabel3->Caption = FloatToStr((float)Report.GradeData.OptionBreakingGrade*30.0 / 10.0 / 1000.0) + " mm";
    OptionFrontStickingGradeType1QRLabel3->Caption = FloatToStr((float)Report.GradeData.OptionFrontStickingGrade_Type1*30.0 / 10.0 / 1000.0) + " mm";
    OptionFrontStickingGradeType2QRLabel3->Caption = FloatToStr((float)Report.GradeData.OptionFrontStickingGrade_Type2*30.0 / 10.0 / 1000.0) + " mm";

    OptionPrintMarkGradeQRLabel3->Caption = IntToStr(Report.GradeData.OptionPrintMarkGrade) + " %";
    PrintEraseGradeQRLabel3->Caption = FloatToStr(DefectSizePixelToMili((Report.GradeData.PrintEraseGrade + 1) * (Report.GradeData.PrintEraseGrade)) / 100.0) + " mm";
    ThreeDHeightMinusLimitQRLabel3->Caption = "-" + FloatToStr((float)Report.GradeData.ThreeDHeightMinusLimit*0.03) + " mm";
    ThreeDHeightPlusLimitQRLabel3->Caption = "+" + FloatToStr((float)Report.GradeData.ThreeDHeightPlusLimit*0.03) + " mm";


		/**************************************************************************/

    OptionBreakingGradeQRLabel4->Caption = FloatToStr((float)Report.GradeData.OptionBreakingGrade*30.0 / 10.0 / 1000.0) + " mm";
    OptionFrontStickingGradeType1QRLabel4->Caption = FloatToStr((float)Report.GradeData.OptionFrontStickingGrade_Type1*30.0 / 10.0 / 1000.0) + " mm";
    OptionFrontStickingGradeType2QRLabel4->Caption = FloatToStr((float)Report.GradeData.OptionFrontStickingGrade_Type2*30.0 / 10.0 / 1000.0) + " mm";

    OptionPrintMarkGradeQRLabel4->Caption = IntToStr(Report.GradeData.OptionPrintMarkGrade) + " %";
    PrintEraseGradeQRLabel4->Caption = FloatToStr(DefectSizePixelToMili((Report.GradeData.PrintEraseGrade + 1) * (Report.GradeData.PrintEraseGrade)) / 100.0) + " mm";
    ThreeDHeightMinusLimitQRLabel4->Caption = "-" + FloatToStr((float)Report.GradeData.ThreeDHeightMinusLimit*0.03) + " mm";
    ThreeDHeightPlusLimitQRLabel4->Caption = "+" + FloatToStr((float)Report.GradeData.ThreeDHeightPlusLimit*0.03) + " mm";


		FrontNormalDirtySizeQRLabel4->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.FrontNormalDirtySize) / 100.0) + " mm";
		FrontEdgeDirtySizeQRLabel4->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.FrontEdgeDirtySize) / 100.0) + " mm";
		FrontStainSizeQRLabel4->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.FrontStainSize) / 100.0) + " mm";
		FrontEdgeSizeQRLabel4->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.FrontEdgeSize) / 100.0) + " mm";
		FrontColorDirtySizeQRLabel4->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.FrontColorDirtySize) / 100.0) + " mm";
		SideDirtySizeQRLabel4->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.SideDirtySize) / 100.0) + " mm";
		SideStainSizeQRLabel4->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.SideStainSize) / 100.0) + " mm";
		OptionBreakingSizeQRLabel4->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.OptionBreakingSize) / 100.0) + " mm";
		OptionFrontStickingSizeType1QRLabel4->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.OptionFrontStickingSize_Type1) / 100.0) + " mm";
    OptionFrontStickingSizeType2QRLabel4->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.OptionFrontStickingSize_Type2) / 100.0) + " mm";

		SideColorDirtySizeQRLabel4->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.SideColorDirtySize) / 100.0) + " mm";
		QRLLABEL11->Caption = FloatToStr((float)Report.GradeData.EngraveDistinguishGradeFor3D*30.0 / 10.0 / 100.0) + " mm";

		if (printModeOption == 0)
		{
			PrintGradeOnlyRadioButton->Checked = true;

			if (!PrintDefectSeriesCheckBox->Checked)
			{
				ReportPanel1->BringToFront();
			}
			else
			{
				ReportPanel3->BringToFront();
			}
			PrintSize = false;
		}
		else
		{
			PrintGradeAndSizeRadioButton->Checked = true;

			if (!PrintDefectSeriesCheckBox->Checked)
			{
				ReportPanel2->BringToFront();
			}
			else
			{
				ReportPanel4->BringToFront();
			}

			PrintSize = true;
		}

		if (threeDHeightOption == 0)
		{
			ThreeDHeightMinusLimitQRLabel->Visible = true;
			ThreeDHeightPlusLimitQRLabel->Visible = true;
			ThreeDHeightGradeQRLabel->Visible = false;
			ThreeDHeightGradeQRLabel->Width = 0;
			ThreeDHeightMinusLimitQRLabel2->Visible = true;
			ThreeDHeightPlusLimitQRLabel2->Visible = true;
			ThreeDHeightGradeQRLabel2->Visible = false;
			ThreeDHeightGradeQRLabel2->Width = 0;
			ThreeDHeightMinusLimitQRLabel3->Visible = true;
			ThreeDHeightPlusLimitQRLabel3->Visible = true;
			ThreeDHeightGradeQRLabel3->Visible = false;
			ThreeDHeightGradeQRLabel3->Width = 0;
			ThreeDHeightMinusLimitQRLabel4->Visible = true;
			ThreeDHeightPlusLimitQRLabel4->Visible = true;
			ThreeDHeightGradeQRLabel4->Visible = false;
			ThreeDHeightGradeQRLabel4->Width = 0;
		}
		else
		{
			ThreeDHeightMinusLimitQRLabel->Visible = false;
			ThreeDHeightMinusLimitQRLabel->Width = 0;
			ThreeDHeightPlusLimitQRLabel->Visible = false;
			ThreeDHeightPlusLimitQRLabel->Width = 0;
			ThreeDHeightGradeQRLabel->Visible = true;
			ThreeDHeightMinusLimitQRLabel2->Visible = false;
			ThreeDHeightMinusLimitQRLabel2->Width = 0;
			ThreeDHeightPlusLimitQRLabel2->Visible = false;
			ThreeDHeightPlusLimitQRLabel2->Width = 0;
			ThreeDHeightGradeQRLabel2->Visible = true;
			ThreeDHeightMinusLimitQRLabel3->Visible = false;
			ThreeDHeightMinusLimitQRLabel3->Width = 0;
			ThreeDHeightPlusLimitQRLabel3->Visible = false;
			ThreeDHeightPlusLimitQRLabel3->Width = 0;
			ThreeDHeightGradeQRLabel3->Visible = true;
			ThreeDHeightMinusLimitQRLabel4->Visible = false;
			ThreeDHeightMinusLimitQRLabel4->Width = 0;
			ThreeDHeightPlusLimitQRLabel4->Visible = false;
			ThreeDHeightPlusLimitQRLabel4->Width = 0;
			ThreeDHeightGradeQRLabel4->Visible = true;
		}
	}
	else
	{
		RefreshDefectsInfo(Report.Data.DefectTabletCount);

    WideString UnitStr = "EA";
    if(DefaultLCID == 1041)
    {
      UnitStr = PRINTINSPECTIONRESULTFORM_UNKNOWN_67;
    }

    ProductionQRLabel->Caption = Format("%.0n "+UnitStr, ARRAYOFCONST(((double)Report.Data.ProductionCount)));
    ProductionQRLabel2->Caption = Format("%.0n "+UnitStr, ARRAYOFCONST(((double)Report.Data.ProductionCount)));
    ProductionQRLabel3->Caption = Format("%.0n "+UnitStr, ARRAYOFCONST(((double)Report.Data.ProductionCount)));
    ProductionQRLabel4->Caption = Format("%.0n "+UnitStr, ARRAYOFCONST(((double)Report.Data.ProductionCount)));

		char operName[33];
		strncpy(operName, Report.Data.OperatorName, 32);
		operName[32] = '\0';
		OperatorQRLabel->Caption = AnsiString(operName);
		OperatorQRLabel2->Caption = AnsiString(operName);
		OperatorQRLabel3->Caption = AnsiString(operName);
		OperatorQRLabel4->Caption = AnsiString(operName);

		TDateTime inspectionStartTime = TDateTime(Report.Data.InspectionStartTime);
		StartDateQRLabel->Caption = inspectionStartTime.FormatString("yyyy") + " / " + inspectionStartTime.FormatString("m") + " / " + inspectionStartTime.FormatString("d");
		StartDateQRLabel2->Caption = inspectionStartTime.FormatString("yyyy") + " / " + inspectionStartTime.FormatString("m") + " / " + inspectionStartTime.FormatString("d");
		StartDateQRLabel3->Caption = inspectionStartTime.FormatString("yyyy") + " / " + inspectionStartTime.FormatString("m") + " / " + inspectionStartTime.FormatString("d");
		StartDateQRLabel4->Caption = inspectionStartTime.FormatString("yyyy") + " / " + inspectionStartTime.FormatString("m") + " / " + inspectionStartTime.FormatString("d");

		StartTimeQRLabel->Caption = inspectionStartTime.FormatString("hh") + " : " + inspectionStartTime.FormatString("nn");
		StartTimeQRLabel2->Caption = inspectionStartTime.FormatString("hh") + " : " + inspectionStartTime.FormatString("nn");
		StartTimeQRLabel3->Caption = inspectionStartTime.FormatString("hh") + " : " + inspectionStartTime.FormatString("nn");
		StartTimeQRLabel4->Caption = inspectionStartTime.FormatString("hh") + " : " + inspectionStartTime.FormatString("nn");

		TDateTime inspectionEndTime = TDateTime(Report.Data.InspectionEndTime);
		EndDateQRLabel->Caption = inspectionEndTime.FormatString("yyyy") + " / " + inspectionEndTime.FormatString("m") + " / " + inspectionEndTime.FormatString("d");
		EndDateQRLabel2->Caption = inspectionEndTime.FormatString("yyyy") + " / " + inspectionEndTime.FormatString("m") + " / " + inspectionEndTime.FormatString("d");
		EndDateQRLabel3->Caption = inspectionEndTime.FormatString("yyyy") + " / " + inspectionEndTime.FormatString("m") + " / " + inspectionEndTime.FormatString("d");
		EndDateQRLabel4->Caption = inspectionEndTime.FormatString("yyyy") + " / " + inspectionEndTime.FormatString("m") + " / " + inspectionEndTime.FormatString("d");

		EndTimeQRLabel->Caption = inspectionEndTime.FormatString("hh") + " : " + inspectionEndTime.FormatString("nn");
		EndTimeQRLabel2->Caption = inspectionEndTime.FormatString("hh") + " : " + inspectionEndTime.FormatString("nn");
		EndTimeQRLabel3->Caption = inspectionEndTime.FormatString("hh") + " : " + inspectionEndTime.FormatString("nn");
		EndTimeQRLabel4->Caption = inspectionEndTime.FormatString("hh") + " : " + inspectionEndTime.FormatString("nn");

		PassCntQRLabel->Caption = Format("%.0n "+UnitStr, ARRAYOFCONST(((double)Report.Data.GoodTabletCount)));
		PassCntQRLabel2->Caption = Format("%.0n "+UnitStr, ARRAYOFCONST(((double)Report.Data.GoodTabletCount)));
		PassCntQRLabel3->Caption = Format("%.0n "+UnitStr, ARRAYOFCONST(((double)Report.Data.GoodTabletCount)));
		PassCntQRLabel4->Caption = Format("%.0n "+UnitStr, ARRAYOFCONST(((double)Report.Data.GoodTabletCount)));

		DefectCntQRLabel->Caption = Format("%.0n "+UnitStr, ARRAYOFCONST(((double)Report.Data.DefectTabletCount)));
		DefectCntQRLabel2->Caption = Format("%.0n "+UnitStr, ARRAYOFCONST(((double)Report.Data.DefectTabletCount)));
		DefectCntQRLabel3->Caption = Format("%.0n "+UnitStr, ARRAYOFCONST(((double)Report.Data.DefectTabletCount)));
		DefectCntQRLabel4->Caption = Format("%.0n "+UnitStr, ARRAYOFCONST(((double)Report.Data.DefectTabletCount)));

        if(PCProgramOption.IncludeUnInsTabletCount == true)
        {
        	UninsCntQRLabel3->Caption = Format("%.0n "+UnitStr, ARRAYOFCONST(((double)Report.Data.UnInsTabletCount)));
            UninsCntQRLabel->Caption = Format("%.0n "+UnitStr, ARRAYOFCONST(((double)Report.Data.UnInsTabletCount)));
        	UninsCntQRLabel2->Caption = Format("%.0n "+UnitStr, ARRAYOFCONST(((double)Report.Data.UnInsTabletCount)));
            UninsCntQRLabel4->Caption = Format("%.0n "+UnitStr, ARRAYOFCONST(((double)Report.Data.UnInsTabletCount)));
        }


		// 검사 결과
		// 미검 옵션 선택 사항에 따른 계산 변경
		int TotalCnt = 0;
		if (PCProgramOption.IncludeUnInsTabletCount)
			TotalCnt = Report.Data.GoodTabletCount + Report.Data.DefectTabletCount + Report.Data.UnInsTabletCount;
		else
			TotalCnt = Report.Data.GoodTabletCount + Report.Data.DefectTabletCount;

		TotalCntQRLabel->Caption = Format("%.0n "+UnitStr, ARRAYOFCONST(((double)(TotalCnt))));
		TotalCntQRLabel2->Caption = Format("%.0n "+UnitStr, ARRAYOFCONST(((double)(TotalCnt))));
		TotalCntQRLabel3->Caption = Format("%.0n "+UnitStr, ARRAYOFCONST(((double)(TotalCnt))));
		TotalCntQRLabel4->Caption = Format("%.0n "+UnitStr, ARRAYOFCONST(((double)(TotalCnt))));

		bool ValidCheck = false; // 각 항목에 따른 총 제품 검사 수량이 0보다 큰지 확인
		if (PCProgramOption.IncludeUnInsTabletCount)
			ValidCheck = (Report.Data.GoodTabletCount + Report.Data.DefectTabletCount + Report.Data.UnInsTabletCount > 0) ? true : false;
		else
			ValidCheck = (Report.Data.GoodTabletCount + Report.Data.DefectTabletCount > 0) ? true : false;

		if (ValidCheck)
		{
			//RPassCntQRLabel->Caption = Format("%.2f %%", ARRAYOFCONST(((double)tabletInspectReport.GoodTabletCount * 100 / (tabletInspectReport.TotalTabletCount))));
			//RDefectCntQRLabel->Caption = Format("%.2f %%", ARRAYOFCONST(((double)tabletInspectReport.DefectTabletCount * 100 / (tabletInspectReport.TotalTabletCount))));
			RPassCntQRLabel->Caption = Format("%.2f %%", ARRAYOFCONST(((double)Report.Data.GoodTabletCount * 100 / TotalCnt)));
			RDefectCntQRLabel->Caption = Format("%.2f %%", ARRAYOFCONST(((double)Report.Data.DefectTabletCount * 100 / TotalCnt)));

			//RPassCntQRLabel2->Caption = Format("%.2f %%", ARRAYOFCONST(((double)tabletInspectReport.GoodTabletCount * 100 / (tabletInspectReport.TotalTabletCount))));
			//RDefectCntQRLabel2->Caption = Format("%.2f %%", ARRAYOFCONST(((double)tabletInspectReport.DefectTabletCount * 100 / (tabletInspectReport.TotalTabletCount))));  
			RPassCntQRLabel2->Caption = Format("%.2f %%", ARRAYOFCONST(((double)Report.Data.GoodTabletCount * 100 / TotalCnt)));
			RDefectCntQRLabel2->Caption = Format("%.2f %%", ARRAYOFCONST(((double)Report.Data.DefectTabletCount * 100 / TotalCnt)));

			//RPassCntQRLabel3->Caption = Format("%.2f %%", ARRAYOFCONST(((double)tabletInspectReport.GoodTabletCount * 100 / (tabletInspectReport.TotalTabletCount))));
			//RDefectCntQRLabel3->Caption = Format("%.2f %%", ARRAYOFCONST(((double)tabletInspectReport.DefectTabletCount * 100 / (tabletInspectReport.TotalTabletCount))));
			RPassCntQRLabel3->Caption = Format("%.2f %%", ARRAYOFCONST(((double)Report.Data.GoodTabletCount * 100 / TotalCnt)));
			RDefectCntQRLabel3->Caption = Format("%.2f %%", ARRAYOFCONST(((double)Report.Data.DefectTabletCount * 100 / TotalCnt)));

			//RPassCntQRLabel4->Caption = Format("%.2f %%", ARRAYOFCONST(((double)tabletInspectReport.GoodTabletCount * 100 / (tabletInspectReport.TotalTabletCount))));
			//RDefectCntQRLabel4->Caption = Format("%.2f %%", ARRAYOFCONST(((double)tabletInspectReport.DefectTabletCount * 100 / (tabletInspectReport.TotalTabletCount))));
			RPassCntQRLabel4->Caption = Format("%.2f %%", ARRAYOFCONST(((double)Report.Data.GoodTabletCount * 100 / TotalCnt)));
			RDefectCntQRLabel4->Caption = Format("%.2f %%", ARRAYOFCONST(((double)Report.Data.DefectTabletCount * 100 / TotalCnt)));
		}
		else
		{
			RDefectCntQRLabel->Caption = "0%";
			RPassCntQRLabel->Caption = "0%";

			RDefectCntQRLabel2->Caption = "0%";
			RPassCntQRLabel2->Caption = "0%";

			RDefectCntQRLabel3->Caption = "0%";
			RPassCntQRLabel3->Caption = "0%";

			RDefectCntQRLabel4->Caption = "0%";
			RPassCntQRLabel4->Caption = "0%";
		}


		/**************************************************************************/
		OptionBreakingGradeQRLabel->Caption = FloatToStr((float)Report.GradeData.OptionBreakingGrade*30.0 / 10.0 / 1000.0) + " mm";
		OptionFrontStickingGradeType1QRLabel->Caption = FloatToStr((float)Report.GradeData.OptionFrontStickingGrade_Type1*30.0 / 10.0 / 1000.0) + " mm";
    OptionFrontStickingGradeType2QRLabel->Caption = FloatToStr((float)Report.GradeData.OptionFrontStickingGrade_Type2*30.0 / 10.0 / 1000.0) + " mm";
    
		OptionPrintMarkGradeQRLabel->Caption = IntToStr(Report.GradeData.OptionPrintMarkGrade) + " % ";

		PrintEraseGradeQRLabel->Caption = FloatToStr(DefectSizePixelToMili((Report.GradeData.PrintEraseGrade + 1) * (Report.GradeData.PrintEraseGrade)) / 100.0) + " mm";
		ThreeDHeightMinusLimitQRLabel->Caption = "-" + FloatToStr((float)Report.GradeData.ThreeDHeightMinusLimit*0.03) + " mm";
		ThreeDHeightPlusLimitQRLabel->Caption = "+" + FloatToStr((float)Report.GradeData.ThreeDHeightPlusLimit*0.03) + " mm";

		OptionBreakingGradeQRLabel3->Caption = FloatToStr((float)Report.GradeData.OptionBreakingGrade*30.0 / 10.0 / 1000.0) + " mm";

		OptionFrontStickingGradeType1QRLabel3->Caption = FloatToStr((float)Report.GradeData.OptionFrontStickingGrade_Type1*30.0 / 10.0 / 1000.0) + " mm";
    OptionFrontStickingGradeType2QRLabel3->Caption = FloatToStr((float)Report.GradeData.OptionFrontStickingGrade_Type2*30.0 / 10.0 / 1000.0) + " mm";

		OptionPrintMarkGradeQRLabel3->Caption = IntToStr(Report.GradeData.OptionPrintMarkGrade) + " % ";

		PrintEraseGradeQRLabel3->Caption = FloatToStr(DefectSizePixelToMili((Report.GradeData.PrintEraseGrade + 1) * (Report.GradeData.PrintEraseGrade)) / 100.0) + " mm";

		ThreeDHeightMinusLimitQRLabel3->Caption = "-" + FloatToStr((float)Report.GradeData.ThreeDHeightMinusLimit*0.03) + " mm";
		ThreeDHeightPlusLimitQRLabel3->Caption = "+" + FloatToStr((float)Report.GradeData.ThreeDHeightPlusLimit*0.03) + " mm";
		/**************************************************************************/
		OptionBreakingGradeQRLabel2->Caption = FloatToStr((float)Report.GradeData.OptionBreakingGrade*30.0 / 10.0 / 1000.0) + " mm";
		OptionFrontStickingGradeType1QRLabel2->Caption = FloatToStr((float)Report.GradeData.OptionFrontStickingGrade_Type1*30.0 / 10.0 / 1000.0) + " mm";
    OptionFrontStickingGradeType2QRLabel2->Caption = FloatToStr((float)Report.GradeData.OptionFrontStickingGrade_Type2*30.0 / 10.0 / 1000.0) + " mm";

		OptionPrintMarkGradeQRLabel2->Caption = IntToStr(Report.GradeData.OptionPrintMarkGrade) + " % ";
		PrintEraseGradeQRLabel2->Caption = FloatToStr(DefectSizePixelToMili((Report.GradeData.PrintEraseGrade + 1) * (Report.GradeData.PrintEraseGrade)) / 100.0) + " mm";
		ThreeDHeightMinusLimitQRLabel2->Caption = "-" + FloatToStr((float)Report.GradeData.ThreeDHeightMinusLimit*0.03) + " mm";
		ThreeDHeightPlusLimitQRLabel2->Caption = "+" + FloatToStr((float)Report.GradeData.ThreeDHeightPlusLimit*0.03) + " mm";

		FrontNormalDirtySizeQRLabel2->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.FrontNormalDirtySize) / 100.0) + " mm";
		FrontEdgeDirtySizeQRLabel2->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.FrontEdgeDirtySize) / 100.0) + " mm";
		FrontStainSizeQRLabel2->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.FrontStainSize) / 100.0) + " mm";
		FrontEdgeSizeQRLabel2->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.FrontEdgeSize) / 100.0) + " mm";
		FrontColorDirtySizeQRLabel2->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.FrontColorDirtySize) / 100.0) + " mm";
		SideDirtySizeQRLabel2->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.SideDirtySize) / 100.0) + " mm";
		SideStainSizeQRLabel2->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.SideStainSize) / 100.0) + " mm";
		OptionBreakingSizeQRLabel2->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.OptionBreakingSize) / 100.0) + " mm";

		OptionFrontStickingSizeType1QRLabel2->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.OptionFrontStickingSize_Type1) / 100.0) + " mm";
    OptionFrontStickingSizeType2QRLabel2->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.OptionFrontStickingSize_Type2) / 100.0) + " mm";

		SideColorDirtySizeQRLabel2->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.SideColorDirtySize) / 100.0) + " mm";
		QRLabel11->Caption = FloatToStr((float)Report.GradeData.EngraveDistinguishGradeFor3D*30.0 / 10.0 / 100.0) + " mm";

		/**************************************************************************/
		OptionBreakingGradeQRLabel4->Caption = FloatToStr((float)Report.GradeData.OptionBreakingGrade*30.0 / 10.0 / 1000.0) + " mm";
		OptionFrontStickingGradeType1QRLabel4->Caption = FloatToStr((float)Report.GradeData.OptionFrontStickingGrade_Type1*30.0 / 10.0 / 1000.0) + " mm";
    OptionFrontStickingGradeType2QRLabel4->Caption = FloatToStr((float)Report.GradeData.OptionFrontStickingGrade_Type2*30.0 / 10.0 / 1000.0) + " mm";
    
		OptionPrintMarkGradeQRLabel4->Caption = IntToStr(Report.GradeData.OptionPrintMarkGrade) + " % ";
		PrintEraseGradeQRLabel4->Caption = FloatToStr(DefectSizePixelToMili((Report.GradeData.PrintEraseGrade + 1) * (Report.GradeData.PrintEraseGrade)) / 100.0) + " mm";

		ThreeDHeightMinusLimitQRLabel4->Caption = "-" + FloatToStr((float)Report.GradeData.ThreeDHeightMinusLimit*0.03) + " mm";
		ThreeDHeightPlusLimitQRLabel4->Caption = "+" + FloatToStr((float)Report.GradeData.ThreeDHeightPlusLimit*0.03) + " mm";

		FrontNormalDirtySizeQRLabel4->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.FrontNormalDirtySize) / 100.0) + " mm";
		FrontEdgeDirtySizeQRLabel4->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.FrontEdgeDirtySize) / 100.0) + " mm";
		FrontStainSizeQRLabel4->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.FrontStainSize) / 100.0) + " mm";
		FrontEdgeSizeQRLabel4->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.FrontEdgeSize) / 100.0) + " mm";
		FrontColorDirtySizeQRLabel4->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.FrontColorDirtySize) / 100.0) + " mm";
		SideDirtySizeQRLabel4->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.SideDirtySize) / 100.0) + " mm";
		SideStainSizeQRLabel4->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.SideStainSize) / 100.0) + " mm";
		OptionBreakingSizeQRLabel4->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.OptionBreakingSize) / 100.0) + " mm";
		OptionFrontStickingSizeType1QRLabel4->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.OptionFrontStickingSize_Type1) / 100.0) + " mm";
    OptionFrontStickingSizeType2QRLabel4->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.OptionFrontStickingSize_Type2) / 100.0) + " mm";

		SideColorDirtySizeQRLabel4->Caption = FloatToStr(DefectSizePixelToMili(Report.GradeData.SideColorDirtySize) / 100.0) + " mm";
		QRLLABEL11->Caption = FloatToStr((float)Report.GradeData.EngraveDistinguishGradeFor3D*30.0 / 10.0 / 100.0) + " mm";

		if (printModeOption == 0)
		{
			PrintGradeOnlyRadioButton->Checked = true;

			if (!PrintDefectSeriesCheckBox->Checked)
			{
				ReportPanel1->BringToFront();
			}
			else
			{
				ReportPanel3->BringToFront();
			}
			PrintSize = false;
		}
		else
		{
			PrintGradeAndSizeRadioButton->Checked = true;

			if (!PrintDefectSeriesCheckBox->Checked)
			{
				ReportPanel2->BringToFront();
			}
			else
			{
				ReportPanel4->BringToFront();
			}

			PrintSize = true;
		}

		if (threeDHeightOption == 0)
		{
			ThreeDHeightMinusLimitQRLabel->Visible = true;
			ThreeDHeightPlusLimitQRLabel->Visible = true;
			ThreeDHeightGradeQRLabel->Visible = false;
			ThreeDHeightGradeQRLabel->Width = 0;
			ThreeDHeightMinusLimitQRLabel2->Visible = true;
			ThreeDHeightPlusLimitQRLabel2->Visible = true;
			ThreeDHeightGradeQRLabel2->Visible = false;
			ThreeDHeightGradeQRLabel2->Width = 0;
			ThreeDHeightMinusLimitQRLabel3->Visible = true;
			ThreeDHeightPlusLimitQRLabel3->Visible = true;
			ThreeDHeightGradeQRLabel3->Visible = false;
			ThreeDHeightGradeQRLabel3->Width = 0;
			ThreeDHeightMinusLimitQRLabel4->Visible = true;
			ThreeDHeightPlusLimitQRLabel4->Visible = true;
			ThreeDHeightGradeQRLabel4->Visible = false;
			ThreeDHeightGradeQRLabel4->Width = 0;
		}
		else
		{
			ThreeDHeightMinusLimitQRLabel->Visible = false;
			ThreeDHeightMinusLimitQRLabel->Width = 0;
			ThreeDHeightPlusLimitQRLabel->Visible = false;
			ThreeDHeightPlusLimitQRLabel->Width = 0;
			ThreeDHeightGradeQRLabel->Visible = true;
			ThreeDHeightMinusLimitQRLabel2->Visible = false;
			ThreeDHeightMinusLimitQRLabel2->Width = 0;
			ThreeDHeightPlusLimitQRLabel2->Visible = false;
			ThreeDHeightPlusLimitQRLabel2->Width = 0;
			ThreeDHeightGradeQRLabel2->Visible = true;
			ThreeDHeightMinusLimitQRLabel3->Visible = false;
			ThreeDHeightMinusLimitQRLabel3->Width = 0;
			ThreeDHeightPlusLimitQRLabel3->Visible = false;
			ThreeDHeightPlusLimitQRLabel3->Width = 0;
			ThreeDHeightGradeQRLabel3->Visible = true;
			ThreeDHeightMinusLimitQRLabel4->Visible = false;
			ThreeDHeightMinusLimitQRLabel4->Width = 0;
			ThreeDHeightPlusLimitQRLabel4->Visible = false;
			ThreeDHeightPlusLimitQRLabel4->Width = 0;
			ThreeDHeightGradeQRLabel4->Visible = true;
		}
	}

  if(ProductData.TabletType == TABLET_TYPE_SUGAR_COATED)
  {
    SideNLabel7->Caption = "";
    QRLabel230->Caption = "";
    SideNLabel8->Caption = "";
    SideEdgeDarkIntensityLabel1->Caption = "";
    SideEdgeBrightIntensityLabel1->Caption = "";
    SideEdgeNeighborIntensityLabel1->Caption = "";
    SideEdgeBreakIntensityLabel1->Caption = "";
    SideEdgeDarkSizeLabel1->Caption = "";
    SideEdgeBrightSizeLabel1->Caption = "";
    SideEdgeNeighborSizeLabel1->Caption = "";
    SideEdgeBreakSizeLabel1->Caption = "";

    SideNLabel3->Caption = "";
    QRLabel12->Caption = "";
    SideNLabel4->Caption = "";
    SideEdgeDarkIntensityLabel2->Caption = "";
    SideEdgeBrightIntensityLabel2->Caption = "";
    SideEdgeNeighborIntensityLabel2->Caption = "";
    SideEdgeBreakIntensityLabel2->Caption = "";
    SideEdgeDarkSizeLabel2->Caption = "";
    SideEdgeBrightSizeLabel2->Caption = "";
    SideEdgeNeighborSizeLabel2->Caption = "";
    SideEdgeBreakSizeLabel2->Caption = "";

    SideNLabel1->Caption = "";
    QRLabel22->Caption = "";
    SideNLabel2->Caption = "";
    SideEdgeDarkIntensityLabel3->Caption = "";
    SideEdgeBrightIntensityLabel3->Caption = "";
    SideEdgeNeighborIntensityLabel3->Caption = "";
    SideEdgeBreakIntensityLabel3->Caption = "";

    SideNLabel5->Caption = "";
    QRLabel149->Caption = "";
    SideNLabel6->Caption = "";
    SideEdgeDarkIntensityLabel4->Caption = "";
    SideEdgeBrightIntensityLabel4->Caption = "";
    SideEdgeNeighborIntensityLabel4->Caption = "";
    SideEdgeBreakIntensityLabel4->Caption = "";
  }

	//대표 불량 이미지 페이지 작성
	PrintImageIndexLoad();
	QRLabel122->Caption = V6_REPORT_PRINT_FORM_ADD_10; // "대표 불량 이미지"; //

	int i, CountImage;
	CountImage = 0;
	newImagePageIndex = 0;
	for (i = 0; i < 12; i++)
	{
		if (PrintImageIndex.DefectImageIndex[i] != 0xAAAA)
			CountImage++;
	}

	if (CountImage > 6)
	{
		if (CountImage > 12)
			CountImage = 12;

		newImagePageIndex = (CountImage - 1) / 6;
		CreateNewDefectImagePage();
	}

	if (CountImage)
		FillDefectImageReport(ProductName, lotName, CountImage);

/*
  if(!(ProductData.TabletShape == TABLET_SHAPE_CIRCLE || ProductData.TabletShape == TABLET_SHAPE_OBLONG || ProductData.TabletShape == TABLET_SHAPE_OVAL))
  {
    AnsiString breakSizeString = SideEdgeBreakSizeLabel2->Caption;
    SideEdgeBreakIntensityLabel1->Caption = "";
    SideEdgeBreakIntensityLabel2->Caption = "";
    SideEdgeBreakIntensityLabel3->Caption = breakSizeString;
    SideEdgeBreakIntensityLabel4->Caption = breakSizeString;
  }
 */

  if (DefaultLCID == 1028 || DefaultLCID == 2052 || DefaultLCID == 3076 || DefaultLCID == 4100)
		ComponentSetFontName(this, "SimSun");
	else if (DefaultLCID == 1041)
		ComponentSetFontName(this, "Meiryo UI");
  else if(DefaultLCID == 3082)
  {
    ComponentSetFontName(this, "Segoe UI");
    ComponentSetMultiLine(this);
  }

  if(MachineName.UpperCase() == "YJ")
  {
    int NameLabelPositionTop3[4];
    int NameLabelPositionTop6[4];
    int NameLabelPositionTop5[4];

    int GradeLabelPositionTop3[4];
    int GradeLabelPositionTop6[4];
    int GradeLabelPositionTop5[4];

    int SizeLabelPositionTop3[2];
    int SizeLabelPositionTop6[2];
    int SizeLabelPositionTop5[2];

    // GetPosition
    NameLabelPositionTop3[0] = QRLabel17->Top;
    NameLabelPositionTop3[1] = QRLabel44->Top;
    NameLabelPositionTop3[2] = QRLabel144->Top;
    NameLabelPositionTop3[3] = QRLabel224->Top;

    GradeLabelPositionTop3[0] = SideColorDirtyGradeQRLabel->Top;
    GradeLabelPositionTop3[1] = SideColorDirtyGradeQRLabel2->Top;
    GradeLabelPositionTop3[2] = SideColorDirtyGradeQRLabel3->Top;
    GradeLabelPositionTop3[3] = SideColorDirtyGradeQRLabel4->Top;

    SizeLabelPositionTop3[0] = SideColorDirtySizeQRLabel4->Top;
    SizeLabelPositionTop3[1] = SideColorDirtySizeQRLabel2->Top;

    NameLabelPositionTop5[0] = QRLabel22->Top;
    NameLabelPositionTop5[1] = QRLabel12->Top;
    NameLabelPositionTop5[2] = QRLabel149->Top;
    NameLabelPositionTop5[3] = QRLabel230->Top;

    GradeLabelPositionTop5[0] = SideEdgeNeighborIntensityLabel3->Top;
    GradeLabelPositionTop5[1] = SideEdgeNeighborIntensityLabel2->Top;
    GradeLabelPositionTop5[2] = SideEdgeNeighborIntensityLabel4->Top;
    GradeLabelPositionTop5[3] = SideEdgeNeighborIntensityLabel1->Top;

    SizeLabelPositionTop5[0] = SideEdgeNeighborSizeLabel1->Top;
    SizeLabelPositionTop5[1] = SideEdgeNeighborSizeLabel2->Top;

    NameLabelPositionTop6[0] = SideNLabel2->Top;
    NameLabelPositionTop6[1] = SideNLabel4->Top;
    NameLabelPositionTop6[2] = SideNLabel6->Top;
    NameLabelPositionTop6[3] = SideNLabel8->Top;

    GradeLabelPositionTop6[0] = SideEdgeBreakIntensityLabel3->Top;
    GradeLabelPositionTop6[1] = SideEdgeBreakIntensityLabel2->Top;
    GradeLabelPositionTop6[2] = SideEdgeBreakIntensityLabel4->Top;
    GradeLabelPositionTop6[3] = SideEdgeBreakIntensityLabel1->Top;

    SizeLabelPositionTop6[0] = SideEdgeBreakSizeLabel2->Top;
    SizeLabelPositionTop6[1] = SideEdgeBreakSizeLabel1->Top;

    // SIDE GRADE

    // 3->6 Color Stain

    QRLabel17->Top = NameLabelPositionTop6[0];
    QRLabel44->Top  = NameLabelPositionTop6[1];
    QRLabel144->Top  = NameLabelPositionTop6[2];
    QRLabel224->Top =  NameLabelPositionTop6[3];

    SideColorDirtyGradeQRLabel->Top = GradeLabelPositionTop6[0];
    SideColorDirtyGradeQRLabel2->Top = GradeLabelPositionTop6[1];
    SideColorDirtyGradeQRLabel3->Top = GradeLabelPositionTop6[2];
    SideColorDirtyGradeQRLabel4->Top = GradeLabelPositionTop6[3];

    SideColorDirtySizeQRLabel2->Top=SizeLabelPositionTop6[0];
    SideColorDirtySizeQRLabel4->Top=SizeLabelPositionTop6[1];


    // 5->3 Side N Edge Blur or Spot
    QRLabel22->Top = NameLabelPositionTop3[0];
    QRLabel12->Top = NameLabelPositionTop3[1];
    QRLabel149->Top =NameLabelPositionTop3[2];
    QRLabel230->Top =NameLabelPositionTop3[3];

    SideEdgeNeighborSizeLabel1->Top = SizeLabelPositionTop3[0];
    SideEdgeNeighborSizeLabel2->Top = SizeLabelPositionTop3[1];

    SideEdgeNeighborIntensityLabel3->Top = GradeLabelPositionTop3[0];
    SideEdgeNeighborIntensityLabel2->Top = GradeLabelPositionTop3[1];
    SideEdgeNeighborIntensityLabel4->Top = GradeLabelPositionTop3[2];
    SideEdgeNeighborIntensityLabel1->Top = GradeLabelPositionTop3[3];


    // 6->5 Edge Blur or Spot
    SideNLabel2->Top = NameLabelPositionTop5[0];
    SideNLabel4->Top = NameLabelPositionTop5[1];
    SideNLabel6->Top = NameLabelPositionTop5[2];
    SideNLabel8->Top = NameLabelPositionTop5[3];

    SideEdgeBreakSizeLabel1->Top = SizeLabelPositionTop5[0];
    SideEdgeBreakSizeLabel2->Top = SizeLabelPositionTop5[1];

    SideEdgeBreakIntensityLabel3->Top = GradeLabelPositionTop5[0];
    SideEdgeBreakIntensityLabel2->Top = GradeLabelPositionTop5[1];
    SideEdgeBreakIntensityLabel4->Top = GradeLabelPositionTop5[2];
    SideEdgeBreakIntensityLabel1->Top = GradeLabelPositionTop5[3];

  }
}
//---------------------------------------------------------------------------

void __fastcall TPrintInspectionResultForm::FormCreate(TObject *Sender)
{
	//	TodayDateQRLabel->Caption = "출력일 : " + Now().DateString();

	bYuhanOption = false;
}
//---------------------------------------------------------------------------

void __fastcall TPrintInspectionResultForm::PrintPreviewButtonClick(
	TObject *Sender)
{
	/*
	if (!PrintSize)
	{
	QRRichText->Enabled = true;

	if(PrintDefectSeriesCheckBox->Checked)
	QuickRep3->Preview();
	else
	QuickRep1->Preview();

	QRRichText->Enabled = false;
	}
	else
	{
	QRRichText2->Enabled = true;

	if(PrintDefectSeriesCheckBox->Checked)
	QuickRep4->Preview();
	else
	QuickRep2->Preview();

	QRRichText2->Enabled = false;
	}*/
	QRCompositeReport1->Preview();
}
//---------------------------------------------------------------------------

void __fastcall TPrintInspectionResultForm::CancelButtonClick(
	TObject *Sender)
{

	if (newImagePageIndex > 0)
	{
		TQuickRep *tempQR;
		for (int PIndex = 1; PIndex <= newImagePageIndex; PIndex++)
		{
			tempQR = (TQuickRep*)FindComponent("newImageQR" + IntToStr(PIndex));
			delete tempQR;
		}
	}

	this->Close();
}
//---------------------------------------------------------------------------

void __fastcall TPrintInspectionResultForm::PrintButtonClick(TObject *Sender)
{
	/*
	if (!PrintSize)
	{
	QRRichText->Enabled = true;

	if(PrintDefectSeriesCheckBox->Checked)
	QuickRep3->Print();
	else
	QuickRep1->Print();

	QRRichText->Enabled = false;
	}
	else
	{
	QRRichText2->Enabled = true;

	if(PrintDefectSeriesCheckBox->Checked)
	QuickRep4->Print();
	else
	QuickRep2->Print();

	QRRichText2->Enabled = false;
	}                         */

	QRCompositeReport1->Print();
}
//---------------------------------------------------------------------------
void __fastcall TPrintInspectionResultForm::PrinterSetupButtonClick(
	TObject *Sender)
{
	//QuickRep1->PrinterSetup();  
	QRCompositeReport1->PrinterSetup();
}
//---------------------------------------------------------------------------

void __fastcall TPrintInspectionResultForm::PrintGradeOnlyRadioButtonClick(
	TObject *Sender)
{
	UpdateTotalReportPages(0);
	if (PrintDefectSeriesCheckBox->Checked)
		ReportPanel3->BringToFront();
	else
		ReportPanel1->BringToFront();

	PrintSize = false;
}
//---------------------------------------------------------------------------

void __fastcall TPrintInspectionResultForm::PrintGradeAndSizeRadioButtonClick(
	TObject *Sender)
{
	UpdateTotalReportPages(0);
	if (PrintDefectSeriesCheckBox->Checked)
		ReportPanel4->BringToFront();
	else
		ReportPanel2->BringToFront();

	PrintSize = true;
}
//---------------------------------------------------------------------------

void __fastcall TPrintInspectionResultForm::PrintDefectSeriesCheckBoxClick(
	TObject *Sender)
{
	UpdateTotalReportPages(0);
	if (PrintDefectSeriesCheckBox->Checked)
	{
		if (PrintGradeOnlyRadioButton->Checked)
		{
			ReportPanel3->BringToFront();
			PrintSize = false;
		}
		else if (PrintGradeAndSizeRadioButton->Checked)
		{
			ReportPanel4->BringToFront();
			PrintSize = true;
		}
	}
	else
	{
		if (PrintGradeOnlyRadioButton->Checked)
		{
			ReportPanel1->BringToFront();
			PrintSize = false;
		}
		else if (PrintGradeAndSizeRadioButton->Checked)
		{
			ReportPanel2->BringToFront();
			PrintSize = true;
		}
	}

	DisplayReportPanelOption1(CheckBox4->Checked);
	DisplayReportPanelOption2(CheckBox4->Checked);
	DisplayReportPanelOption3(CheckBox4->Checked);
	DisplayReportPanelOption4(CheckBox4->Checked);
}
//---------------------------------------------------------------------------
void __fastcall TPrintInspectionResultForm::CreateNewDefectImagePage()
{
	int pageIndex;

	for (pageIndex = 1; pageIndex <= newImagePageIndex; pageIndex++)
	{
		//Report
		TQuickRep *tempQR = (TQuickRep*)FindComponent("newImageQR" + IntToStr(pageIndex));
		if (tempQR != NULL)
			continue;

		TQuickRep * pQR = new TQuickRep(this);
		pQR->Name = "newImageQR" + IntToStr(pageIndex);
		pQR->Parent = ReportPanel5;


		//상단 QRBand 
		TQRBand *pQRBand1 = new TQRBand(this);
		pQRBand1->Parent = pQR;
		pQRBand1->Name = "newImageQRBand" + IntToStr(pageIndex * 2 - 1);
		pQRBand1->Left = QRBand9->Left;
		pQRBand1->Top = QRBand9->Top;
		pQRBand1->Width = QRBand9->Width;
		pQRBand1->Height = QRBand9->Height;
		pQRBand1->BandType = QRBand9->BandType;


		//하단 QRBand
		TQRBand *pQRBand2 = new TQRBand(this);
		pQRBand2->Parent = pQR;
		pQRBand2->Name = "newImageQRBand" + IntToStr(pageIndex * 2);
		pQRBand2->Left = QRBand10->Left;
		pQRBand2->Top = QRBand10->Top;
		pQRBand2->Width = QRBand10->Width;
		pQRBand2->Height = QRBand10->Height;
		pQRBand2->BandType = QRBand10->BandType;



		// Main Title
		TQRLabel *pQRMainTitle = new TQRLabel(this);
		pQRMainTitle->Parent = pQRBand1;
		pQRMainTitle->Name = "ImageQRMainTitle" + IntToStr(pageIndex);
		pQRMainTitle->Left = QRLabel122->Left;
		pQRMainTitle->Top = QRLabel122->Top;
		pQRMainTitle->Width = QRLabel122->Width;
		pQRMainTitle->Caption = QRLabel122->Caption;
		pQRMainTitle->Font = QRLabel122->Font;
		pQRMainTitle->Height = QRLabel122->Height;
		pQRMainTitle->Alignment = pQRMainTitle->Alignment;
		pQRMainTitle->AutoSize = pQRMainTitle->AutoSize;

		//Frame 
		for (int FrameIndex = 1; FrameIndex <= 16; FrameIndex++)
		{
			int tempComponentIndex = pageIndex * 16 - (16 - FrameIndex);
			TQRShape *pBaseFrame = new TQRShape(this);
			pBaseFrame->Parent = pQRBand2;
			pBaseFrame->Name = "newImageBaseFrame" + IntToStr(tempComponentIndex);
			pBaseFrame->Left = ((TQRShape*)FindComponent("QRImageFrame" + IntToStr(FrameIndex)))->Left;
			pBaseFrame->Top = ((TQRShape*)FindComponent("QRImageFrame" + IntToStr(FrameIndex)))->Top;
			pBaseFrame->Width = ((TQRShape*)FindComponent("QRImageFrame" + IntToStr(FrameIndex)))->Width;
			pBaseFrame->Height = ((TQRShape*)FindComponent("QRImageFrame" + IntToStr(FrameIndex)))->Height;
			pBaseFrame->Shape = ((TQRShape*)FindComponent("QRImageFrame" + IntToStr(FrameIndex)))->Shape;
			pBaseFrame->Enabled = ((TQRShape*)FindComponent("QRImageFrame" + IntToStr(FrameIndex)))->Enabled;
			pBaseFrame->Cursor = ((TQRShape*)FindComponent("QRImageFrame" + IntToStr(FrameIndex)))->Cursor;

			pBaseFrame->Frame->Color = ((TQRShape*)FindComponent("QRImageFrame" + IntToStr(FrameIndex)))->Frame->Color;
			pBaseFrame->Frame->DrawBottom = ((TQRShape*)FindComponent("QRImageFrame" + IntToStr(FrameIndex)))->Frame->DrawBottom;
			pBaseFrame->Frame->DrawLeft = ((TQRShape*)FindComponent("QRImageFrame" + IntToStr(FrameIndex)))->Frame->DrawLeft;
			pBaseFrame->Frame->DrawRight = ((TQRShape*)FindComponent("QRImageFrame" + IntToStr(FrameIndex)))->Frame->DrawRight;
			pBaseFrame->Frame->DrawTop = ((TQRShape*)FindComponent("QRImageFrame" + IntToStr(FrameIndex)))->Frame->DrawTop;
			pBaseFrame->Frame->Style = ((TQRShape*)FindComponent("QRImageFrame" + IntToStr(FrameIndex)))->Frame->Style;
			pBaseFrame->Frame->Width = ((TQRShape*)FindComponent("QRImageFrame" + IntToStr(FrameIndex)))->Frame->Width;

			pBaseFrame->Brush->Color = ((TQRShape*)FindComponent("QRImageFrame" + IntToStr(FrameIndex)))->Brush->Color;
			pBaseFrame->Brush->Style = ((TQRShape*)FindComponent("QRImageFrame" + IntToStr(FrameIndex)))->Brush->Style;

			pBaseFrame->Pen->Color = ((TQRShape*)FindComponent("QRImageFrame" + IntToStr(FrameIndex)))->Pen->Color;
			pBaseFrame->Pen->Mode = ((TQRShape*)FindComponent("QRImageFrame" + IntToStr(FrameIndex)))->Pen->Mode;
			pBaseFrame->Pen->Style = ((TQRShape*)FindComponent("QRImageFrame" + IntToStr(FrameIndex)))->Pen->Style;
			pBaseFrame->Pen->Width = ((TQRShape*)FindComponent("QRImageFrame" + IntToStr(FrameIndex)))->Pen->Width;

			pBaseFrame->Size->Height = ((TQRShape*)FindComponent("QRImageFrame" + IntToStr(FrameIndex)))->Size->Height;
			pBaseFrame->Size->Width = ((TQRShape*)FindComponent("QRImageFrame" + IntToStr(FrameIndex)))->Size->Width;
			pBaseFrame->Size->Top = ((TQRShape*)FindComponent("QRImageFrame" + IntToStr(FrameIndex)))->Size->Top;
			pBaseFrame->Size->Left = ((TQRShape*)FindComponent("QRImageFrame" + IntToStr(FrameIndex)))->Size->Left;
		}

		// QRDefectNameLabel
		for (int SortIndex = 1; SortIndex <= 6; SortIndex++)
		{
			TQRLabel *pQRDefectNameLabel = new TQRLabel(this);
			pQRDefectNameLabel->Parent = pQRBand2;
			pQRDefectNameLabel->Name = "QRDefectNameLabel" + IntToStr((pageIndex + 1) * 6 - (6 - SortIndex));
			pQRDefectNameLabel->Left = ((TQRLabel*)FindComponent("QRDefectNameLabel" + IntToStr(SortIndex)))->Left;
			pQRDefectNameLabel->Top = ((TQRLabel*)FindComponent("QRDefectNameLabel" + IntToStr(SortIndex)))->Top;
			pQRDefectNameLabel->Width = ((TQRLabel*)FindComponent("QRDefectNameLabel" + IntToStr(SortIndex)))->Width;

			pQRDefectNameLabel->Font = ((TQRLabel*)FindComponent("QRDefectNameLabel" + IntToStr(SortIndex)))->Font;
			pQRDefectNameLabel->Height = ((TQRLabel*)FindComponent("QRDefectNameLabel" + IntToStr(SortIndex)))->Height;
			pQRDefectNameLabel->Alignment = ((TQRLabel*)FindComponent("QRDefectNameLabel" + IntToStr(SortIndex)))->Alignment;
			pQRDefectNameLabel->AutoSize = ((TQRLabel*)FindComponent("QRDefectNameLabel" + IntToStr(SortIndex)))->AutoSize;

			pQRDefectNameLabel->Size->Height = ((TQRLabel*)FindComponent("QRDefectNameLabel" + IntToStr(SortIndex)))->Size->Height;
			pQRDefectNameLabel->Size->Width = ((TQRLabel*)FindComponent("QRDefectNameLabel" + IntToStr(SortIndex)))->Size->Width;
			pQRDefectNameLabel->Size->Top = ((TQRLabel*)FindComponent("QRDefectNameLabel" + IntToStr(SortIndex)))->Size->Top;
			pQRDefectNameLabel->Size->Left = ((TQRLabel*)FindComponent("QRDefectNameLabel" + IntToStr(SortIndex)))->Size->Left;
			pQRDefectNameLabel->Caption = "";
		}

		// QRDefectNameContent
		for (int SortIndex = 1; SortIndex <= 6; SortIndex++)
		{
			TQRLabel *pQRDefectNameContentLabel = new TQRLabel(this);
			pQRDefectNameContentLabel->Parent = pQRBand2;
			pQRDefectNameContentLabel->Name = "QRDefectNameContent" + IntToStr((pageIndex + 1) * 6 - (6 - SortIndex));
			pQRDefectNameContentLabel->Left = ((TQRLabel*)FindComponent("QRDefectNameContent" + IntToStr(SortIndex)))->Left;
			pQRDefectNameContentLabel->Top = ((TQRLabel*)FindComponent("QRDefectNameContent" + IntToStr(SortIndex)))->Top;
			pQRDefectNameContentLabel->Width = ((TQRLabel*)FindComponent("QRDefectNameContent" + IntToStr(SortIndex)))->Width;

			pQRDefectNameContentLabel->Font = ((TQRLabel*)FindComponent("QRDefectNameContent" + IntToStr(SortIndex)))->Font;
			pQRDefectNameContentLabel->Height = ((TQRLabel*)FindComponent("QRDefectNameContent" + IntToStr(SortIndex)))->Height;
			pQRDefectNameContentLabel->Alignment = ((TQRLabel*)FindComponent("QRDefectNameContent" + IntToStr(SortIndex)))->Alignment;
			pQRDefectNameContentLabel->AutoSize = ((TQRLabel*)FindComponent("QRDefectNameContent" + IntToStr(SortIndex)))->AutoSize;

			pQRDefectNameContentLabel->Size->Height = ((TQRLabel*)FindComponent("QRDefectNameContent" + IntToStr(SortIndex)))->Size->Height;
			pQRDefectNameContentLabel->Size->Width = ((TQRLabel*)FindComponent("QRDefectNameContent" + IntToStr(SortIndex)))->Size->Width;
			pQRDefectNameContentLabel->Size->Top = ((TQRLabel*)FindComponent("QRDefectNameContent" + IntToStr(SortIndex)))->Size->Top;
			pQRDefectNameContentLabel->Size->Left = ((TQRLabel*)FindComponent("QRDefectNameContent" + IntToStr(SortIndex)))->Size->Left;
			pQRDefectNameContentLabel->Caption = "";
		}

		// QRDefectSizeLabel
		for (int SortIndex = 1; SortIndex <= 6; SortIndex++)
		{
			TQRLabel *pQRDefectSizeLabel = new TQRLabel(this);
			pQRDefectSizeLabel->Parent = pQRBand2;
			pQRDefectSizeLabel->Name = "QRDefectSizeLabel" + IntToStr((pageIndex + 1) * 6 - (6 - SortIndex));
			pQRDefectSizeLabel->Left = ((TQRLabel*)FindComponent("QRDefectSizeLabel" + IntToStr(SortIndex)))->Left;
			pQRDefectSizeLabel->Top = ((TQRLabel*)FindComponent("QRDefectSizeLabel" + IntToStr(SortIndex)))->Top;
			pQRDefectSizeLabel->Width = ((TQRLabel*)FindComponent("QRDefectSizeLabel" + IntToStr(SortIndex)))->Width;

			pQRDefectSizeLabel->Font = ((TQRLabel*)FindComponent("QRDefectSizeLabel" + IntToStr(SortIndex)))->Font;
			pQRDefectSizeLabel->Height = ((TQRLabel*)FindComponent("QRDefectSizeLabel" + IntToStr(SortIndex)))->Height;
			pQRDefectSizeLabel->Alignment = ((TQRLabel*)FindComponent("QRDefectSizeLabel" + IntToStr(SortIndex)))->Alignment;
			pQRDefectSizeLabel->AutoSize = ((TQRLabel*)FindComponent("QRDefectSizeLabel" + IntToStr(SortIndex)))->AutoSize;

			pQRDefectSizeLabel->Size->Height = ((TQRLabel*)FindComponent("QRDefectSizeLabel" + IntToStr(SortIndex)))->Size->Height;
			pQRDefectSizeLabel->Size->Width = ((TQRLabel*)FindComponent("QRDefectSizeLabel" + IntToStr(SortIndex)))->Size->Width;
			pQRDefectSizeLabel->Size->Top = ((TQRLabel*)FindComponent("QRDefectSizeLabel" + IntToStr(SortIndex)))->Size->Top;
			pQRDefectSizeLabel->Size->Left = ((TQRLabel*)FindComponent("QRDefectSizeLabel" + IntToStr(SortIndex)))->Size->Left;
			pQRDefectSizeLabel->Caption = "";
		}

		// QRDefectSizeContent
		for (int SortIndex = 1; SortIndex <= 6; SortIndex++)
		{
			TQRLabel *pQRDefectSizeContent = new TQRLabel(this);
			pQRDefectSizeContent->Parent = pQRBand2;
			pQRDefectSizeContent->Name = "QRDefectSizeContent" + IntToStr((pageIndex + 1) * 6 - (6 - SortIndex));
			pQRDefectSizeContent->Left = ((TQRLabel*)FindComponent("QRDefectSizeContent" + IntToStr(SortIndex)))->Left;
			pQRDefectSizeContent->Top = ((TQRLabel*)FindComponent("QRDefectSizeContent" + IntToStr(SortIndex)))->Top;
			pQRDefectSizeContent->Width = ((TQRLabel*)FindComponent("QRDefectSizeContent" + IntToStr(SortIndex)))->Width;

			pQRDefectSizeContent->Font = ((TQRLabel*)FindComponent("QRDefectSizeContent" + IntToStr(SortIndex)))->Font;
			pQRDefectSizeContent->Height = ((TQRLabel*)FindComponent("QRDefectSizeContent" + IntToStr(SortIndex)))->Height;
			pQRDefectSizeContent->Alignment = ((TQRLabel*)FindComponent("QRDefectSizeContent" + IntToStr(SortIndex)))->Alignment;
			pQRDefectSizeContent->AutoSize = ((TQRLabel*)FindComponent("QRDefectSizeContent" + IntToStr(SortIndex)))->AutoSize;

			pQRDefectSizeContent->Size->Height = ((TQRLabel*)FindComponent("QRDefectSizeContent" + IntToStr(SortIndex)))->Size->Height;
			pQRDefectSizeContent->Size->Width = ((TQRLabel*)FindComponent("QRDefectSizeContent" + IntToStr(SortIndex)))->Size->Width;
			pQRDefectSizeContent->Size->Top = ((TQRLabel*)FindComponent("QRDefectSizeContent" + IntToStr(SortIndex)))->Size->Top;
			pQRDefectSizeContent->Size->Left = ((TQRLabel*)FindComponent("QRDefectSizeContent" + IntToStr(SortIndex)))->Size->Left;
			pQRDefectSizeContent->Caption = "";
		}


		// QRImage
		for (int SortIndex = 1; SortIndex <= 6; SortIndex++)
		{
			TQRImage *pQRImage = new TQRImage(this);
			pQRImage->Parent = pQRBand2;
			pQRImage->Name = "QRImage" + IntToStr((pageIndex + 1) * 6 - (6 - SortIndex));
			pQRImage->Left = ((TQRImage*)FindComponent("QRImage" + IntToStr(SortIndex)))->Left;
			pQRImage->Top = ((TQRImage*)FindComponent("QRImage" + IntToStr(SortIndex)))->Top;
			pQRImage->Width = ((TQRImage*)FindComponent("QRImage" + IntToStr(SortIndex)))->Width;

			pQRImage->Height = ((TQRImage*)FindComponent("QRImage" + IntToStr(SortIndex)))->Height;
			pQRImage->AutoSize = ((TQRImage*)FindComponent("QRImage" + IntToStr(SortIndex)))->AutoSize;
			pQRImage->Stretch = ((TQRImage*)FindComponent("QRImage" + IntToStr(SortIndex)))->Stretch;

			pQRImage->Size->Height = ((TQRImage*)FindComponent("QRImage" + IntToStr(SortIndex)))->Size->Height;
			pQRImage->Size->Width = ((TQRImage*)FindComponent("QRImage" + IntToStr(SortIndex)))->Size->Width;
			pQRImage->Size->Top = ((TQRImage*)FindComponent("QRImage" + IntToStr(SortIndex)))->Size->Top;
			pQRImage->Size->Left = ((TQRImage*)FindComponent("QRImage" + IntToStr(SortIndex)))->Size->Left;
		}

		TQRLabel * pQRLabel = new TQRLabel(this);
		pQRLabel->Parent = pQRBand2;

		pQRLabel->Left = ((TQRLabel*)FindComponent("QRPageDfImage0"))->Left;
		pQRLabel->Top = ((TQRLabel*)FindComponent("QRPageDfImage0"))->Top;
		pQRLabel->Width = ((TQRLabel*)FindComponent("QRPageDfImage0"))->Width;

		pQRLabel->Font = ((TQRLabel*)FindComponent("QRPageDfImage0"))->Font;
		pQRLabel->Height = ((TQRLabel*)FindComponent("QRPageDfImage0"))->Height;
		pQRLabel->Alignment = ((TQRLabel*)FindComponent("QRPageDfImage0"))->Alignment;
		pQRLabel->AutoSize = ((TQRLabel*)FindComponent("QRPageDfImage0"))->AutoSize;
		pQRLabel->Caption = "";

		pQRLabel->Name = "QRPageDfImage" + IntToStr(pageIndex);
		pQRLabel->Visible = false;
		pQRLabel->Enabled = false;

	}
}
//---------------------------------------------------------------------------
void __fastcall TPrintInspectionResultForm::RefreshDefectsInfo(int totalDefectCount)
{
	const int DISPLAY_DEFECT_COUNT = 10;
	int DefectCountList[MAX_DEFECT_SERIES_COUNT + 1];
	int DefectSeriesList[MAX_DEFECT_SERIES_COUNT + 1];
  int HCBDefectTabletCount;

  if(MachineSetupData.LasercomplexerInfo.Laser_complexer_Enable)
  {
    HCBDefectTabletCount = Report.Data.SPBProcessingNCTabletCount + Report.Data.FRMisMatchTabletCount + Report.Data.ClosedTabletDefectCount + Report.Data.NozzErrorDefectTabletCount;
  }
  else
  {
    HCBDefectTabletCount = Report.Data.SPBProcessingNCTabletCount + Report.Data.FRMisMatchTabletCount + Report.Data.ClosedTabletDefectCount + Report.Data.NozzErrorDefectTabletCount + Report.Data.UnPrintTabletCount;
  }
  
	for (int defectSeriesIndex = 0; defectSeriesIndex < MAX_DEFECT_SERIES_COUNT + 1; defectSeriesIndex++)
	{
		DefectCountList[defectSeriesIndex] = DefectSeriesCount[defectSeriesIndex];
		if (defectSeriesIndex < MAX_CPB_DEFECT_SERIES_COUNT)
		{
			DefectSeriesList[defectSeriesIndex] = defectSeriesIndex;
		}
		else
		{
			DefectSeriesList[defectSeriesIndex] = defectSeriesIndex - MAX_CPB_DEFECT_SERIES_COUNT + THIN_TALBET;
		}
	}

	for (int i = 0; i < MAX_DEFECT_SERIES_COUNT; i++)
	{
		for (int j = i; j < MAX_DEFECT_SERIES_COUNT; j++)
		{
			if (DefectCountList[i] < DefectCountList[j])
			{
				int temp = DefectCountList[i];
				DefectCountList[i] = DefectCountList[j];
				DefectCountList[j] = temp;

				temp = DefectSeriesList[i];
				DefectSeriesList[i] = DefectSeriesList[j];
				DefectSeriesList[j] = temp;
			}
		}
	}

	double defectCountList[DISPLAY_DEFECT_COUNT];
	int defectSeriesList[DISPLAY_DEFECT_COUNT];
	int defectSeriesCount = 0;
	defectCountList[DISPLAY_DEFECT_COUNT - 1] = 0;
	for (int defectSeriesIndex = 0; defectSeriesIndex < MAX_DEFECT_SERIES_COUNT; defectSeriesIndex++)
	{
		if (DefectCountList[defectSeriesIndex] > 0)
		{
			if (defectSeriesCount < DISPLAY_DEFECT_COUNT - 1)
			{
				defectCountList[defectSeriesCount] = DefectCountList[defectSeriesIndex];
				defectSeriesList[defectSeriesCount] = DefectSeriesList[defectSeriesIndex];
				defectSeriesCount++;
			}
			else
			{
				defectCountList[DISPLAY_DEFECT_COUNT - 1] += DefectCountList[defectSeriesIndex];
			}
		}
	}

  defectCountList[DISPLAY_DEFECT_COUNT - 1] += HCBDefectTabletCount;

	defectCountList[defectSeriesCount] = defectCountList[DISPLAY_DEFECT_COUNT - 1];

	int otherSW;
	int defectCount;
	int otherDefectCount;
	int lastDefectSeriesIndex;

	defectCount = 0;
	otherSW = 0;
	otherDefectCount = 0;

	for (int defectSeriesIndex = 0; defectSeriesIndex < DISPLAY_DEFECT_COUNT; defectSeriesIndex++)
	{
		TQRLabel *defectNameLabel = (TQRLabel *)FindComponent("DefectNameLabel" + IntToStr(defectSeriesIndex + 1));
		TQRLabel *defectCountLabel = (TQRLabel *)FindComponent("DefectCountLabel" + IntToStr(defectSeriesIndex + 1));
		TQRLabel *defectRatioLabel = (TQRLabel *)FindComponent("DefectRatioLabel" + IntToStr(defectSeriesIndex + 1));
		if (defectCountList[defectSeriesIndex] > 0 && defectSeriesIndex <= defectSeriesCount)
		{
			if (defectNameLabel)
			{
				if (defectSeriesIndex == defectSeriesCount)
				{
					defectNameLabel->Caption = INSPECTIONREPORTFORM_LABEL_CAPTION_05;
					otherSW = 1;
				}
				else
				{
					defectNameLabel->Caption = GetDefectSeriesStr(defectSeriesList[defectSeriesIndex]);
				}
				defectNameLabel->Visible = true;
			}
			if (defectCountLabel)
			{
				if (otherSW)
				{
					otherDefectCount = totalDefectCount - defectCount;

					if (otherDefectCount > -1)
					{
						defectCountLabel->Caption = FloatToStrF((float)otherDefectCount, ffNumber, 10, 0);
						defectCountLabel->Visible = true;
					}
				}
				else
				{
					defectCountLabel->Caption = FloatToStrF((float)defectCountList[defectSeriesIndex], ffNumber, 10, 0);
					defectCountLabel->Visible = true;

					defectCount += defectCountList[defectSeriesIndex];

					lastDefectSeriesIndex = defectSeriesIndex;
				}
			}
			if (defectRatioLabel)
			{
				if (otherSW)
				{
					if (totalDefectCount)
					{
						if (otherDefectCount > -1)
							defectRatioLabel->Caption = FloatToStrF((otherDefectCount / (float)totalDefectCount) * 100, ffFixed, 10, 2);
					}
					else
						defectRatioLabel->Caption = "0";

					defectRatioLabel->Visible = true;
				}
				else
				{
					if (totalDefectCount)
						defectRatioLabel->Caption = FloatToStrF((defectCountList[defectSeriesIndex] / totalDefectCount) * 100, ffFixed, 10, 2);
					else
						defectRatioLabel->Caption = "0";

					defectRatioLabel->Visible = true;
				}
			}
		}
		else
		{
			if (defectNameLabel)
			{
				defectNameLabel->Caption = GetDefectSeriesStr(defectSeriesList[defectSeriesIndex]);
				defectNameLabel->Caption = "";
			}
			if (defectCountLabel)
			{
				defectCountLabel->Caption = FloatToStrF((float)defectCountList[defectSeriesIndex], ffNumber, 10, 0);
				defectCountLabel->Caption = "";
			}
			if (defectRatioLabel)
			{
				if (totalDefectCount)
					defectRatioLabel->Caption = FloatToStr(defectCountList[defectSeriesIndex] / totalDefectCount);
				else
					defectRatioLabel->Caption = "0";

				defectRatioLabel->Caption = "";
			}
		}
	}

	if (otherSW == 0)
	{
		if (totalDefectCount > defectCount)
		{
			otherDefectCount = totalDefectCount - defectCount;

			TQRLabel *defectNameLabel = (TQRLabel *)FindComponent("DefectNameLabel" + IntToStr(lastDefectSeriesIndex + 1 + 1));
			TQRLabel *defectCountLabel = (TQRLabel *)FindComponent("DefectCountLabel" + IntToStr(lastDefectSeriesIndex + 1 + 1));
			TQRLabel *defectRatioLabel = (TQRLabel *)FindComponent("DefectRatioLabel" + IntToStr(lastDefectSeriesIndex + 1 + 1));

			if (defectNameLabel)
			{
				defectNameLabel->Caption = INSPECTIONREPORTFORM_LABEL_CAPTION_05;
				defectNameLabel->Visible = true;
			}
			if (defectCountLabel)
			{
				defectCountLabel->Caption = FloatToStrF((float)otherDefectCount, ffNumber, 10, 0);
				defectCountLabel->Visible = true;
			}
			if (defectRatioLabel)
			{
				defectRatioLabel->Caption = FloatToStrF((otherDefectCount / (float)totalDefectCount) * 100, ffFixed, 10, 2);
				defectRatioLabel->Visible = true;
			}
		}
	}

	defectCount = 0;
	otherSW = 0;
	otherDefectCount = 0;

	for (int defectSeriesIndex = 0; defectSeriesIndex < DISPLAY_DEFECT_COUNT; defectSeriesIndex++)
	{
		TQRLabel *defectNameLabel = (TQRLabel *)FindComponent("bDefectNameLabel" + IntToStr(defectSeriesIndex + 1));
		TQRLabel *defectCountLabel = (TQRLabel *)FindComponent("bDefectCountLabel" + IntToStr(defectSeriesIndex + 1));
		TQRLabel *defectRatioLabel = (TQRLabel *)FindComponent("bDefectRatioLabel" + IntToStr(defectSeriesIndex + 1));

		if (defectCountList[defectSeriesIndex] > 0 && defectSeriesIndex <= defectSeriesCount)
		{
			if (defectNameLabel)
			{
				if (defectSeriesIndex == defectSeriesCount)
				{
					defectNameLabel->Caption = INSPECTIONREPORTFORM_LABEL_CAPTION_05;
					otherSW = 1;
				}
				else
				{
					defectNameLabel->Caption = GetDefectSeriesStr(defectSeriesList[defectSeriesIndex]);
				}
				defectNameLabel->Visible = true;
			}
			if (defectCountLabel)
			{
				if (otherSW)
				{
					otherDefectCount = totalDefectCount - defectCount;

					if (otherDefectCount > -1)
					{
						defectCountLabel->Caption = FloatToStrF((float)otherDefectCount, ffNumber, 10, 0);
						defectCountLabel->Visible = true;
					}
				}
				else
				{
					defectCountLabel->Caption = FloatToStrF((float)defectCountList[defectSeriesIndex], ffNumber, 10, 0);
					defectCountLabel->Visible = true;

					defectCount += defectCountList[defectSeriesIndex];

					lastDefectSeriesIndex = defectSeriesIndex;
				}
			}
			if (defectRatioLabel)
			{
				if (otherSW)
				{
					if (totalDefectCount)
					{
						if (otherDefectCount > -1)
							defectRatioLabel->Caption = FloatToStrF((otherDefectCount / (float)totalDefectCount) * 100, ffFixed, 10, 2);
					}
					else
						defectRatioLabel->Caption = "0";

					defectRatioLabel->Visible = true;
				}
				else
				{
					if (totalDefectCount)
						defectRatioLabel->Caption = FloatToStrF((defectCountList[defectSeriesIndex] / totalDefectCount) * 100, ffFixed, 10, 2);
					else
						defectRatioLabel->Caption = "0";

					defectRatioLabel->Visible = true;
				}
			}
		}
		else
		{
			if (defectNameLabel)
			{
				defectNameLabel->Caption = GetDefectSeriesStr(defectSeriesList[defectSeriesIndex]);
				defectNameLabel->Caption = "";
			}
			if (defectCountLabel)
			{
				defectCountLabel->Caption = FloatToStrF((float)defectCountList[defectSeriesIndex], ffNumber, 10, 0);
				defectCountLabel->Caption = "";
			}
			if (defectRatioLabel)
			{
				if (totalDefectCount)
					defectRatioLabel->Caption = FloatToStr(defectCountList[defectSeriesIndex] / totalDefectCount);
				else
					defectRatioLabel->Caption = "0";

				defectRatioLabel->Caption = "";
			}
		}
	}

	if (otherSW == 0)
	{
		if (totalDefectCount > defectCount)
		{
			otherDefectCount = totalDefectCount - defectCount;

			TQRLabel *defectNameLabel = (TQRLabel *)FindComponent("bDefectNameLabel" + IntToStr(lastDefectSeriesIndex + 1 + 1));
			TQRLabel *defectCountLabel = (TQRLabel *)FindComponent("bDefectCountLabel" + IntToStr(lastDefectSeriesIndex + 1 + 1));
			TQRLabel *defectRatioLabel = (TQRLabel *)FindComponent("bDefectRatioLabel" + IntToStr(lastDefectSeriesIndex + 1 + 1));

			if (defectNameLabel)
			{
				defectNameLabel->Caption = INSPECTIONREPORTFORM_LABEL_CAPTION_05;
				defectNameLabel->Visible = true;
			}
			if (defectCountLabel)
			{
				defectCountLabel->Caption = FloatToStrF((float)otherDefectCount, ffNumber, 10, 0);
				defectCountLabel->Visible = true;
			}
			if (defectRatioLabel)
			{
				defectRatioLabel->Caption = FloatToStrF((otherDefectCount / (float)totalDefectCount) * 100, ffFixed, 10, 2);
				defectRatioLabel->Visible = true;
			}
		}
	}
}

//---------------------------------------------------------------------------
void __fastcall TPrintInspectionResultForm::FillDefectImageReport(WideString productName, WideString lotName, int displayCnt)
{
	AnsiString saveImageFileName;
	AnsiString saveDir = GetDefectDataPath(productName, lotName);

	int DefectCountList[12];
	int DefectSeriesList[12];

	for (int defectSeriesIndex = 0; defectSeriesIndex < displayCnt + 1; defectSeriesIndex++)
	{
		DefectCountList[defectSeriesIndex] = DefectSeriesCount[defectSeriesIndex];
		if (defectSeriesIndex < displayCnt)
		{
			DefectSeriesList[defectSeriesIndex] = defectSeriesIndex;
		}
		else
		{
			DefectSeriesList[defectSeriesIndex] = defectSeriesIndex - displayCnt + THIN_TALBET;
		}
	}

	for (int i = 0; i < displayCnt; i++)
	{
		for (int j = i; j < displayCnt; j++)
		{
			if (DefectCountList[i] < DefectCountList[j])
			{
				int temp = DefectCountList[i];
				DefectCountList[i] = DefectCountList[j];
				DefectCountList[j] = temp;

				temp = DefectSeriesList[i];
				DefectSeriesList[i] = DefectSeriesList[j];
				DefectSeriesList[j] = temp;
			}
		}
	}
	//
	for (int idx = 0; idx < 12; idx++)
	{
		TQRImage *pQRImage;
		pQRImage = (TQRImage*)FindComponent("QRImage" + IntToStr(idx + 1));
		if (pQRImage != NULL)
		{
			pQRImage->Canvas->Brush->Color = clWhite;
			pQRImage->Canvas->FillRect(Rect(0, 0, 640, 480));
			pQRImage->Repaint();

			TQRLabel *pQRDefectNameContent;
			pQRDefectNameContent = (TQRLabel*)FindComponent("QRDefectNameContent" + IntToStr(idx + 1));
			pQRDefectNameContent->Caption = "";

			TQRLabel *pQRDefectSizeContent;
			pQRDefectSizeContent = (TQRLabel*)FindComponent("QRDefectSizeContent" + IntToStr(idx + 1));
			pQRDefectSizeContent->Caption = "";
		}
	}

	//
	for (int idx = 0; idx < displayCnt; idx++)
	{
		TQRImage *pQRImage;
		pQRImage = (TQRImage*)FindComponent("QRImage" + IntToStr(idx + 1));
		saveImageFileName = "Image" + IntToStr(PrintImageIndex.DefectImageIndex[idx] + 1) + ".fbm";
		TTntImage *pBmp = new TTntImage(this);
		if (ExtractImageFromContainer(pQRImage->Picture->Bitmap, GetDefectContainerFileName(PrintImageIndex.DefectImageIndex[idx], productName, lotName), saveImageFileName, false, NULL, 0 ))
		{
      if (pQRImage->Picture->Bitmap->Width == SYSTEM_CAMERA_HD_WIDTH && ProductData.SubSamplingMode == IMAGE_FULL_SCALE_MODE)
      {
        ReductionImageScale(pQRImage->Picture->Bitmap);
      }
      
			TQRLabel *pQRDefectNameLabel;
			pQRDefectNameLabel = (TQRLabel*)FindComponent("QRDefectNameLabel" + IntToStr(idx + 1));
			pQRDefectNameLabel->Caption = V6_REPORT_PRINT_FORM_ADD_11;  //"불량 항목";  //

			TQRLabel *pQRDefectSizeLabel;
			pQRDefectNameLabel = (TQRLabel*)FindComponent("QRDefectSizeLabel" + IntToStr(idx + 1));
			pQRDefectNameLabel->Caption = V6_REPORT_PRINT_FORM_ADD_12;   //     "불량 크기";  //

			TQRLabel *pQRDefectNameContent;
			pQRDefectNameLabel = (TQRLabel*)FindComponent("QRDefectNameContent" + IntToStr(idx + 1));
			pQRDefectNameLabel->Caption = GetDefectSeriesStr(PrintImageIndex.DefectSeries[idx]);

			TQRLabel *pQRDefectSizeContent;
			pQRDefectNameLabel = (TQRLabel*)FindComponent("QRDefectSizeContent" + IntToStr(idx + 1));
			pQRDefectNameLabel->Caption = FloatToStr(DefectSizePixelToMili(PrintImageIndex.DefectSize[idx]) / 100.0) + "mm";
		}    /*
				 else
				 {
				 pQRImage->Canvas->Brush->Color = clWhite;
				 pQRImage->Canvas->FillRect(Rect(0, 0, 640, 480));
				 pQRImage->Repaint();
				 }      */
	}
}

WideString __fastcall TPrintInspectionResultForm::GetDefectContainerFileName(int defectIndex, WideString productName, WideString lotName)
{
	int containerIndex = defectIndex / DEFECT_DATA_CONTAINER_SIZE;
	AnsiString saveDir = ProgramPath.Defect + "\\" + productName + "\\" + lotName;
	return saveDir + "\\DefectImage" + IntToStr(containerIndex + 1) + ".FAC";
}

//---------------------------------------------------------------------------
void __fastcall TPrintInspectionResultForm::UpdateTotalReportPages(int option)
{
	int TotalRP;
	AnsiString str;
	if (option == 0) // 기본 페이지만 출력
	{
		ReportPageLabel->Caption = "1 / 1";

		UpDown1->Min = 1;
		UpDown1->Max = 1;

		UpDown1->Position = 1;
	}
	else // 등급 설정 이력 + 기본 페이지 출력
	{
		TotalRP = 1;

		/*if(DefectImagePrintCheckBox->Checked)
		TotalRP = TotalRP + newImagePageIndex;  //+1 */

		ReportPageLabel->Caption = "1 / " + IntToStr(TotalRP);

		UpDown1->Min = 1;
		UpDown1->Max = TotalRP;

		UpDown1->Position = 1;
	}

	PageList->Clear();
	TotalRP = 1;

	bool bReportOption = false;
	bool bReportGridOption = false;
	if (PrintGradeOnlyRadioButton->Checked)
	{
		if (PrintDefectSeriesCheckBox->Checked)
		{
			PageList->Add("QuickRep3");
			if (PCProgramOption.DetailRportView)
			{
				PageList->Add("QuickRep6");
				TotalRP++;

				bReportOption = true;
				bReportGridOption = false;
			}
			else
			{
				bReportOption = false;
				bReportGridOption = true;
			}
		}
		else
		{
			PageList->Add("QuickRep1");
			if (PCProgramOption.DetailRportView)
			{
				bReportOption = true;
				bReportGridOption = false;
			}
		}

	}

	if (PrintGradeAndSizeRadioButton->Checked)
	{
		if (PrintDefectSeriesCheckBox->Checked)
		{
			PageList->Add("QuickRep4");
			if (PCProgramOption.DetailRportView)
			{
				PageList->Add("QuickRep6");
				bReportOption = true;
				bReportGridOption = false;
				TotalRP++;
			}
			else
			{
				bReportOption = false;
				bReportGridOption = true;
			}

		}
		else
		{
			if (PCProgramOption.DetailRportView)
			{
				bReportOption = true;
				bReportGridOption = false;
			}
			PageList->Add("QuickRep2");
		}

	}

	if (DefectImagePrintCheckBox->Checked)
	{
		TotalRP = TotalRP + 1 + newImagePageIndex;

		PageList->Add("QuickRep5");

		for (int i = 1; i <= newImagePageIndex; i++)
		{
			PageList->Add("newImageQR" + IntToStr(i));
		}

		if (PCProgramOption.DetailRportView && PrintDefectSeriesCheckBox->Checked)
		{
			QRPageDfImage0->Visible = true;
			QRPageDfImage0->Enabled = true;
		}
		else
		{
			QRPageDfImage0->Visible = false;
			QRPageDfImage0->Enabled = false;
		}

	}

	SetDetailReportOption(bReportOption, TotalRP);
	SetDetailReportOptionGridShape(bReportGridOption);
	ReportPageLabel->Caption = "1 / " + IntToStr(TotalRP);

	int idx = 1;
	for (int i = 0; i < TotalRP; i++)
	{
		if (PageList->Strings[i] == AnsiString("QuickRep3"))
		{
			QRSignaturePage3->Caption = "Page " + IntToStr(idx) + " of " + IntToStr(TotalRP);
			idx++;
		}
		else if (PageList->Strings[i] == AnsiString("QuickRep4"))
		{
			QRSignaturePage4->Caption = "Page " + IntToStr(idx) + " of " + IntToStr(TotalRP);
			idx++;
		}
		else if (PageList->Strings[i] == AnsiString("QuickRep6"))
		{
			QRSignaturePage6->Caption = "Page " + IntToStr(idx) + " of " + IntToStr(TotalRP);
			idx++;
		}
		else if (PageList->Strings[i] == AnsiString("QuickRep5"))
		{
			QRPageDfImage0->Caption = "Page " + IntToStr(idx) + " of " + IntToStr(TotalRP);
			idx++;
		}
    else if (PageList->Strings[i] == AnsiString("QuickRep1")||PageList->Strings[i] == AnsiString("QuickRep2"))
		{
			idx++;
		}
		else
		{
			for (int j = 1; j < (newImagePageIndex + 1); j++) 
			{
				if (PageList->Strings[i] == AnsiString("newImageQR" + IntToStr(j)))
				{
					TQRLabel *tempLabel = (TQRLabel *)FindComponent("QRPageDfImage" + IntToStr(j));
					tempLabel->Caption = "Page " + IntToStr(idx) + " of " + IntToStr(TotalRP);
					idx++;
				}
			}
		}
	}

	UpDown1->Min = 1;
	UpDown1->Max = TotalRP;

	UpDown1->Position = 1;
	if (TotalRP > 1)
		UpDown1->Enabled = true;
	else
		UpDown1->Enabled = false;
}
//---------------------------------------------------------------------------
void __fastcall TPrintInspectionResultForm::UpDown1Click(TObject *Sender,
	TUDBtnType Button)
{
	int CurrentPageN = UpDown1->Position;
	AnsiString  ComponentName;

	ComponentName = PageList->Strings[CurrentPageN - 1];

	if (ComponentName == "QuickRep1")
		ReportPanel1->BringToFront();
	else if (ComponentName == "QuickRep2")
		ReportPanel2->BringToFront();
	else if (ComponentName == "QuickRep3")
		ReportPanel3->BringToFront();
	else if (ComponentName == "QuickRep4")
		ReportPanel4->BringToFront();
	else if (ComponentName == "QuickRep5")
		ReportPanel5->BringToFront();
	else if (ComponentName == "QuickRep6")
		ReportPanel6->BringToFront();

	TQuickRep *pTempRP;
	pTempRP = (TQuickRep*)FindComponent(ComponentName);
	pTempRP->BringToFront();


	//현재 페이지 Label 업데이트
	ReportPageLabel->Caption = IntToStr(CurrentPageN) + " / " + IntToStr(UpDown1->Max);
}
//---------------------------------------------------------------------------

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


void __fastcall TPrintInspectionResultForm::SelectDefectImageButtonClick(
	TObject *Sender)
{
	SelectDefectImageForm = new TSelectDefectImageForm(this);
	//SelectDefectImageForm->ShowModal();
	SelectDefectImageForm->DefectImageLoad(LOTName, DefectSeriesCount);
	SelectDefectImageForm->InitSelectDefect();
	SelectDefectImageForm->ShowModal();

	if (SelectDefectImageForm->ModalStat == mrOk)
	{
		PrintImageIndexLoad();

		int i, CountImage;
		CountImage = 0;
		newImagePageIndex = 0;
		for (i = 0; i < 12; i++)
		{
			if (PrintImageIndex.DefectImageIndex[i] != 0xAAAA)
				CountImage++;
		}

		if (CountImage > 6)
		{
			newImagePageIndex = (CountImage-1) / 6;
			CreateNewDefectImagePage();
		}

		if (CountImage)
			FillDefectImageReport(AnsiString(ProductName), LOTName, CountImage);


		UpdateTotalReportPages(0);

		if (PrintGradeOnlyRadioButton->Checked)
		{
			if (PrintDefectSeriesCheckBox->Checked)
				ReportPanel3->BringToFront();
			else
				ReportPanel1->BringToFront();
		}

		if (PrintGradeAndSizeRadioButton->Checked)
		{
			if (PrintDefectSeriesCheckBox->Checked)
				ReportPanel4->BringToFront();
			else
				ReportPanel2->BringToFront();
		}
	}
}
//---------------------------------------------------------------------------
void __fastcall TPrintInspectionResultForm::PrintImageIndexLoad()
{

	AnsiString FilePath = ProgramPath.Product + "\\" + ProductData.ProductCode + "\\Report";
	AnsiString SelectDataFileName = FilePath + "\\" + LOTName + ".dsi";

	if (!FileExists(SelectDataFileName))
	{
		TSelectDefectImageForm *tempSelectDefectImageForm;
		tempSelectDefectImageForm = new TSelectDefectImageForm(this);
		tempSelectDefectImageForm->DefectImageLoad(LOTName, DefectSeriesCount);
		tempSelectDefectImageForm->WriteDefectSelectionData(LOTName);

		delete tempSelectDefectImageForm;
	}

	TFileStream *fileStream = new TFileStream(SelectDataFileName, fmOpenRead);
	fileStream->Read(&PrintImageIndex, sizeof(PrintImageIndex));
	delete fileStream;


}


void __fastcall TPrintInspectionResultForm::DefectImagePrintCheckBoxClick(
	TObject *Sender)
{
	if (!DefectImagePrintCheckBox->Checked && !PrintDefectSeriesCheckBox->Checked) // 한장 출력
	{
		UpdateTotalReportPages(0);
		UpDown1->Enabled = false;
	}
	else
	{
		UpdateTotalReportPages(1);
		UpDown1->Enabled = true;
	}

	if (PrintDefectSeriesCheckBox->Checked)
		ReportPanel3->BringToFront();
	else if (PrintDefectSeriesCheckBox->Checked)
		ReportPanel1->BringToFront();

	if (PrintDefectSeriesCheckBox->Checked)
		ReportPanel4->BringToFront();
	else if (PrintDefectSeriesCheckBox->Checked)
		ReportPanel2->BringToFront();
}
//---------------------------------------------------------------------------

void __fastcall TPrintInspectionResultForm::QRCompositeReport1AddReports(
	TObject *Sender)
{
	int PageCnt;
	AnsiString  ComponentName;

	PageCnt = PageList->Count;

	QRCompositeReport1->Reports->Clear();

	for (int cnt = 0; cnt < PageCnt; cnt++)
	{
		ComponentName = PageList->Strings[cnt];
		TQuickRep *tempQR;
		tempQR = (TQuickRep*)FindComponent(ComponentName);
		QRCompositeReport1->Reports->Add(tempQR);
	}
}
//---------------------------------------------------------------------------

void __fastcall TPrintInspectionResultForm::SetDefectInfoPage2()
{
  int DefectCountList[MAX_DEFECT_SERIES_COUNT + 1];
  int DefectSeriesList[MAX_DEFECT_SERIES_COUNT + 1];
  int DefectCountListSort[MAX_DEFECT_SERIES_COUNT + 1];
  int DefectSeriesListSort[MAX_DEFECT_SERIES_COUNT + 1];
  int defectCount = 0, errorCount = 0;
  int sortIdx;
  int idx;

  TQRLabel *defectNameLabel;
  TQRLabel *defectCountLabel;
  TQRLabel *defectRatioLabel;
  int count;
  int ETCCount;
  int CPBDefectTabletCount;
  int HCBDefectTabletCount;
  int notReceivedTabletCount = 0;

  memset(DefectCountList, 0, sizeof(int) * (MAX_DEFECT_SERIES_COUNT + 1));
  memset(DefectSeriesList, 0, sizeof(int) * (MAX_DEFECT_SERIES_COUNT + 1));
  memset(DefectCountListSort, 0, sizeof(int) * (MAX_DEFECT_SERIES_COUNT + 1));
  memset(DefectSeriesListSort, 0, sizeof(int) * (MAX_DEFECT_SERIES_COUNT + 1));

  for (int defectSeriesIndex = 0; defectSeriesIndex < MAX_DEFECT_SERIES_COUNT + 1; defectSeriesIndex++)
  {
    if (defectSeriesIndex < MAX_CPB_DEFECT_SERIES_COUNT)
		{
			DefectSeriesList[defectSeriesIndex] = defectSeriesIndex;
		}
		else
		{
			DefectSeriesList[defectSeriesIndex] = defectSeriesIndex - MAX_CPB_DEFECT_SERIES_COUNT + THIN_TALBET;
		}

    DefectCountList[defectSeriesIndex] = DefectSeriesCount[defectSeriesIndex];
    defectCount += DefectSeriesCount[defectSeriesIndex];
  }
    
  memcpy(DefectCountListSort, DefectCountList, sizeof(DefectCountListSort));
  memcpy(DefectSeriesListSort, DefectSeriesList, sizeof(DefectCountListSort));
  for (int i = 0; i < MAX_DEFECT_SERIES_COUNT + 1; i++)
  {
    for (int j = i; j < MAX_DEFECT_SERIES_COUNT + 1; j++)
    {
      if (DefectCountListSort[i] < DefectCountListSort[j])
      {
        int temp = DefectCountListSort[i];
        DefectCountListSort[i] = DefectCountListSort[j];
        DefectCountListSort[j] = temp;

        temp = DefectSeriesListSort[i];
        DefectSeriesListSort[i] = DefectSeriesListSort[j];
        DefectSeriesListSort[j] = temp;
      }
    }
  }

  if(MachineSetupData.LasercomplexerInfo.Laser_complexer_Enable)
  {
    HCBDefectTabletCount = Report.Data.SPBProcessingNCTabletCount + Report.Data.FRMisMatchTabletCount + Report.Data.ClosedTabletDefectCount + Report.Data.NozzErrorDefectTabletCount;
  }
  else
  {
    HCBDefectTabletCount = Report.Data.SPBProcessingNCTabletCount + Report.Data.FRMisMatchTabletCount + Report.Data.ClosedTabletDefectCount +
    Report.Data.NozzErrorDefectTabletCount + Report.Data.UnPrintTabletCount;
  }

  CPBDefectTabletCount = Report.Data.DefectTabletCount - HCBDefectTabletCount;

  if(CPBDefectTabletCount > defectCount)
  {
    // 기타 count 처리
    notReceivedTabletCount = CPBDefectTabletCount - defectCount;
  }
  else if(CPBDefectTabletCount < defectCount)
  {
  	if(PCProgramOption.InsRepOpt.SPB_HCB_InsCntMatchingOptionOff == false)
  	{
  	/*
	    //////임시
	    //현재 SPB에서 모두 미검처리되었으나 HCB에서 불량 카운트가 올라가는것으로 보여짐(SHILPA)	
	    int SeriesNumber[10];
	    int validDataCount = 1;
	    memset(SeriesNumber, 0, sizeof(int) * 10);

	    for(int i = 0; i < 10; i++)
	    {
	      if(DefectCountListSort[i])
	      {
	        SeriesNumber[i] = DefectSeriesListSort[i];
	        validDataCount++;
	        if(validDataCount > 10) validDataCount = 10;
	      }
	    }

	    count = defectCount - CPBDefectTabletCount;


	    while(1)
	    {
	      sortIdx = rand() % validDataCount;
	      idx = SeriesNumber[sortIdx];

	      if(idx >= MAX_CPB_DEFECT_SERIES_COUNT)
	      {
	        idx = idx - THIN_TALBET + MAX_CPB_DEFECT_SERIES_COUNT;
	      }

	      if(DefectCountList[idx] - count >= 0)
	      {
	        DefectCountList[idx] -= count;
	        DefectCountListSort[sortIdx] -= count;
	        defectCount -= count;

	        count = DefectCountList[idx];

	        break;
	      }
	      else
	      {
	        int tempCount = DefectCountList[idx];

	        DefectCountList[idx] -= tempCount;
	        DefectCountListSort[sortIdx] -= tempCount;
	        defectCount -= tempCount;

	        count = defectCount - CPBDefectTabletCount;
	      }
	    }

	    */

		int restCnt = (defectCount + HCBDefectTabletCount) - Report.Data.DefectTabletCount;

		do
		{
			if(Report.Data.SPBProcessingNCTabletCount > 0)
			{
				Report.Data.SPBProcessingNCTabletCount--;
				restCnt--;
			}
			else if(Report.Data.ClosedTabletDefectCount > 0)
			{
				Report.Data.ClosedTabletDefectCount--;
				restCnt--;			
			}
			else if(Report.Data.FRMisMatchTabletCount > 0)
			{
				Report.Data.FRMisMatchTabletCount--;
				restCnt--;			
			}			
			else if(Report.Data.UnPrintTabletCount > 0)
			{
				Report.Data.UnPrintTabletCount--;
				restCnt--;			
			}	
			else if(Report.Data.NozzErrorDefectTabletCount > 0)
			{
				Report.Data.NozzErrorDefectTabletCount--;
				restCnt--;			
			}				
		}
		while(restCnt > 0);

    	HCBDefectTabletCount = Report.Data.SPBProcessingNCTabletCount + Report.Data.FRMisMatchTabletCount + Report.Data.ClosedTabletDefectCount +
    	Report.Data.NozzErrorDefectTabletCount + Report.Data.UnPrintTabletCount;  	    
    }

    AnsiString resultDir = ProgramPath.Product + "\\" + ProductName + "\\Result";
    AnsiString inspectionReportFileName = resultDir + "\\" + LOTName + ".dat";

    try
    {
      memcpy(DefectSeriesCount, DefectCountList, (MAX_DEFECT_SERIES_COUNT + 1) * sizeof(int));
      memcpy(Report.DefectSeriesCount.DefectSeriesCount,DefectCountList, (MAX_DEFECT_SERIES_COUNT + 1) * sizeof(int));
      Create_Report_Data(Report,inspectionReportFileName);
    }
    catch(...)
    {
      WritePCProgramErrorLog(this->Name, __LINE__);
    }
  }

  for (int i = 0; i < MAX_DEFECT_SERIES_COUNT + 1; i++)
  {
    for (int j = i; j < MAX_DEFECT_SERIES_COUNT + 1; j++)
    {
      if (DefectCountListSort[i] <= DefectCountListSort[j])
      {
        int temp = DefectCountListSort[i];
        DefectCountListSort[i] = DefectCountListSort[j];
        DefectCountListSort[j] = temp;

        temp = DefectSeriesListSort[i];
        DefectSeriesListSort[i] = DefectSeriesListSort[j];
        DefectSeriesListSort[j] = temp;
      }
    }
  }

  for (int i = 0; i < MAX_DEFECT_SERIES_COUNT; i++)
  {
    if (GetDefectSeriesStr(DefectSeriesListSort[i]) == COMMONPC_RETURNSTR_04)
    {
      for (int j = MAX_DEFECT_SERIES_COUNT; j > i ; j--)
      {
        if (GetDefectSeriesStr(DefectSeriesListSort[j]) != COMMONPC_RETURNSTR_04)
        {
          int temp = DefectCountListSort[i];
          DefectCountListSort[i] = DefectCountListSort[j];
          DefectCountListSort[j] = temp;

          temp = DefectSeriesListSort[i];
          DefectSeriesListSort[i] = DefectSeriesListSort[j];
          DefectSeriesListSort[j] = temp;

          break;
        }
      }
    }
  }

  ETCCount = 0;
  for (int defectSeriesIndex = 0; defectSeriesIndex < MAX_DEFECT_SERIES_COUNT + 1; defectSeriesIndex++)
  {
    if(defectSeriesIndex + 1 < ETC_MAX_LIST_NUMBER)
    {
      defectNameLabel = (TQRLabel *) FindComponent("QRItemLabel" + IntToStr(defectSeriesIndex + 1));
      defectCountLabel = (TQRLabel *) FindComponent("QRQuantityLabel" + IntToStr(defectSeriesIndex + 1));
      defectRatioLabel = (TQRLabel *) FindComponent("QRRateLabel" + IntToStr(defectSeriesIndex + 1));

      count = DefectCountListSort[defectSeriesIndex];

      defectNameLabel->Caption = GetDefectSeriesStr(DefectSeriesListSort[defectSeriesIndex]);
      defectCountLabel->Caption = FloatToStrF((float)count, ffNumber, 10, 0);
      if(Report.Data.DefectTabletCount)
        defectRatioLabel->Caption = FloatToStrF(((float)count / (float)Report.Data.DefectTabletCount) * 100, ffFixed, 10, 2);
      else
        defectRatioLabel->Caption = "0";
    }
    else
    {
      defectNameLabel = (TQRLabel *) FindComponent("QRItemLabel" + IntToStr(ETC_MAX_LIST_NUMBER));
      defectCountLabel = (TQRLabel *) FindComponent("QRQuantityLabel" + IntToStr(ETC_MAX_LIST_NUMBER));
      defectRatioLabel = (TQRLabel *) FindComponent("QRRateLabel" + IntToStr(ETC_MAX_LIST_NUMBER));

      ETCCount += DefectCountListSort[defectSeriesIndex];

      defectNameLabel->Caption = GetDefectSeriesStr(0xFF);
      defectCountLabel->Caption = FloatToStrF((float)ETCCount + HCBDefectTabletCount + notReceivedTabletCount, ffNumber, 10, 0);

      if(PCProgramOption.InsRepOpt.SPB_HCB_InsCntMatchingOptionOff == false)
      {
	      if(Report.Data.DefectTabletCount)
	        defectRatioLabel->Caption = FloatToStrF(((float)(ETCCount + HCBDefectTabletCount + notReceivedTabletCount) / (float)Report.Data.DefectTabletCount) * 100, ffFixed, 10, 2);
	      else
	        defectRatioLabel->Caption = "0";
	       }
       else
       {
	        defectRatioLabel->Caption = FloatToStrF(((float)(ETCCount + HCBDefectTabletCount + notReceivedTabletCount) / (float)(Report.Data.DefectTabletCount + HCBDefectTabletCount + notReceivedTabletCount)) * 100, ffFixed, 10, 2);
       }
    }
  }

  defectNameLabel = (TQRLabel *) FindComponent("QRItemLabelTotal");
  defectCountLabel = (TQRLabel *) FindComponent("QRQuantityLabelTotal");
  defectRatioLabel = (TQRLabel *) FindComponent("QRRateLabelTotal");
  defectNameLabel->Caption = PRINTINSPECTIONRESULTFORM_UNKNOWN_65;
  defectCountLabel->Caption =  FloatToStrF((float)defectCount + HCBDefectTabletCount + notReceivedTabletCount, ffNumber, 10, 0);

  if(PCProgramOption.InsRepOpt.SPB_HCB_InsCntMatchingOptionOff == false)
  {
	  if(Report.Data.DefectTabletCount)
	    defectRatioLabel->Caption =  FloatToStrF((float)(defectCount + HCBDefectTabletCount + notReceivedTabletCount) / (float)Report.Data.DefectTabletCount * 100, ffFixed, 10, 2);
	  else
	    defectRatioLabel->Caption = "0";
  }
  else
  {
		defectRatioLabel->Caption =  FloatToStrF((float)(defectCount + HCBDefectTabletCount + notReceivedTabletCount) / (float)(Report.Data.DefectTabletCount + HCBDefectTabletCount + notReceivedTabletCount) * 100, ffFixed, 10, 2);
  }

  //chart 
  //QRInspectionChartDB->Title->Text->Strings[0] = "Inspection Info";
  QRInspectionChartDB->Series[0]->Clear();
  //QRInspectionChartDB->Series[0]->Add(Report.Data.GoodTabletCount, "Good Tablet", clLime);
  //QRInspectionChartDB->Series[0]->Add(Report.Data.DefectTabletCount, "Defect Tablet", clRed);
  //QRInspectionChartDB->Series[0]->Add(Report.Data.UnInsTabletCount, "Un-Inspection", clYellow);
  QRInspectionChartDB->Series[0]->Add(Report.Data.GoodTabletCount, INSPECTIONFORM_LABEL_CAPTION_62, clLime);
  QRInspectionChartDB->Series[0]->Add(Report.Data.DefectTabletCount, INSPECTIONFORM_LABEL_CAPTION_63, clRed);
  QRInspectionChartDB->Series[0]->Add(Report.Data.UnInsTabletCount, INSPECTIONFORM_LABEL_CAPTION_64, clYellow);

}
//-----------------------------------------------------------------------------------------------------------------------------------
void __fastcall TPrintInspectionResultForm::SetDetailReportOption(bool On, int TotalRP)
{
	if (On)
	{
		QRSignatureCheck3->Enabled = true;
		QRSignatureCheck4->Enabled = true;
		QRSignatureDate13->Enabled = true;
		QRSignatureDate23->Enabled = true;
		QRSignatureDate33->Enabled = true;
		QRSignatureDate14->Enabled = true;
		QRSignatureDate24->Enabled = true;
		QRSignatureDate34->Enabled = true;
		QRSignatureDone3->Enabled = true;
		QRSignatureDone4->Enabled = true;
		QRSignaturePage3->Enabled = true;
		QRSignaturePage4->Enabled = true;
		QRSignaturePage6->Enabled = true;
		QRSignatureReview3->Enabled = true;
		QRSignatureReview4->Enabled = true;
		QRPageDfImage0->Enabled = true;

		QRSignatureCheck3->Visible = true;
		QRSignatureCheck4->Visible = true;
		QRSignatureDate13->Visible = true;
		QRSignatureDate23->Visible = true;
		QRSignatureDate33->Visible = true;
		QRSignatureDate14->Visible = true;
		QRSignatureDate24->Visible = true;
		QRSignatureDate34->Visible = true;
		QRSignatureDone3->Visible = true;
		QRSignatureDone4->Visible = true;
		QRSignaturePage3->Visible = true;
		QRSignaturePage4->Visible = true;
		QRSignaturePage6->Visible = true;
		QRSignatureReview3->Visible = true;
		QRSignatureReview4->Visible = true;
		QRPageDfImage0->Visible = true;

		for (int i = 0; i < TotalRP + 1; ++i)
		{
			TQRLabel* pLabel = (TQRLabel*)FindComponent("QRPageDfImage" + IntToStr(i));
			if (pLabel != NULL)
			{
				pLabel->Visible = true;
				pLabel->Enabled = true;
			}
		}
	}
	else
	{
		QRPageDfImage0->Enabled = false;
		QRSignatureCheck3->Enabled = false;
		QRSignatureCheck4->Enabled = false;
		QRSignatureDate13->Enabled = false;
		QRSignatureDate23->Enabled = false;
		QRSignatureDate33->Enabled = false;
		QRSignatureDate14->Enabled = false;
		QRSignatureDate24->Enabled = false;
		QRSignatureDate34->Enabled = false;
		QRSignatureDone3->Enabled = false;
		QRSignatureDone4->Enabled = false;
		QRSignaturePage3->Enabled = false;
		QRSignaturePage4->Enabled = false;
		QRSignaturePage6->Enabled = false;
		QRSignatureReview3->Enabled = false;
		QRSignatureReview4->Enabled = false;

		QRPageDfImage0->Visible = false;
		QRSignatureCheck3->Visible = false;
		QRSignatureCheck4->Visible = false;
		QRSignatureDate13->Visible = false;
		QRSignatureDate23->Visible = false;
		QRSignatureDate33->Visible = false;
		QRSignatureDate14->Visible = false;
		QRSignatureDate24->Visible = false;
		QRSignatureDate34->Visible = false;
		QRSignatureDone3->Visible = false;
		QRSignatureDone4->Visible = false;
		QRSignaturePage3->Visible = false;
		QRSignaturePage4->Visible = false;
		QRSignaturePage6->Visible = false;
		QRSignatureReview3->Visible = false;
		QRSignatureReview4->Visible = false;

		for (int i = 0; i < TotalRP + 1; ++i)
		{
			TQRLabel* pLabel = (TQRLabel*)FindComponent("QRPageDfImage" + IntToStr(i));
			if (pLabel != NULL)
			{
				pLabel->Visible = false;
				pLabel->Enabled = false;
			}
		}
	}
}

void __fastcall TPrintInspectionResultForm::SetDetailReportOptionGridShape(bool On)
{
	if (On)
	{
		DefectSeriesLabel11->Visible = true;
		DefectSeriesLabel22->Visible = true;
		DefectSeriesLabel33->Visible = true;
		DefectSeriesLabel44->Visible = true;
		DefectSeriesLabel55->Visible = true;
		DefectSeriesLabel66->Visible = true;
		DefectSeriesLabel77->Visible = true;

		bDefectNameLabel1->Visible = true;
		bDefectNameLabel2->Visible = true;
		bDefectNameLabel3->Visible = true;
		bDefectNameLabel4->Visible = true;
		bDefectNameLabel5->Visible = true;
		bDefectNameLabel6->Visible = true;
		bDefectNameLabel7->Visible = true;
		bDefectNameLabel8->Visible = true;
		bDefectNameLabel9->Visible = true;
		bDefectNameLabel10->Visible = true;

		bDefectCountLabel1->Visible = true;
		bDefectCountLabel2->Visible = true;
		bDefectCountLabel3->Visible = true;
		bDefectCountLabel4->Visible = true;
		bDefectCountLabel5->Visible = true;
		bDefectCountLabel6->Visible = true;
		bDefectCountLabel7->Visible = true;
		bDefectCountLabel8->Visible = true;
		bDefectCountLabel9->Visible = true;
		bDefectCountLabel10->Visible = true;

		bDefectRatioLabel1->Visible = true;
		bDefectRatioLabel2->Visible = true;
		bDefectRatioLabel3->Visible = true;
		bDefectRatioLabel4->Visible = true;
		bDefectRatioLabel5->Visible = true;
		bDefectRatioLabel6->Visible = true;
		bDefectRatioLabel7->Visible = true;
		bDefectRatioLabel8->Visible = true;
		bDefectRatioLabel9->Visible = true;
		bDefectRatioLabel10->Visible = true;

		QRShape156->Visible = true;
		QRShape157->Visible = true;
		QRShape158->Visible = true;
		QRShape159->Visible = true;
		QRShape160->Visible = true;
		QRShape161->Visible = true;
		QRShape162->Visible = true;
		QRShape163->Visible = true;
		QRShape164->Visible = true;
		QRShape165->Visible = true;
		QRShape166->Visible = true;
		QRShape167->Visible = true;

		//Enabled
		DefectSeriesLabel11->Enabled = true;
		DefectSeriesLabel22->Enabled = true;
		DefectSeriesLabel33->Enabled = true;
		DefectSeriesLabel44->Enabled = true;
		DefectSeriesLabel55->Enabled = true;
		DefectSeriesLabel66->Enabled = true;
		DefectSeriesLabel77->Enabled = true;

		bDefectNameLabel1->Enabled = true;
		bDefectNameLabel2->Enabled = true;
		bDefectNameLabel3->Enabled = true;
		bDefectNameLabel4->Enabled = true;
		bDefectNameLabel5->Enabled = true;
		bDefectNameLabel6->Enabled = true;
		bDefectNameLabel7->Enabled = true;
		bDefectNameLabel8->Enabled = true;
		bDefectNameLabel9->Enabled = true;
		bDefectNameLabel10->Enabled = true;

		bDefectCountLabel1->Enabled = true;
		bDefectCountLabel2->Enabled = true;
		bDefectCountLabel3->Enabled = true;
		bDefectCountLabel4->Enabled = true;
		bDefectCountLabel5->Enabled = true;
		bDefectCountLabel6->Enabled = true;
		bDefectCountLabel7->Enabled = true;
		bDefectCountLabel8->Enabled = true;
		bDefectCountLabel9->Enabled = true;
		bDefectCountLabel10->Enabled = true;

		bDefectRatioLabel1->Enabled = true;
		bDefectRatioLabel2->Enabled = true;
		bDefectRatioLabel3->Enabled = true;
		bDefectRatioLabel4->Enabled = true;
		bDefectRatioLabel5->Enabled = true;
		bDefectRatioLabel6->Enabled = true;
		bDefectRatioLabel7->Enabled = true;
		bDefectRatioLabel8->Enabled = true;
		bDefectRatioLabel9->Enabled = true;
		bDefectRatioLabel10->Enabled = true;

		QRShape156->Enabled = true;
		QRShape157->Enabled = true;
		QRShape158->Enabled = true;
		QRShape159->Enabled = true;
		QRShape160->Enabled = true;
		QRShape161->Enabled = true;
		QRShape162->Enabled = true;
		QRShape163->Enabled = true;
		QRShape164->Enabled = true;
		QRShape165->Enabled = true;
		QRShape166->Enabled = true;
		QRShape167->Enabled = true;
		DefectSeriesLabel1->Visible = true;
		DefectSeriesShape1->Visible = true;
		DefectSeriesLabel2->Visible = true;
		DefectSeriesLabel3->Visible = true;
		DefectSeriesLabel4->Visible = true;
		DefectSeriesLabel5->Visible = true;
		DefectSeriesLabel6->Visible = true;
		DefectSeriesLabel7->Visible = true;

		DefectNameLabel1->Visible = true;
		DefectNameLabel2->Visible = true;
		DefectNameLabel3->Visible = true;
		DefectNameLabel4->Visible = true;
		DefectNameLabel5->Visible = true;
		DefectNameLabel6->Visible = true;
		DefectNameLabel7->Visible = true;
		DefectNameLabel8->Visible = true;
		DefectNameLabel9->Visible = true;
		DefectNameLabel10->Visible = true;

		DefectCountLabel1->Visible = true;
		DefectCountLabel2->Visible = true;
		DefectCountLabel3->Visible = true;
		DefectCountLabel4->Visible = true;
		DefectCountLabel5->Visible = true;
		DefectCountLabel6->Visible = true;
		DefectCountLabel7->Visible = true;
		DefectCountLabel8->Visible = true;
		DefectCountLabel9->Visible = true;
		DefectCountLabel10->Visible = true;

		DefectRatioLabel1->Visible = true;
		DefectRatioLabel2->Visible = true;
		DefectRatioLabel3->Visible = true;
		DefectRatioLabel4->Visible = true;
		DefectRatioLabel5->Visible = true;
		DefectRatioLabel6->Visible = true;
		DefectRatioLabel7->Visible = true;
		DefectRatioLabel8->Visible = true;
		DefectRatioLabel9->Visible = true;
		DefectRatioLabel10->Visible = true;

		DefectSeriesShape2->Visible = true;
		DefectSeriesShape3->Visible = true;
		DefectSeriesShape4->Visible = true;
		DefectSeriesShape5->Visible = true;
		DefectSeriesShape6->Visible = true;

		DefectSeriesShape7->Visible = true;
		DefectSeriesShape8->Visible = true;
		DefectSeriesShape9->Visible = true;
		DefectSeriesShape10->Visible = true;
		DefectSeriesShape11->Visible = true;


		DefectSeriesLabel1->Enabled = true;
		DefectSeriesShape1->Enabled = true;
		DefectSeriesLabel2->Enabled = true;
		DefectSeriesLabel3->Enabled = true;
		DefectSeriesLabel4->Enabled = true;
		DefectSeriesLabel5->Enabled = true;
		DefectSeriesLabel6->Enabled = true;
		DefectSeriesLabel7->Enabled = true;

		DefectNameLabel1->Enabled = true;
		DefectNameLabel2->Enabled = true;
		DefectNameLabel3->Enabled = true;
		DefectNameLabel4->Enabled = true;
		DefectNameLabel5->Enabled = true;
		DefectNameLabel6->Enabled = true;
		DefectNameLabel7->Enabled = true;
		DefectNameLabel8->Enabled = true;
		DefectNameLabel9->Enabled = true;
		DefectNameLabel10->Enabled = true;

		DefectCountLabel1->Enabled = true;
		DefectCountLabel2->Enabled = true;
		DefectCountLabel3->Enabled = true;
		DefectCountLabel4->Enabled = true;
		DefectCountLabel5->Enabled = true;
		DefectCountLabel6->Enabled = true;
		DefectCountLabel7->Enabled = true;
		DefectCountLabel8->Enabled = true;
		DefectCountLabel9->Enabled = true;
		DefectCountLabel10->Enabled = true;

		DefectRatioLabel1->Enabled = true;
		DefectRatioLabel2->Enabled = true;
		DefectRatioLabel3->Enabled = true;
		DefectRatioLabel4->Enabled = true;
		DefectRatioLabel5->Enabled = true;
		DefectRatioLabel6->Enabled = true;
		DefectRatioLabel7->Enabled = true;
		DefectRatioLabel8->Enabled = true;
		DefectRatioLabel9->Enabled = true;
		DefectRatioLabel10->Enabled = true;

		DefectSeriesShape2->Enabled = true;
		DefectSeriesShape3->Enabled = true;
		DefectSeriesShape4->Enabled = true;
		DefectSeriesShape5->Enabled = true;
		DefectSeriesShape6->Enabled = true;

		DefectSeriesShape7->Enabled = true;
		DefectSeriesShape8->Enabled = true;
		DefectSeriesShape9->Enabled = true;
		DefectSeriesShape10->Enabled = true;
		DefectSeriesShape11->Enabled = true;
	}
	else
	{
		DefectSeriesLabel11->Visible = false;
		DefectSeriesLabel22->Visible = false;
		DefectSeriesLabel33->Visible = false;
		DefectSeriesLabel44->Visible = false;
		DefectSeriesLabel55->Visible = false;
		DefectSeriesLabel66->Visible = false;
		DefectSeriesLabel77->Visible = false;

		bDefectNameLabel1->Visible = false;
		bDefectNameLabel2->Visible = false;
		bDefectNameLabel3->Visible = false;
		bDefectNameLabel4->Visible = false;
		bDefectNameLabel5->Visible = false;
		bDefectNameLabel6->Visible = false;
		bDefectNameLabel7->Visible = false;
		bDefectNameLabel8->Visible = false;
		bDefectNameLabel9->Visible = false;
		bDefectNameLabel10->Visible = false;

		bDefectCountLabel1->Visible = false;
		bDefectCountLabel2->Visible = false;
		bDefectCountLabel3->Visible = false;
		bDefectCountLabel4->Visible = false;
		bDefectCountLabel5->Visible = false;
		bDefectCountLabel6->Visible = false;
		bDefectCountLabel7->Visible = false;
		bDefectCountLabel8->Visible = false;
		bDefectCountLabel9->Visible = false;
		bDefectCountLabel10->Visible = false;

		bDefectRatioLabel1->Visible = false;
		bDefectRatioLabel2->Visible = false;
		bDefectRatioLabel3->Visible = false;
		bDefectRatioLabel4->Visible = false;
		bDefectRatioLabel5->Visible = false;
		bDefectRatioLabel6->Visible = false;
		bDefectRatioLabel7->Visible = false;
		bDefectRatioLabel8->Visible = false;
		bDefectRatioLabel9->Visible = false;
		bDefectRatioLabel10->Visible = false;

		QRShape156->Visible = false;
		QRShape157->Visible = false;
		QRShape158->Visible = false;
		QRShape159->Visible = false;
		QRShape160->Visible = false;
		QRShape161->Visible = false;
		QRShape162->Visible = false;
		QRShape163->Visible = false;
		QRShape164->Visible = false;
		QRShape165->Visible = false;
		QRShape166->Visible = false;
		QRShape167->Visible = false;

		//Enabled
		DefectSeriesLabel11->Enabled = false;
		DefectSeriesLabel22->Enabled = false;
		DefectSeriesLabel33->Enabled = false;
		DefectSeriesLabel44->Enabled = false;
		DefectSeriesLabel55->Enabled = false;
		DefectSeriesLabel66->Enabled = false;
		DefectSeriesLabel77->Enabled = false;

		bDefectNameLabel1->Enabled = false;
		bDefectNameLabel2->Enabled = false;
		bDefectNameLabel3->Enabled = false;
		bDefectNameLabel4->Enabled = false;
		bDefectNameLabel5->Enabled = false;
		bDefectNameLabel6->Enabled = false;
		bDefectNameLabel7->Enabled = false;
		bDefectNameLabel8->Enabled = false;
		bDefectNameLabel9->Enabled = false;
		bDefectNameLabel10->Enabled = false;

		bDefectCountLabel1->Enabled = false;
		bDefectCountLabel2->Enabled = false;
		bDefectCountLabel3->Enabled = false;
		bDefectCountLabel4->Enabled = false;
		bDefectCountLabel5->Enabled = false;
		bDefectCountLabel6->Enabled = false;
		bDefectCountLabel7->Enabled = false;
		bDefectCountLabel8->Enabled = false;
		bDefectCountLabel9->Enabled = false;
		bDefectCountLabel10->Enabled = false;

		bDefectRatioLabel1->Enabled = false;
		bDefectRatioLabel2->Enabled = false;
		bDefectRatioLabel3->Enabled = false;
		bDefectRatioLabel4->Enabled = false;
		bDefectRatioLabel5->Enabled = false;
		bDefectRatioLabel6->Enabled = false;
		bDefectRatioLabel7->Enabled = false;
		bDefectRatioLabel8->Enabled = false;
		bDefectRatioLabel9->Enabled = false;
		bDefectRatioLabel10->Enabled = false;

		QRShape156->Enabled = false;
		QRShape157->Enabled = false;
		QRShape158->Enabled = false;
		QRShape159->Enabled = false;
		QRShape160->Enabled = false;
		QRShape161->Enabled = false;
		QRShape162->Enabled = false;
		QRShape163->Enabled = false;
		QRShape164->Enabled = false;
		QRShape165->Enabled = false;
		QRShape166->Enabled = false;
		QRShape167->Enabled = false;
		DefectSeriesLabel1->Visible = false;
		DefectSeriesShape1->Visible = false;
		DefectSeriesLabel2->Visible = false;
		DefectSeriesLabel3->Visible = false;
		DefectSeriesLabel4->Visible = false;
		DefectSeriesLabel5->Visible = false;
		DefectSeriesLabel6->Visible = false;
		DefectSeriesLabel7->Visible = false;

		DefectNameLabel1->Visible = false;
		DefectNameLabel2->Visible = false;
		DefectNameLabel3->Visible = false;
		DefectNameLabel4->Visible = false;
		DefectNameLabel5->Visible = false;
		DefectNameLabel6->Visible = false;
		DefectNameLabel7->Visible = false;
		DefectNameLabel8->Visible = false;
		DefectNameLabel9->Visible = false;
		DefectNameLabel10->Visible = false;

		DefectCountLabel1->Visible = false;
		DefectCountLabel2->Visible = false;
		DefectCountLabel3->Visible = false;
		DefectCountLabel4->Visible = false;
		DefectCountLabel5->Visible = false;
		DefectCountLabel6->Visible = false;
		DefectCountLabel7->Visible = false;
		DefectCountLabel8->Visible = false;
		DefectCountLabel9->Visible = false;
		DefectCountLabel10->Visible = false;

		DefectRatioLabel1->Visible = false;
		DefectRatioLabel2->Visible = false;
		DefectRatioLabel3->Visible = false;
		DefectRatioLabel4->Visible = false;
		DefectRatioLabel5->Visible = false;
		DefectRatioLabel6->Visible = false;
		DefectRatioLabel7->Visible = false;
		DefectRatioLabel8->Visible = false;
		DefectRatioLabel9->Visible = false;
		DefectRatioLabel10->Visible = false;

		DefectSeriesShape2->Visible = false;
		DefectSeriesShape3->Visible = false;
		DefectSeriesShape4->Visible = false;
		DefectSeriesShape5->Visible = false;
		DefectSeriesShape6->Visible = false;

		DefectSeriesShape7->Visible = false;
		DefectSeriesShape8->Visible = false;
		DefectSeriesShape9->Visible = false;
		DefectSeriesShape10->Visible = false;
		DefectSeriesShape11->Visible = false;


		DefectSeriesLabel1->Enabled = false;
		DefectSeriesShape1->Enabled = false;
		DefectSeriesLabel2->Enabled = false;
		DefectSeriesLabel3->Enabled = false;
		DefectSeriesLabel4->Enabled = false;
		DefectSeriesLabel5->Enabled = false;
		DefectSeriesLabel6->Enabled = false;
		DefectSeriesLabel7->Enabled = false;

		DefectNameLabel1->Enabled = false;
		DefectNameLabel2->Enabled = false;
		DefectNameLabel3->Enabled = false;
		DefectNameLabel4->Enabled = false;
		DefectNameLabel5->Enabled = false;
		DefectNameLabel6->Enabled = false;
		DefectNameLabel7->Enabled = false;
		DefectNameLabel8->Enabled = false;
		DefectNameLabel9->Enabled = false;
		DefectNameLabel10->Enabled = false;

		DefectCountLabel1->Enabled = false;
		DefectCountLabel2->Enabled = false;
		DefectCountLabel3->Enabled = false;
		DefectCountLabel4->Enabled = false;
		DefectCountLabel5->Enabled = false;
		DefectCountLabel6->Enabled = false;
		DefectCountLabel7->Enabled = false;
		DefectCountLabel8->Enabled = false;
		DefectCountLabel9->Enabled = false;
		DefectCountLabel10->Enabled = false;

		DefectRatioLabel1->Enabled = false;
		DefectRatioLabel2->Enabled = false;
		DefectRatioLabel3->Enabled = false;
		DefectRatioLabel4->Enabled = false;
		DefectRatioLabel5->Enabled = false;
		DefectRatioLabel6->Enabled = false;
		DefectRatioLabel7->Enabled = false;
		DefectRatioLabel8->Enabled = false;
		DefectRatioLabel9->Enabled = false;
		DefectRatioLabel10->Enabled = false;

		DefectSeriesShape2->Enabled = false;
		DefectSeriesShape3->Enabled = false;
		DefectSeriesShape4->Enabled = false;
		DefectSeriesShape5->Enabled = false;
		DefectSeriesShape6->Enabled = false;

		DefectSeriesShape7->Enabled = false;
		DefectSeriesShape8->Enabled = false;
		DefectSeriesShape9->Enabled = false;
		DefectSeriesShape10->Enabled = false;
		DefectSeriesShape11->Enabled = false;
	}
}

//---------------------------------------------------------------------------
void __fastcall TPrintInspectionResultForm::TntFormActivate(
	TObject *Sender)
{
  SetScreenPosition(this);
	SetDetailReportOption(PCProgramOption.DetailRportView, 0);

    if(PCProgramOption.IncludeUnInsTabletCount == true)
    {
//type 1
    	QRLabel15->Visible = true;
        UninsCntQRLabel->Visible = true;
    	QRLabel15->Enabled = true;
        UninsCntQRLabel->Enabled = true;

        QRLabel61->Top = 232;
        RDefectCntQRLabel->Top = 232;

        QRLabel47->Top = 268;
        RPassCntQRLabel->Top = 268;

        QRShape7->Visible = true;
        QRShape7->Enabled = true;

//type 2
    	QRLabel21->Visible = true;
        UninsCntQRLabel2->Visible = true;
    	QRLabel21->Enabled = true;
        UninsCntQRLabel2->Enabled = true;

        QRLabel61->Top = 232;
        RDefectCntQRLabel->Top = 232;

        QRLabel47->Top = 268;
        RPassCntQRLabel->Top = 268;

        QRShape98->Visible = true;
        QRShape98->Enabled = true;

//type3
    	QRLabel14->Visible = true;
        UninsCntQRLabel3->Visible = true;
    	QRLabel14->Enabled = true;
        UninsCntQRLabel3->Enabled = true;

        QRShape87->Height = 170;
        QRShape97->Height = 143;

        QRLabel142->Top = 146;
        RDefectCntQRLabel3->Top = 146;

        QRLabel136->Top = 169;
        RPassCntQRLabel3->Top = 169;

        QRShape86->Visible = true;
        QRShape86->Enabled = true;

//type 4
    	QRLabel28->Visible = true;
        UninsCntQRLabel4->Visible = true;
    	QRLabel28->Enabled = true;
        UninsCntQRLabel4->Enabled = true;

        QRShape117->Height = 170;
        QRShape129->Height = 139;

        QRLabel198->Top = 145;
        RDefectCntQRLabel4->Top = 145;

        QRLabel171->Top = 168;
        RPassCntQRLabel4->Top = 168;

        QRShape86->Visible = true;
        QRShape86->Enabled = true;
    }
    else
    {
//type 1
    	QRLabel15->Visible = false;
        UninsCntQRLabel->Visible = false;
    	QRLabel15->Enabled = false;
        UninsCntQRLabel->Enabled = false;

        QRShape3->Height = 223;
        QRShape9->Height = 180;

        QRLabel61->Top = 196;
        RDefectCntQRLabel->Top = 196;

        QRLabel47->Top = 232;
        RPassCntQRLabel->Top = 232;

        QRShape7->Visible = false;
        QRShape7->Enabled = false;

//type 2
    	QRLabel21->Visible = false;
        UninsCntQRLabel2->Visible = false;
    	QRLabel21->Enabled = false;
        UninsCntQRLabel2->Enabled = false;

        QRShape37->Height = 223;
        QRShape49->Height = 180;

        QRLabel83->Top = 196;
        RDefectCntQRLabel2->Top = 196;

        QRLabel56->Top = 232;
        RPassCntQRLabel2->Top = 232;

        QRShape98->Visible = false;
        QRShape98->Enabled = false;

//type 3
    	QRLabel14->Visible = false;
        UninsCntQRLabel3->Visible = false;
    	QRLabel14->Enabled = false;
        UninsCntQRLabel3->Enabled = false;

        QRShape87->Height = 144;
        QRShape97->Height = 117;

        QRLabel142->Top = 121;
        RDefectCntQRLabel3->Top = 121;

        QRLabel136->Top = 144;
        RPassCntQRLabel3->Top = 144;

        QRShape86->Visible = false;
        QRShape86->Enabled = false;

//type 4
    	QRLabel28->Visible = false;
        UninsCntQRLabel4->Visible = false;
    	QRLabel28->Enabled = false;
        UninsCntQRLabel4->Enabled = false;

        QRShape117->Height = 144;
        QRShape129->Height = 117;

        QRLabel198->Top = 121;
        RDefectCntQRLabel4->Top = 121;

        QRLabel171->Top = 144;
        RPassCntQRLabel4->Top = 144;

        QRShape101->Visible = false;
        QRShape101->Enabled = false;
    }

}
//---------------------------------------------------------------------------

void __fastcall TPrintInspectionResultForm::SetThroughtputChart(WideString productName, WideString lotName)
{
	double *ThroughputChartList;
	int ThroughputChartListSize;
	int ThroughputChartCount;

	ThroughputChartList = NULL;
	ThroughputChartListSize = 0;
	ThroughputChartCount = 0;

	AnsiString productPath;
	productPath = ProgramPath.Product + "\\" + productName + "\\result";

	AnsiString throughputFileName = productPath + "\\" + lotName + ".trp";
  TFileStream *fileStream;
  fileStream = NULL;

  try
  {
    if (!FileExists(throughputFileName))
    {
      throw("Throughput File Does Not Exist");
    }

    fileStream = new TFileStream(throughputFileName, fmOpenRead);
    unsigned int thorughputFileVerion;
    fileStream->Read(&thorughputFileVerion, sizeof(unsigned int));
    if (thorughputFileVerion != THROUGHPUT_FILE_VERSION)
    {
      throw("Throughput File Version Is Not Matched");
    }
    fileStream->Read(&ThroughputChartCount, sizeof(int));
    if (ThroughputChartCount <= 0)
    {
      throw("Wrong Throughput Data Count");
    }
    if (ThroughputChartListSize == 0) ThroughputChartListSize = THROUGHPUT_CHART_DEFAULT_SIZE;
    while (ThroughputChartListSize < ThroughputChartCount)
    {
      ThroughputChartListSize *= 2;
    }
    if (ThroughputChartList) delete[] ThroughputChartList;
    ThroughputChartList = new double[ThroughputChartListSize];
    memset(ThroughputChartList, 0, sizeof(double) * ThroughputChartListSize);
    fileStream->Read(ThroughputChartList, ThroughputChartCount * sizeof(double));
    delete fileStream;

    ThroughputChartDB->Series[0]->Clear();
    ThroughputChartDB->Series[0]->AddArray(ThroughputChartList, ThroughputChartCount);

    double fstAvgSpeed;
    double secAvgSpeed;
    double MaxSpeed;
    double UpperBoundary, LowerBoundary;
    int tempCount;

    fstAvgSpeed = secAvgSpeed = MaxSpeed = tempCount = 0;

    if (ThroughputChartCount)
    {
      for (int m = 0; m < ThroughputChartCount; m++)
      {
        fstAvgSpeed += ThroughputChartList[m];

        if (MaxSpeed < ThroughputChartList[m])
        {
          MaxSpeed = ThroughputChartList[m];
        }
      }

      fstAvgSpeed /= ThroughputChartCount;

      UpperBoundary = fstAvgSpeed + fstAvgSpeed * 0.5;
      LowerBoundary = fstAvgSpeed - fstAvgSpeed * 0.5;

      // 50% 유동범위 내에서 평균속도 측정
      for (int m = 0; m < ThroughputChartCount; m++)
      {
        if (ThroughputChartList[m] > LowerBoundary)// && ThroughputChartList[m] < UpperBoundary)
        {
          secAvgSpeed += ThroughputChartList[m];
          tempCount++;
        }
      }

      if (tempCount)
      {
        secAvgSpeed /= tempCount;
      }
    }

    AvgSpeedLabel->Caption = FloatToStrF(secAvgSpeed, ffNumber, 10, 0) + " T/H";
    MaxSpeedLabel->Caption = FloatToStrF(MaxSpeed, ffNumber, 10, 0) + " T/H";

    if (ThroughputChartCount >= 200)
    {
      ThroughputChartDB->BottomAxis->SetMinMax(ThroughputChartCount - 199, ThroughputChartCount + 1);
    }

    if (ThroughputChartCount + 1 >= ThroughputChartListSize)
    {
      double *tempArray = new double[ThroughputChartListSize];
      memcpy(tempArray, ThroughputChartList, ThroughputChartListSize);
      delete[] ThroughputChartList;
      ThroughputChartList = new double[ThroughputChartListSize * 2];
      memcpy(ThroughputChartList, tempArray, ThroughputChartListSize);
      delete[] tempArray;
      ThroughputChartListSize *= 2;
    }
  }
  catch(...)
  {
    WritePCProgramErrorLog(this->Name, __LINE__);
    
    if (fileStream) delete fileStream;

    if (ThroughputChartList) delete[] ThroughputChartList;
    ThroughputChartList = new double[THROUGHPUT_CHART_DEFAULT_SIZE];
    ThroughputChartListSize = THROUGHPUT_CHART_DEFAULT_SIZE;
    ThroughputChartCount = 0;
    ThroughputChartDB->Series[0]->Clear();
  }
}
//---------------------------------------------------------------------------
void __fastcall TPrintInspectionResultForm::CalGoodRateOptionBoxClick(TObject *Sender)
{
	if (!Report.Data.ProductionCount)
	{
		if (CalGoodRateOptionBox->Checked)
		{
			ShowMessage(PRINTINSPECTIONRESULTFORM_UNKNOWN_66);

			CalGoodRateOptionBox->Checked = false;
			return;
		}
	}

	int TotalCnt = 0;

	if (!CalGoodRateOptionBox->Checked)
	{
		if (PCProgramOption.IncludeUnInsTabletCount)
			TotalCnt = Report.Data.GoodTabletCount + Report.Data.DefectTabletCount + Report.Data.UnInsTabletCount;
		else
			TotalCnt = Report.Data.GoodTabletCount + Report.Data.DefectTabletCount;

		bool ValidCheck = false; // 각 항목에 따른 총 제품 검사 수량이 0보다 큰지 확인
		ValidCheck = (TotalCnt > 0) ? true : false;

		if (ValidCheck)
		{
			RPassCntQRLabel->Caption = Format("%.2f %%", ARRAYOFCONST(((double)Report.Data.GoodTabletCount * 100 / TotalCnt)));
			RDefectCntQRLabel->Caption = Format("%.2f %%", ARRAYOFCONST(((double)Report.Data.DefectTabletCount * 100 / TotalCnt)));

			RPassCntQRLabel2->Caption = Format("%.2f %%", ARRAYOFCONST(((double)Report.Data.GoodTabletCount * 100 / TotalCnt)));
			RDefectCntQRLabel2->Caption = Format("%.2f %%", ARRAYOFCONST(((double)Report.Data.DefectTabletCount * 100 / TotalCnt)));

			RPassCntQRLabel3->Caption = Format("%.2f %%", ARRAYOFCONST(((double)Report.Data.GoodTabletCount * 100 / TotalCnt)));
			RDefectCntQRLabel3->Caption = Format("%.2f %%", ARRAYOFCONST(((double)Report.Data.DefectTabletCount * 100 / TotalCnt)));

			RPassCntQRLabel4->Caption = Format("%.2f %%", ARRAYOFCONST(((double)Report.Data.GoodTabletCount * 100 / TotalCnt)));
			RDefectCntQRLabel4->Caption = Format("%.2f %%", ARRAYOFCONST(((double)Report.Data.DefectTabletCount * 100 / TotalCnt)));
		}
		else
		{
			RDefectCntQRLabel->Caption = "0%";
			RPassCntQRLabel->Caption = "0%";

			RDefectCntQRLabel2->Caption = "0%";
			RPassCntQRLabel2->Caption = "0%";

			RDefectCntQRLabel3->Caption = "0%";
			RPassCntQRLabel3->Caption = "0%";

			RDefectCntQRLabel4->Caption = "0%";
			RPassCntQRLabel4->Caption = "0%";
		}
	}
	else
	{
		// 20180319
		// 유한양행 요청사항
		// 입력한 생산단위를 기준으로 수율 계산
		// 수량에 대한 정보는 변경하지 않음
		// 일단 미검사에 대한 옵션 상태는 무시하도록 한다

		TotalCnt = Report.Data.ProductionCount;

		bool ValidCheck = false; // 각 항목에 따른 총 제품 검사 수량이 0보다 큰지 확인
		ValidCheck = (TotalCnt > 0) ? true : false;

		if (ValidCheck)
		{
			RPassCntQRLabel->Caption = Format("%.2f %%", ARRAYOFCONST(((double)Report.Data.GoodTabletCount * 100 / TotalCnt)));
			RDefectCntQRLabel->Caption = Format("%.2f %%", ARRAYOFCONST(((double)(TotalCnt - Report.Data.GoodTabletCount) * 100 / TotalCnt)));

			RPassCntQRLabel2->Caption = Format("%.2f %%", ARRAYOFCONST(((double)Report.Data.GoodTabletCount * 100 / TotalCnt)));
			RDefectCntQRLabel2->Caption = Format("%.2f %%", ARRAYOFCONST(((double)(TotalCnt - Report.Data.GoodTabletCount) * 100 / TotalCnt)));

			RPassCntQRLabel3->Caption = Format("%.2f %%", ARRAYOFCONST(((double)Report.Data.GoodTabletCount * 100 / TotalCnt)));
			RDefectCntQRLabel3->Caption = Format("%.2f %%", ARRAYOFCONST(((double)(TotalCnt - Report.Data.GoodTabletCount) * 100 / TotalCnt)));

			RPassCntQRLabel4->Caption = Format("%.2f %%", ARRAYOFCONST(((double)Report.Data.GoodTabletCount * 100 / TotalCnt)));
			RDefectCntQRLabel4->Caption = Format("%.2f %%", ARRAYOFCONST(((double)(TotalCnt - Report.Data.GoodTabletCount) * 100 / TotalCnt)));
		}
		else
		{
			RDefectCntQRLabel->Caption = "0%";
			RPassCntQRLabel->Caption = "0%";

			RDefectCntQRLabel2->Caption = "0%";
			RPassCntQRLabel2->Caption = "0%";

			RDefectCntQRLabel3->Caption = "0%";
			RPassCntQRLabel3->Caption = "0%";

			RDefectCntQRLabel4->Caption = "0%";
			RPassCntQRLabel4->Caption = "0%";
		}
	}
}
//---------------------------------------------------------------------------

void __fastcall TPrintInspectionResultForm::GroupBox1DblClick(
	TObject *Sender)
{
  if(!(MachineSetupData.CompanyID == INTERNATIONAL_MACHINE1 ||MachineSetupData.CompanyID == INTERNATIONAL_MACHINE2))
  {
    if (!bYuhanOption)
    {
      CalGoodRateOptionBox->Visible = true;
      RemoveGradeInfoOptionBox->Visible = true;
      bYuhanOption = true;
      CheckBox4->Visible = true;
    }
    else
    {
      CalGoodRateOptionBox->Visible = false;
      RemoveGradeInfoOptionBox->Visible = false;
      bYuhanOption = false;
      CheckBox4->Visible = false;
    }
  }
}
//---------------------------------------------------------------------------

void __fastcall TPrintInspectionResultForm::RemoveGradeInfoOptionBoxClick(
	TObject *Sender)
{
	if (RemoveGradeInfoOptionBox->Checked)
	{
		QRBand5->Enabled = false;
		QRBand5->Visible = false;

		QRBand2->Enabled = false;
		QRBand2->Visible = false;

		QRBand3->Enabled = false;
		QRBand3->Visible = false;

		QRBand7->Enabled = false;
		QRBand7->Visible = false;
	}
	else
	{
		QRBand5->Enabled = true;
		QRBand5->Visible = true;

		QRBand2->Enabled = true;
		QRBand2->Visible = true;

		QRBand3->Enabled = true;
		QRBand3->Visible = true;

		QRBand7->Enabled = true;
		QRBand7->Visible = true;
	}
}
//---------------------------------------------------------------------------


void __fastcall TPrintInspectionResultForm::Timer1Timer(TObject *Sender)
{
  HWND h_wnd = FindWindowW(NULL,L"Save As");
  if(h_wnd != NULL)
  {
        if(Zorder != 1)
        {
                SetWindowPos(h_wnd, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
                CloseHandle(h_wnd);
        }
  }
  else
  {

        if(Zorder != 2)
        {
                SetWindowPos(Handle, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
                Zorder = 2;
        }
  }
}
//---------------------------------------------------------------------------

void __fastcall TPrintInspectionResultForm::CheckBox1Click(TObject *Sender)
{
  AnsiString title;
  if(DefaultLCID == 1042)
  {
    title = " 등급";
  }
  else
  {
    title = " grade";
  }
    
  if(CheckBox1->Checked)
  {
    PrintEraseGradeQRLabel->Caption = IntToStr(Report.GradeData.PrintEraseGrade) + title;
    PrintEraseGradeQRLabel2->Caption = IntToStr(Report.GradeData.PrintEraseGrade) + title;
    PrintEraseGradeQRLabel3->Caption = IntToStr(Report.GradeData.PrintEraseGrade) + title;
    PrintEraseGradeQRLabel4->Caption = IntToStr(Report.GradeData.PrintEraseGrade) + title;
  }
  else
  {
    CheckBox2->Checked = false;
    PrintEraseGradeQRLabel->Caption = FloatToStr(DefectSizePixelToMili((Report.GradeData.PrintEraseGrade + 1) * (Report.GradeData.PrintEraseGrade)) / 100.0) + " mm";
    PrintEraseGradeQRLabel2->Caption = FloatToStr(DefectSizePixelToMili((Report.GradeData.PrintEraseGrade + 1) * (Report.GradeData.PrintEraseGrade)) / 100.0) + " mm";
    PrintEraseGradeQRLabel3->Caption = FloatToStr(DefectSizePixelToMili((Report.GradeData.PrintEraseGrade + 1) * (Report.GradeData.PrintEraseGrade)) / 100.0) + " mm";
    PrintEraseGradeQRLabel4->Caption = FloatToStr(DefectSizePixelToMili((Report.GradeData.PrintEraseGrade + 1) * (Report.GradeData.PrintEraseGrade)) / 100.0) + " mm";

    ColorGradeQRLabel->Caption = IntToStr(Report.GradeData.ColorGrade) + title;
    ColorGradeQRLabel2->Caption = IntToStr(Report.GradeData.ColorGrade) + title;
    ColorGradeQRLabel3->Caption = IntToStr(Report.GradeData.ColorGrade) + title;
    ColorGradeQRLabel4->Caption = IntToStr(Report.GradeData.ColorGrade) + title;
  }

  if(globalIsPrintedTablet)
  {
    if(CheckBox1->Checked)
    {
      PrintSpreadLabel1->Caption = IntToStr(Report.GradeData.PrintSpreadGrade) + title;
      PrintSpreadLabel2->Caption = IntToStr(Report.GradeData.PrintSpreadGrade) + title;
      PrintSpreadLabel3->Caption = IntToStr(Report.GradeData.PrintSpreadGrade) + title;
      PrintSpreadLabel4->Caption = IntToStr(Report.GradeData.PrintSpreadGrade) + title;
    }
    else
    {
      CheckBox2->Checked = false;
      PrintSpreadLabel1->Caption = FloatToStr(DefectSizePixelToMili((Report.GradeData.PrintSpreadGrade + 1) * (Report.GradeData.PrintSpreadGrade)) / 100.0) + " mm";
      PrintSpreadLabel2->Caption = FloatToStr(DefectSizePixelToMili((Report.GradeData.PrintSpreadGrade + 1) * (Report.GradeData.PrintSpreadGrade)) / 100.0) + " mm";
      PrintSpreadLabel3->Caption = FloatToStr(DefectSizePixelToMili((Report.GradeData.PrintSpreadGrade + 1) * (Report.GradeData.PrintSpreadGrade)) / 100.0) + " mm";
      PrintSpreadLabel4->Caption = FloatToStr(DefectSizePixelToMili((Report.GradeData.PrintSpreadGrade + 1) * (Report.GradeData.PrintSpreadGrade)) / 100.0) + " mm";
    }
  }
}
//---------------------------------------------------------------------------

void __fastcall TPrintInspectionResultForm::CheckBox2Click(TObject *Sender)
{
  AnsiString title;
  if(DefaultLCID == 1042)
  {
    title = " 등급";
  }
  else
  {
    title = " grade";
  }

  if(CheckBox1->Checked== false)
  {
   CheckBox2->Checked = false;
   return;
  }

  if(CheckBox1->Checked && CheckBox2->Checked)
  {
    PrintEraseGradeQRLabel->Caption = "0" + title;
    PrintEraseGradeQRLabel2->Caption = "0" + title;
    PrintEraseGradeQRLabel3->Caption = "0" + title;
    PrintEraseGradeQRLabel4->Caption = "0" + title;

    ColorGradeQRLabel->Caption = "0" + title;
    ColorGradeQRLabel2->Caption = "0" + title;
    ColorGradeQRLabel3->Caption = "0" + title;
    ColorGradeQRLabel4->Caption = "0" + title;
  }
  else if(CheckBox1->Checked && CheckBox2->Checked == false)
  {
    PrintEraseGradeQRLabel->Caption = IntToStr(Report.GradeData.PrintEraseGrade) + title;
    PrintEraseGradeQRLabel2->Caption = IntToStr(Report.GradeData.PrintEraseGrade) + title;
    PrintEraseGradeQRLabel3->Caption = IntToStr(Report.GradeData.PrintEraseGrade) + title;
    PrintEraseGradeQRLabel4->Caption = IntToStr(Report.GradeData.PrintEraseGrade) + title;

    ColorGradeQRLabel->Caption = IntToStr(Report.GradeData.ColorGrade) + title;
    ColorGradeQRLabel2->Caption = IntToStr(Report.GradeData.ColorGrade) + title;
    ColorGradeQRLabel3->Caption = IntToStr(Report.GradeData.ColorGrade) + title;
    ColorGradeQRLabel4->Caption = IntToStr(Report.GradeData.ColorGrade) + title;
  }

  if(globalIsPrintedTablet)
  {
    if(CheckBox1->Checked && CheckBox2->Checked)
    {
      PrintSpreadLabel1->Caption = "0" + title;
      PrintSpreadLabel2->Caption = "0" + title;
      PrintSpreadLabel3->Caption = "0" + title;
      PrintSpreadLabel4->Caption = "0" + title;
    }
    else if(CheckBox1->Checked && CheckBox2->Checked == false)
    {
      PrintSpreadLabel1->Caption = IntToStr(Report.GradeData.PrintSpreadGrade) + title;
      PrintSpreadLabel2->Caption = IntToStr(Report.GradeData.PrintSpreadGrade) + title;
      PrintSpreadLabel3->Caption = IntToStr(Report.GradeData.PrintSpreadGrade) + title;
      PrintSpreadLabel4->Caption = IntToStr(Report.GradeData.PrintSpreadGrade) + title;
    }
  }


}
//---------------------------------------------------------------------------

void __fastcall TPrintInspectionResultForm::CheckBox3Click(TObject *Sender)
{
  if(CheckBox3->Checked)
  {
    OptionPrintMarkGradeQRLabel->Caption = "0 %";
    OptionPrintMarkGradeQRLabel2->Caption = "0 %";
    OptionPrintMarkGradeQRLabel3->Caption = "0 %";
    OptionPrintMarkGradeQRLabel4->Caption = "0 %";
  }
  else
  {
    OptionPrintMarkGradeQRLabel->Caption = IntToStr(Report.GradeData.OptionPrintMarkGrade) + " %";
    OptionPrintMarkGradeQRLabel2->Caption = IntToStr(Report.GradeData.OptionPrintMarkGrade) + " %";
    OptionPrintMarkGradeQRLabel3->Caption = IntToStr(Report.GradeData.OptionPrintMarkGrade) + " %";
    OptionPrintMarkGradeQRLabel4->Caption = IntToStr(Report.GradeData.OptionPrintMarkGrade) + " %";
  }

}
//---------------------------------------------------------------------------

void __fastcall TPrintInspectionResultForm::Panel1DblClick(TObject *Sender)
{
  if(OptionGroupBox->Visible == true)
  {
    OptionGroupBox->Visible = false;
  }
  else
  {
    OptionGroupBox->Visible = true;
  }
}
//---------------------------------------------------------------------------

void __fastcall TPrintInspectionResultForm::DefectImagePrintLabelClick(
      TObject *Sender)
{
  DefectImagePrintCheckBox->Checked = ! DefectImagePrintCheckBox->Checked;  
}
//---------------------------------------------------------------------------

void __fastcall TPrintInspectionResultForm::CheckBox4Click(TObject *Sender)
{

  if (CheckBox4->Checked)
	{
		DisplayReportPanelOption1(true);
		DisplayReportPanelOption2(true);
		DisplayReportPanelOption3(true);
		DisplayReportPanelOption4(true);
	}
	else
	{
		DisplayReportPanelOption1(false);
		DisplayReportPanelOption2(false);
		DisplayReportPanelOption3(false);
		DisplayReportPanelOption4(false);
	}
}
//---------------------------------------------------------------------------

void __fastcall TPrintInspectionResultForm::DisplayReportPanelOption1(bool switchVal)
{
		QRBand14->Enabled = switchVal;
		QRBand14->Visible = switchVal;
}

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

void __fastcall TPrintInspectionResultForm::DisplayReportPanelOption2(bool switchVal)
{
		QRBand16->Enabled = switchVal;
		QRBand16->Visible = switchVal;
}

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

void __fastcall TPrintInspectionResultForm::DisplayReportPanelOption3(bool switchVal)
{
//ReportPanel3 Start
		QRLabel128->Enabled = switchVal;
        QRLabel137->Enabled = switchVal;
        QRLabel135->Enabled = switchVal;
        QRLabel129->Enabled = switchVal;
        QRLabel130->Enabled = switchVal;
        QRLabel142->Enabled = switchVal;
        QRLabel136->Enabled = switchVal;

        TotalCntQRLabel3->Enabled = switchVal;
        PassCntQRLabel3->Enabled = switchVal;
        DefectCntQRLabel3->Enabled = switchVal;
        RDefectCntQRLabel3->Enabled = switchVal;
        RPassCntQRLabel3->Enabled = switchVal;

        QRShape87->Enabled = switchVal;
        QRShape96->Enabled = switchVal;
        QRShape93->Enabled = switchVal;
        QRShape94->Enabled = switchVal;
        QRShape91->Enabled = switchVal;
        QRShape95->Enabled = switchVal;
        QRShape97->Enabled = switchVal;

		QRLabel128->Visible = switchVal;
        QRLabel137->Visible = switchVal;
        QRLabel135->Visible = switchVal;
        QRLabel129->Visible = switchVal;
        QRLabel130->Visible = switchVal;
        QRLabel142->Visible = switchVal;
        QRLabel136->Visible = switchVal;

        TotalCntQRLabel3->Visible = switchVal;
        PassCntQRLabel3->Visible = switchVal;
        DefectCntQRLabel3->Visible = switchVal;
        RDefectCntQRLabel3->Visible = switchVal;
        RPassCntQRLabel3->Visible = switchVal;

        QRShape87->Visible = switchVal;
        QRShape96->Visible = switchVal;
        QRShape93->Visible = switchVal;
        QRShape94->Visible = switchVal;
        QRShape91->Visible = switchVal;
        QRShape95->Visible = switchVal;
        QRShape97->Visible = switchVal;        
//ReportPanel3 End
}

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

void __fastcall TPrintInspectionResultForm::DisplayReportPanelOption4(bool switchVal)
{
//Inspection Result Start
		QRLabel156->Enabled = switchVal;
        QRLabel173->Enabled = switchVal;
        QRLabel170->Enabled = switchVal;
        QRLabel157->Enabled = switchVal;
        QRLabel158->Enabled = switchVal;
        QRLabel198->Enabled = switchVal;
        QRLabel171->Enabled = switchVal;

        TotalCntQRLabel4->Enabled = switchVal;
        PassCntQRLabel4->Enabled = switchVal;
        DefectCntQRLabel4->Enabled = switchVal;
        RDefectCntQRLabel4->Enabled = switchVal;
        RPassCntQRLabel4->Enabled = switchVal;

        QRShape117->Enabled = switchVal;
        QRShape118->Enabled = switchVal;
        QRShape123->Enabled = switchVal;
        QRShape124->Enabled = switchVal;
        QRShape127->Enabled = switchVal;
        QRShape128->Enabled = switchVal;
        QRShape129->Enabled = switchVal;

		QRLabel156->Visible = switchVal;
        QRLabel173->Visible = switchVal;
        QRLabel170->Visible = switchVal;
        QRLabel157->Visible = switchVal;
        QRLabel158->Visible = switchVal;
        QRLabel198->Visible = switchVal;
        QRLabel171->Visible = switchVal;

        TotalCntQRLabel4->Visible = switchVal;
        PassCntQRLabel4->Visible = switchVal;
        DefectCntQRLabel4->Visible = switchVal;
        RDefectCntQRLabel4->Visible = switchVal;
        RPassCntQRLabel4->Visible = switchVal;

        QRShape117->Visible = switchVal;
        QRShape118->Visible = switchVal;
        QRShape123->Visible = switchVal;
        QRShape124->Visible = switchVal;
        QRShape127->Visible = switchVal;
        QRShape128->Visible = switchVal;
        QRShape129->Visible = switchVal;
//Inspection Result End        
}

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