UnicodeString encoding_html(UnicodeString str) { str = StringReplace(str, "&", "&", TReplaceFlags() << rfReplaceAll); str = StringReplace(str, "<", "<", TReplaceFlags() << rfReplaceAll); str = StringReplace(str, ">", ">", TReplaceFlags() << rfReplaceAll); str = StringReplace(str, "\r\n", "\n", TReplaceFlags() << rfReplaceAll); str = StringReplace(str, "\r", "", TReplaceFlags() << rfReplaceAll); return str; }
void __fastcall TForm4::Button1Click(TObject *Sender) { AnsiString a_s = Form4->ADOQuery1->FieldByName("applicant_surname")->AsString; AnsiString a_n = Form4->ADOQuery1->FieldByName("applicant_name")->AsString; AnsiString a_p = Form4->ADOQuery1->FieldByName("applicant_patronymic")->AsString; AnsiString csac = Trim(Form4->ADOQuery1->FieldByName("call_specialized_academic_council")->AsString); //applicant_patronymic AnsiString res_send = a_s+a_n+a_p+csac+"_1.csv"; res_send = StringReplace(res_send, " ", "_", TReplaceFlags()<<rfReplaceAll<<rfIgnoreCase); Form4->SaveDialog1->FileName = res_send; Form4->SaveDialog1->Title = "Save As"; if(Form4->ItemsFiles->Lines->Count > 0) { if (Form4->SaveDialog1->Execute()) { Form4->ItemsFiles->Lines->SaveToFile(SaveDialog1->FileName); Form4->ItemsFiles->Modified = false; } } else { ShowMessage("Выберите диссертацию с таблицы!"); } }
void doc2txt::convertPro(AnsiString WordFile,AnsiString PathPutTxt) { TStringList* word=new TStringList; String filename = WordFile; Variant vVarApp,vVarDoc,vVarParagraphs,vVarParagraph; AnsiString resolution = ExtractFileExt(filename); AnsiString str = StringReplace( ExtractFileName(filename),resolution,"",TReplaceFlags()<< rfReplaceAll << rfIgnoreCase); try { vVarApp=CreateOleObject("Word.Application"); } catch(...) { MessageBox(0, "Не удачно получилось открыть Word", "Внимание", MB_OK); return; } vVarApp.OlePropertySet("Visible",false); vVarDoc = vVarApp.OlePropertyGet("Documents"); vVarDoc.OleProcedure("Open", StringToOleStr(filename)); vVarDoc = vVarDoc.OleFunction("Item",1); vVarDoc.OleProcedure("Activate"); String s = vVarDoc.OlePropertyGet("Content").OlePropertyGet("Text"); word->Add(s); word->SaveToFile( PathPutTxt + str +".txt" ); vVarApp.OleProcedure("Quit"); delete word; }
AnsiString _fastcall TSaveObj::GetOrderby() { //AnsiString tmp =FPrimaryKey[FPrimaryKey.Length-1]; AnsiString tmp =FPrimaryKey[0]; tmp = StringReplace(tmp, ';', ',', TReplaceFlags()<<rfReplaceAll); return tmp+" asc"; }
//--------------------------------------------------------------------------- AnsiString __fastcall TFormReport::DateReplace(AnsiString str) { AnsiString result = str; result = StringReplace(result, "[DateStart]", DateToStr(DateStart->Date), TReplaceFlags() <<rfReplaceAll<< rfIgnoreCase); result = StringReplace(result, "[DateEnd]", DateToStr(DateEnd->Date), TReplaceFlags() <<rfReplaceAll<< rfIgnoreCase); AnsiString s = ""; result = StringReplace(result, "[Pokupatel]", (id_partner > 0) ? " and id_partner="+IntToStr(id_partner) : s, TReplaceFlags() <<rfReplaceAll<< rfIgnoreCase); result = StringReplace(result, "[Grupa]", (id_group > 0) ? " and id_group="+IntToStr(id_group) : s, TReplaceFlags() <<rfReplaceAll<< rfIgnoreCase); return result; }
void LoadLocalization(TMemIniFile *localization_file, String language) { TResourceStream *localization_resource = NULL; TStringList *localization_strings = NULL; TMemIniFile *default_localization_file = NULL; TStringList *sections = NULL; TStringList *keys = NULL; try { // Loading defaul localization form application resources. localization_resource = new TResourceStream((unsigned int)Instance, "en_lang", (System::WideChar*)RT_RCDATA); localization_strings = new TStringList(); localization_strings->LoadFromStream(localization_resource); default_localization_file = new TMemIniFile(""); default_localization_file->SetStrings(localization_strings); sections = new TStringList(); keys = new TStringList(); String key = "", value = ""; default_localization_file->ReadSections(sections); l18n.empty(); for (int i = 0; i < sections->Count; i++) { if (!sections->Strings[i].IsEmpty()) { default_localization_file->ReadSection(sections->Strings[i], keys); for (int j = 0; j < keys->Count; j++) { key = keys->Strings[j]; if (!key.IsEmpty()) { if (language != "en" && localization_file->ValueExists(sections->Strings[i], key)) { value = localization_file->ReadString(sections->Strings[i], key, ""); } else { value = default_localization_file->ReadString(sections->Strings[i], key, ""); } value = StringReplace(value, "\\n", "\n", TReplaceFlags() << rfReplaceAll); l18n.insert(MapList::value_type(key, value)); } } } } } catch(Exception *E) { if (localization_resource) { delete localization_resource; } if (localization_strings) { delete localization_strings; } if (default_localization_file) { delete localization_file; } if (sections) { delete sections; } if (keys) { delete keys; } } }
String GetEscapedValue(String value) { value = StringReplace(value, "\\", "\\\\", TReplaceFlags() << rfReplaceAll); value = StringReplace(value, "\"", "\\\"", TReplaceFlags() << rfReplaceAll); value = StringReplace(value, "/", "\\/", TReplaceFlags() << rfReplaceAll); value = StringReplace(value, "\r", "\\r", TReplaceFlags() << rfReplaceAll); value = StringReplace(value, "\n", "\\n", TReplaceFlags() << rfReplaceAll); value = StringReplace(value, "\b", "\\b", TReplaceFlags() << rfReplaceAll); value = StringReplace(value, "\f", "\\f", TReplaceFlags() << rfReplaceAll); value = StringReplace(value, "\t", "\\t", TReplaceFlags() << rfReplaceAll); return value; }
//--------------------------------------------------------------------------- WideString ParseCode(const WideString wsInput) { /* * translate & to &, > to >, and so on */ std::map <WideString, WideString>::iterator Iter; WideString result(wsInput); for (Iter = mCode.begin(); Iter != mCode.end(); ++Iter) { result = WideStringReplace(result, Iter->first, Iter->second, TReplaceFlags() << rfReplaceAll); } return result; }
void __fastcall TForm1::StringToRegion(String AString, String &Guid,int &Major, int &Minor) { AString = StringReplace(AString,";"," ", TReplaceFlags() << rfReplaceAll); TStringList *LSplitted; LSplitted = new TStringList; try { LSplitted->DelimitedText = AString; Guid = LSplitted->Strings[0]; Major = StrToInt(LSplitted->Strings[1]); Minor = StrToInt(LSplitted->Strings[2]); } __finally { LSplitted->Free(); } };
//--------------------------------------------------------------------------- __fastcall TForm2::TForm2(TComponent* Owner) : TForm(Owner) { /* //バージョン情報取得 pAppInfoString->Comments; pAppInfoString->InternalName; pAppInfoString->ProductName; pAppInfoString->CompanyName; pAppInfoString->LegalCopyright; pAppInfoString->ProductVersion; pAppInfoString->FileDescription; pAppInfoString->LegalTrademarks; pAppInfoString->PrivateBuild; pAppInfoString->FileVersion; pAppInfoString->OriginalFilename; pAppInfoString->SpecialBuild; */ TGetAppInfoString *pAppInfoString = new TGetAppInfoString(); //アプリケーション名 lblAppName->Caption = pAppInfoString->ProductName; //バージョン情報 lblVersion->Caption = "ver."+ pAppInfoString->FileVersion; //zlibバージョン String ZlibVersion = ZLIB_VERSION; lblZlibVersion->Caption = "(zlib ver."+ ZlibVersion + ")"; //著作権表示 lblCopyright->Caption = StringReplace(pAppInfoString->LegalCopyright, ",", ",\n", TReplaceFlags()<<rfReplaceAll); //サイト表示 lblHomePage->Caption = pAppInfoString->CompanyName; delete pAppInfoString; }
//hides Form2 from view when this form is shown, sets up form for certain input level void __fastcall TForm3::FormShow(TObject *Sender) { //hide welcome form Form2->Hide(); //set alreadyThere boolean to false alreadyThere = false; //get the current date in case accessLevel is 0 TDateTime d = Now(); pureDate = d; dateChosen = d.FormatString(L"yyyy-mm-dd"); if (Form1->getAccessLevel() == 0) { //get the hotelID and query hotel_ref to find out which table to input to and which table to read from chooseDateImageButton->Visible = false; datePopupBoxLabel->Visible = false; calendar->Visible = false; String currentHotelID = Form1->getHotelID(); inputTable = ""; readTable = ""; laborTable = ""; overtimePerHour = 0; SQLQuery2->SQL->Text = "SELECT input_table, read_table, labor_table, Overtime_Per_Hour FROM hotel_ref WHERE hotelID = '"+currentHotelID+"';"; SQLQuery2->Open(); SQLQuery2->First(); if (!SQLQuery2->Eof) { inputTable = SQLQuery2->Fields->Fields[0]->AsString; readTable = SQLQuery2->Fields->Fields[1]->AsString; laborTable = SQLQuery2->Fields->Fields[2]->AsString; overtimePerHour = SQLQuery2->Fields->Fields[3]->AsFloat; } //show user input screen based on input level (i.e. default or advanced) if (Form1->getInputLevel() == 0) { //input level is "default", query db schema SQLQuery2->SQL->Text = "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'baldwins_hotel_data' AND TABLE_NAME = '"+inputTable+"';"; //open query and temporarily skip first two column headings SQLQuery2->Open(); SQLQuery2->First(); SQLQuery2->Next(); SQLQuery2->Next(); //strings used in if for holdling column headings String originalHeading = ""; String editedHeading = ""; //set label to represent first editable column heading if(!SQLQuery2->Eof) { //get initial column heading without formatting (i.e. removing "_") originalHeading = SQLQuery2->Fields->Fields[0]->AsString; //replace underscores with spaces and set label editedHeading = StringReplace(originalHeading, "_", " ", TReplaceFlags() << rfReplaceAll); dbFieldLabel->Text = editedHeading; inputLabelImage->Visible=true; dbFieldLabel->Visible = true; dbFieldEdit->Visible = true; dbFieldEdit->Text = ""; nextImageButton->Visible = true; //initially set index and size to zero inputObject.currentIndex = 0; inputObject.size = 0; } } //input level is "advanced" for when userAccess == 0 else { //hide form items dbFieldLabel->Visible = false; dbFieldEdit->Visible = false; nextImageButton->Visible = false; SQLQuery2->SQL->Text = "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'baldwins_hotel_data' AND TABLE_NAME = '"+inputTable+"';"; //open query and temporarily skip first two column headings SQLQuery2->Open(); SQLQuery2->First(); SQLQuery2->Next(); SQLQuery2->Next(); int count = 0; //strings used in if for holdling column headings String originalHeading = ""; String editedHeading = ""; while (!SQLQuery2->Eof) { //get initial column heading without formatting (i.e. removing "_") originalHeading = SQLQuery2->Fields->Fields[0]->AsString; //replace underscores with spaces and set label editedHeading = StringReplace(originalHeading, "_", " ", TReplaceFlags() << rfReplaceAll); //show and populate displayGrid displayGrid->Cells[0][count] = editedHeading; displayGrid->Cells[1][count] = ""; ++count; SQLQuery2->Next(); } displayGrid->RowCount = count; Image3->Visible=false; inputLabelImage->Visible=false; displayGrid->Visible = true; submitButton->Visible = true; Image1->Visible=true; } } else { //accessLevel is not 0, show date picker before progressing //hide uneccessary items from this page dbFieldLabel->Visible = false; dbFieldEdit->Visible = false; nextImageButton->Visible = false; //get today's date TDateTime d = Now(); pureDate = d; dateChosen = d.FormatString(L"yyyy-mm-dd"); chooseDateImageButton->Visible = true; datePopupBoxLabel->Visible = true; calendar->Visible = true; } }
//=========================================================================== // ヘッダ情報を生成する //=========================================================================== bool __fastcall TAttacheCaseFileEncrypt::CreateHeaderData (TMemoryStream *pms, TStringList *FileList, TStringList *FilePathList, __int64 &AllTotalFileSize) { int i, c; int ret; int Index = 0; int HeaderSizeAddress = 0; TSearchRec sr; String OneLine; String DirPath, FileName; String MsgText; //暗号部トークン const AnsiString Passcode_AttacheCase = "Passcode:AttacheCase\n"; //暗号化ファイルの作成日 AnsiString LastDateTimeString = "LastDateTime:" + DateTimeToStr(Now()) + "\n"; //旧ヘッダーテキストすべて AnsiString Fn_HeaderText; //Unicode用ヘッダーテキストすべて String U_HeaderText; int EncryptHeaderSize = 0; //暗号部ヘッダサイズ char buffer[BUF_SIZE]; char chain_buffer[BUF_SIZE]; TStringList *HeaderDataList; TMemoryStream* tpms; //テンポラリメモリストリーム //----------------------------------- // ヘッダ情報(平文) //----------------------------------- const char charReservedValue[4] = { 0, 0, 0, 0 }; const char charDataSubVersion = ATC_DATA_SUB_VERSION; const char charOptMissTypeLimitsNumOption = intOptMissTypeLimitsNumOption; const char charOptBrokenFileOption = (fOptBrokenFileOption > 0 ? 1 : 0); const char charTokenString[17] = "_AttacheCaseData"; const int DataFileVersion = ATC_DATA_FILE_VERSION; const int AlgorismType = TYPE_ALGORISM_RIJNDAEL; //データサブバージョン : 1byte pms->Write(&charDataSubVersion, sizeof(char)); //予約データ(reserved) : 1byte pms->Write(&charReservedValue, sizeof(char)); //ミスタイプ回数 : 1byte pms->Write(&charOptMissTypeLimitsNumOption, sizeof(char)); //破壊するか否か : 1byte pms->Write(&charOptBrokenFileOption, sizeof(char)); //トークン : 16byte pms->Write(&charTokenString, 16); //データファイルバージョン : 4byte pms->Write(&DataFileVersion, sizeof(int)); //アルゴリズムタイプ : 4byte pms->Write(&AlgorismType, sizeof(int)); //暗号化部分のヘッダデータサイズ(先に確保しておく):4byte HeaderSizeAddress = pms->Position; pms->Write(&EncryptHeaderSize, sizeof(int)); //----------------------------------- // ヘッダ情報(暗号化部分) //----------------------------------- //進捗状況表示 ProgressPercentNum = -1; //'暗号化するファイルリストの生成中...' ProgressStatusText = LoadResourceString(&Msgencrypt::_LABEL_STATUS_TITLE_LISTING); //ヘッダデータリスト(文字列) HeaderDataList = new TStringList; //パスワード HeaderDataList->Add(Passcode_AttacheCase); //作成日 HeaderDataList->Add(LastDateTimeString); for ( i = 0; i < FileList->Count; i++ ){ //ファイル if (FileExists(FileList->Strings[i]) == true) { DirPath = ExtractFileDir(FileList->Strings[i]); FileName = ExtractFileName(FileList->Strings[i]); ProgressMsgText = FileName; //処理中のファイル名 AllTotalFileSize += GetFileInfoList(Index, DirPath, FileName, FileList->Strings[i], FilePathList, HeaderDataList); } //ディレクトリ else{ DirPath = ExtractFileDir(FileList->Strings[i]); FileName = ExtractFileName(FileList->Strings[i]); ProgressMsgText = FileName; //処理中のファイル名 //トップディレクトリ GetFileInfoList(Index, DirPath, FileName, FileList->Strings[i], FilePathList, HeaderDataList); //その配下 AllTotalFileSize += GetFileInfoList(Index, FileList->Strings[i], "", FileList->Strings[i], FilePathList, HeaderDataList); } //ユーザーキャンセル if (Terminated == true) { delete HeaderDataList; return(false); } }// end for; //進捗状況表示 ProgressPercentNum = -1; //'ヘッダデータを書き込んでいます...' ProgressStatusText = LoadResourceString(&Msgencrypt::_LABEL_STATUS_TITLE_ENCRYPTING_LIST); ProgressMsgText = ""; //メモリストリームへ書き込み tpms = new TMemoryStream; //------------------------------------------------ // 暗号化時にヘッダデータの互換性維持 //--------------------------------------------------- HeaderDataList->SaveToStream(tpms, TEncoding::GetEncoding(932)); //新バージョン(ver.2.8.0~)用(UTF-8)に保存 for (i = 0; i < HeaderDataList->Count; i++) { HeaderDataList->Strings[i] = StringReplace(HeaderDataList->Strings[i],"Fn_","U_",TReplaceFlags()<<rfIgnoreCase ); } HeaderDataList->SaveToStream(tpms, TEncoding::UTF8); delete HeaderDataList; //----------------------------------- //ヘッダ情報の暗号化 //----------------------------------- //暗号化の準備 gentables(); //キー入力 gkey( 8, 8, key); for (i = 0; i < BUF_SIZE; i++) { buffer[i] = 0; } //初期化ベクトル(IV)を生成 fillrand(chain_buffer, BUF_SIZE); pms->Write(chain_buffer, BUF_SIZE); //先頭にポインタを戻す tpms->Seek((__int64)0, TSeekOrigin::soBeginning); EncryptHeaderSize = 0; //CBCモードで書き込む while (tpms->Read( buffer, BUF_SIZE ) != NULL){ EncryptHeaderSize += BUF_SIZE; // xor for ( i = 0; i < BUF_SIZE; i++ ){ buffer[i] ^= chain_buffer[i]; } // rijndael rijndael_encrypt(buffer); pms->Write(buffer, BUF_SIZE); //CBC&バッファの初期化 for ( i = 0; i < BUF_SIZE; i++ ){ chain_buffer[i] = buffer[i]; buffer[i] = 0; } //ユーザーキャンセル if (Terminated == true) { delete tpms; return(false); } }//loop; delete tpms; //暗号化部分のヘッダデータサイズ(確保しておいた場所へ改めて書き込む) pms->Position = HeaderSizeAddress; pms->Write(&EncryptHeaderSize, sizeof(int)); //先頭にポインタを戻す pms->Seek((__int64)0, TSeekOrigin::soBeginning); return(true); }//end CreateHeaderData;
} //--------------------------------------------------------------------------- void __fastcall TFrBlockProduceCost::RzToolButton1Click(TObject *Sender) { if (PeriodBox->ItemIndex == -1) { ShowMessage("Для сохранения цены блока необходимо выбрать период."); PeriodBox->SetFocus(); return; } float c = StrToFloat(CostBlockEd->Text); if (c == 0 && BaseCheck->Checked == true) { ShowMessage("Нельзя сохранить базовую стоимость БЛОКА без указания его базовой стоимости!"); CostBlockEd->SetFocus(); CostBlockEd->SelectAll(); return; } if ((FrBlockProduceAddEd->CostQuer->RecordCount == 0 && BaseCheck->Checked != true && ActivCheck->Checked != true) || (FrBlockProduceAddEd->CostQuer->RecordCount == 0 && BaseCheck->Checked != true && ActivCheck->Checked == true)) { ShowMessage("Сначала требуется создать АКТУАЛЬНУЮ БАЗОВУЮ стоимость блока, прежде чем создавать СОСТАВНУЮ!"); return; } if (flreg == "N") //Эту проверку следует переделать??? { FrBlockProduceAddEd->CostQuer->First(); while (!FrBlockProduceAddEd->CostQuer->Eof) { String v1 = TrimRight(TrimLeft(FrBlockProduceAddEd->CostQuerCycle->Value)); String v2 = TrimRight(TrimLeft(PeriodBox->Text)); for (int i = 0; i < v1.Length(); ++i) v1 = v1.LowerCase(); for (int i = 0; i < v2.Length(); ++i) v2 = v2.LowerCase(); if (v1 == v2) { String Caption = "Ошибка при записи стоимости блока!"; String Text = "Такое значение: ''" + PeriodBox->Text + "'' периодичности стоимости блока уже существует!"; Application->MessageBox(Text.w_str(), Caption.w_str(), MB_ICONHAND | MB_OK); return; } FrBlockProduceAddEd->CostQuer->Next(); } } String bc = ""; if (BaseCheck->Checked == true) {bc = "1";} //установлен признак "Базовая стоимость блока if (BaseCheck->Checked != true) {bc = "0";} // снят признак "Базовая стоимость блока String ac = ""; if (ActivCheck->Checked == true) {ac = "1";} //установлен признак "Активная стоимость блока if (ActivCheck->Checked != true) {ac = "0";} // снят признак "Активная стоимость блока if (flreg == "N") { String q1 = "BEGIN TRY " "BEGIN TRANSACTION; " "DECLARE @BlockId AS int " " SET @BlockId = " + IntToStr(FrBlockProduce->BlockQueridn->Value) + " " "DECLARE @CycleId AS int " " SET @CycleId = " + IntToStr(Cid) + " " "DECLARE @Cost AS money " " SET @Cost = " + StringReplace(CostBlockEd->Text, ",", ".", TReplaceFlags()<<rfReplaceAll) + " " "DECLARE @Disc AS int " " SET @Disc = " + DiscountEd->IntValue + " " "DECLARE @CostWD AS money " " SET @CostWD = " + StringReplace(WithDiscEd->Text, ",", ".", TReplaceFlags()<<rfReplaceAll) + " " "DECLARE @BaseCost AS bit " " SET @BaseCost = " + bc + " " "DECLARE @Description AS nvarchar(255) " " SET @Description = '" + DescMemo->Text + "' " "DECLARE @Dept AS int " " SET @Dept = " + chcbKanalSale->Value + " " "DECLARE @IdIns AS int " " SET @IdIns = " + IntToStr(PermisHdr.KeyUserStartProgramm) + " " "DECLARE @DateDel AS datetime " " SET @DateDel = NULL " "DECLARE @IdDel AS int " " SET @IdDel = NULL " "DECLARE @Active AS bit " " SET @Active = " + ac + " " "INSERT INTO [dbo].[ProduceBlockCost] " "VALUES(@BlockId, @CycleId, @Cost, @Disc, @CostWD, @BaseCost, @Description, @Dept, GETDATE(), @IdIns, " " NULL, NULL, @DateDel, @IdDel, @Active) " "COMMIT TRANSACTION; " "END TRY " "BEGIN CATCH " " ROLLBACK TRANSACTION; " " PRINT 'Error transaction!'; " "END CATCH;"; CostComm->CommandText = q1; CostComm->Execute(); FrBlockProduceAddEd->QCost(); ShowMessage("Новые стоимость блока и период успешно добавлены!"); } if (flreg == "E") { String q1 = "BEGIN TRY " "BEGIN TRANSACTION; " "DECLARE @CycleId AS int " " SET @CycleId = " + IntToStr(Cid) + " " "DECLARE @Cost AS money " " SET @Cost = " + StringReplace(CostBlockEd->Text, ",", ".", TReplaceFlags()<<rfReplaceAll) + " " "DECLARE @Disc AS int " " SET @Disc = " + DiscountEd->IntValue + " " "DECLARE @CostWD AS money " " SET @CostWD = " + StringReplace(WithDiscEd->Text, ",", ".", TReplaceFlags()<<rfReplaceAll) + " " "DECLARE @BaseCost AS bit " " SET @BaseCost = " + bc + " " "DECLARE @Description AS nvarchar(255) " " SET @Description = '" + DescMemo->Text + "' " "DECLARE @Dept AS int " " SET @Dept = " + chcbKanalSale->Value + " " "DECLARE @DateEdit AS datetime " " SET @DateEdit = GETDATE() " "DECLARE @IdEdit AS int " " SET @IdEdit = " + IntToStr(PermisHdr.KeyUserStartProgramm) + " " "DECLARE @Active AS bit " " SET @Active = " + ac + " " " UPDATE [dbo].[ProduceBlockCost] " " SET CycleId = @CycleId, Cost = @Cost, Discount = @Disc, CostWitnDiscount = @CostWD, BaseCost = @BaseCost, " " Description = @Description, Dept = @Dept, DateEdit = @DateEdit, IdEdit = @IdEdit, Active = @Active " " WHERE idn = " + IntToStr(FrBlockProduceAddEd->CostQueridn->Value) + " " "COMMIT TRANSACTION; " "END TRY " "BEGIN CATCH " " ROLLBACK TRANSACTION; " " PRINT 'Error transaction!'; " "END CATCH;"; CostComm->CommandText = q1; CostComm->Execute(); FrBlockProduceAddEd->QCost(); ShowMessage("Стоимость блока успешно изменена!"); }
bool keyHistory::testCombo(String c) const { String combo = StringReplace( StringReplace(c," ","",TReplaceFlags()<<rfReplaceAll<<rfIgnoreCase), ".","*",TReplaceFlags()<<rfReplaceAll<<rfIgnoreCase); int _keys [16]; memset(_keys,0,16); int lastkey = 0; TStringList * dcomp = new TStringList(); dcomp->Delimiter = '-'; dcomp->DelimitedText = combo; uint maxLen = StrToInt(dcomp->Strings[0]); combo = dcomp->Strings[1]; bool mode = 0; if (index>8) { int a=2; a = 2+2+a; } for (int i=0; i<combo.Length(); i++) { if (combo.c_str()[i] == '!') { mode = 1; continue; } else if (i!=0) if (combo.c_str()[i-1] != '!') mode = 0; _keys[lastkey] = mode?KEY_UP:KEY_DOWN; if (combo.c_str()[i] == '>') _keys[lastkey] += VK_RIGHT; else if (combo.c_str()[i] == '<') _keys[lastkey] += VK_LEFT; else if (combo.c_str()[i] == '^') _keys[lastkey] += VK_UP; else if (combo.c_str()[i] == '*') _keys[lastkey] += VK_DOWN; else _keys[lastkey] += combo.c_str()[i]; lastkey++; } bool comboFound = false; for (int ki = 0; ki<KH_BUFFER_SIZE+1-lastkey; ki++) { if (getSKey(ki) == 0) break; for (int ci=0; ci<lastkey;ci++) { if (getSKey(ki+ci) != _keys[ci]) { comboFound = false; break; } else if ((ci == lastkey-1) && (getSKey(ki+ci) == _keys[ci])) { if ((keyTime[ki+ci] - keyTime[ki]) < maxLen) if (::GetTickCount()-keyTime[ki+ci] < 1000) { comboFound = true; break; } } } if (comboFound) { int a=2+1; a = a+2; break; } } return comboFound; }
void __fastcall TForm4::Button3Click(TObject *Sender) { AnsiString r_tt_name, applicant_surname, applicant_name, applicant_patronymic, job_seeker, name_institutions_job, thesis_theme, r_fs_name, r_cns_name, call_specialized_academic_council, name_institutions_protect, address_institutions_protected, phone_institutions_protected, supervisor, oficial, adopted, web_result; Form4->ItemsFiles->Lines->Clear(); r_tt_name = "Здобуття наукового ступеня;"; r_tt_name += Form4->ADOQuery1->FieldByName("tt_name")->AsString+";"; applicant_surname = "Прізвище здобувача;"; applicant_surname += Form4->ADOQuery1->FieldByName("applicant_surname")->AsString+";"; applicant_name = "Ім’я здобувача;"; applicant_name += Form4->ADOQuery1->FieldByName("applicant_name")->AsString+";"; applicant_patronymic = "По батькові здобувача;"; applicant_patronymic += Form4->ADOQuery1->FieldByName("applicant_patronymic")->AsString+";"; job_seeker = "Посада здобувача;"; job_seeker += Form4->ADOQuery1->FieldByName("job_seeker")->AsString+";"; //Найменування установи, в якій працює здобувач name_institutions_job = "Найменування установи, в якій працює здобувач;"; name_institutions_job += "\""+Trim(Form4->ADOQuery1->FieldByName("name_institutions_job")->AsString)+"\";"; // Тема дисертації thesis_theme = "Тема дисертації;"; thesis_theme += Form4->ADOQuery1->FieldByName("thesis_theme")->AsString+";"; // Шифр і назва наукової спеціальності r_cns_name = "Шифр і назва наукової спеціальності;"; r_cns_name += "\""+Form4->ADOQuery1->FieldByName("name")->AsString+"\";"; // Прийнято дисертацію до захисту adopted = "Прийнято дисертацію до захисту;"; adopted += Form4->ADOQuery1->FieldByName("date_adopted")->AsString+" протокол № "+"\""+Trim(Form4->ADOQuery1->FieldByName("number_protocol_adopted")->AsString)+"\""+";"; // Галузь науки r_fs_name = "Галузь науки;"; r_fs_name += Form4->ADOQuery1->FieldByName("fs_name")->AsString+";"; // Шифр спеціалізованої вченої ради call_specialized_academic_council = "Шифр спеціалізованої вченої ради;"; call_specialized_academic_council += "\""+Trim(Form4->ADOQuery1->FieldByName("call_specialized_academic_council")->AsString)+"\";"; // Найменування установи, в якій відбудеться захист name_institutions_protect = "Найменування установи, в якій відбудеться захист;"; name_institutions_protect += "\""+Trim(Form4->ADOQuery1->FieldByName("name_institutions_protect")->AsString)+"\";"; // Адреса установи, в якій відбудеться захист address_institutions_protected = "Адреса установи, в якій відбудеться захист;"; address_institutions_protected += "\""+Trim(Form4->ADOQuery1->FieldByName("address_institutions_protected")->AsString)+"\";"; // Телефон установи, в якій відбудеться захист phone_institutions_protected = "Телефон установи, в якій відбудеться захист;"; phone_institutions_protected += Form4->ADOQuery1->FieldByName("phone_institutions_protected")->AsString+";"; // Науковий керівник (консультатнт) supervisor = "Науковий керівник (консультатнт);"; supervisor += "\""+Trim(Form4->ADOQuery1->FieldByName("supervisor")->AsString)+"\";"; // Офіційні опоненти oficial = "Офіційні опоненти;"; oficial += "\""+Trim(Form4->ADOQuery1->FieldByName("oficial")->AsString)+"\";"; // set listin by memo1 Form4->ItemsFiles->Lines->Add( r_tt_name ); Form4->ItemsFiles->Lines->Add( applicant_surname ); Form4->ItemsFiles->Lines->Add( applicant_name ); Form4->ItemsFiles->Lines->Add( applicant_patronymic ); Form4->ItemsFiles->Lines->Add( job_seeker ); Form4->ItemsFiles->Lines->Add( name_institutions_job ); Form4->ItemsFiles->Lines->Add( thesis_theme ); Form4->ItemsFiles->Lines->Add( r_cns_name ); Form4->ItemsFiles->Lines->Add( adopted ); Form4->ItemsFiles->Lines->Add( r_fs_name ); Form4->ItemsFiles->Lines->Add( call_specialized_academic_council ); Form4->ItemsFiles->Lines->Add( name_institutions_protect ); Form4->ItemsFiles->Lines->Add( address_institutions_protected ); Form4->ItemsFiles->Lines->Add( phone_institutions_protected ); Form4->ItemsFiles->Lines->Add( supervisor ); Form4->ItemsFiles->Lines->Add( oficial ); // nij = StringReplace(nij, ";", "", TReplaceFlags()<<rfReplaceAll<<rfIgnoreCase); //ItemsFilesWeb web_result = ""; web_result += Form4->ADOQuery1->FieldByName("type_this")->AsString+";"; // 0 (int) web_result += Form4->ADOQuery1->FieldByName("applicant_surname")->AsString+";"; // 1 web_result += Form4->ADOQuery1->FieldByName("applicant_name")->AsString+";"; // 2 web_result += Form4->ADOQuery1->FieldByName("applicant_patronymic")->AsString+";"; // 3 web_result += Form4->ADOQuery1->FieldByName("job_seeker")->AsString+";"; // 4 web_result += Form4->ADOQuery1->FieldByName("name_institutions_job")->AsString+";"; // 5 web_result += Form4->ADOQuery1->FieldByName("thesis_theme")->AsString+";"; // 6 web_result += Form4->ADOQuery1->FieldByName("code_name_specialty")->AsString+";"; // 7 (int) web_result += Form4->ADOQuery1->FieldByName("field_science")->AsString+";"; // 8 (int) web_result += Form4->ADOQuery1->FieldByName("call_specialized_academic_council")->AsString+";"; // 9 web_result += Form4->ADOQuery1->FieldByName("name_institutions_protect")->AsString+";"; // 10 web_result += Form4->ADOQuery1->FieldByName("address_institutions_protected")->AsString+";"; // 11 web_result += Form4->ADOQuery1->FieldByName("phone_institutions_protected")->AsString+";"; // 12 web_result += Form4->ADOQuery1->FieldByName("supervisor")->AsString+";"; // 13 web_result += Form4->ADOQuery1->FieldByName("oficial")->AsString+";"; // 14 web_result += Form4->ADOQuery1->FieldByName("date_adopted")->AsString+";"; // 15 web_result += Form4->ADOQuery1->FieldByName("number_protocol_adopted")->AsString+";"; // 16 web_result += Form4->ADOQuery1->FieldByName("data_publications")->AsString+";"; // 17 web_result = StringReplace(web_result, "\n", "<br />", TReplaceFlags()<<rfReplaceAll<<rfIgnoreCase); Form4->ItemsFilesWeb->Lines->Add( web_result ); // show button Form4->Button1->Visible = true; Form4->Button2->Visible = true; }
void __fastcall TfrmMachineParam::m_dLamHeightDblClick(TObject *Sender) { //pEdit->Tag X=0, Y=1, Lane Changer=2, Front Lifter=3, Rear Lifter=4 TEdit *pEdit=(TEdit *)Sender; TfrmMotorCheck *pMotorCheckDlg; AnsiString strCap = ""; if (pEdit->Tag == 0) { strCap = "X"; if (!g_DIO.ReadDIBit(DI::LoadCellDown)) { Application->MessageBoxA("請確認LoadCell是否在上位!!", "Confirm", MB_OK); return; } } else if (pEdit->Tag == 1) { strCap = "Y"; if (!g_DIO.ReadDIBit(DI::LoadCellDown)) { Application->MessageBoxA("請確認LoadCell是否在上位!!", "Confirm", MB_OK); return; } } else if (pEdit->Tag == 2) strCap = "Lane Changer"; else if (pEdit->Tag == 4) { strCap = "Front Lifter"; if (!g_DIO.ReadDIBit(DI::YAxisSafePosA) || !g_DIO.ReadDIBit(DI::YAxisSafePosB)) { Application->MessageBoxA("請確認LoadCell是否在安全位置!!", "Confirm", MB_OK); return; } } else if (pEdit->Tag == 5) { strCap = "Rear Lifter"; if (!g_DIO.ReadDIBit(DI::YAxisSafePosA) || !g_DIO.ReadDIBit(DI::YAxisSafePosB)) { Application->MessageBoxA("請確認LoadCell是否在安全位置!!", "Confirm", MB_OK); return; } } else strCap = "Error!"; pMotorCheckDlg=new TfrmMotorCheck(this); pMotorCheckDlg->m_nActiveAxis=pEdit->Tag; pMotorCheckDlg->Caption=strCap; AnsiString sPath = g_IniFile.m_strApplicationPath; sPath = StringReplace(sPath, "\\exe\\", "", TReplaceFlags()); if (pMotorCheckDlg->m_nActiveAxis == 0) { pMotorCheckDlg->btnFWD->Glyph->LoadFromFile(sPath + "\\bmp\\right.bmp"); pMotorCheckDlg->btnRWD->Glyph->LoadFromFile(sPath + "\\bmp\\left.bmp"); } else if (pMotorCheckDlg->m_nActiveAxis == 4 || pMotorCheckDlg->m_nActiveAxis == 5) { pMotorCheckDlg->btnRWD->Glyph->LoadFromFile(sPath + "\\bmp\\down.bmp"); pMotorCheckDlg->btnFWD->Glyph->LoadFromFile(sPath + "\\bmp\\up.bmp"); } if(pMotorCheckDlg->ShowModal()==mrOk) { TEdit *pEdit2=(TEdit *)FindComponent(pEdit->Hint); if(pEdit2) pEdit2->Text=pMotorCheckDlg->m_dCurrPos; else ShowMessage("寫入失敗"); } delete pMotorCheckDlg; }
void __fastcall TForm1::createItemsClick(TObject *Sender) { AnsiString date_adopted; try { if(Application->MessageBox("Виконати?","Підтвердження!",MB_YESNO) == IDYES) { Form2->MON->Insert(); date_adopted = Form1->date_adopted->Text.c_str(); //Form2->MON->Fields->Fields[18]->Value = Form1->date_adopted->Text; Form2->MON->Fields->Fields[18]->Value = Form1->date_adopted->Text; // settings params type_thises = Form1->TypeThesis->ItemIndex; switch( type_thises ) { case 0: result = 1; break; case 1: result = 2; break; default: result = 1; break; } // settings fields Form2->MON->Fields->Fields[1]->Value = IntToStr( result ); Form2->MON->Fields->Fields[2]->Value = Form1->ApplicantSurname->Text; Form2->MON->Fields->Fields[3]->Value = Form1->ApplicantName->Text; Form2->MON->Fields->Fields[4]->Value = Form1->ApplicantPatronymic->Text; Form2->MON->Fields->Fields[5]->Value = Form1->JobSeeker->Text; nij = " "; Form2->MON->Fields->Fields[6]->Value = " "; if(Form1->NameInstitutionsJob->Lines->Count > 0) { for(int i = 0; i < Form1->NameInstitutionsJob->Lines->Count; i++) { nij += Form1->NameInstitutionsJob->Lines->Strings[ i ]+"\n"; } nij = StringReplace(nij, ";", "", TReplaceFlags()<<rfReplaceAll<<rfIgnoreCase); nij = StringReplace(nij, "\"", "'", TReplaceFlags()<<rfReplaceAll<<rfIgnoreCase); Form2->MON->Fields->Fields[6]->Value = nij; } Form2->MON->Fields->Fields[7]->Value = Form1->ThesisTheme->Text; if(IntToStr( Form1->CodeNameSpecialty->ItemIndex ) < 1 || IntToStr( Form1->FieldScience->ItemIndex ) < 1) { if(IntToStr( Form1->CodeNameSpecialty->ItemIndex ) < 1) { Application->MessageBox("Виберіть будь ласка дату 'Шифр і назва наукової спеціальності'!", "Помилка!", NULL); } if(IntToStr( Form1->FieldScience->ItemIndex ) < 1) { Application->MessageBox("Виберіть будь ласка 'Галузь науки'!", "Помилка!", NULL); } return; } Form2->MON->Fields->Fields[8]->Value = IntToStr( Form1->CodeNameSpecialty->ItemIndex ); Form2->MON->Fields->Fields[9]->Value = IntToStr( Form1->FieldScience->ItemIndex ); //csac csac = " "; Form2->MON->Fields->Fields[10]->Value = " "; if(Form1->CallSpecializedAcademicCouncil->Lines->Count > 0) { for(int i = 0; i < Form1->CallSpecializedAcademicCouncil->Lines->Count; i++) { csac += Form1->CallSpecializedAcademicCouncil->Lines->Strings[ i ]+"\n"; } csac = StringReplace(csac, ";", "", TReplaceFlags()<<rfReplaceAll<<rfIgnoreCase); csac = StringReplace(csac, "\"", "'", TReplaceFlags()<<rfReplaceAll<<rfIgnoreCase); Form2->MON->Fields->Fields[10]->Value = csac; } //nip nip = " "; Form2->MON->Fields->Fields[11]->Value = " "; if(Form1->NameInstitutionsProtect->Lines->Count > 0) { for(int i = 0; i < Form1->NameInstitutionsProtect->Lines->Count; i++) { nip += Form1->NameInstitutionsProtect->Lines->Strings[ i ]+"\n"; } nip = StringReplace(nip, ";", "", TReplaceFlags()<<rfReplaceAll<<rfIgnoreCase); nip = StringReplace(nip, "\"", "'", TReplaceFlags()<<rfReplaceAll<<rfIgnoreCase); Form2->MON->Fields->Fields[11]->Value = nip; } // aip aip = " "; Form2->MON->Fields->Fields[12]->Value = " "; if(Form1->AddressInstitutionsProtect->Lines->Count > 0) { for(int i = 0; i < Form1->AddressInstitutionsProtect->Lines->Count; i++) { aip += Form1->AddressInstitutionsProtect->Lines->Strings[ i ]+"\n"; } aip = StringReplace(aip, ";", "", TReplaceFlags()<<rfReplaceAll<<rfIgnoreCase); aip = StringReplace(aip, "\"", "'", TReplaceFlags()<<rfReplaceAll<<rfIgnoreCase); Form2->MON->Fields->Fields[12]->Value = aip; } Form2->MON->Fields->Fields[13]->Value = Form1->PhoneintitutionsProtect->Text; Form2->MON->Fields->Fields[14]->Value = Form1->Supervisor->Text; // of of = " "; Form2->MON->Fields->Fields[15]->Value = " "; if(Form1->Oficial->Lines->Count > 0) { for(int i = 0; i < Form1->Oficial->Lines->Count; i++) { of += Form1->Oficial->Lines->Strings[ i ]+"\n"; } of = StringReplace(of, ";", "", TReplaceFlags()<<rfReplaceAll<<rfIgnoreCase); of = StringReplace(of, "\"", "'", TReplaceFlags()<<rfReplaceAll<<rfIgnoreCase); Form2->MON->Fields->Fields[15]->Value = of; } Form2->MON->Fields->Fields[16]->Value = Form1->setDatePublication->Text; // npa npa = " "; Form2->MON->Fields->Fields[17]->Value = " "; if(Form1->number_protocol_adopted->Lines->Count > 0) { for(int i = 0; i < Form1->number_protocol_adopted->Lines->Count; i++) { npa += Form1->number_protocol_adopted->Lines->Strings[ i ]+"\n"; } npa = StringReplace(npa, ";", "", TReplaceFlags()<<rfReplaceAll<<rfIgnoreCase); npa = StringReplace(npa, "\"", "'", TReplaceFlags()<<rfReplaceAll<<rfIgnoreCase); Form2->MON->Fields->Fields[17]->Value = npa; } /* if(Form1->date_adopted->Text == "") { ShowMessage("Введіть будь ласка дату прийнятої дисертації!"); break; // return; } else { Form1->date_adopted->Text = ""; } */ // save DB Form2->MON->Post(); Form2->MON->Refresh(); // clear fields Form1->ApplicantSurname->Text = ""; Form1->ApplicantName->Text = ""; Form1->ApplicantPatronymic->Text = ""; Form1->JobSeeker->Text = ""; Form1->ThesisTheme->Text = ""; Form1->PhoneintitutionsProtect->Text = 0; Form1->Supervisor->Text = ""; TDateTime today; today = Now(); Form1->setDatePublication->Text = DateToStr(today); Form1->date_adopted->Text = ""; Form1->CodeNameSpecialty->ItemIndex = 0; Form1->FieldScience->ItemIndex = 0; Form1->NameInstitutionsJob->Lines->Clear(); Form1->CallSpecializedAcademicCouncil->Lines->Clear(); Form1->NameInstitutionsProtect->Lines->Clear(); Form1->AddressInstitutionsProtect->Lines->Clear(); Form1->Oficial->Lines->Clear(); Form1->number_protocol_adopted->Lines->Clear(); } } catch( Exception *ex ) { AnsiString ErrorMessageHint, messange_e; messange_e = ex->Message; ShowMessage( messange_e ); // string1.Pos(substring1); if(messange_e.Pos("date_adopted")) { if(Sender->ClassName().operator AnsiString() == AnsiString("TMaskEdit")) { TMaskEdit *me = (TMaskEdit *)Sender; me->Clear(); me->Refresh(); Perform(WM_NEXTDLGCTL, 0, 0); ErrorMessageHint = ""; } else ErrorMessageHint = "Введено неправильне значення 'Дати прийнятя дисертації'. Натисніть ESC!"; } else if(messange_e.Pos("PhoneintitutionsProtect")) { if(Sender->ClassName().operator AnsiString() == AnsiString("TMaskEdit")) { TMaskEdit *me = (TMaskEdit *)Sender; me->Clear(); me->Refresh(); Perform(WM_NEXTDLGCTL, 0, 0); ErrorMessageHint = ""; } else ErrorMessageHint = "Введено неправильне значення 'Телефон установи, в якій відбудеться захист'. Натисніть ESC!"; } else { ErrorMessageHint = ""; } if(ErrorMessageHint != "") { Application->MessageBox(ErrorMessageHint.c_str(), "Помилка!", NULL); } else { } } }
void __fastcall TMarksXYStyle::Series1GetMarkText(TChartSeries *Sender, int ValueIndex, AnsiString &MarkText) { MarkText = StringReplace(MarkText," ","-",TReplaceFlags()); }
void __fastcall TForm3::chooseDateImageButtonClick(TObject *Sender) { //hide date related items chooseDateImageButton->Visible = false; datePopupBoxLabel->Visible = false; calendar->Visible = false; inputLabelImage->Visible=true; //at this point dateChosen has whatever date is desired //need to now do normal basic or advanced input depending on accessLevel //query input_table to see if dateChosen is filled already or not //if filled, show advanced view with data filled in //if not filled, show basic view and allow normal progression //check if current date already input for most basic user String currentHotelID = Form1->getHotelID(); SQLQuery2->SQL->Text = "SELECT input_table, read_table, labor_table, Overtime_Per_Hour FROM hotel_ref WHERE hotelID = '"+currentHotelID+"';"; SQLQuery2->Open(); SQLQuery2->First(); if (!SQLQuery2->Eof) { //get what the inputTable is and what read table is (for future insert) inputTable = SQLQuery2->Fields->Fields[0]->AsString; readTable = SQLQuery2->Fields->Fields[1]->AsString; laborTable = SQLQuery2->Fields->Fields[2]->AsString; overtimePerHour = SQLQuery2->Fields->Fields[3]->AsFloat; //query to see if tuple exists for dateChosen SQLQuery2->SQL->Text = "SELECT * FROM "+inputTable+" WHERE Date = '"+dateChosen+"';"; SQLQuery2->Open(); SQLQuery2->First(); //if tuple exists, display in grid similar to advanced view if (!SQLQuery2->Eof) { //hide form items dbFieldLabel->Visible = false; dbFieldEdit->Visible = false; nextImageButton->Visible = false; SQLQuery2->SQL->Text = "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'baldwins_hotel_data' AND TABLE_NAME = '"+inputTable+"';"; SQLQuery3->SQL->Text = "SELECT * FROM "+inputTable+" WHERE Date = '"+dateChosen+"';"; //open query and temporarily skip first two column headings (Date/Day_Of_Week) SQLQuery2->Open(); SQLQuery2->First(); SQLQuery2->Next(); SQLQuery2->Next(); //open second query SQLQuery3->Open(); SQLQuery3->First(); int count = 0; //strings used in if for holdling column headings String originalHeading = ""; String editedHeading = ""; while (!SQLQuery2->Eof) { //get initial column heading without formatting (i.e. removing "_") originalHeading = SQLQuery2->Fields->Fields[0]->AsString; //replace underscores with spaces and set label editedHeading = StringReplace(originalHeading, "_", " ", TReplaceFlags() << rfReplaceAll); //show and populate displayGrid displayGrid->Cells[0][count] = editedHeading; displayGrid->Cells[1][count] = SQLQuery3->Fields->Fields[count+2]->AsString; //increase count and cursors ++count; SQLQuery2->Next(); } inputLabelImage->Visible=false; displayGrid->RowCount = count; displayGrid->Visible = true; Image3->Visible=false; submitButton->Visible = true; Image1->Visible=true; //set alreadyThere boolean to true (signifying the need for an update query when submit is clicked) alreadyThere = true; } //if inputLevel is advanced and no input for this date, show blank advanced view else if (Form1->getInputLevel() == 1) { //hide form items inputLabelImage->Visible=false; dbFieldLabel->Visible = false; dbFieldEdit->Visible = false; nextImageButton->Visible = false; Image3->Visible=false; SQLQuery2->SQL->Text = "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'baldwins_hotel_data' AND TABLE_NAME = '"+inputTable+"';"; //open query and temporarily skip first two column headings (Date/Day_Of_Week) SQLQuery2->Open(); SQLQuery2->First(); SQLQuery2->Next(); SQLQuery2->Next(); int count = 0; //strings used in if for holdling column headings String originalHeading = ""; String editedHeading = ""; while (!SQLQuery2->Eof) { //get initial column heading without formatting (i.e. removing "_") originalHeading = SQLQuery2->Fields->Fields[0]->AsString; //replace underscores with spaces and set label editedHeading = StringReplace(originalHeading, "_", " ", TReplaceFlags() << rfReplaceAll); //show and populate displayGrid displayGrid->Cells[0][count] = editedHeading; displayGrid->Cells[1][count] = ""; ++count; SQLQuery2->Next(); } displayGrid->RowCount = count; displayGrid->Visible = true; inputLabelImage->Visible=false; Image3->Visible=false; submitButton->Visible = true; Image1->Visible=true; } //otherwise, run basic input for this chosenDate else { //hide/show uneccessary/necessary items from this page dbFieldLabel->Visible = true; dbFieldEdit->Visible = true; nextImageButton->Visible = true; chooseDateImageButton->Visible = false; calendar->Visible = false; datePopupBoxLabel->Visible = false; //input level is "default", query db schema SQLQuery2->SQL->Text = "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'baldwins_hotel_data' AND TABLE_NAME = '"+inputTable+"';"; //open query and temporarily skip first two column headings SQLQuery2->Open(); SQLQuery2->First(); SQLQuery2->Next(); SQLQuery2->Next(); //strings used in if for holdling column headings String originalHeading = ""; String editedHeading = ""; //set label to represent first editable column heading if(!SQLQuery2->Eof) { //get initial column heading without formatting (i.e. removing "_") originalHeading = SQLQuery2->Fields->Fields[0]->AsString; //replace underscores with spaces and set label editedHeading = StringReplace(originalHeading, "_", " ", TReplaceFlags() << rfReplaceAll); dbFieldLabel->Text = editedHeading; dbFieldLabel->Visible = true; dbFieldEdit->Visible = true; dbFieldEdit->Text = ""; nextImageButton->Visible = true; //initially set index and size to zero inputObject.currentIndex = 0; inputObject.size = 0; } } } //set date chosen back to current date calendar->Date = Now(); }
String GetModuleDirectory(void) { return ExtractFilePath(StringReplace(GetModuleName((unsigned int)HInstance), "\\\\?\\", "", TReplaceFlags() << System::Sysutils::rfReplaceAll)); }
//--------------------------------------------------------------------------- UnicodeString TCustomCommand::Complete(const UnicodeString & Command, bool LastPass) { UnicodeString Result; intptr_t Index = 1; while (Index <= Command.Length()) { intptr_t Len; wchar_t PatternCmd; GetToken(Command, Index, Len, PatternCmd); if (PatternCmd == TEXT_TOKEN) { Result += Command.SubString(Index, Len); } else if (PatternCmd == L'!') { if (LastPass) { Result += L'!'; } else { Result += Command.SubString(Index, Len); } } else { wchar_t Quote = NoQuote; if ((Index > 1) && (Index + Len - 1 < Command.Length()) && Command.IsDelimiter(Quotes, Index - 1) && Command.IsDelimiter(Quotes, Index + Len) && (Command[Index - 1] == Command[Index + Len])) { Quote = Command[Index - 1]; } UnicodeString Pattern = Command.SubString(Index, Len); UnicodeString Replacement; bool Delimit = true; if (PatternReplacement(Pattern, Replacement, Delimit)) { if (!LastPass) { Replacement = StringReplace(Replacement, L"!", L"!!", TReplaceFlags() << rfReplaceAll); } if (Delimit) { DelimitReplacement(Replacement, Quote); } Result += Replacement; } else { Result += Pattern; } } Index += Len; } return Result; }
void __fastcall TMyThread::Execute() { //disable home button Form3->homeImageButton5->Enabled=false; //yes selected, save information in grid to database //create empty strings to add to query once populated from grid String headings = ""; String values = ""; String update = ""; String updateHeading = ""; //get day of week int Day = DayOfWeek(Form3->pureDate); String DayName; switch(Day) { case 1: DayName = L"Sunday"; break; case 2: DayName = L"Monday"; break; case 3: DayName = L"Tuesday"; break; case 4: DayName = L"Wednesday"; break; case 5: DayName = L"Thursday"; break; case 6: DayName = L"Friday"; break; case 7: DayName = L"Saturday"; } //populate date and day of week (probably temporary solution) headings += ("Date, Day_Of_Week, "); values += ("'" + Form3->dateChosen + "', '" + DayName + "', "); //construct headings and values for an update query instead of insert query if (Form3->alreadyThere) { //populate strings only from the grid for (int i = 0; i < Form3->displayGrid->RowCount; ++i) { updateHeading = StringReplace(Form3->displayGrid->Cells[0][i], " ", "_", TReplaceFlags() << rfReplaceAll); if (i + 1 == Form3->displayGrid->RowCount) { update += (updateHeading + " = '" + Form3->displayGrid->Cells[1][i] + "'"); } else { update += (updateHeading + " = '" + Form3->displayGrid->Cells[1][i] + "', "); } } } //check if basic input was used, if so populate headings/values from inputObject else if (Form1->getInputLevel() == 0) { //populate rest of strings from grid for (int i = 0; i < Form3->inputObject.size; ++i) { if (i + 1 == Form3->inputObject.size) { headings += ("" + Form3->inputObject.valueMap[i][0] + ""); values += ("'" + Form3->displayGrid->Cells[1][i] + "'"); } else { headings += ("" + Form3->inputObject.valueMap[i][0] + ", "); values += ("'" + Form3->displayGrid->Cells[1][i] + "', "); } } } //if inputLevel is not basic, get both headings and values from the grid else { //populate strings only from the grid (might not be "minus 1") for (int i = 0; i < Form3->displayGrid->RowCount; ++i) { if (i + 1 == Form3->displayGrid->RowCount) { headings += ("" + StringReplace(Form3->displayGrid->Cells[0][i], " ", "_", TReplaceFlags() << rfReplaceAll) + ""); values += ("'" + Form3->displayGrid->Cells[1][i] + "'"); } else { headings += ("" + StringReplace(Form3->displayGrid->Cells[0][i], " ", "_", TReplaceFlags() << rfReplaceAll) + ", "); values += ("'" + Form3->displayGrid->Cells[1][i] + "', "); } } } //run update query if item already in database if (Form3->alreadyThere) { //update the raw_input table Form3->SQLQuery2->SQL->Text = "UPDATE baldwins_hotel_data."+Form3->inputTable+" SET "+update+" WHERE "+Form3->inputTable+".Date = '"+Form3->dateChosen+"';"; Form3->SQLQuery2->ExecSQL(); //update the read_data table Form3->SQLQuery2->SQL->Text = "UPDATE baldwins_hotel_data."+Form3->readTable+" SET "+update+" WHERE "+Form3->readTable+".Date = '"+Form3->dateChosen+"';"; Form3->SQLQuery2->ExecSQL(); } //if item not there, then run the normal insert query else { //query input_table db and insert new row Form3->SQLQuery2->SQL->Text = "INSERT INTO baldwins_hotel_data."+Form3->inputTable+" ("+headings+") VALUES ("+values+");"; Form3->SQLQuery2->ExecSQL(); //query read_table db and insert new row Form3->SQLQuery2->SQL->Text = "INSERT INTO baldwins_hotel_data."+Form3->readTable+" ("+headings+") VALUES ("+values+");"; Form3->SQLQuery2->ExecSQL(); } //Calculate and update values for Standard_Hours and Percent_Performance //first, query role_table to get all the Role_Name, Bare_Role_Name and Standard_Hours_Reference String currentHotelID = Form1->getHotelID(); vector<calculateInfo> infoVector; String roleName = ""; String roleStandardHoursName = ""; String bareRoleName = ""; String standardHoursReference = ""; int context = 0; double actual = 0; double labor = 0; double roleWages = 0; double totalLaborHoursHoursPaid = 0; double totalLaborHoursStandardHours = 0; double totalLaborHoursPercentPerformance = 0; double totalLaborCostHoursPaid = 0; double totalLaborCostStandardHours = 0; double totalLaborCostPercentPerformance = 0; Form3->SQLQuery2->SQL->Text = "SELECT Role_Name, Bare_Role_Name, Standard_Hours_Reference, Role_Wages FROM baldwins_hotel_data.role_table WHERE hotelID = '"+currentHotelID+"';"; Form3->SQLQuery2->Open(); Form3->SQLQuery2->First(); while (!Form3->SQLQuery2->Eof) { //fill strings roleName = Form3->SQLQuery2->Fields->Fields[0]->AsString; roleStandardHoursName = StringReplace(roleName, "Hours_Paid", "Standard_Hours", TReplaceFlags() << rfReplaceAll); bareRoleName = Form3->SQLQuery2->Fields->Fields[1]->AsString; standardHoursReference = Form3->SQLQuery2->Fields->Fields[2]->AsString; roleWages = Form3->SQLQuery2->Fields->Fields[3]->AsFloat; //get the integer value based on above strings Form3->SQLQuery3->SQL->Text = "SELECT "+roleName+", "+standardHoursReference+" FROM baldwins_hotel_data."+Form3->readTable+" WHERE Date = '"+Form3->dateChosen+"';"; Form3->SQLQuery3->Open(); Form3->SQLQuery3->First(); if (!Form3->SQLQuery3->Eof) { //get values for normal use in this while loop actual = Form3->SQLQuery3->Fields->Fields[0]->AsFloat; context = Form3->SQLQuery3->Fields->Fields[1]->AsInteger; } //get the labor value for standard hours Form3->SQLQuery3->SQL->Text = "SELECT "+bareRoleName+" FROM baldwins_hotel_data."+Form3->laborTable+" WHERE "+context+" >= Rooms_Occupied_Low AND "+context+" <= Rooms_Occupied_High;"; Form3->SQLQuery3->Open(); Form3->SQLQuery3->First(); if (!Form3->SQLQuery3->Eof) { labor = Form3->SQLQuery3->Fields->Fields[0]->AsFloat; } //push_back calculateInfo object infoVector.push_back(calculateInfo(roleName, roleStandardHoursName, bareRoleName, standardHoursReference, context, actual, labor)); //compute values used below this while loop in actual update query totalLaborHoursHoursPaid += actual; totalLaborHoursStandardHours += labor; totalLaborCostHoursPaid = totalLaborCostHoursPaid + (actual * roleWages); totalLaborCostStandardHours = totalLaborCostStandardHours + (labor * roleWages); //reset strings and doubles to empty for next iteration roleName = ""; roleStandardHoursName = ""; bareRoleName = ""; standardHoursReference = ""; actual = 0; context = 0; labor = 0; roleWages = 0; /*totalLaborHoursHoursPaid = 0; totalLaborHoursStandardHours = 0; totalLaborHoursPercentPerformance = 0; totalLaborCostHoursPaid = 0; totalLaborCostStandardHours = 0; totalLaborCostPercentPerformance = 0;*/ //move cursor to next item Form3->SQLQuery2->Next(); } //run update query that updates standard hours and percent performance updateHeading = ""; String updateHeading2 = ""; update = ""; labor = 0; double percent = 0; for (int i = 0; i < infoVector.size(); ++i) { updateHeading = infoVector[i].roleStandardHours; updateHeading2 = StringReplace(updateHeading, "Standard_Hours", "Percent_Performance", TReplaceFlags() << rfReplaceAll); labor = infoVector[i].laborValue; percent = infoVector[i].percentPerformance; /*if (i + 1 == infoVector.size()) { update += (updateHeading + " = '" + labor + "', " + updateHeading2 + " = '" + percent + "'"); }*/ //else //{ update += (updateHeading + " = '" + labor + "', " + updateHeading2 + " = '" + percent + "', "); //} } //calculate/store overtime, total_labor_hours, total_labor_cost in read_data double overtimeHoursPaid = 0; double overtimeStandardHours = 0; double overtimePercentPerformance = 0; Form3->SQLQuery3->SQL->Text = "SELECT Overtime_Hours_Paid FROM baldwins_hotel_data."+Form3->inputTable+" WHERE "+Form3->inputTable+".Date = '"+Form3->dateChosen+"';"; Form3->SQLQuery3->Open(); Form3->SQLQuery3->First(); if (!Form3->SQLQuery3->Eof) overtimeHoursPaid = Form3->SQLQuery3->Fields->Fields[0]->AsFloat; overtimeStandardHours = Form3->overtimePerHour * overtimeHoursPaid; overtimePercentPerformance = overtimeStandardHours / 3; if (totalLaborHoursHoursPaid != 0) totalLaborHoursPercentPerformance = totalLaborHoursStandardHours / totalLaborHoursHoursPaid; else totalLaborHoursPercentPerformance = 0; if (totalLaborCostHoursPaid != 0) totalLaborCostPercentPerformance = totalLaborCostStandardHours / totalLaborCostHoursPaid; else totalLaborCostPercentPerformance = 0; totalLaborCostHoursPaid += overtimePercentPerformance; String spaceTaker = ""; update += (spaceTaker + "Overtime_Hours_Paid = '" + overtimeHoursPaid + "', " + "Overtime_Standard_Hours = '" + overtimeStandardHours + "', " + "Overtime_Percent_Performance = '" + overtimePercentPerformance + "', "); update += (spaceTaker + "Total_Labor_Hours_Hours_Paid = '" + totalLaborHoursHoursPaid + "', " + "Total_Labor_Hours_Standard_Hours = '" + totalLaborHoursStandardHours + "', " + "Total_Labor_Hours_Percent_Performance = '" + totalLaborHoursPercentPerformance + "', "); update += (spaceTaker + "Total_Labor_Cost_Hours_Paid = '" + totalLaborCostHoursPaid + "', " + "Total_Labor_Cost_Standard_Hours = '" + totalLaborCostStandardHours + "', " + "Total_Labor_Cost_Percent_Performance = '" + totalLaborCostPercentPerformance + "'"); Form3->SQLQuery2->SQL->Text = "UPDATE baldwins_hotel_data."+Form3->readTable+" SET "+update+" WHERE "+Form3->readTable+".Date = '"+Form3->dateChosen+"';"; Form3->SQLQuery2->ExecSQL(); }
void TfrmLerCartaPlotar::Plotar() { if (plotar == false && edtBD->Text.Length() > 0 || edtDYN->Text.Length() > 0) { indice = 0; if (pgcPrincipal->ActivePage == tbsBD) { texto = edtBD->Text; } else { texto = edtDYN->Text; } texto = StringReplace(texto, ".", ",", TReplaceFlags() << rfReplaceAll); pos = texto.Pos("&"); resultado = texto.SubString(1, pos.ToInt() - 1); texto = texto.SubString(pos.ToInt() + 1, texto.Length()); pos = texto.Pos("&"); pontos = texto.SubString(1, pos.ToInt() - 1); texto = texto.SubString(pos.ToInt() + 1, texto.Length()); Label1->Caption = "Resultado: " + resultado + " | " + "Quantidade de Pontos: " + pontos; Grid->RowCount = pontos.ToInt()+1; percorrer = true; while (percorrer) { String pos = texto.Pos("&"); if (texto.Length() > 0) { carga[indice] = texto.SubString(1, pos.ToInt() - 1); texto = texto.SubString(pos.ToInt() + 1, texto.Length()); String pos = texto.Pos("&"); posicao[indice] = texto.SubString(1, pos.ToInt() - 1); texto = texto.SubString(pos.ToInt() + 1, texto.Length()); } else { percorrer = false; } indice++; } for (i = 0; i < pontos/2; i++) { Grid->Cells[0][i + 1] = carga[i]; Grid->Cells[1][i + 1] = posicao[i]; } for (i = 0; i < pontos/2; i++) { double x,y; x = carga[i].ToDouble(); y = posicao[i].ToDouble(); Series1->AddX(x,"",clRed); Series1->AddY(y,"",clRed); } plotar = true; } else { return; } }
//--------------------------------------------------------------------------- //go through column headings as desired by the user void __fastcall TForm3::nextImageButtonClick(TObject *Sender) { //check for blank input if (SameText(dbFieldEdit->Text,"")) { errorLabel->Visible=true; return; } //check to see if string contains only digits and decimal int numDecimals=0; string inputString=AnsiString(dbFieldEdit->Text).c_str(); for (int i = 0; i < inputString.length(); i++) { //check to see if the character is 0-9 or a decimal //if((inputString[i]<48 || inputString[i]>57) && inputString[i]!=46) if(inputString[i]<48 || inputString[i]>57) { if(inputString[i]==46) { numDecimals++; if(numDecimals>1) { dbFieldEdit->Text=""; errorLabel->Visible=true; return; } if(inputString[i+1]<48 || inputString[i+1]>57) { dbFieldEdit->Text=""; errorLabel->Visible=true; return; } } else { dbFieldEdit->Text=""; errorLabel->Visible=true; return; } } } //make sure the error label does not appear errorLabel->Visible=false; if (inputObject.currentIndex == 0 && inputObject.size == 0) { //run when displayObject is empty //strings used in if for holdling column headings String originalHeading = ""; String editedHeading = ""; //get initial column heading without formatting (i.e. removing "_") originalHeading = SQLQuery2->Fields->Fields[0]->AsString; //replace underscores with spaces and set label editedHeading = StringReplace(originalHeading, "_", " ", TReplaceFlags() << rfReplaceAll); //add data to inputObject and increase index/size vector<String> temp; temp.push_back(originalHeading); temp.push_back(editedHeading); temp.push_back(dbFieldEdit->Text); inputObject.valueMap[inputObject.currentIndex] = temp; dbFieldEdit->Text = ""; (inputObject.currentIndex)++; (inputObject.size)++; originalHeading = ""; editedHeading = ""; //advance query SQLQuery2->Next(); //get initial column heading without formatting (i.e. removing "_") originalHeading = SQLQuery2->Fields->Fields[0]->AsString; //replace underscores with spaces and set label editedHeading = StringReplace(originalHeading, "_", " ", TReplaceFlags() << rfReplaceAll); dbFieldLabel->Text = editedHeading; backImageButton->Visible = true; } else if (inputObject.currentIndex == inputObject.size) { //will run when it is time to get the next column from the db //strings used in if for holdling column headings String originalHeading = ""; String editedHeading = ""; if(!SQLQuery2->Eof) { //get initial column heading without formatting (i.e. removing "_") originalHeading = SQLQuery2->Fields->Fields[0]->AsString; //replace underscores with spaces and set label editedHeading = StringReplace(originalHeading, "_", " ", TReplaceFlags() << rfReplaceAll); //fill inputObject with data and increse index/size vector<String> temp; temp.push_back(originalHeading); temp.push_back(editedHeading); temp.push_back(dbFieldEdit->Text); inputObject.valueMap[inputObject.currentIndex] = temp; dbFieldEdit->Text = ""; (inputObject.currentIndex)++; (inputObject.size)++; originalHeading = ""; editedHeading = ""; //advance query cursor SQLQuery2->Next(); //check if now at the end of the query if(SQLQuery2->Eof) { //spawn next part that displays desired changes and asks if sure //hide all other items on form besides home button dbFieldLabel->Visible = false; dbFieldEdit->Visible = false; nextImageButton->Visible = false; nextLabelImage->Visible=false; //show and populate displayGrid displayGrid->RowCount = inputObject.valueMap.size(); for (int i = 0; i < inputObject.size; ++i) { displayGrid->Cells[0][i] = inputObject.valueMap[i][1]; displayGrid->Cells[1][i] = inputObject.valueMap[i][2]; } Image3->Visible=false; Image4->Visible=false; inputLabelImage->Visible=false; displayGrid->Visible = true; submitButton->Visible = true; Image1->Visible=true; } else { //get initial column heading without formatting (i.e. removing "_") originalHeading = SQLQuery2->Fields->Fields[0]->AsString; //replace underscores with spaces and set label editedHeading = StringReplace(originalHeading, "_", " ", TReplaceFlags() << rfReplaceAll); dbFieldLabel->Text = editedHeading; backImageButton->Visible = true; } } } else { //don't query db, only go to next item in struct, replace item before advancing inputObject.valueMap[inputObject.currentIndex].pop_back(); inputObject.valueMap[inputObject.currentIndex].push_back(dbFieldEdit->Text); dbFieldEdit->Text = ""; (inputObject.currentIndex)++; if (inputObject.currentIndex == inputObject.size) { //accounts for case when coming back after pressing previous if data not previously captured //strings used in if for holdling column headings String originalHeading = ""; String editedHeading = ""; if(!SQLQuery2->Eof) { //get initial column heading without formatting (i.e. removing "_") originalHeading = ""; editedHeading = ""; //get initial column heading without formatting (i.e. removing "_") originalHeading = SQLQuery2->Fields->Fields[0]->AsString; //replace underscores with spaces and set label editedHeading = StringReplace(originalHeading, "_", " ", TReplaceFlags() << rfReplaceAll); dbFieldLabel->Text = editedHeading; backImageButton->Visible = true; } else { //spawn next part that displays desired changes and asks if sure //hide all other items on form besides home button dbFieldLabel->Visible = false; dbFieldEdit->Visible = false; nextImageButton->Visible = false; Image3->Visible=false; Image4->Visible=false; nextLabelImage->Visible=false; //show and populate displayGrid for (int i = 0; i < inputObject.size; ++i) { displayGrid->Cells[0][i+1] = inputObject.valueMap[i][1]; displayGrid->Cells[1][i+1] = inputObject.valueMap[i][2]; } submitButton->Visible = true; Image1->Visible=true; displayGrid->Visible = true; } } else { //when next pressed and data for this index has previously been captured dbFieldEdit->Text = inputObject.valueMap[inputObject.currentIndex][2]; dbFieldLabel->Text = inputObject.valueMap[inputObject.currentIndex][1]; backImageButton->Visible = true; } } }
//--------------------------------------------------------------------------- AnsiString __fastcall TRawPrint::ProcessarComandos(AnsiString Linha) { AnsiString Comando; AnsiString NovoComando; TStringList *Comandos; int CharComandos = 0; bool TemTexto = true; AnsiString NovaLinha = (String)char(10) + (String)char(13); AnsiString BackSpace = (String)char(8); AnsiString Acento; AnsiString Imp; Comandos = new TStringList; try { for(int i = 1; i < Linha.Length(); i++) { if(Linha[i] == '#') //Caso localizar Caracter indicando Comando { if(Linha[i + 4] == '#') //Caso for um Comando com um Parâmetro { if(ValidaComando(Linha.SubString(i + 1, 3))) { Comandos->Add(Linha.SubString(i, 5)); //Armazena o Comando na Lista de Comandos i = i + 4; CharComandos += 5; } } else if(Linha[i + 7] == '#') //Caso for um Comando com dois Parâmetros { if(ValidaComando(Linha.SubString(i + 1, 6))) { Comandos->Add(Linha.SubString(i, 8)); i = i + 7; CharComandos += 8; } } else if (Linha[i + 10] == '#') //Caso for um Comando com três Parâmetros { if(ValidaComando(Linha.SubString(i + 1, 9))) Comandos->Add(Linha.SubString(i, 11)); i = i + 10; CharComandos += 11; } } Linha = StringReplace(Linha, Linha[i], TiraAcento(Linha[i]), TReplaceFlags()); } if (CharComandos == Linha.Length() && Trim(Linha) != "") TemTexto = false; for (int i = 0; i < Comandos->Count; i++) { Comando = Comandos->Strings[i]; if(Comando.Length() == 5)//Substitui Comando com um Parâmetro NovoComando = (String)char(StrToInt(Comando.SubString(2, 3))); else if(Comando.Length() == 8)//Substitui Comando com dois Parâmetros NovoComando = (String)char(StrToInt(Comando.SubString(2, 3))) + (String)char(StrToInt(Comando.SubString(5, 3))); else//Substitui Comando com três Parâmetros NovoComando = (String)char(StrToInt(Comando.SubString(2, 3))) + (String)char(StrToInt(Comando.SubString(5, 3))) + (String)char(StrToInt(Comando.SubString(8, 3))); Linha = StringReplace(Linha, Comando, NovoComando, TReplaceFlags() << rfReplaceAll << rfIgnoreCase); } if (TemTexto) Linha += NovaLinha; } catch(Exception & E) { Erro("Erro ao processar Comandos informados no Texto.\r\n\r\n" + E.Message + "\r\n"); } return Linha; };