int main(int argc, char const *argv[]) { char command, condition = 1; FILE *stockBase; struct stock thisStock; if (stockBase = fopen("stocker.dat", "r")) { while (fread(&thisStock,sizeof(struct stock),1,stockBase) != NULL) gRecordNr = thisStock.recordNr; fclose(stockBase); } else gRecordNr = 0; puts("welcome to the stocker app!"); while(condition) { puts("A - list stocks"); puts("B - add stock"); puts("C - edit stock"); puts("D - delete stock"); puts("E - compare stocks"); puts("Q - quit"); putchar('\n'); printf("type in command: " ); fpurge(stdin); command = getchar(); command = toupper(command); putchar('\n'); switch(command) { case 'A': ListStocks(); break; case 'B': AddStock(); break; case 'C': EditStock(); break; case 'D': DeleteStock(); break; case 'E': CompareStocks(); break; case 'Q': condition = 0; break; default: puts("please enter valid input!"); break; } } return 0; }
LRESULT CDlgStockList::OnUserDragData(WPARAM wParam, LPARAM lParam) { HSCurKeyInfo* pData = (HSCurKeyInfo*)lParam; if(pData == NULL) return -1; StockUserInfo* pStock = (StockUserInfo*)::SendMessage(g_hParentWnd, HX_USER_COMPILEDATA, 19, (LPARAM)&pData->m_cCode); if( pStock == NULL ) return -1; AddStock(pStock); return 0; }
int CDomain::AddFxjDomain( LPCTSTR lpszFile ) { CSPFile file; DWORD dwMagic; if( !file.Open( lpszFile, CSPFile::modeRead ) || sizeof(dwMagic) != file.Read(&dwMagic,sizeof(dwMagic)) || dwMagic != 0xFF5100A5 ) return 0; int nCount = 0; struct fxj_block_t stock; while( sizeof(stock) == file.Read(&stock,sizeof(stock)) ) { if( 0 == stock.szCode[6] ) { CSPString sCode = stock.szCode; if( sCode.GetLength() == 4 ) sCode = "00" + sCode; if( sCode.GetLength() == 6 ) AddStock( sCode ); } } return GetSize(); }
BOOL QuoteTableCtrlGeneralSort::HandleRecvData(AnsGeneralSortEx* pData, int nIndex) { GeneralSortData* pReportTotalData = (GeneralSortData*)pData->m_prptData; DeleteStock(); int nDataNumber = 0; StockUserInfo* pStockInfo; long lMinsize = min(m_sDisplayRow, pData->m_nSize); for (int i = 0; i < lMinsize; i++) { pStockInfo = GetStockUserInfo(pReportTotalData[i].m_ciStockCode.m_cCode, pReportTotalData[i].m_ciStockCode.m_cCodeType); if ( pStockInfo != NULL) { AddStock(pStockInfo); nDataNumber++; } } if (nDataNumber < 1) return FALSE; InitRowData(); //DrawTitle(); long nUnit; short nDecimal; long lClose; char strText[64]; int col; CGridCell* pCell; int nFixedRows = 1; for(int i = 0; i < nDataNumber; i++) { pStockInfo = m_pStock.GetAt(i); lClose = pStockInfo->m_lPrevClose; nUnit = 1000; nDecimal = 2; //特殊处理价格 BOOL bNegative = FALSE; #ifdef Support_XHX_Dll bNegative = MakeNegativeIndex(pStockInfo->m_ciStockCode.m_cCodeType); #endif col = 0; pCell = (CGridCell*)GetCell(nFixedRows+i, col); if( pCell == NULL ) continue; SetFixedData(nFixedRows+i,col,pCell,(StockUserInfo*)pStockInfo, -1, TRUE); // 价格 if ( Negative(pReportTotalData[i].m_lNewPrice,bNegative) == 0 ) CGeneralHelper::LongToString(lClose, lClose, nUnit, nDecimal, strText); else CGeneralHelper::LongToString(Negative(pReportTotalData[i].m_lNewPrice,bNegative), lClose, nUnit, nDecimal, strText); UpdateCellText(nFixedRows+i,1,strText,GRID_DATA_UPDATE_DEFAULT); // 排名值 switch(nIndex) { case 1: // 5分钟涨幅排名 case 4: // 5分钟跌幅排名 { long lNewClose = 0; if((pReportTotalData[i].m_lValue*((g_bOldMode)?1:10000) + 10000) > 0) { lNewClose = (long)(Negative(pReportTotalData[i].m_lNewPrice,bNegative) * 10000 / (pReportTotalData[i].m_lValue*((g_bOldMode)?1:10000) + 10000)); } /* if(lNewClose > 0) { pStockInfo->m_lPrevClose = lNewClose; } */ } CGeneralHelper::LongToString((long)(pReportTotalData[i].m_lValue*((g_bOldMode)?1:10000)),0,100,nDecimal,strText, 0x0400); break; case 2: // 今日委比前六名 case 5: // 今日委比后六名 case 6: // 今日震幅排名 CGeneralHelper::LongToString((long)(pReportTotalData[i].m_lValue*((g_bOldMode)?1:10000)),0,100,2,strText, 0x0400); break; case 0: // 今日涨幅排名 case 3: // 今日跌幅排名 { CGeneralHelper::LongToString((long)(pReportTotalData[i].m_lValue*((g_bOldMode)?1:10000)),0,100,nDecimal,strText, 0x0400); break; } case 7: // 今日量比排名 CGeneralHelper::LongToString((long)(pReportTotalData[i].m_lValue),0,100,2,strText); break; case 8: // 今日总金额排名 CGeneralHelper::LongToString((long)(pReportTotalData[i].m_lValue),0,100,2,strText); // 服务器除以100传过来的机会 break; default: break; } UpdateCellText(nFixedRows+i,2,strText,GRID_DATA_UPDATE_DEFAULT ); } Invalidate(); return TRUE; }