//--------------------------------------------------------------------------- void __fastcall TObf1003::btOKClick(TObject *Sender) { TZQuery *QyImport; String sDateTime; if (num_pedido_venda == 0) { MessageBox(Handle,"Selecione ao menos um pedido para importação!",Caption.c_str(),APP_INFORM); return; } QyPedidoVenda->DisableControls(); QyPedidoVenda->First(); //Deve validar se foi informado a natureza de operação para importação while (!QyPedidoVenda->Eof) { if (QyPedidoVenda->FieldByName("importado")->AsString == "S") { if (QyPedidoVenda->FieldByName("natureza_operacao")->AsInteger == 0) { MessageBox(Handle,"Não foi informado a natureza de operação!",Caption.c_str(),APP_INFORM); ListItens->SelectedField = QyPedidoVenda->FieldByName("natureza_operacao"); QyPedidoVenda->EnableControls(); return; } } QyPedidoVenda->Next(); } QyImport = new TZQuery(Application); QyImport->Connection = AppConnection; pnProgress->Show(); ProgressImport->Max = num_pedido_venda; Application->ProcessMessages(); QyPedidoVenda->First(); while (!QyPedidoVenda->Eof) { if (QyPedidoVenda->FieldByName("importado")->AsString == "S") { if (!SfgDataCenter->StartTrans()) { MessageBox(Handle,"Erro ao iniciar uma transação no banco de dados", "Mensagem de Erro", APP_ERROR); break; } try { DateTimeToString(sDateTime, "yyyy-mm-dd hh:nn:ss", Now()); QyImport->SQL->Text = "CALL fatura_pedido_venda(" \ + QyPedidoVenda->FieldByName("cod_pedido_venda")->AsString + "," \ + QuotedStr(AppUser->CodEmpresa) + "," \ + QyPedidoVenda->FieldByName("natureza_operacao")->AsString + "," \ + QuotedStr(AppUser->Usuario) + "," \ + QuotedStr(sDateTime) + ");"; QyImport->ExecSQL(); SfgDataCenter->CommitTrans(); } catch(Exception &e){ SfgDataCenter->RollbackTrans(); String Msg = "Ocorreu o seguinte erro ao importar o pedido de venda " + QyPedidoVenda->FieldByName("cod_pedido_venda")->AsString + ":\n"; Msg = Msg + e.Message; MessageBox(NULL,Msg.c_str(), "Mensagem de Erro", APP_ERROR); } ProgressImport->StepIt(); Application->ProcessMessages(); } QyPedidoVenda->Next(); } if (AfterImport != NULL) AfterImport(); Close(); }
void HttpServer::setDefaultResponseHeaders(HttpResponseHeader & hdr,const QString & content_type,bool with_session_info) { hdr.setValue("Server","KTorrent/" KT_VERSION_MACRO); hdr.setValue("Date",DateTimeToString(QDateTime::currentDateTime(Qt::UTC),false)); hdr.setValue("Content-Type",content_type); hdr.setValue("Connection","keep-alive"); if (with_session_info && session.sessionId && session.logged_in) { hdr.setValue("Set-Cookie",QString("KT_SESSID=%1").arg(session.sessionId)); } }
LPCSTR TimeDriver::DateTimeToString( const INT64& time) { static char rgBuffer[128]; LPSTR szBuffer = rgBuffer; size_t iBuffer = ARRAYSIZE(rgBuffer); DateTimeToString( time, szBuffer, iBuffer ); return rgBuffer; }
//--------------------------------------------------------------------------- __fastcall TFrListMail::TFrListMail(TComponent* Owner) : TForm(Owner) { DateTimeToString(TempTableName,"yyyymmdd",Now()); TempTableName="#TMP_"+TempTableName+"_"+"_"+IntToStr(PermisHdr.KeyUserStartProgramm)+"_"+IntToStr(PermisHdr.KeyConnect);// Уникальный код подключения; Код текущего пользователя vsSQLTmpTable= "IF(EXISTS (select * from tempdb..sysobjects where id = object_id('tempdb.."+TempTableName+"')))DROP TABLE "+TempTableName+";" "CREATE TABLE "+TempTableName+"( MailPathAddFile varchar(8000) NULL);"; QTmpTable->Close(); QTmpTable->SQL->Clear(); QTmpTable->SQL->Add(vsSQLTmpTable); QTmpTable->ExecSQL(); }
//--------------------------------------------------------------------------- UnicodeString TFileMasks::TParams::ToString() const { return UnicodeString(L"[") + Int64ToStr(Size) + L"/" + DateTimeToString(Modification) + L"]"; }
void HttpServer::handleGet(HttpClientHandler* hdlr,const QHttpRequestHeader & hdr,bool do_not_check_session) { QString file = hdr.path(); if (file == "/") file = "/login.html"; //Out(SYS_WEB|LOG_DEBUG) << "GET " << hdr.path() << endl; KURL url; url.setEncodedPathAndQuery(file); QString path = rootDir + bt::DirSeparator() + WebInterfacePluginSettings::skin() + url.path(); // first check if the file exists (if not send 404) if (!bt::Exists(path)) { HttpResponseHeader rhdr(404); setDefaultResponseHeaders(rhdr,"text/html",false); hdlr->send404(rhdr,path); return; } QFileInfo fi(path); QString ext = fi.extension(); // if it is the login page send that if (file == "/login.html" || file == "/") { session.logged_in = false; ext = "html"; path = rootDir + bt::DirSeparator() + WebInterfacePluginSettings::skin() + "/login.html"; } else if (!session.logged_in && (ext == "html" || ext == "php")) { // for any html or php page, a login is necessary redirectToLoginPage(hdlr); return; } else if (session.logged_in && !do_not_check_session && (ext == "html" || ext == "php")) { // if we are logged in and it's a html or php page, check the session id if (!checkSession(hdr)) { session.logged_in = false; // redirect to login page redirectToLoginPage(hdlr); return; } } if (ext == "html") { HttpResponseHeader rhdr(200); setDefaultResponseHeaders(rhdr,"text/html",true); if (path.endsWith("login.html")) { // clear cookie in case of login page QDateTime dt = QDateTime::currentDateTime().addDays(-1); QString cookie = QString("KT_SESSID=666; expires=%1 +0000").arg(DateTimeToString(dt,true)); rhdr.setValue("Set-Cookie",cookie); } if (!hdlr->sendFile(rhdr,path)) { HttpResponseHeader nhdr(404); setDefaultResponseHeaders(nhdr,"text/html",false); hdlr->send404(nhdr,path); } } else if (ext == "css" || ext == "js" || ext == "png" || ext == "ico" || ext == "gif" || ext == "jpg") { if (hdr.hasKey("If-Modified-Since")) { QDateTime dt = parseDate(hdr.value("If-Modified-Since")); if (dt.isValid() && dt < fi.lastModified()) { HttpResponseHeader rhdr(304); setDefaultResponseHeaders(rhdr,"text/html",true); rhdr.setValue("Cache-Control","max-age=0"); rhdr.setValue("Last-Modified",DateTimeToString(fi.lastModified(),false)); rhdr.setValue("Expires",DateTimeToString(QDateTime::currentDateTime(Qt::UTC).addSecs(3600),false)); hdlr->sendResponse(rhdr); return; } } HttpResponseHeader rhdr(200); setDefaultResponseHeaders(rhdr,ExtensionToContentType(ext),true); rhdr.setValue("Last-Modified",DateTimeToString(fi.lastModified(),false)); rhdr.setValue("Expires",DateTimeToString(QDateTime::currentDateTime(Qt::UTC).addSecs(3600),false)); rhdr.setValue("Cache-Control","private"); if (!hdlr->sendFile(rhdr,path)) { HttpResponseHeader nhdr(404); setDefaultResponseHeaders(nhdr,"text/html",false); hdlr->send404(nhdr,path); } } else if (ext == "php") { bool redirect = false; bool shutdown = false; if (url.queryItems().count() > 0 && session.logged_in) redirect = php_i->exec(url,shutdown); if (shutdown) { // first send back login page redirectToLoginPage(hdlr); QTimer::singleShot(1000,kapp,SLOT(quit())); } else if (redirect) { HttpResponseHeader rhdr(301); setDefaultResponseHeaders(rhdr,"text/html",true); rhdr.setValue("Location",url.encodedPathAndQuery()); hdlr->executePHPScript(php_i,rhdr,WebInterfacePluginSettings::phpExecutablePath(), path,url.queryItems()); } else { HttpResponseHeader rhdr(200); setDefaultResponseHeaders(rhdr,"text/html",true); hdlr->executePHPScript(php_i,rhdr,WebInterfacePluginSettings::phpExecutablePath(), path,url.queryItems()); } } else { HttpResponseHeader rhdr(404); setDefaultResponseHeaders(rhdr,"text/html",false); hdlr->send404(rhdr,path); } }
// --------------------------------------------------------------------------- void __fastcall TFrPrintProductCatalog::Timer1Timer(TObject *Sender) { int i;//, y; int j, k; TcxGridDBBandedColumn *c; // TcxGridBand *b; TLocateOptions Opts; Variant locvalues[1]; UnicodeString SL, SL1, sT1, sT2; TDateTime T1, T2; Timer1->Enabled = false; RzPanel300->Left = (RzSplitter1->Width - RzPanel300->Width) / 2; RzPanel300->Top = (RzSplitter1->Height / 2) - RzPanel300->Height; RzPanel300->Visible = true; RzPanel300->BringToFront(); Repaint(); // ---------------------------- cxGrid1DBBandedTableView1->BeginUpdate(); Q1->DisableControls(); Q1->Close(); cxGrid1DBBandedTableView1->ClearItems(); cxGrid1DBBandedTableView1->Bands->Clear(); cxGrid1DBBandedTableView1->Bands->Add(); Q1->Parameters->Items[0]->Value = cxCheckComboBox2->Value; Q1->Parameters->Items[1]->Value = tmpSqlDDel; /* if(RzCheckBox1->Checked==true)T1=RzDateTimeEdit1->Date;else T1=Now()-365; Q1->Parameters->Items[0]->Value=T1; if(RzCheckBox2->Checked==true)T2=RzDateTimeEdit2->Date;else T2=Now(); Q1->Parameters->Items[1]->Value=T2+1; y=0;if(RzCheckBox21->Checked==true)y=1; Q1->Parameters->Items[2]->Value=y; Q1->Parameters->Items[3]->Value=PermisHdr.KeyUserStartProgramm; */ try { Q1->Open(); } catch (Exception &exception) { Application->ShowException(&exception); RzPanel300->Visible = false; Timer1->Enabled = false; return; } // b = cxGrid1DBBandedTableView1->Bands->Add(); // b = cxGrid1DBBandedTableView1->Bands->Add(); // b = cxGrid1DBBandedTableView1->Bands->Add(); cxGrid1DBBandedTableView1->Bands->Add(); cxGrid1DBBandedTableView1->Bands->Add(); cxGrid1DBBandedTableView1->Bands->Add(); cxGrid1DBBandedTableView1->Bands->Items[0]->Position->BandIndex = -1; cxGrid1DBBandedTableView1->Bands->Items[1]->Position->ColIndex = 0; cxGrid1DBBandedTableView1->Bands->Items[1]->Position->BandIndex = 0; cxGrid1DBBandedTableView1->Bands->Items[1]->Position->ColIndex = 0; cxGrid1DBBandedTableView1->Bands->Items[2]->Position->BandIndex = 1; cxGrid1DBBandedTableView1->Bands->Items[2]->Position->ColIndex = 0; for (/*y = 0,*/ i = 0; i < Q1->FieldCount; i++) { SL1 = Q1->Fields->Fields[i]->FieldName; // if(SL1=="ClientID")continue; if (SL1 == "idInvoices") continue; c = cxGrid1DBBandedTableView1->CreateColumn(); c->Caption = SL1; c->DataBinding->FieldName = Q1->Fields->Fields[i]->FieldName; //ShowMessage(c->DataBinding->FieldName); c->Width = 100; if (SL1 == "Код продукта" || SL1 == "Код ПП" || SL1 == "id продукта" || SL1 == "id ПП" || SL1 == "КПП") { c->Width = 70; c->Options->HorzSizing = false; } if (SL1 == "Название ПП" || SL1 == "Название продукта" || SL1 == "Адрес организации по счету" || SL1 == "Контактное лицо" || SL1 == "Наименование подписного индекса") { c->Width = 320; continue; } if (SL1 == "Тип ПП") { c->Width = 120; c->Options->HorzSizing = false; continue; } if (SL1 == "id продукта" || SL1 == "id ПП" || SL1 == "id ТН" || SL1 == "Год" || SL1 == "НДС") { if (SL1 == "id продукта") { c->Summary->FooterKind = skCount; c->Summary->GroupFooterKind = skCount; } c->Width = 60; c->Options->HorzSizing = false; c->Summary->FooterFormat = "### ### ### ##0"; c->Summary->GroupFooterFormat = "### ### ### ##0"; continue; } if (SL1 == "Дата создания" || SL1 == " ") { c->Width = 120; c->Options->HorzSizing = false; continue; } if (SL1 == "Сумма" || SL1 == "Цена с НДС") { c->Width = 100; c->RepositoryItem = cxEditRepository1CurrencyItem1; c->Options->HorzSizing = false; c->Summary->FooterFormat = "### ### ### ##0.00"; c->Summary->GroupFooterFormat = "### ### ### ##0.00"; continue; } /* if (SL1 == "DeptsFlag") { c->Width=110; c->Caption="Каналы продаж"; c->RepositoryItem = PLFrom; c->Options->HorzSizing=false; continue; } */ if (SL1 == "Каналы продаж") { c->Width=110; c->Options->HorzSizing=false; continue; } if (SL1 == "Актуальность") { c->Width = 70; c->Options->HorzSizing = false; } } //end for cxGrid1DBBandedTableView1->EndUpdate(); DateTimeToString(sT1, "dd.mm.yyyy", RzDateTimeEdit1->Date); DateTimeToString(sT2, "dd.mm.yyyy", RzDateTimeEdit2->Date); cxGrid1DBBandedTableView1->Bands->Items[0]->HeaderAlignmentHorz = taLeftJustify; cxGrid1DBBandedTableView1->Bands->RootItems[0]->Caption = FrPrintProductCatalog->Caption; /* if (RzCheckBox1->Checked) cxGrid1DBBandedTableView1->Bands->RootItems[0]->Caption = cxGrid1DBBandedTableView1->Bands->RootItems[0]->Caption + " с " + sT1; if (RzCheckBox2->Checked) cxGrid1DBBandedTableView1->Bands->RootItems[0]->Caption = cxGrid1DBBandedTableView1->Bands->RootItems[0]->Caption + " по " + sT2; */ cxGrid1DBBandedTableView1->Bands->Items[1]->Caption = ""; cxGrid1DBBandedTableView1->Bands->Items[1]->HeaderAlignmentHorz = taLeftJustify; // if(RzComboBox9->ItemIndex>0) cxGrid1DBBandedTableView1->Bands->Items[1]->Caption=cxGrid1DBBandedTableView1->Bands->Items[1]->Caption+" по руководителю: "+RzComboBox9->Text.Trim(); // if(RzComboBox2->ItemIndex>0) cxGrid1DBBandedTableView1->Bands->Items[1]->Caption=cxGrid1DBBandedTableView1->Bands->Items[1]->Caption+" по менеджеру: "+RzComboBox2->Text.Trim(); // if(RzComboBox2->ItemIndex<1 && RzComboBox9->ItemIndex<1) cxGrid1DBBandedTableView1->Bands->Items[1]->Caption=cxGrid1DBBandedTableView1->Bands->Items[1]->Caption+" по сотрудникам: "+RzMenedger1->Text; if (RzCheckBox21->Checked) { cxGrid1DBBandedTableView1->Bands->Items[1]->Caption = cxGrid1DBBandedTableView1->Bands->Items[1]->Caption + " по изданиям: " + RzEdit21->Text.Trim(); } for (k = 0, j = cxGrid1DBBandedTableView1->ColumnCount, i = 0; i < j; i++) { if (cxGrid1DBBandedTableView1->Columns[i]->DataBinding->FieldName == "ClientID") { cxGrid1DBBandedTableView1->Columns[i]->GroupIndex = -1; cxGrid1DBBandedTableView1->Columns[i]->Index = 0; cxGrid1DBBandedTableView1->Columns[i]->Visible = false; cxGrid1DBBandedTableView1->Columns[i]->Width = 5; k |= 2; if (k == 3) break; } if (cxGrid1DBBandedTableView1->Columns[i]->DataBinding->FieldName == "IDManager") { cxGrid1DBBandedTableView1->Columns[i]->GroupIndex = -1; cxGrid1DBBandedTableView1->Columns[i]->Index = 2; cxGrid1DBBandedTableView1->Columns[i]->Visible = false; cxGrid1DBBandedTableView1->Columns[i]->Width = 5; k |= 2; if (k == 3) break; } } // ---------------------------- RzPanel300->Visible = false; Q1->EnableControls(); }
//返回16字节格式的当前日期时间 "20030602224623" AnsiString f_get_datetime(void) { AnsiString s1; DateTimeToString(s1,"yyyymmddhhnnss",Now()); return s1; }