//--------------------------------------------------------------------------- #include #pragma hdrstop #include "Cost.h" #include "common.h" #include "HiddenPrintData_F.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "CurrEdit" #pragma link "ToolEdit" #pragma link "RzEdit" #pragma link "RzButton" #pragma resource "*.dfm" //--------------------------------------------------------------------------- #define IDS_TOTAL_COST StringTable[0] #define IDS_EXCHANGE_RATE StringTable[1] #define IDS_POLY_LOSS StringTable[2] #define IDS_NYLON_LOSS StringTable[3] #define IDS_SPAN_LOSS StringTable[4] #define IDS_CAPA StringTable[5] #define IDS_MACHINE_COUNT StringTable[6] #define IDS_CMT_MACHINE StringTable[7] #define IDS_RAW_MARGIN StringTable[8] #define IDS_TREATMENT_LOSS StringTable[9] #define IDS_TREAT_MARGIN StringTable[10] #define IDS_LOAD StringTable[11] #define IDS_SAVE StringTable[12] #define IDS_POLY_TREAT_LOSS StringTable[13] #define IDS_NYLON_TREAT_LOSS StringTable[14] #define IDS_SPAN_TREAT_LOSS StringTable[15] #define IDS_RAW_LOSS StringTable[16] #define IDS_WORK_DAY StringTable[17] #define IDS_TREATMENT_COST StringTable[18] //--------------------------------------------------------------------------- TCost_F *Cost_F; //--------------------------------------------------------------------------- __fastcall TCost_F::TCost_F(TComponent* Owner) : TForm(Owner) { reset(); ShowData(); } //--------------------------------------------------------------------------- void __fastcall TCost_F::FormCreate(TObject *Sender) { StringTable.Create(BaseDir, Language, "Cost"); Caption=IDS_TOTAL_COST; lbExchangeRate->Caption=IDS_EXCHANGE_RATE; lbPolyLoss->Caption=IDS_POLY_LOSS; lbNylonLoss->Caption=IDS_NYLON_LOSS; lbSpanLoss->Caption=IDS_SPAN_LOSS; lbCAPA->Caption=IDS_CAPA; lbMachineCount->Caption=IDS_MACHINE_COUNT; lbCMT_Machine->Caption=IDS_CMT_MACHINE; lbRawMargin->Caption=IDS_RAW_MARGIN; lbTreatLoss->Caption=IDS_TREATMENT_LOSS; lbTreatMargin->Caption=IDS_TREAT_MARGIN; sbLoad->Caption=IDS_LOAD; sbSave->Caption=IDS_SAVE; lbPolyTreatLoss->Caption=IDS_POLY_TREAT_LOSS; lbNylonTreatLoss->Caption=IDS_NYLON_TREAT_LOSS; lbSpanTreatLoss->Caption=IDS_SPAN_TREAT_LOSS; lbRawLoss->Caption=IDS_RAW_LOSS; lbWorkDay->Caption=IDS_WORK_DAY; lbTreatCost->Caption=IDS_TREATMENT_COST; SetFont(); } //--------------------------------------------------------------------------- void __fastcall TCost_F::SetFont(){ SetSmallFont(Font); SetSmallFont(lbCAPA->Font); SetSmallFont(lbMachineCount->Font); SetSmallFont(lbCMT_Machine->Font); SetSmallFont(lbWorkDay->Font); SetSmallFont(lbTreatCost->Font); SetSmallFont(lbExchangeRate->Font); SetSmallFont(lbPolyLoss->Font); SetSmallFont(lbNylonLoss->Font); SetSmallFont(lbSpanLoss->Font); SetSmallFont(lbPolyTreatLoss->Font); SetSmallFont(lbNylonTreatLoss->Font); SetSmallFont(lbSpanTreatLoss->Font); SetSmallFont(lbRawLoss->Font); SetSmallFont(lbRawMargin->Font); SetSmallFont(lbTreatLoss->Font); SetSmallFont(lbTreatMargin->Font); SetSmallFont(Label3->Font); SetSmallFont(Label5->Font); SetSmallFont(Label6->Font); SetSmallFont(Label10->Font); SetSmallFont(Label11->Font); SetSmallFont(Label12->Font); SetSmallFont(Label8->Font); SetSmallFont(Label1->Font); SetSmallFont(Label2->Font); SetSmallFont(Label4->Font); } //--------------------------------------------------------------------------- __fastcall TCost_F::reset(){ exchange_rate=1200; work_day_month=23.5; memset(data1,0,128); memset(data2,0,128); memset(data3,0,128); memset(data4,0,128); memset(data5,0,128); memset(data6,0,128); memset(data7,0,128); memset(data8,0,128); val1=0,val2=0,val3=0,val4=0,val5=0,val6=0,val7=0,val8=0; PolyLoss=2,SpanLoss=3,NylonLoss=2; PolyTreatLoss=0,SpanTreatLoss=0,NylonTreatLoss=0; CAPA=1,MachineCount=1,CMT_Machine=0/*ÀÏ´ë´ç CMT*/; RawLoss=3; RawMargin=5; TreatCost=0; TreatLoss=3; TreatMargin=5; } //--------------------------------------------------------------------------- bool __fastcall TCost_F::ReadFromFile(HANDLE fh){ reset(); DWORD dwRead; int ver; if(!ReadFile(fh, &ver, sizeof(int), &dwRead, NULL)) { return false; } if(ver>=1){ if(!ReadFile(fh, &exchange_rate, sizeof(double), &dwRead, NULL)) { return false; } if(!ReadFile(fh, &work_day_month, sizeof(double), &dwRead, NULL)) { return false; } if(!ReadFile(fh, &data1, 128, &dwRead, NULL)) { return false; } if(!ReadFile(fh, &data2, 128, &dwRead, NULL)) { return false; } if(!ReadFile(fh, &data3, 128, &dwRead, NULL)) { return false; } if(!ReadFile(fh, &data4, 128, &dwRead, NULL)) { return false; } if(!ReadFile(fh, &data5, 128, &dwRead, NULL)) { return false; } if(!ReadFile(fh, &data6, 128, &dwRead, NULL)) { return false; } if(!ReadFile(fh, &data7, 128, &dwRead, NULL)) { return false; } if(!ReadFile(fh, &data8, 128, &dwRead, NULL)) { return false; } if(!ReadFile(fh, &val1, sizeof(double), &dwRead, NULL)) { return false; } if(!ReadFile(fh, &val2, sizeof(double), &dwRead, NULL)) { return false; } if(!ReadFile(fh, &val3, sizeof(double), &dwRead, NULL)) { return false; } if(!ReadFile(fh, &val4, sizeof(double), &dwRead, NULL)) { return false; } if(!ReadFile(fh, &val5, sizeof(double), &dwRead, NULL)) { return false; } if(!ReadFile(fh, &val6, sizeof(double), &dwRead, NULL)) { return false; } if(!ReadFile(fh, &val7, sizeof(double), &dwRead, NULL)) { return false; } if(!ReadFile(fh, &val8, sizeof(double), &dwRead, NULL)) { return false; } if(!ReadFile(fh, &PolyLoss, sizeof(double), &dwRead, NULL)) { return false; } if(!ReadFile(fh, &SpanLoss, sizeof(double), &dwRead, NULL)) { return false; } if(!ReadFile(fh, &NylonLoss, sizeof(double), &dwRead, NULL)) { return false; } if(!ReadFile(fh, &PolyTreatLoss, sizeof(double), &dwRead, NULL)) { return false; } if(!ReadFile(fh, &SpanTreatLoss, sizeof(double), &dwRead, NULL)) { return false; } if(!ReadFile(fh, &NylonTreatLoss, sizeof(double), &dwRead, NULL)) { return false; } if(!ReadFile(fh, &CAPA, sizeof(double), &dwRead, NULL)) { return false; } if(!ReadFile(fh, &MachineCount, sizeof(double), &dwRead, NULL)) { return false; } if(!ReadFile(fh, &CMT_Machine, sizeof(double), &dwRead, NULL)) { return false; } if(!ReadFile(fh, &RawLoss, sizeof(double), &dwRead, NULL)) { return false; } if(!ReadFile(fh, &RawMargin, sizeof(double), &dwRead, NULL)) { return false; } if(!ReadFile(fh, &TreatCost, sizeof(double), &dwRead, NULL)) { return false; } if(!ReadFile(fh, &TreatLoss, sizeof(double), &dwRead, NULL)) { return false; } if(!ReadFile(fh, &TreatMargin, sizeof(double), &dwRead, NULL)) { return false; } } return true; } //--------------------------------------------------------------------------- bool __fastcall TCost_F::SaveToFile(HANDLE fh){ DWORD dwWrite; int ver=1; if(!WriteFile(fh, &ver, sizeof(int), &dwWrite, NULL)) { return false; } if(!WriteFile(fh, &exchange_rate, sizeof(double), &dwWrite, NULL)) { return false; } if(!WriteFile(fh, &work_day_month, sizeof(double), &dwWrite, NULL)) { return false; } if(!WriteFile(fh, &data1, 128, &dwWrite, NULL)) { return false; } if(!WriteFile(fh, &data2, 128, &dwWrite, NULL)) { return false; } if(!WriteFile(fh, &data3, 128, &dwWrite, NULL)) { return false; } if(!WriteFile(fh, &data4, 128, &dwWrite, NULL)) { return false; } if(!WriteFile(fh, &data5, 128, &dwWrite, NULL)) { return false; } if(!WriteFile(fh, &data6, 128, &dwWrite, NULL)) { return false; } if(!WriteFile(fh, &data7, 128, &dwWrite, NULL)) { return false; } if(!WriteFile(fh, &data8, 128, &dwWrite, NULL)) { return false; } if(!WriteFile(fh, &val1, sizeof(double), &dwWrite, NULL)) { return false; } if(!WriteFile(fh, &val2, sizeof(double), &dwWrite, NULL)) { return false; } if(!WriteFile(fh, &val3, sizeof(double), &dwWrite, NULL)) { return false; } if(!WriteFile(fh, &val4, sizeof(double), &dwWrite, NULL)) { return false; } if(!WriteFile(fh, &val5, sizeof(double), &dwWrite, NULL)) { return false; } if(!WriteFile(fh, &val6, sizeof(double), &dwWrite, NULL)) { return false; } if(!WriteFile(fh, &val7, sizeof(double), &dwWrite, NULL)) { return false; } if(!WriteFile(fh, &val8, sizeof(double), &dwWrite, NULL)) { return false; } if(!WriteFile(fh, &PolyLoss, sizeof(double), &dwWrite, NULL)) { return false; } if(!WriteFile(fh, &SpanLoss, sizeof(double), &dwWrite, NULL)) { return false; } if(!WriteFile(fh, &NylonLoss, sizeof(double), &dwWrite, NULL)) { return false; } if(!WriteFile(fh, &PolyTreatLoss, sizeof(double), &dwWrite, NULL)) { return false; } if(!WriteFile(fh, &SpanTreatLoss, sizeof(double), &dwWrite, NULL)) { return false; } if(!WriteFile(fh, &NylonTreatLoss, sizeof(double), &dwWrite, NULL)) { return false; } if(!WriteFile(fh, &CAPA, sizeof(double), &dwWrite, NULL)) { return false; } if(!WriteFile(fh, &MachineCount, sizeof(double), &dwWrite, NULL)) { return false; } if(!WriteFile(fh, &CMT_Machine, sizeof(double), &dwWrite, NULL)) { return false; } if(!WriteFile(fh, &RawLoss, sizeof(double), &dwWrite, NULL)) { return false; } if(!WriteFile(fh, &RawMargin, sizeof(double), &dwWrite, NULL)) { return false; } if(!WriteFile(fh, &TreatCost, sizeof(double), &dwWrite, NULL)) { return false; } if(!WriteFile(fh, &TreatLoss, sizeof(double), &dwWrite, NULL)) { return false; } if(!WriteFile(fh, &TreatMargin, sizeof(double), &dwWrite, NULL)) { return false; } return true; } //--------------------------------------------------------------------------- void __fastcall TCost_F::sbSaveClick(TObject *Sender) { SaveDialog->InitialDir=BaseDir + "\\cost"; SaveDialog->DefaultExt="cst"; SaveDialog->Filter="Cost Files(*.cst)|*.cst"; if(SaveDialog->Execute()){ HANDLE hFile; hFile = CreateFile(SaveDialog->FileName.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); SaveToFile(hFile); CloseHandle(hFile); } } //--------------------------------------------------------------------------- void __fastcall TCost_F::sbLoadClick(TObject *Sender) { OpenDialog->InitialDir=BaseDir + "\\cost"; OpenDialog->DefaultExt="cst"; OpenDialog->Filter="Cost Files(*.cst)|*.cst"; if(OpenDialog->Execute()){ HANDLE hFile = INVALID_HANDLE_VALUE; hFile = CreateFile(OpenDialog->FileName.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL, NULL); ReadFromFile(hFile); CloseHandle(hFile); hFile = INVALID_HANDLE_VALUE; ShowData(); } } //--------------------------------------------------------------------------- void __fastcall TCost_F::ShowData(){ cedExchangeRate->Text=exchange_rate; ed1->Text=data1; ed2->Text=data2; ed3->Text=data3; ed4->Text=data4; ed5->Text=data5; ed6->Text=data6; ed7->Text=data7; ced1->Text=val1; ced2->Text=val2; ced3->Text=val3; ced4->Text=val4; ced5->Text=val5; ced6->Text=val6; ced7->Text=val7; edPolyLoss->Text=FloatToStr(PolyLoss); edSpanLoss->Text=FloatToStr(SpanLoss); edNylonLoss->Text=FloatToStr(NylonLoss); edPolyTreatLoss->Text=FloatToStr(PolyTreatLoss); edSpanTreatLoss->Text=FloatToStr(SpanTreatLoss); edNylonTreatLoss->Text=FloatToStr(NylonTreatLoss); edCAPA->Text=FloatToStr(CAPA); edMachineCount->Text=FloatToStr(MachineCount); cedCMT_Machine->Text=CMT_Machine/*ÀÏ´ë´ç CMT*/; edWorkDay->Text=FloatToStr(work_day_month); edRawLoss->Text=FloatToStr(RawLoss); edRawMargin->Text=FloatToStr(RawMargin); cedTreatCost->Text=TreatCost;//°¡°ø·á edTreatLoss->Text=FloatToStr(TreatLoss); edTreatMargin->Text=FloatToStr(TreatMargin); } //--------------------------------------------------------------------------- void __fastcall TCost_F::cedExchangeRateKeyPress(TObject *Sender, char &Key) { if(Key==VK_RETURN){ if(cedExchangeRate->Text=="")return; exchange_rate=atof(cedExchangeRate->Text.c_str()); } } //--------------------------------------------------------------------------- void __fastcall TCost_F::ed1KeyPressced(TObject *Sender, char &Key) { if(Key==VK_RETURN){ strcpy(data1,ed1->Text.c_str()); } } //--------------------------------------------------------------------------- void __fastcall TCost_F::ed2KeyPress(TObject *Sender, char &Key) { if(Key==VK_RETURN){ strcpy(data2,ed2->Text.c_str()); } } //--------------------------------------------------------------------------- void __fastcall TCost_F::ed3KeyPress(TObject *Sender, char &Key) { if(Key==VK_RETURN){ strcpy(data3,ed3->Text.c_str()); } } //--------------------------------------------------------------------------- void __fastcall TCost_F::ed4KeyPress(TObject *Sender, char &Key) { if(Key==VK_RETURN){ strcpy(data4,ed4->Text.c_str()); } } //--------------------------------------------------------------------------- void __fastcall TCost_F::ed5KeyPress(TObject *Sender, char &Key) { if(Key==VK_RETURN){ strcpy(data5,ed5->Text.c_str()); } } //--------------------------------------------------------------------------- void __fastcall TCost_F::ed6KeyPress(TObject *Sender, char &Key) { if(Key==VK_RETURN){ strcpy(data6,ed6->Text.c_str()); } } //--------------------------------------------------------------------------- void __fastcall TCost_F::ed7KeyPress(TObject *Sender, char &Key) { if(Key==VK_RETURN){ strcpy(data7,ed7->Text.c_str()); } } //--------------------------------------------------------------------------- void __fastcall TCost_F::ced1KeyPress(TObject *Sender, char &Key) { if(Key==VK_RETURN){ val1=atof(ced1->Text.c_str()); } } //--------------------------------------------------------------------------- void __fastcall TCost_F::ced2KeyPress(TObject *Sender, char &Key) { if(Key==VK_RETURN){ val2=atof(ced2->Text.c_str()); } } //--------------------------------------------------------------------------- void __fastcall TCost_F::ced3KeyPress(TObject *Sender, char &Key) { if(Key==VK_RETURN){ val3=atof(ced3->Text.c_str()); } } //--------------------------------------------------------------------------- void __fastcall TCost_F::ced4KeyPress(TObject *Sender, char &Key) { if(Key==VK_RETURN){ val4=atof(ced4->Text.c_str()); } } //--------------------------------------------------------------------------- void __fastcall TCost_F::ced5KeyPress(TObject *Sender, char &Key) { if(Key==VK_RETURN){ val5=atof(ced5->Text.c_str()); } } //--------------------------------------------------------------------------- void __fastcall TCost_F::ced6KeyPress(TObject *Sender, char &Key) { if(Key==VK_RETURN){ val6=atof(ced6->Text.c_str()); } } //--------------------------------------------------------------------------- void __fastcall TCost_F::ced7KeyPress(TObject *Sender, char &Key) { if(Key==VK_RETURN){ val7=atof(ced7->Text.c_str()); } } //--------------------------------------------------------------------------- void __fastcall TCost_F::edPolyLossKeyPress(TObject *Sender, char &Key) { if(Key==VK_RETURN){ if(edPolyLoss->Text=="")return; PolyLoss=atof(edPolyLoss->Text.c_str()); } } //--------------------------------------------------------------------------- void __fastcall TCost_F::edNylonLossKeyPress(TObject *Sender, char &Key) { if(Key==VK_RETURN){ if(edNylonLoss->Text=="")return; NylonLoss=atof(edNylonLoss->Text.c_str()); } } //--------------------------------------------------------------------------- void __fastcall TCost_F::edSpanLossKeyPress(TObject *Sender, char &Key) { if(Key==VK_RETURN){ if(edSpanLoss->Text=="")return; SpanLoss=atof(edSpanLoss->Text.c_str()); } } //--------------------------------------------------------------------------- void __fastcall TCost_F::edCAPAKeyPress(TObject *Sender, char &Key) { if(Key==VK_RETURN){ if(edCAPA->Text=="")return; CAPA=atof(edCAPA->Text.c_str()); } } //--------------------------------------------------------------------------- void __fastcall TCost_F::edMachineCountKeyPress(TObject *Sender, char &Key) { if(Key==VK_RETURN){ if(edMachineCount->Text=="")return; MachineCount=atof(edMachineCount->Text.c_str()); } } //--------------------------------------------------------------------------- void __fastcall TCost_F::cedCMT_MachineKeyPress(TObject *Sender, char &Key) { if(Key==VK_RETURN){ if(cedCMT_Machine->Text=="")return; CMT_Machine=atof(cedCMT_Machine->Text.c_str()); } } //--------------------------------------------------------------------------- void __fastcall TCost_F::edRawMarginKeyPress(TObject *Sender, char &Key) { if(Key==VK_RETURN){ if(edRawMargin->Text=="")return; RawMargin=atof(edRawMargin->Text.c_str()); } } //--------------------------------------------------------------------------- void __fastcall TCost_F::edTreatLossKeyPress(TObject *Sender, char &Key) { if(Key==VK_RETURN){ if(edTreatLoss->Text=="")return; TreatLoss=atof(edTreatLoss->Text.c_str()); } } //--------------------------------------------------------------------------- void __fastcall TCost_F::edTreatMarginKeyPress(TObject *Sender, char &Key) { if(Key==VK_RETURN){ if(edTreatMargin->Text=="")return; TreatMargin=atof(edTreatMargin->Text.c_str()); } } //--------------------------------------------------------------------------- void __fastcall TCost_F::edPolyTreatLossKeyPress(TObject *Sender, char &Key) { if(Key==VK_RETURN){ if(edPolyTreatLoss->Text=="")return; PolyTreatLoss=atof(edPolyTreatLoss->Text.c_str()); } } //--------------------------------------------------------------------------- void __fastcall TCost_F::edNylonTreatLossKeyPress(TObject *Sender, char &Key) { if(Key==VK_RETURN){ if(edNylonTreatLoss->Text=="")return; NylonTreatLoss=atof(edNylonTreatLoss->Text.c_str()); } } //--------------------------------------------------------------------------- void __fastcall TCost_F::edSpanTreatLossKeyPress(TObject *Sender, char &Key) { if(Key==VK_RETURN){ if(edSpanTreatLoss->Text=="")return; SpanTreatLoss=atof(edSpanTreatLoss->Text.c_str()); } } //--------------------------------------------------------------------------- void __fastcall TCost_F::edWorkDayKeyPress(TObject *Sender, char &Key) { if(Key==VK_RETURN){ if(edWorkDay->Text=="")return; work_day_month=atof(edWorkDay->Text.c_str()); } } //--------------------------------------------------------------------------- void __fastcall TCost_F::edRawLossKeyPress(TObject *Sender, char &Key) { if(Key==VK_RETURN){ if(edRawLoss->Text=="")return; RawLoss=atof(edRawLoss->Text.c_str()); } } //--------------------------------------------------------------------------- void __fastcall TCost_F::cedTreatCostKeyPress(TObject *Sender, char &Key) { if(Key==VK_RETURN){ if(cedTreatCost->Text=="")return; TreatCost=atof(cedTreatCost->Text.c_str()); } } //---------------------------------------------------------------------------