Example #1
0
//---------------------------------------------------------------------------
void __fastcall TFrmUserDataView::BtnSavePKGDataClick(TObject *Sender)
{
	BtnSavePKGData->Enabled = false;
	BtnInputPKGData->Enabled = true;

	UserData_PKG_SaveToSEQ();
	UserData_PKG_SaveToDB();

	UserData_PKG_ReadFromDB();
    UserData_PKG_ReadFromSEQ();

	TFileStream *File;
	TDateTime dt = Now();
	String FolderName = dt.FormatString("yyyy-mm-dd");
	String FileName = dt.FormatString("yyyy-mm-dd hh-nn-ss");
	ForceDirectories("C:\\KOSES\\History\\PKGParamLog\\"+ FolderName);

	String FullPath  =  "C:\\KOSES\\History\\PKGParamLog\\"+ FolderName+"\\"+FileName+".txt";

	File = new TFileStream(FullPath, fmCreate | fmOpenReadWrite);
	File->Position = 0;
	String Strtemp = "PKGParamLog \r\n";
	for(int i=0; i<PkgParamGrid->RowCount; i++)
	{
		Strtemp += " No:"+IntToStr(i)+ ":"+ PkgParamGrid->Cells[3][i+1] +"\r\n";
	}
	File->Write(Strtemp.c_str(),Strtemp.Length());
	delete File;
}
Example #2
0
//---------------------------------------------------------------------------
void __fastcall TFormClientRep::InitCommon()
{
	SetFormPosStd(this,Screen->Width,750,0,true);

	TDateTime DT = Date();
	SelYY = MaxYY = CurYY = StrToInt(DT.FormatString("yy"));
	SelMM = MaxMM = CurMM = StrToInt(DT.FormatString("m"));
	SetDates(CurMM, CurYY);
	SetButtonCaption(CurMM);
}
Example #3
0
//---------------------------------------------------------------------------
void __fastcall TFormSummaryRep::InitCommon()
{
	SetFormPosStd(this,Screen->Width,750,0,true);

	TDateTime DT = Date();
	SelYY = MaxYY = CurYY = StrToInt(DT.FormatString("yy"));
	SelMM = MaxMM = CurMM = StrToInt(DT.FormatString("m"));
	SetDates(CurMM, CurYY);
	SetButtonCaption(CurMM);
	SetColumns();
	ToggleShowCost(false);
}
Example #4
0
String TTimeLapse::AsStr(TDateTime dt)
{
	if ((int)dt == 0) dt = Elapsed();

	dt.DecodeTime(&FHour, &FMin, &FSec, &FMSec);

	String str;
	if (FHour != 0)
		str = dt.FormatString("h':'nn':'ss");
	else
		str = dt.FormatString("n':'ss");
	return str;
}
//---------------------------------------------------------------------------
void TClockDlg::setEdits()
{
   initialised = false;
   TDateTime corr = dtg::getUTC( correction );
   DayEdit->Text = corr.FormatString( "dd" );
   MonthEdit->Text = corr.FormatString( "mm" );
   YearEdit->Text = corr.FormatString( "yyyy" );

   TDateTime dtt = TDateTime( correction );
   HoursEdit->Text = dtt.FormatString( "h" );
   MinutesEdit->Text = dtt.FormatString( "n" );
   SecondsEdit->Text = dtt.FormatString( "s" );
   initialised = true;
}
Example #6
0
String TTimeLapse::AsString(const bool ms, TDateTime dt)
{
	if ((int)dt == 0)
        dt = Elapsed();

	dt.DecodeTime(&FHour, &FMin, &FSec, &FMSec);

	String str;
	if (FHour != 0)
		str = IntToStr(FHour) + " Hours, ";
	str += dt.FormatString("n' Minutes, 's");
	if (ms)
		str +=  dt.FormatString("'.'z");
	str += " Seconds";
	return str;
}
Example #7
0
UnicodeString DateTimeToStr(UnicodeString & Result, const UnicodeString & Format,
  TDateTime DateTime)
{
  (void)Result;
  (void)Format;
  return DateTime.FormatString(L"");
}
void TMinosChatForm::addChat(const std::string &mess)
{
   TDateTime dt = TDateTime::CurrentDateTime();
   unsigned short h, m, s, ms;
   dt.DecodeTime( &h, &m, &s, &ms );
   String sdt = dt.FormatString( "hh:nn:ss " ) + mess.c_str();
   chatQueue.push_back(sdt.c_str());
}
Example #9
0
AnsiString TUtilities::Format96HHMM(TDateTime DateTime)
//Formats a TDateTime into an AnsiString of the form hh:mm where hh runs from 00 to 95 & resets when it reaches 96
{
AnsiString MinString = DateTime.FormatString(":nn");
int Hours = (int)(((double)(DateTime + 0.0003)) * 24);//for v0.6 round up by ~0.5min to prevent undershooting the hour in formatted tts
while(Hours >= 96) Hours -= 96;
AnsiString HourString = AnsiString(Hours);
while(HourString.Length() < 2) HourString = "0" + HourString;;
return (HourString + MinString);
}
Example #10
0
// We really need to hold FULL dates internally!
dtg::dtg( bool now )
{
   if ( now )
   {
      TDateTime tdt = dtg::getUTC();
      setDate( tdt.FormatString( "dd/mm/yy" ).c_str(), DTGDISP );
      setTime( tdt.FormatString( "hh:nn:ss" ).c_str(), DTGDISP );
   }
   else
   {
      setDate( "", DTGDISP );
      setTime( "", DTGDISP );
   }
}
Example #11
0
void Loga(String msg)
{
FILE *fp;

  if ( ( fp = fopen(FILE_LOG, "at")) != NULL )
    {
    TDateTime dt;
    dt = dt.CurrentDateTime();
    String S = dt.FormatString("dd/mm/yy hh:nn:ss(");
    S = S + GetTickCount() % 1000;
    S = S + ") - " + msg;
    if ( FormMain->lbLog->Items->Count > 150 )
      {
      FormMain->lbLog->Items->Delete(0);
      }
    FormMain->lbLog->Items->Add(S);
    fprintf( fp, S.c_str() );
    fprintf( fp, "\n" );
    fclose( fp );
    }
}
Example #12
0
void CSelfTestMenu::OnButton13(int iEvent, unsigned char * pEventData, int iDataLen)
{
	TDateTime curDate;
	char chValue[64];
	UINT8 nKeyTime = 1;
	while(1)
	{
		curDate = TDateTime::CurrentDateTime();
		memset(chValue, 0, sizeof(chValue));
		sprintf(chValue, "   %s", curDate.FormatString(YYYYMMDDHHMMSS).c_str());
		
		CaProgressBar proBar(chValue);
		proBar.Show();
		
		if(CheckKey(nKeyTime)==SUCCESS)
		{
			break;
		}
		CommonSleep(1000);
	}
	
	this->ReFresh();
	return;
}
//---------------------------------------------------------------------------
TData __fastcall MyArhiv::GetFDataTag(TDateTime DateArhiv, int IDTag)
{
 struct TData         Ret;
 static TDateTime     Old;
 static char          NameCurDir[255];
 static AnsiString    TekDir         ;
 static bool          first=true     ;
 int                  handle_file    ;
 static AnsiString    OldName=""     ;
 static unsigned long kb = 0L;
 static bool          Error = true;
 static double tim;
 if (first) // определить текущую директорию                           
  {
   GetCurrentDirectory(255,NameCurDir);
   TekDir    = NameCurDir;
   first     = false     ;
  }
 if (IDTag>=10000)
  {
   Ret.Status  = 1;
   Ret.Val     = 0;
   Ret.YesData = true;
   return Ret;
  }
 if (Old!=DateArhiv)
  {
   AnsiString ARHIV = "ARHIV";
   AnsiString YEAR  = DateArhiv.FormatString("yyyy");
   AnsiString MON   = DateArhiv.FormatString("mm")  ;
   AnsiString DAT   = DateArhiv.FormatString("dd")  ;
   AnsiString HOUR  = DateArhiv.FormatString("hh")  ;
   int min = StrToInt(DateArhiv.FormatString("nn"));
   int sec = StrToInt(DateArhiv.FormatString("ss"));
   Old = DateArhiv;
   AnsiString  NameFile   = TekDir+"\\"+ARHIV+"\\"+YEAR+"\\"+MON+"\\"+DAT+"\\" + HOUR +".dat";
   Error=true;
   if ((handle_file=_open(NameFile.c_str(),O_RDONLY|O_BINARY))>0) // чтение информации из файла
    {
/*     unsigned int  kb_zag  = sizeof(int)*ActiveArhiv->CountTags+sizeof(int);
     unsigned int  len_buf = ((sizeof(double)+sizeof(int))*ActiveArhiv->CountTags+sizeof(double))*3600; //  ((    значение и статус   ) *кол-во тэгов + дата и время) 60 сек * 60 мин
     unsigned char *buf; */
     if (OldName!=NameFile) // разбор заголовка
      {
       lseek(handle_file,0L,SEEK_SET)    ;
       Error = false;
       _read(handle_file,&kb,sizeof(int)); // размер заголовка
       if (kb == sizeof(int)*ActiveArhiv->CountTags+sizeof(int)) // размер заголовка должен соответствовать количеству архивных тэгов
        {
         if (_read(handle_file,FArhivIDTags,sizeof(int)*ActiveArhiv->CountTags)!=(signed int)(sizeof(int)*ActiveArhiv->CountTags)) Error=true;
        }
       else Error = true;
       OldName = NameFile;
      }
     else Error = false;
     if (!Error)
      {
       unsigned long sm = min * 60 + sec;
       sm = kb + sm * ((sizeof(double)+sizeof(int))*ActiveArhiv->CountTags+sizeof(double));
       sm = lseek(handle_file,sm,SEEK_SET);
       if (_read(handle_file,(unsigned char *)&tim,sizeof(double))!=sizeof(double)) Error=true;
       else if (_read(handle_file,(unsigned char *)FArhivValTags,(unsigned int)(sizeof(double)*ActiveArhiv->CountTags))!=(signed int)(sizeof(double)*ActiveArhiv->CountTags)) Error=true;
       else if (_read(handle_file,(unsigned char *)FArhivStatTags,sizeof(int)*ActiveArhiv->CountTags)!=(signed int)(sizeof(int)*ActiveArhiv->CountTags))      Error=true;
      }
     _close(handle_file);
     handle_file = -1;
    }
  }
 if ((tim==0)||(Error)) { FDataTag.YesData=false;FDataTag.Val=0;FDataTag.Status=1; }
 else
  {
   FDataTag.YesData=false;
   for (int pc=0;pc<FCountTags;pc++)
    {
     if (FArhivIDTags[pc]==IDTag)
      {
       FDataTag.Val     = FArhivValTags[pc];
       FDataTag.Status  = FArhivStatTags[pc];
       FDataTag.YesData = true;break;
      }
    }
   if (!FDataTag.YesData) { FDataTag.Val=0;FDataTag.Status=1; }
  }
 Ret = FDataTag;
 return Ret;
}
Example #14
0
UnicodeString DateTimeToString(TDateTime DateTime)
{
  return DateTime.FormatString(L"");
}
/*int old_sec=-1;
unsigned int old_kb=1000; */
void __stdcall Timer1Timer(UINT TimerID, UINT Message, DWORD dwUser, DWORD dw1, DWORD dw2)
{
 // раз в секунду запись в архив
 static char       NameCurDir[255];
 static AnsiString TekDir         ;
 static bool       first=true     ;
 int               handle_file    ;
 AnsiString ARHIV = "ARHIV";
 TDateTime TD = Now();
 AnsiString YEAR  = TD.FormatString("yyyy");
 AnsiString MON   = TD.FormatString("mm")  ;
 AnsiString DAT   = TD.FormatString("dd")  ;
 AnsiString HOUR  = TD.FormatString("hh")  ;
 int min = StrToInt(TD.FormatString("nn"));
 int sec = StrToInt(TD.FormatString("ss"));
 double tim = TD.Val;
 /*if ((old_sec!=-1)&&((sec-old_sec)>1)&&(old_sec!=59))
  int l=0;
 old_sec = sec;*/
 if (ActiveArhiv==NULL) return;
 if (first) // определить текущую директорию
  {
   GetCurrentDirectory(255,NameCurDir);
   TekDir    = NameCurDir;
   first     = false     ;
  }
 AnsiString  NameFile   = TekDir+"\\"+ARHIV+"\\"+YEAR+"\\"+MON+"\\"+DAT+"\\" + HOUR +".dat";
 if (!FileExists(TekDir+"\\"+ARHIV+"\\"+YEAR+"\\"+MON+"\\"+DAT+"\\" + HOUR +".dat")) // создать файл ARHIV\\XXXX\\MM\\DD\\hh - час
  {
   // Проверить наличие директории ARHIV
   if (!DirectoryExists(TekDir+"\\"+ARHIV))  if (!CreateDir(TekDir+"\\"+ARHIV)) { ActiveArhiv->Com=-10;/* FErrorDostup=true;*/return; }
   // Проверить наличие директории ARHIV\\XXXX - год
   if (!DirectoryExists(TekDir+"\\"+ARHIV+"\\"+YEAR))  if (!CreateDir(TekDir+"\\"+ARHIV+"\\"+YEAR)) { ActiveArhiv->Com=-10; /* FErrorDostup=true; */return; }
   // Проверить наличие директории ARHIV\\XXXX\\MM - месяц
   if (!DirectoryExists(TekDir+"\\"+ARHIV+"\\"+YEAR+"\\"+MON))  if (!CreateDir(TekDir+"\\"+ARHIV+"\\"+YEAR+"\\"+MON)) { ActiveArhiv->Com=-10; /*FErrorDostup=true; */return; }
   // Проверить наличие директории ARHIV\\XXXX\\MM\\DD - день
   if (!DirectoryExists(TekDir+"\\"+ARHIV+"\\"+YEAR+"\\"+MON+"\\"+DAT))  if (!CreateDir(TekDir+"\\"+ARHIV+"\\"+YEAR+"\\"+MON+"\\"+DAT)) { ActiveArhiv->Com=-10;/*FErrorDostup=true;*/return; }
   // создать файл      ARHIV\\XXXX\\MM\\DD\\hh - час

   if ((handle_file=_open(NameFile.c_str(),O_RDWR|O_BINARY|O_CREAT))>0) // создание нулевого файла
    {
     unsigned int  kb_zag = sizeof(int)*ActiveArhiv->CountTags+sizeof(int);
     unsigned char *buf;
     lseek(handle_file,0L,SEEK_SET);
     _write(handle_file,(unsigned char *)&kb_zag,sizeof(int))           ;
     _write(handle_file,(unsigned char *)ActiveArhiv->IDTags,sizeof(int)*ActiveArhiv->CountTags);
     unsigned int len_buf = ((sizeof(double)+sizeof(int))*ActiveArhiv->CountTags+sizeof(double))*3600; //  ((    значение и статус   ) *кол-во тэгов + дата и время) 60 сек * 60 мин
     buf = (unsigned char *)calloc(len_buf,sizeof(char));
     // заполнение нулями
     _write(handle_file,(unsigned char *)buf,len_buf);
     _close(handle_file);
     handle_file=-1;
     free(buf);
    }
   else { ActiveArhiv->Com = -10;/* FErrorDostup = true; */return; }
  }
 if ((handle_file=_open(NameFile.c_str(),O_RDWR|O_CREAT|O_BINARY))>0) // Запись информации в файл
  {
   // чтение размера заголовка
   unsigned int  kb = 0L;
   unsigned long sm = min * 60 + sec;
 /*  static int old_sm=0;
   if ((sm-old_sm)>1)
    {

     int k=0;
    }
   old_sm=sm;  */
   lseek(handle_file,0L,SEEK_SET);
   _read(handle_file,&kb,sizeof(int));
  /*  int k2=0;
   else
    if ((old_kb!=kb)&&(old_kb!=1000))
     int k3=0;
   old_kb=kb;*/
   sm = kb + sm * ((sizeof(double)+sizeof(int))*ActiveArhiv->CountTags+sizeof(double));
   lseek(handle_file,sm,SEEK_SET);
   _write(handle_file,&tim,sizeof(double));//!=sizeof(double))
   /* int k4=0;   */
   /*if (ActiveArhiv->ValTags[1]<1)
    int i=0;
   if (
   */
   _write(handle_file,(unsigned char *)ActiveArhiv->ValTags,sizeof(double)*ActiveArhiv->CountTags);
   /*!=sizeof(double)*ActiveArhiv->CountTags)
    int k=0;
   if (*/
   _write(handle_file,(unsigned char *)ActiveArhiv->StatTags,sizeof(int)*ActiveArhiv->CountTags);
   /*!=sizeof(int)*ActiveArhiv->CountTags)
    int k1=0;  */
   _close(handle_file);
   handle_file=-1;
   ActiveArhiv->Com = -11; /* FErrorDostup = false;*/
  }
 else { ActiveArhiv->Com=-10;/* FErrorDostup = true;*/return; }
}
Example #16
0
// 抓拍数据
void CALLBACK VehicleDataCallbackFuc(void *pUserData, VehicleData *pData)
{
    TForm1 *pThis = (TForm1 *)pUserData;
    if(pThis->tvConnectDev->Selected == NULL) return;

    String strIP;
    bool bFlag = false;
    PDevInfo pDev = NULL;
    TTreeNodes *nodes = pThis->tvConnectDev->Items;
    if(nodes != NULL)
    {
        for(int i = 0; i < nodes->Count; i++)
        {
            if(TreeView_GetCheckState(pThis->tvConnectDev->Handle,nodes->Item[i]->ItemId))
            {
                String strViewIP = nodes->Item[i]->Text;

                // 只显示指定抓拍的设备数据
                strIP.sprintf("%s", pData->ucDeviceIP);
                if(strIP == strViewIP)
                {
                    bFlag = true;
                    break;
                }
            }
        }
    }

     if(!bFlag) return;


     int nColor = pData->PlateColor;
     TDateTime dataTime = Now();
     SYSTEMTIME tm;
     GetSystemTime(&tm);

     String strPlate = (char *)pData->ucPlate;

     String strPath;
     String strBigFile, strCifFile, strPlateFile, strPlateNoFile;
     int iFileHandle = 0;

     // 大图
     if(pData->pucBigImage != NULL && pData->uiBigImageLen > 0)
     {
        strPath = pThis->strImagePath + strIP + "\\大图\\" + FormatDateTime("yyyymmdd", dataTime) + "\\";
        pThis->CreateDirectoryRecurrent(strPath);
        strBigFile = Format("%s%s%03d(%s).jpg", ARRAYOFCONST((strPath, dataTime.FormatString("hhmmss"), tm.wMilliseconds, strPlate)));
        iFileHandle = FileCreate(strBigFile);
        if(iFileHandle != 0)
        {
            FileWrite(iFileHandle, pData->pucBigImage, pData->uiBigImageLen);
            FileClose(iFileHandle);

            if(FileExists(strBigFile))
            {
                pThis->imgBigImg->Picture->LoadFromFile(strBigFile);
            }
        }
     }

     // CIF图
     if(pData->pucCIFImage != NULL && pData->uiCIFImageLen > 0)
     {
        strPath = pThis->strImagePath + strIP + "\\CIF图\\" + dataTime.FormatString("yyyymmdd") + "\\";
        pThis->CreateDirectoryRecurrent(strPath);
        strCifFile = Format("%s%s%03d(%s).jpg", ARRAYOFCONST((strPath, dataTime.FormatString("hhmmss"), tm.wMilliseconds, strPlate)));
        iFileHandle = FileCreate(strCifFile);
        if(iFileHandle != 0)
        {
            FileWrite(iFileHandle, pData->pucCIFImage, pData->uiCIFImageLen);
            FileClose(iFileHandle);

            if(FileExists(strCifFile))
            {
                pThis->imgCIFImg->Picture->LoadFromFile(strCifFile);
            }
        }
     }
     // 车牌图
     if(pData->pucPlateImage != NULL && pData->uiPlateImageLen > 0)
     {
        strPath = pThis->strImagePath + strIP + "\\车牌图\\" + dataTime.FormatString("yyyymmdd") + "\\";
        pThis->CreateDirectoryRecurrent(strPath);
        strPlateFile = Format("%s%s%03d(%s).jpg", ARRAYOFCONST((strPath, dataTime.FormatString("hhmmss"), tm.wMilliseconds, strPlate)));
        iFileHandle = FileCreate(strPlateFile);
        if(iFileHandle != 0)
        {
            FileWrite(iFileHandle, pData->pucPlateImage, pData->uiPlateImageLen);
            FileClose(iFileHandle);
        }

        if(FileExists(strPlateFile))
        {
            pThis->imgPlateImg->Picture->LoadFromFile(strPlateFile);
        }
     }

     // 车牌号码
     pThis->ShowPlate(strPlate, nColor);

}
Example #17
0
String TDTToCanonical( TDateTime d )
{
   String s = d.FormatString( "yyyymmddhhnn" );
   return s;
}
//---------------------------------------------------------------------------
void TGJVQSOEditFrame::selectEntry( BaseContact *slct )
{
   selectedContact = slct;   // contact from log list selected

   FirstUnfilledButton->Visible = false;
   CatchupButton->Visible = false;

   screenContact.copyFromArg( *slct );
   showScreenEntry();

   PriorButton->Enabled = getPriorContact();
   NextButton->Enabled = getNextContact();
   InsertAfterButton->Enabled = getNextContact();  // dont allow insert after last contact

   MainOpComboBox->Text = screenContact.op1.c_str();
   SecondOpComboBox->Text = screenContact.op2.c_str();
   if ( !contest->isReadOnly() && (screenContact.contactFlags & TO_BE_ENTERED || catchup))
   {
      // Uri Mode - catchuping QSOs from paper while logging current QSOs
      // and we need to set the date/time from the previous contact
      TimeEdit->ReadOnly = false;
      DateEdit->ReadOnly = false;

      int tne = screenContact.time.notEntered(); // partial dtg will give +fe
      // full dtg gives -ve, none gives 0
      if ( tne == 0 )
      {
         BaseContact * pct = getPriorContact();
         if ( pct )
         {
            screenContact.time = pct->time;
            DateEdit->Text = screenContact.time.getDate( DTGDISP ).c_str();
            TimeEdit->Text = screenContact.time.getTime( DTGDISP ).c_str();
         }
         else
         {
            // use contest start time
            TDateTime DTGStart = CanonicalToTDT(contest->DTGStart.getValue().c_str());
            DateEdit->Text = DTGStart.FormatString("dd/mm/yy");
            TimeEdit->Text = DTGStart.FormatString("hh:nn");
            dtg time(false);
            time.setDate( DateEdit->Text.c_str(), DTGDISP );
            time.setTime( TimeEdit->Text.SubString(1, 5).c_str(), DTGDISP );
            screenContact.time = time;
         }
         int selpt = DateEdit->Text.Length();
         if ( selpt > 2 )
         {
            DateEdit->SelStart = 1;
            DateEdit->SelLength = 1;
         }

         selpt = TimeEdit->Text.Length();
         if ( selpt > 0 )
         {
            TimeEdit->SelStart = selpt - 1;
            TimeEdit->SelLength = 1;
         }
      }
   }
   else
   {
      TimeEdit->ReadOnly = true;
      DateEdit->ReadOnly = true;
   }
   SerTXEdit->ReadOnly = true;

   bool timeOK = false;
   int tne = screenContact.time.notEntered(); // partial dtg will give +fe
   // full dtg gives -ve, none gives 0

   if (tne < 0)
   {
      dtg time(false);
      time.setDate( DateEdit->Text.c_str(), DTGDISP );
      time.setTime( TimeEdit->Text.SubString(1, 5).c_str(), DTGDISP );

      timeOK = contest->checkTime(time);
   }

//   DateEdit->Font->Assign(MinosParameters::getMinosParameters() ->getSysFont());
//   TimeEdit->Font->Assign(MinosParameters::getMinosParameters() ->getSysFont());
   if (timeOK)
   {
      DateEdit->Font->Color = clWindowText;
      TimeEdit->Font->Color = clWindowText;
   }
   else
   {
      DateEdit->Font->Color = clRed;
      TimeEdit->Font->Color = clRed;
   }

   MinosLoggerEvents::SendAfterSelectContact(catchup?0:slct, contest);
   selectField( 0 );
}
Example #19
0
//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;
	}
}
Example #20
0
void __fastcall TReportForm::ToolButton3Click(TObject *Sender)
{

  Variant WordApp, WordSel, WordDoc, EmptyParam, table, cell, range;
  TDateTime dtReport = Date();
  UnicodeString s=ExtractFileDir(Application->ExeName)+"\\template.doc";

  if (!FileExists(s)) {
	ShowMessage("Файл шаблона не найден");
	return;
  }

  TVirtualNode *t_root=VirtualStringTree1->RootNode->FirstChild;
  TVirtualNode *t_child;
  TReportData *data_root, *data_child;

  try {
	WordApp=GetActiveOleObject("Word.Application");
  } catch (...) {
	try {
	  WordApp=CreateOleObject("Word.Application");

	} catch (...) {
	  ShowMessage("Microsoft Word не установлен");
	  return;
	}
  }



  try {
	WordApp.OlePropertySet("Visible", false);
	WordDoc=WordApp.OlePropertyGet("Documents").OleFunction("Add", s.t_str());


//	if (WordDoc.OlePropertyGet("Bookmarks").OleFunction("Exists", "date"))
//	  ShowMessage("!");

//	WordDoc.OleFunction("GoTo", 0xFFFFFFFF, EmptyParam, EmptyParam, "date").OleFunction("Select");
	WordApp.OlePropertyGet("Selection").OleFunction("goto", 0xFFFFFFFF, EmptyParam, EmptyParam, "date");
	WordApp.OlePropertyGet("Selection").OleProcedure("TypeText", dtReport.FormatString("dd.mm.yyyy").t_str());
	WordApp.OlePropertyGet("Selection").OleFunction("goto", 0xFFFFFFFF, EmptyParam, EmptyParam, "img");
	MainForm->Chart5->CopyToClipboardMetafile(true);
	WordApp.OlePropertyGet("Selection").OleFunction("Paste");


	WordApp.OlePropertyGet("Selection").OleFunction("goto", 0xFFFFFFFF, EmptyParam, EmptyParam, "table");

//	table=WordDoc.OlePropertyGet("Tables").OleFunction("Item", 1);
//	cell=table.OleFunction("Cell", 1, 1);
//	range=cell.OlePropertyGet("Range");
//	range.OlePropertySet("Text", "F**k");
	for (size_t i=0; i < VirtualStringTree1->RootNodeCount; i++) {
	  if (!(t_root == NULL)) {
		data_root=(TReportData *)ReportForm->VirtualStringTree1->GetNodeData(t_root);
		if (!(data_root == NULL)) {
		  s=data_root->Name;
		  WordApp.OlePropertyGet("Selection").OleProcedure("TypeText", s.t_str());
		  WordApp.OlePropertyGet("Selection").OleFunction("MoveRight", 12);
		  WordApp.OlePropertyGet("Selection").OleFunction("MoveRight", 12);
		  WordApp.OlePropertyGet("Selection").OleFunction("MoveRight", 12);
		  WordApp.OlePropertyGet("Selection").OleFunction("MoveRight", 12);
		}
		else
		  continue;

		t_child=t_root->FirstChild;
		while (!(t_child == NULL))
		{
		  data_child=(TReportData *)ReportForm->VirtualStringTree1->GetNodeData(t_child);
		  if (!(data_child == NULL) && (t_child->CheckState == csCheckedNormal)) {
			s=data_child->Name;
			WordApp.OlePropertyGet("Selection").OleProcedure("TypeText", s.t_str());
			WordApp.OlePropertyGet("Selection").OleFunction("MoveRight", 12);
			WordApp.OlePropertyGet("Selection").OleProcedure("TypeText",  FloatToStrF(data_child->pcs, ffFixed, 5, 2).t_str());
			WordApp.OlePropertyGet("Selection").OleFunction("MoveRight", 12);
			WordApp.OlePropertyGet("Selection").OleProcedure("TypeText",  FloatToStrF(data_child->pi, ffFixed, 5, 2).t_str());
			WordApp.OlePropertyGet("Selection").OleFunction("MoveRight", 12);
			WordApp.OlePropertyGet("Selection").OleProcedure("TypeText",  FloatToStr(data_child->angle).t_str());
			WordApp.OlePropertyGet("Selection").OleFunction("MoveRight", 12);
		  }
		  t_child=t_child->NextSibling;
		}
		WordApp.OlePropertyGet("Selection").OlePropertyGet("Font").OlePropertySet("Bold", true);
		WordApp.OlePropertyGet("Selection").OlePropertyGet("ParagraphFormat").OlePropertySet("Alignment", 0);
		WordApp.OlePropertyGet("Selection").OleProcedure("TypeText", "Средний диаметр");
		WordApp.OlePropertyGet("Selection").OleFunction("MoveRight", 12);
		WordApp.OlePropertyGet("Selection").OlePropertyGet("Font").OlePropertySet("Bold", false);
		WordApp.OlePropertyGet("Selection").OlePropertyGet("ParagraphFormat").OlePropertySet("Alignment", 1);
		s=FloatToStrF(data_root->pcs, ffFixed, 5, 2)+" нм.";
		WordApp.OlePropertyGet("Selection").OleProcedure("TypeText",  s.t_str());
		WordApp.OlePropertyGet("Selection").OleFunction("MoveRight", 12);
		WordApp.OlePropertyGet("Selection").OleFunction("MoveRight", 12);
		WordApp.OlePropertyGet("Selection").OleFunction("MoveRight", 12);
		WordApp.OlePropertyGet("Selection").OleProcedure("TypeText", "Средний ППД");
		WordApp.OlePropertyGet("Selection").OleFunction("MoveRight", 12);
		WordApp.OlePropertyGet("Selection").OleProcedure("TypeText",  FloatToStrF(data_root->pi, ffFixed, 5, 2).t_str());
		WordApp.OlePropertyGet("Selection").OleFunction("MoveRight", 12);
		WordApp.OlePropertyGet("Selection").OleFunction("MoveRight", 12);
		WordApp.OlePropertyGet("Selection").OleFunction("MoveRight", 12);
		WordApp.OlePropertyGet("Selection").OleProcedure("TypeText", "СКО");
		WordApp.OlePropertyGet("Selection").OleFunction("MoveRight", 12);
		s=FloatToStrF(data_root->rms, ffFixed, 5, 2)+" нм.";
		WordApp.OlePropertyGet("Selection").OleProcedure("TypeText",  s.t_str());
		WordApp.OlePropertyGet("Selection").OleFunction("MoveRight", 12);
		WordApp.OlePropertyGet("Selection").OleFunction("MoveRight", 12);
		if (!(i == (VirtualStringTree1->RootNodeCount-1))) {
		  WordApp.OlePropertyGet("Selection").OleFunction("MoveRight", 12);
		  WordApp.OlePropertyGet("Selection").OlePropertyGet("Font").OlePropertySet("Bold", false);
		  WordApp.OlePropertyGet("Selection").OlePropertyGet("ParagraphFormat").OlePropertySet("Alignment", 1);
		}
	  }
	  t_root=t_root->NextSibling;
	}




	/*

	for (int i=0; i < 100; i++) {
	  WordApp.OlePropertyGet("Selection").OleProcedure("TypeText", "F**k");
	  WordApp.OlePropertyGet("Selection").OleFunction("MoveRight", 12);
	}
	  */

	/*WordApp.OlePropertyGet("Selection").OlePropertyGet("ParagraphFormat").OlePropertySet("Alignment", 1);
	WordApp.OlePropertyGet("Selection").OlePropertyGet("Font").OlePropertySet("Bold", true);
	WordApp.OlePropertyGet("Selection").OleProcedure("TypeText", "Протокол измерений");
	WordApp.OlePropertyGet("Selection").OleProcedure("TypeParagraph");
	WordApp.OlePropertyGet("Selection").OleProcedure("TypeParagraph");
	WordApp.OlePropertyGet("Selection").OlePropertyGet("ParagraphFormat").OlePropertySet("Alignment", 0);
	WordApp.OlePropertyGet("Selection").OlePropertyGet("Font").OlePropertySet("Bold", false);
	WordApp.OlePropertyGet("Selection").OleProcedure("TypeText", dtReport.FormatString("dd.mm.yyyy").t_str());
	WordApp.OlePropertyGet("Selection").OleProcedure("TypeParagraph");
	WordApp.OlePropertyGet("Selection").OleProcedure("TypeParagraph");
	WordApp.OlePropertyGet("Tables").OlePropertySet("Add", 3, 3);
	 */
  }
  __finally{
    WordApp.OlePropertySet("Visible", true);
	WordApp=Unassigned();
  }

}
Example #21
0
void __fastcall TReportForm::ToolButton6Click(TObject *Sender)
{
	Variant ExcelApp, ExcelBooks, Book, WorkSheet, Cells, EmptyParam;
	TDateTime dtReport = Date();
	UnicodeString s=ExtractFileDir(Application->ExeName)+"\\template.xls";

	if (!FileExists(s))
	{
		ShowMessage("Файл шаблона не найден");
		return;
	}

	TVirtualNode *t_root=VirtualStringTree1->RootNode->FirstChild;
	TVirtualNode *t_child;
	TReportData *data_root, *data_child;

	try
	{
		ExcelApp = GetActiveOleObject("Excel.Application");
		ExcelBooks = ExcelApp.OlePropertyGet("WorkBooks");
	}
	catch (...)
	{
		try
		{
			ExcelApp = CreateOleObject("Excel.Application");
			ExcelBooks = ExcelApp.OlePropertyGet("WorkBooks");

		}
		catch (...)
		{
		  ShowMessage("Microsoft Excel не установлен");
		return;
		}
	}

	int i = 27;
	int j = 2;
	TFormatSettings format_settings;
	GetLocaleFormatSettings(LOCALE_SYSTEM_DEFAULT, format_settings);
	format_settings.DecimalSeparator = ',';

	try
	{
    	ExcelApp.OlePropertySet("Visible", false);
		Book = ExcelBooks.OleFunction("Add", s.t_str());
		WorkSheet = Book.OlePropertyGet("Worksheets").OlePropertyGet("Item", 1);
		Cells = WorkSheet.OlePropertyGet("Cells");
		Cells.OlePropertyGet("Item",4,3).OlePropertySet("Value", dtReport.FormatString("dd.mm.yyyy").t_str());
		Cells.OlePropertyGet("Item",8,1).OleProcedure("Select");
		MainForm->Chart5->CopyToClipboardMetafile(true);
		WorkSheet.OleProcedure("Paste");
		Variant shapes = WorkSheet.OlePropertyGet("Shapes").OleFunction("Item", 1);
		shapes.OleFunction("ScaleWidth", 0.9, EmptyParam, EmptyParam);
		shapes.OleFunction("ScaleHeight", 0.9, EmptyParam, EmptyParam);


		for (size_t k=0; k < VirtualStringTree1->RootNodeCount; k++)
		{
			if (t_root)
			{
				data_root = (TReportData *)ReportForm->VirtualStringTree1->GetNodeData(t_root);
				if (data_root)
				{
					s=data_root->Name;
					Cells.OlePropertyGet("Item",i,j).OlePropertySet("Value", s.t_str());
					i++;
				}


				t_child=t_root->FirstChild;
				while (t_child)
				{
					data_child=(TReportData *)ReportForm->VirtualStringTree1->GetNodeData(t_child);
					if (data_root)
					{
						s=data_child->Name;
						Cells.OlePropertyGet("Item",i,j).OlePropertySet("Value", s.t_str());
						Cells.OlePropertyGet("Item",i,j+1).OlePropertySet("Value", FloatToStrF(data_child->pcs, ffFixed, 5, 2, format_settings).t_str());
						Cells.OlePropertyGet("Item",i,j+2).OlePropertySet("Value", FloatToStrF(data_child->pi, ffFixed, 5, 2, format_settings).t_str());
						Cells.OlePropertyGet("Item",i,j+3).OlePropertySet("Value", FloatToStrF(data_child->angle, ffFixed, 5, 2,format_settings).t_str());
						i++;

					}
					t_child = t_child->NextSibling;
				}

				Cells.OlePropertyGet("Item",i,j).OlePropertySet("Value", "Средний диаметр");
				Cells.OlePropertyGet("Item",i,j).OlePropertyGet("Font").OlePropertySet("Bold", true);
				Cells.OlePropertyGet("Item",i,j+1).OlePropertySet("Value", FloatToStrF(data_root->pcs, ffFixed, 5, 2, format_settings).t_str());
				i++;
				Cells.OlePropertyGet("Item",i,j).OlePropertySet("Value", "Средний ПДД");
				Cells.OlePropertyGet("Item",i,j).OlePropertyGet("Font").OlePropertySet("Bold", true);
				Cells.OlePropertyGet("Item",i,j+1).OlePropertySet("Value", FloatToStrF(data_root->pi, ffFixed, 5, 2, format_settings).t_str());
				i++;
				Cells.OlePropertyGet("Item",i,j).OlePropertySet("Value", "СКО");
				Cells.OlePropertyGet("Item",i,j).OlePropertyGet("Font").OlePropertySet("Bold", true);
				Cells.OlePropertyGet("Item",i,j+1).OlePropertySet("Value", FloatToStrF(data_root->rms, ffFixed, 5, 2, format_settings).t_str());
				i++;
			}

			t_root=t_root->NextSibling;
		}
	}
	__finally
	{
		ExcelApp.OlePropertySet("Visible", true);
		ExcelApp=Unassigned();
	}

}
Example #22
0
//---------------------------------------------------------------------------
void __fastcall TFormLog::ButtonLogClick(TObject *Sender)
{
        if(EditQRZ->Text=="") return;

        int H;
        AnsiString LogName = ThePath + "\\stream.adi";

        if(FileExists(LogName))
        {
           H = FileOpen(LogName,fmOpenReadWrite);
           if(H<0)
           {
              Application->MessageBox("Cannot write to log","IZ8BLY PSK31 Lab",MB_OK | MB_ICONSTOP);
              return;
           }
           FileSeek(H,0,2);
        }
        else
        {
           H = FileCreate(LogName);
           if(H<0)
           {
              Application->MessageBox("Cannot write to log","IZ8BLY PSK31 Lab",MB_OK | MB_ICONSTOP);
              return;
           }
           FileWriteString(H,"Created by IZ8BLY PSK31 Lab\r\n<EOH>\r\n");
        }

        AnsiString Linea;

        TDateTime TD;
        if(UTCTimeLog)
        {
           SYSTEMTIME SystemTime;
           GetSystemTime(&SystemTime);
           TD = SystemTimeToDateTime(SystemTime);
        }
        else
        {
           TD = TDateTime().CurrentDateTime();
        }

        Linea = FormatAdif("CALL",EditQRZ->Text) +
                FormatAdif("NAME",EditName->Text)+
                FormatAdif("QTH",EditQTH->Text)+
                FormatAdif("RST_RCVD",EditRSTReceived->Text)+
                FormatAdif("RST_SENT",EditRSTSent->Text)+
                FormatAdif("FREQ",EditFrequency->Text)+
                FormatAdif("MODE","STREAM")+
                FormatAdif("QSO_DATE",TD.FormatString("yyyymmdd"))+
                FormatAdif("TIME_ON",TD.FormatString("hhmm"))+
                FormatAdif("COMMENT",EditComments->Text)+
                "<EOR>\r\n";

        FileWriteString(H,Linea);
        FileClose(H);

        char oldclip[2048];
        Clipboard()->GetTextBuf(oldclip,2048);

        Clipboard()->SetTextBuf(Linea.c_str());
        SendMessage(HWND_BROADCAST,IZ8BLY,0,0);
        Clipboard()->SetTextBuf(oldclip);

        ButtonLog->Enabled = false;
}
//---------------------------------------------------------------------------
__fastcall TCalendarForm::TCalendarForm( TComponent* Owner )
      : TForm( Owner ), vhf(2000)
{
   TDateTime tnow = TDateTime::CurrentDateTime();
   YearEdit->Text = tnow.FormatString("yyyy");
}
//---------------------------------------------------------------------------
void TGJVQSOEditFrame::selectEntry( BaseContact *lct )
{
   selectedContact = lct;   // contact from log list selected

   if (contest->unfilledCount <= 0)
   {
      FirstUnfilledButton->Visible = false;
   }
   else
   {
      FirstUnfilledButton->Visible = true;
   }
   updateTimeAllowed = false;   // whatever the time says, leave it alone

   screenContact.copyFromArg( *lct );
   showScreenEntry();
   if ( !contest->isReadOnly() && (screenContact.contactFlags & TO_BE_ENTERED || catchup))
   {
      // Uri Mode - catchuping QSOs from paper while logging current QSOs
      // and we need to set the date/time from the previous contact
      TimeEdit->ReadOnly = false;
      DateEdit->ReadOnly = false;

      int tne = screenContact.time.notEntered(); // partial dtg will give +fe
      // full dtg gives -ve, none gives 0
      if ( tne == 0 )
      {
         BaseContact * lct = getPriorContact();
         if ( lct )
         {
            screenContact.time = lct->time;
            DateEdit->Text = screenContact.time.getDate( DTGDISP ).c_str();
            TimeEdit->Text = screenContact.time.getTime( DTGDISP ).c_str();
         }
         else
         {
            // use contest start time
            TDateTime DTGStart = CanonicalToTDT(contest->DTGStart.getValue().c_str());
            DateEdit->Text = DTGStart.FormatString("dd/mm/yy");
            TimeEdit->Text = DTGStart.FormatString("hh:nn");
            dtg time(false);
            time.setDate( DateEdit->Text.c_str(), DTGDISP );
            time.setTime( TimeEdit->Text.SubString(1, 5).c_str(), DTGDISP );
            screenContact.time = time;
         }
         int selpt = DateEdit->Text.Length();
         if ( selpt > 2 )
         {
            DateEdit->SelStart = 1;
            DateEdit->SelLength = 1;
         }

         selpt = TimeEdit->Text.Length();
         if ( selpt > 0 )
         {
            TimeEdit->SelStart = selpt - 1;
            TimeEdit->SelLength = 1;
         }
      }
   }
   else
   {
      TimeEdit->ReadOnly = true;
      DateEdit->ReadOnly = true;
   }
   SerTXEdit->ReadOnly = true;

   bool timeOK = false;
   int tne = screenContact.time.notEntered(); // partial dtg will give +fe
   // full dtg gives -ve, none gives 0

   if (tne < 0)
   {
      dtg time(false);
      time.setDate( DateEdit->Text.c_str(), DTGDISP );
      time.setTime( TimeEdit->Text.SubString(1, 5).c_str(), DTGDISP );

      timeOK = contest->checkTime(time);
   }

   if (timeOK)
   {
      DateEdit->Font->Color = clWindowText;
      TimeEdit->Font->Color = clWindowText;
   }
   else
   {
      DateEdit->Font->Color = clRed;
      TimeEdit->Font->Color = clRed;
   }

   editScreen->afterSelectEntry( lct );
   selectField( 0 );
}