Exemplo n.º 1
0
void __fastcall TForm1::FormCreate(TObject *Sender)
{
    //адреса гридов заносятся в соответственные им панели
    //чтобы потом при ресайзе изменять кол-во строк
    //в процедуре amb_panelResize
    dop_panel->Tag=(int)dop_grd;
    man_panel->Tag=(int)man_grd;
    prep_panel->Tag=(int)prep_grd;
    sales_panel->Tag=(int)sales_grd;
    std_panel->Tag=(int)std_grd;

    vdop_panel->Tag=(int)vdop_grd;
    vman_panel->Tag=(int)vman_grd;
    vprep_panel->Tag=(int)vprep_grd;
    vsales_panel->Tag=(int)vsales_grd;
    vstd_panel->Tag=(int)vstd_grd;

    tmr->Enabled=true;
    table->Last();
    table->Refresh();
    vact->Last();
    vact->Refresh();
    //предыдущий месяц
    USHORT y,m,d;
    TDate x=Date();
    x.DecodeDate(&y,&m,&d);
    x=EncodeDate(y,m,1);
    x--;
    do_date->Date=x;
    x.DecodeDate(&y,&m,&d);
    x=EncodeDate(y,m,1);
    ot_date->Date=x;

    WindowState=wsMaximized;
}
Exemplo n.º 2
0
int CDate::CompareDates(const CString& First, const CString& Second) {
  struct tm FirstDate;
  EncodeDate(First, FirstDate);
  struct tm SecondDate;
  EncodeDate(Second, SecondDate);
  time_t Time1 = mktime(&FirstDate);
  time_t Time2 = mktime(&SecondDate);
  return Time1 - Time2;
}
Exemplo n.º 3
0
TDateTime SystemTimeToDateTime(const SYSTEMTIME & SystemTime)
{
  TDateTime Result(0.0);
  Result = ComposeDateTime(EncodeDate(SystemTime.wYear, SystemTime.wMonth, SystemTime.wDay),
    EncodeTime(SystemTime.wHour, SystemTime.wMinute, SystemTime.wSecond, SystemTime.wMilliseconds));
  return Result;
}
Exemplo n.º 4
0
//---------------------------------------------------------------------------
__fastcall TQueryCustDlg::TQueryCustDlg(TComponent* Owner)
	: TForm(Owner)
{
  Msglab->Caption = "Customers with LastInvoiceDate ranging:";
  FromDate = EncodeDate(1995, 01, 01);
  ToDate = Now();
}
Exemplo n.º 5
0
//---------------------------------------------------------------------------
TDateTime Now()
{
  TDateTime Result(0.0);
  SYSTEMTIME SystemTime;
  ::GetLocalTime(&SystemTime);
  Result = EncodeDate(SystemTime.wYear, SystemTime.wMonth, SystemTime.wDay) +
    EncodeTime(SystemTime.wHour, SystemTime.wMinute, SystemTime.wSecond, SystemTime.wMilliseconds);
  return Result;
}
Exemplo n.º 6
0
TDateTime IncMonth(const TDateTime & AValue, const Int64 NumberOfMonths)
{
  TDateTime Result;
  Word Year, Month, Day;
  DecodeDate(AValue, Year, Month, Day);
  IncAMonth(Year, Month, Day, NumberOfMonths);
  Result = EncodeDate(Year, Month, Day);
  ReplaceTime(Result, AValue);
  return Result;
}
Exemplo n.º 7
0
bool CDate::EncodeDate(const CString& DateString, struct tm& Result) {
  // date format: Fri, 16 Jul 1999 15:35:06 GMT
  if (!EncodeDate(DateString, g_strHttpCookieScanDateFormat, Result)) {
    time_t TimeT;
    time(&TimeT);
    base_localtime(TimeT, Result);
    return false;
  }
  return true;
}
Exemplo n.º 8
0
//---------------------------------------------------------------------------
void __fastcall TDBDemoMainForm::FormCreate(TObject *Sender)
{
  TDemoBasicMainForm::FormCreate(Sender);
  mdEvents->LoadFromBinaryFile("..\\..\\Data\\cxSchedulerEvents.dat");
  mdEvents->Open();
  Scheduler->GoToDate(EncodeDate(2005, 9, 20));
  FEventCount = SchedulerDBStorage->EventCount;
  FMaxID = 0;
  for (int i = 0; i < SchedulerDBStorage->EventCount; i++)
	FMaxID = Max(FMaxID, SchedulerDBStorage->Events[i]->ID);
}
Exemplo n.º 9
0
//---------------------------------------------------------------------------
bool __fastcall TSfgClientLicence::LicenceValidFile()
{
   String sMsgError;
   char ErrorMsg[255];

   if (AppLicence->CodCliente.Length() != SFG_SIZE_CODCLI) {
      sMsgError = "Não foi passado o código do cliente ou o mesmo não está no formato correto." \
                  "\nVerifique a sessão [LicenceClient] do arquivo de conexão.";
      MessageBox(NULL,sMsgError.c_str(),"Arquivo de Licenças",APP_ERROR);
      return false;
   }
   //Deve verificar se o arquivo de licenças está OK
   if (!SfgLoadLicenceFile(ErrorMsg)) {
      sMsgError = "O sistema está parametrizado para utilizar arquivo de licença local.\n" \
                  "Porém ocorreu o seguinte problema ao carregar o arquivo de licenças:\n";
      sMsgError += ErrorMsg;
      MessageBox(NULL,sMsgError.c_str(),"Arquivo de Licenças",APP_ERROR);
      return false;
   }
   if (AppLicence->CodCliente != CodCliente) {
      sMsgError = "O arquivo de licenças encontrado não é valido para o código de cliente informado." \
                  "\nVerifique a sessão [LicenceClient] do arquivo de conexão.";
      MessageBox(NULL,sMsgError.c_str(),"Arquivo de Licenças",APP_ERROR);
      return false;
   }
   AppLicence->DenCliente = DenCliente;
   AppLicence->IdLicence = SerialLic;
   AppLicence->NumLicence = NumberLic;
   int iYear, iMonth, iDay;
   iYear = HIWORD(ValidadeLic);
   iMonth = HIBYTE(LOWORD(ValidadeLic));
   iDay = LOBYTE(LOWORD(ValidadeLic));
try {
   AppLicence->Validade = EncodeDate(iYear,iMonth,iDay);
} catch(...) {
   AppLicence->Validade = 0;
}
   if ((int)AppLicence->Validade == 0) {
      MessageBox(NULL,"Não foi possível determinar a validade da licença de uso do sistema!","Arquivo de Licenças",APP_ERROR);
      return false;
   }
   if (AppLicence->Validade < Date()) {
      sMsgError = "O arquivo de licenças encontrado está com a validade expirada. Validade: " + FormatDateTime("dd/mm/yyyy",AppLicence->Validade);
      MessageBox(NULL,sMsgError.c_str(),"Arquivo de Licenças",APP_ERROR);
      return false;
   }
   return true;
}
Exemplo n.º 10
0
// ---------------------------------------------------------------------------
void __fastcall TStdDataForm::FormCreate(TObject *Sender) {
	FLastDate = EncodeDate(2010, 1, 1);
	FLastAmount = 1000;
	FilterOnRadioGroup->ItemIndex = 0;
}
Exemplo n.º 11
0
//---------------------------------------------------------------------------
bool __fastcall TSfgClientLicence::LicenceAddClient()
{
   //NxNNNNNNNN -> PID do processo client no formato Hexadecimal
   //NxNNNNNNNN -> Identificador da mensagem no formato Hexadecimal
   //NNNC[N] -> Tamanho seguido da string de caracteres que indicam o usuário do sistema operacional
   //NNNC[N] -> Tamanho seguido da string de caracteres que indicam o usuário do sistema SFG

   String sMsgError;
   //Deve calcular o tamanho da mensagem que deve enviar
   int iSfgUser = AppUser->Usuario.Length();

   //Se nunca enviou uma mensagem deve pré-alocar a memória
   if (AppLicenceSvr->MsgBuffer == NULL) {
      AppLicenceSvr->MsgBuffer = (char*)HeapAlloc(GetProcessHeap(),0,(SFG_MAX_SIZE_MSG+1)*sizeof(char));
   }

   //Zerando o buffer, caso tenha alguma mensagem
   ZeroMemory(AppLicenceSvr->MsgBuffer,(SFG_MAX_SIZE_MSG+1)*sizeof(char));
   //Formatando a mensagem para o servidor de licenças
   wsprintf(AppLicenceSvr->MsgBuffer,
            SfgAddClientMsg,
            GetCurrentProcessId(),
            SFG_ADD_CLIENT,
            FOSUserNameLenght,
            FOSUserName,
            iSfgUser,
            AppUser->Usuario.c_str());

   //Se não puder adicionar um cliente também retorna
   if (!LicenceSendRecvMsg(SFG_ADD_CLIENT,sMsgError)) {
      SfgDataCenter->CloseClientSocket();
      MessageBox(NULL,sMsgError.c_str(),"Servidor de Licenças",APP_ERROR);
      return false;
   }
   //Deve recuperar as informações sobre a licença
   //Mensagem de retorno deve enviar o código do identificador, número de licenças, validade, cliente e denominação
   char Info[100];
   int iNumber;
   //Identificador
   for (int i=0;i<16;i++)
      Info[i] = AppLicenceSvr->MsgBuffer[i+20];
   Info[16] = '\0';
   AppLicence->IdLicence = Info;
   //Número de licenças
   for (int i=0;i<10;i++)
      Info[i] = AppLicenceSvr->MsgBuffer[i+36];
   Info[10] = '\0';
   sscanf( Info, "%i", &iNumber );
   AppLicence->NumLicence = iNumber;
   //Validade
   for (int i=0;i<10;i++)
      Info[i] = AppLicenceSvr->MsgBuffer[i+46];
   Info[10] = '\0';
   sscanf( Info, "%i", &iNumber );
   int iYear, iMonth, iDay;
   iYear = HIWORD(iNumber);
   iMonth = HIBYTE(LOWORD(iNumber));
   iDay = LOBYTE(LOWORD(iNumber));
try {
   AppLicence->Validade = EncodeDate(iYear,iMonth,iDay);
} catch(...) {
   AppLicence->Validade = 0;
}
   //Código do cliente
   for (int i=0;i<15;i++)
      Info[i] = AppLicenceSvr->MsgBuffer[i+56];
   Info[15] = '\0';
   AppLicence->CodCliente = Info;
   //Denominação do cliente
   for (int i=0;i<3;i++)
      Info[i] = AppLicenceSvr->MsgBuffer[i+71];
   Info[3] = '\0';
   iNumber = atoi(Info);
   for (int i=0;i<iNumber;i++)
      Info[i] = AppLicenceSvr->MsgBuffer[i+74];
   Info[iNumber] = '\0';
   AppLicence->DenCliente = Info;

   //Criando o evento que será responsável por sinalizar o fim da aplicação para as threads
   AppEndSignEvent = CreateEvent(NULL,true,false,NULL);
   //Criando o semáforo que será responsável por controlar a comunicação do Socket
   AppSocketSemaphore = CreateSemaphore(NULL,1,1,NULL);
   //Criando Thread que será responsável por sinalizar ao servidor de licenças
   AppSignLicence = new TSfgSignLicence(false);

   return true;
}