void __fastcall TDicDeliveryForm::btnPrintClick(TObject *Sender) { if(!dm1->OpenDatabase()) return; AnsiString szSQL="select dd_code as prnID,dd_name as prnName from DicDelivery order by dd_code"; if(!OpenQuery(dm1->sqlPrint,szSQL.c_str())) return; try { TPrnBaseDataForm *pForm; pForm=new TPrnBaseDataForm(this); pForm->txtTitle->Caption="交货方式字典表"; pForm->txtText2->Caption=""; pForm->txtText3->Caption=""; pForm->PrnView->PreviewModal() ; delete pForm; } catch(...) { ShowMessage("打印机返回错误信息,请检查是否安装并设置了默认打印机"); return; } }
void __fastcall TStockHandlemanForm::btnPrintClick(TObject *Sender) { if(!dm1->OpenDatabase()) return; AnsiString szSQL="select sh_code as prnID,sh_name as prnName,sh_tel as prnText2,sd_name as prnText3" " from StockHandleman,StockDepart where sh_sdcode*=sd_code order by sh_code"; if(!OpenQuery(dm1->sqlPrint,szSQL.c_str())) return; try { TPrnBaseDataForm *pForm; pForm=new TPrnBaseDataForm(this); pForm->txtTitle->Caption="采购经办字典表"; pForm->txtText2->Caption="分机"; pForm->txtText3->Caption="采购部门"; pForm->PrnView->PreviewModal() ; delete pForm; } catch(...) { ShowMessage("打印机返回错误信息,请检查是否安装并设置了默认打印机"); return; } }
void __fastcall TGoodsAddrForm::btnPrintClick(TObject *Sender) { if(!dm1->OpenDatabase()) return; AnsiString szSQL="select ga_code as prnID,ga_area as prnName,ga_name as prnText2 from GoodsAddr order by ga_code"; if(!OpenQuery(dm1->sqlPrint,szSQL.c_str())) return; try { TPrnBaseDataForm *pForm; pForm=new TPrnBaseDataForm(this); pForm->txtTitle->Caption="交货地点字典表"; pForm->txtText1->Caption="交货公司或区域"; pForm->txtText2->Caption="交货地点"; pForm->txtText3->Caption=""; pForm->PrnView->PreviewModal() ; delete pForm; } catch(...) { ShowMessage("打印机返回错误信息,请检查是否安装并设置了默认打印机"); return; } }
//--------------------------------------------------------------------------- void __fastcall TUnitTreatListForm::btnPrintClick(TObject *Sender) { CString szSQL,szFilter0,szFilter1; char strCorp[80],strLarge[80],strTemp[80]; int nSel; TListItem *pItem; AnsiString szDays; BASE2COLDATA rwBase; TPrnUnitTreatListForm *pForm; TDateTime tNow; pForm=new TPrnUnitTreatListForm(Application); assert(pForm!=NULL); strCorp[0]='\0'; strLarge[0]='\0'; if((nSel=lstCorp->ItemIndex)>=0 && nSel<m_lstCorpID.GetSize()) { strcpy(strCorp,m_lstCorpID[nSel]); } if((nSel=lstLarge->ItemIndex)>=0 && nSel<m_lstLargeID.GetSize()) { strcpy(strLarge,m_lstLargeID[nSel]); } if(strCorp[0]!='\0' || strLarge[0]!='\0') { szFilter0.Format(" and mn_code like '%s%s%%'",strCorp,strLarge); szFilter1.Format(" and pd_mncode like '%s%s%%'",strCorp,strLarge); } szSQL="select pd_mncode,count(pd_mncode) as pd_count from BookFactory,PurchaseDetail" " where bf_apcode=pd_code"; szSQL+=szFilter1; szSQL+=" group by pd_mncode" " order by pd_mncode"; RunSQL(dm1->Query1,szSQL,true); while(!dm1->Query1->Eof) { strcpy(rwBase.strCode,dm1->Query1->FieldByName("pd_mncode")->AsString.c_str()); sprintf(rwBase.strName,"%d",dm1->Query1->FieldByName("pd_count")->AsInteger); pForm->m_lstBook.Add(rwBase); dm1->Query1->Next(); } szSQL="select * from TreatStock,DicUnits,materialno,Manufactur" " where ts_ducode=du_code" " and ts_mncode=mn_code" " and ts_mfcode*=mf_code"; szSQL+=szFilter0; szSQL+=" order by ts_mncode"; tNow=GetSysTime(false); if(!OpenQuery(dm1->sqlPrint,szSQL)) return; pForm->txtPrnDate->Caption=(LPCSTR)Time2DBDateString(tNow); pForm->PrnView->PreviewModal(); delete pForm; }
DWORD CNHSQLServerDBO::ExecuteCount(const _ConnectionPtr &pConnection, const wchar_t *const pwchSQL, int *const pnCountNum) { assert(NULL != pConnection); assert(NULL != pwchSQL); assert(NULL != pnCountNum); DWORD dwReturn(0x00); try { _RecordsetPtr pRecordset(NULL); if (0x00 == OpenQuery(pConnection, pRecordset, pwchSQL)) { _variant_t v; v.ChangeType(VT_NULL); CNHSQLServerDBO::GetFieldValue(pRecordset, v, L"CountNum"); if (VT_NULL!=v.vt && VT_EMPTY!=v.vt) { (*pnCountNum) = static_cast<int>(v); } CNHSQLServerDBO::CloseQuery(pRecordset); } else { dwReturn = 0x01; } } catch (_com_error &e) { //#ifdef _DEBUG const int nErrMsgLength(MAX_PATH); wchar_t *pwchErrMsg = new wchar_t[nErrMsgLength](); _snwprintf_s(pwchErrMsg, nErrMsgLength, _TRUNCATE, L"CNHSQLServerDBO::ExecuteCount发生错误(执行%s)。", pwchSQL); // 输出错误信息到输出窗口 OutputDebugStringW(L"\t"); OutputDebugStringW(pwchErrMsg); OutputDebugStringW(L"\n"); // 输出错误信息到日志文件 if (0 != wcscmp(m_wchLogFilePath, L"")) { // 当日志文件路径不为空时,写日志 CNHLogAPI::WriteLogEx(m_wchLogFilePath, LOG_ERR, L"NHSQLServerDBO", pwchErrMsg); } if (NULL != pwchErrMsg) { delete[] pwchErrMsg; pwchErrMsg = NULL; } OutputDBErrMsg(e); //#endif dwReturn = 0xff; } return dwReturn; }
bool C4ChatControl::ProcessInput(const char *szInput, ChatSheet *pChatSheet) { CStdLock Lock(pIRCClient->getCSec()); // process chat input - return false if no more pasting is to be done (i.e., // on /quit or /part in channel) bool fResult = true; bool fIRCSuccess = true; // not connected? if (!pIRCClient->IsConnected()) { pChatSheet->DoError(LoadResStr("IDS_ERR_NOTCONNECTEDTOSERVER")); return fResult; } // safety if (!szInput || !*szInput || !pChatSheet) return fResult; // command? if (*szInput == '/' && !SEqual2NoCase(szInput + 1, "me ")) { StdStrBuf sCommand, sParam(""); ; sCommand.Copy(szInput + 1); sCommand.SplitAtChar(' ', &sParam); if (SEqualNoCase(sCommand.getData(), "quit")) { // query disconnect from IRC server fIRCSuccess = pIRCClient->Quit(sParam.getData()); fResult = false; } else if (SEqualNoCase(sCommand.getData(), "part")) { // part channel. Default to current channel if typed within a channel if (!sParam.getLength() && pChatSheet->GetSheetType() == ChatSheet::CS_Channel) { sParam.Copy(pChatSheet->GetIdent()); fResult = false; } fIRCSuccess = pIRCClient->Part(sParam.getData()); } else if (SEqualNoCase(sCommand.getData(), "join") || SEqualNoCase(sCommand.getData(), "j")) { if (!sParam.getLength()) sParam.Copy(Config.IRC.Channel); fIRCSuccess = pIRCClient->Join(sParam.getData()); } else if (SEqualNoCase(sCommand.getData(), "notice") || SEqualNoCase(sCommand.getData(), "msg")) { bool fMsg = SEqualNoCase(sCommand.getData(), "msg"); StdStrBuf sMsg; if (!sParam.SplitAtChar(' ', &sMsg) || !sMsg.getLength()) { pChatSheet->DoError( FormatString(LoadResStr("IDS_ERR_INSUFFICIENTPARAMETERS"), sCommand.getData()).getData()); } else { if (fMsg) fIRCSuccess = pIRCClient->Message(sParam.getData(), sMsg.getData()); else fIRCSuccess = pIRCClient->Notice(sParam.getData(), sMsg.getData()); } } else if (SEqualNoCase(sCommand.getData(), "raw")) { if (!sParam.getLength()) pChatSheet->DoError( FormatString(LoadResStr("IDS_ERR_INSUFFICIENTPARAMETERS"), sCommand.getData()).getData()); else fIRCSuccess = pIRCClient->Send(sParam.getData()); } else if (SEqualNoCase(sCommand.getData(), "ns") || SEqualNoCase(sCommand.getData(), "cs") || SEqualNoCase(sCommand.getData(), "ms")) { if (!sParam.getLength()) pChatSheet->DoError( FormatString(LoadResStr("IDS_ERR_INSUFFICIENTPARAMETERS"), sCommand.getData()).getData()); else { const char *szMsgTarget; if (SEqualNoCase(sCommand.getData(), "ns")) szMsgTarget = "NickServ"; else if (SEqualNoCase(sCommand.getData(), "cs")) szMsgTarget = "ChanServ"; else szMsgTarget = "MemoServ"; fIRCSuccess = pIRCClient->Message(szMsgTarget, sParam.getData()); } } else if (SEqualNoCase(sCommand.getData(), "query") || SEqualNoCase(sCommand.getData(), "q")) { if (!sParam.getLength()) pChatSheet->DoError( FormatString(LoadResStr("IDS_ERR_INSUFFICIENTPARAMETERS"), sCommand.getData()).getData()); else OpenQuery(sParam.getData(), true, NULL); } else if (SEqualNoCase(sCommand.getData(), "nick")) { if (C4InVal::ValidateString(sParam, C4InVal::VAL_IRCName)) pChatSheet->DoError(FormatString(LoadResStr("IDS_ERR_INVALIDNICKNAME2"), sCommand.getData()).getData()); else fIRCSuccess = pIRCClient->ChangeNick(sParam.getData()); } else { // unknown command pChatSheet->DoError(FormatString(LoadResStr("IDS_ERR_UNKNOWNCMD"), sCommand.getData()).getData()); } } else { // regular chat input: Send as message to current channel/user const char *szMsgTarget; ChatSheet::SheetType eSheetType = pChatSheet->GetSheetType(); if (eSheetType == ChatSheet::CS_Server) { pChatSheet->DoError(LoadResStr("IDS_ERR_NOTONACHANNEL")); } else { szMsgTarget = pChatSheet->GetTitle(); if (*szInput == '/') // action fIRCSuccess = pIRCClient->Action(szMsgTarget, szInput + 4); else fIRCSuccess = pIRCClient->Message(szMsgTarget, szInput); } } // IRC sending error? log it if (!fIRCSuccess) { pChatSheet->DoError(pIRCClient->GetError()); } return fResult; }
void C4ChatControl::Update() { CStdLock Lock(pIRCClient->getCSec()); // update channels for (C4Network2IRCChannel *pChan = pIRCClient->getFirstChannel(); pChan; pChan = pIRCClient->getNextChannel(pChan)) { ChatSheet *pChanSheet = GetSheetByIdent(pChan->getName(), ChatSheet::CS_Channel); if (!pChanSheet) { // new channel! Create sheet for it pTabChats->AddCustomSheet( pChanSheet = new ChatSheet(this, pChan->getName(), pChan->getName(), ChatSheet::CS_Channel)); // and show immediately pTabChats->SelectSheet(pChanSheet, false); } } // remove parted channels int32_t i = 0; C4GUI::Tabular::Sheet *pSheet; while (pSheet = pTabChats->GetSheet(i++)) { C4Network2IRCChannel *pIRCChan; ChatSheet *pChatSheet = static_cast<ChatSheet *>(pSheet); if (pChatSheet->GetSheetType() == ChatSheet::CS_Channel) if (!(pIRCChan = pIRCClient->getChannel(pChatSheet->GetTitle()))) { delete pChatSheet; --i; } } // retrieve messages: All messages in initial update; only unread in // subsequent calls C4Network2IRCMessage *pMsg; if (fInitialMessagesReceived) { pMsg = pIRCClient->getUnreadMessageLog(); } else { pMsg = pIRCClient->getMessageLog(); fInitialMessagesReceived = true; } // update messages for (; pMsg; pMsg = pMsg->getNext()) { // get target sheet to put message into ChatSheet *pChatSheet; StdStrBuf sUser, sIdent; bool fMsgToService = false; if (pMsg->getType() == MSG_Server) { // server messages in server sheet pChatSheet = GetServerSheet(); } else { if (pMsg->getType() != MSG_Status) sUser.Copy(pMsg->getSource()); if (!sUser.SplitAtChar('!', &sIdent)) sIdent.Ref(sUser); // message: Either channel or user message (or channel notify). Get // correct sheet. if (pMsg->isChannel()) { // if no sheet is found, don't create - assume it's an outdated message // with the cahnnel window already closed pChatSheet = GetSheetByIdent(pMsg->getTarget(), ChatSheet::CS_Channel); } else if (IsServiceName(sUser.getData())) { // notices and messages by services always in server sheet pChatSheet = GetServerSheet(); } else if (pMsg->getType() == MSG_Notice) { // notifies in current sheet; default to server sheet pChatSheet = GetActiveChatSheet(); if (!pChatSheet) pChatSheet = GetServerSheet(); } else if (pMsg->getType() == MSG_Status || !sUser.getLength()) { // server message pChatSheet = GetServerSheet(); } else if (sUser == pIRCClient->getUserName()) { // private message by myself // message to a service into service window; otherwise (new) query if (IsServiceName(pMsg->getTarget())) { pChatSheet = GetServerSheet(); fMsgToService = true; } else { pChatSheet = OpenQuery(pMsg->getTarget(), true, NULL); if (pChatSheet) pChatSheet->SetChatTitle(pMsg->getTarget()); } } else { // private message pChatSheet = OpenQuery(sUser.getData(), false, sIdent.getData()); if (pChatSheet) pChatSheet->SetChatTitle(pMsg->getSource()); } } if (pChatSheet) { // get message formatting and color StdStrBuf sMsg; uint32_t dwClr = C4GUI_MessageFontClr; switch (pMsg->getType()) { case MSG_Server: sMsg.Format("- %s", pMsg->getData()); break; case MSG_Status: sMsg.Format("- %s", pMsg->getData()); dwClr = C4GUI_InactMessageFontClr; break; case MSG_Notice: if (sUser.getLength()) if (sUser != pIRCClient->getUserName()) sMsg.Format("-%s- %s", sUser.getData(), pMsg->getData()); else sMsg.Format("-> -%s- %s", pMsg->getTarget(), pMsg->getData()); else sMsg.Format("* %s", pMsg->getData()); dwClr = C4GUI_NotifyFontClr; break; case MSG_Message: if (fMsgToService) sMsg.Format("-> *%s* %s", pMsg->getTarget(), pMsg->getData()); else if (sUser.getLength()) sMsg.Format("<%s> %s", sUser.getData(), pMsg->getData()); else sMsg.Format("* %s", pMsg->getData()); break; case MSG_Action: if (sUser.getLength()) sMsg.Format("* %s %s", sUser.getData(), pMsg->getData()); else sMsg.Format("* %s", pMsg->getData()); break; default: sMsg.Format("??? %s", pMsg->getData()); dwClr = C4GUI_ErrorFontClr; break; } pChatSheet->AddTextLine(sMsg.getData(), dwClr); } } // OK; all messages processed. Delete overflow messages. pIRCClient->MarkMessageLogRead(); // update selected channel (users, topic) ChatSheet *pActiveSheet = GetActiveChatSheet(); if (pActiveSheet) pActiveSheet->Update(false); // update title UpdateTitle(); }
void __fastcall TSumBookNotEndForm::btnPrintClick(TObject *Sender) { CString szSQL,szTable; TPrnSumNotEndForm *pPrn; TListItem *pItem; int i; TDateTime tNow; szTable=GetTmpTableName(); try { BeginTransact(); szSQL.Format("create table dbo.%s (" "m_id varchar(80)," "m_sh varchar(80)," "m_corp varchar(80)," "m_ap varchar(80)," "m_afd varchar(80)," "m_type varchar(80)," "m_mnname varchar(80)," "m_mfsname varchar(80)," "m_count varchar(80)," "m_hm varchar(80)," "m_date varchar(80)," "m_money varchar(80)" ")",szTable); RunTransactSQL(szSQL); for(i=0;i<lstView->Items->Count;i++) { pItem=lstView->Items->Item[i]; szSQL.Format("insert into %s values(",szTable); szSQL+=Int2DBString(i+1); szSQL+=","; szSQL+=Str2DBString(pItem->Caption.c_str()); szSQL+=","; szSQL+=Str2DBString(pItem->SubItems->Strings[0].c_str()); szSQL+=","; szSQL+=Str2DBString(pItem->SubItems->Strings[1].c_str()); szSQL+=","; szSQL+=Str2DBString(pItem->SubItems->Strings[2].c_str()); szSQL+=","; szSQL+=Str2DBString(pItem->SubItems->Strings[3].c_str()); szSQL+=","; szSQL+=Str2DBString(pItem->SubItems->Strings[4].c_str()); szSQL+=","; szSQL+=Str2DBString(pItem->SubItems->Strings[5].c_str()); szSQL+=","; szSQL+=Str2DBString(pItem->SubItems->Strings[6].c_str()); szSQL+=","; szSQL+=Str2DBString(pItem->SubItems->Strings[7].c_str()); szSQL+=","; szSQL+=Str2DBString(pItem->SubItems->Strings[8].c_str()); szSQL+=","; szSQL+=Str2DBString(pItem->SubItems->Strings[9].c_str()); szSQL+=")"; RunTransactSQL(szSQL); } CommitTransact(); } catch(...) { RollBackTransact(); ShowMessage("数据库操作异常"); return; } pPrn=new TPrnSumNotEndForm(this); assert(pPrn!=NULL); tNow=GetSysTime(false); pPrn->txtPrnTime->Caption=(LPCSTR)Time2DBTimeString(tNow); pPrn->txtDate->Caption="呈核日"; if(!m_bMonth) { pPrn->txtTitle->Caption="逾期未订购案件周报表(催办单)"; pPrn->QRLabel12->Caption="逾时说明"; pPrn->QRLabel17->Caption="说明: 未订购的案件若其订购最後限期在统计范围之内就被视为逾期"; pPrn->QRLabel19->Caption=" 一般件:订购最後限期=呈核日+6 急件:订购最後限期=呈核日+2"; } else { pPrn->txtTitle->Caption="订购逾期案件月报明细"; pPrn->QRLabel12->Caption="备注"; pPrn->QRLabel17->Caption="说明: 逾期案件是指 订购最後限期在统计范围之内并且订购最後限期<实际订购日"; pPrn->QRLabel19->Caption=" 一般件:订购最後限期=呈核日+6 急件:订购最後限期=呈核日+2"; } // pPrn->txtTitle->Caption="订购逾期未完成案件统计表"; szSQL.Format("select * from %s",szTable); OpenQuery(dm1->sqlPrint,szSQL); pPrn->PrnView->PreviewModal(); delete pPrn; DROP_TABLE: szSQL.Format("drop table %s",szTable); RunSQL(dm1->Query1,szSQL); }
void __fastcall TAPAffirmAndNotBookForm::btnPrintClick(TObject *Sender) { CString szSQL,szTable; int i; TListItem *pItem; TPrnApafmNotBookForm *pPrn; TDateTime tNow; szTable=GetTmpTableName(); szSQL.Format("create table dbo.%s (" "m_apcode varchar(20)," "m_aptype varchar(20)," "m_sdname varchar(80)," "m_corp varchar(80)," "m_reqdep varchar(80)," "m_type varchar(20)," "m_apdate varchar(20)," "m_needdate varchar(20)," "m_mnname varchar(80)," "m_afmdate varchar(80)," "m_shname varchar(80)" ")",szTable); if(!RunSQL(dm1->Query1,szSQL)) return; for(i=0;i<lstView->Items->Count;i++) { pItem=lstView->Items->Item[i]; szSQL.Format("insert into %s values(",szTable); szSQL+=Str2DBString(pItem->Caption.c_str()); szSQL+=","; szSQL+=Str2DBString(pItem->SubItems->Strings[0].c_str()); szSQL+=","; szSQL+=Str2DBString(pItem->SubItems->Strings[1].c_str()); szSQL+=","; szSQL+=Str2DBString(pItem->SubItems->Strings[2].c_str()); szSQL+=","; szSQL+=Str2DBString(pItem->SubItems->Strings[3].c_str()); szSQL+=","; szSQL+=Str2DBString(pItem->SubItems->Strings[4].c_str()); szSQL+=","; szSQL+=Str2DBString(pItem->SubItems->Strings[5].c_str()); szSQL+=","; szSQL+=Str2DBString(pItem->SubItems->Strings[6].c_str()); szSQL+=","; szSQL+=Str2DBString(pItem->SubItems->Strings[7].c_str()); szSQL+=","; szSQL+=Str2DBString(pItem->SubItems->Strings[8].c_str()); szSQL+=","; szSQL+=Str2DBString(pItem->SubItems->Strings[9].c_str()); szSQL+=")"; if(!RunSQL(dm1->Query1,szSQL)) goto DROP_TABLE; } pPrn=new TPrnApafmNotBookForm(this); assert(pPrn!=NULL); tNow=GetSysTime(false); pPrn->txtPrnTime->Caption=(LPCSTR)Time2DBTimeString(tNow); szSQL.Format("select * from %s",szTable); if(OpenQuery(dm1->sqlPrint,szSQL)) { pPrn->PrnView->PreviewModal(); } delete pPrn; DROP_TABLE: szSQL.Format("drop table dbo.%s",szTable); RunSQL(dm1->Query1,szSQL); }