XTable.cpp 58 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541
  1. // XTable.cpp : implementation file
  2. #include "stdafx.h"
  3. #include "YLGL.h"
  4. #include "XTable.h"
  5. #include "InputDate.h"
  6. #include "MemDC.h"
  7. #include "TodayForm2.h"
  8. #include "TodayForm.h"
  9. #define XTABLE_CLASSNAME _T("XTableCtrl") // Window class name
  10. #ifdef _DEBUG
  11. #define new DEBUG_NEW
  12. #endif
  13. // XTable
  14. IMPLEMENT_DYNAMIC(XTable, CWnd)
  15. BEGIN_MESSAGE_MAP(XTable, CWnd)
  16. ON_WM_PAINT()
  17. ON_WM_KEYDOWN()
  18. ON_WM_LBUTTONDOWN()
  19. ON_WM_LBUTTONDBLCLK()
  20. ON_MESSAGE(WM_USER_EDIT_END,OnEditEnd)
  21. ON_WM_ERASEBKGND()
  22. END_MESSAGE_MAP()
  23. XTable::XTable(int rows, int cols)
  24. {
  25. RegisterWindowClass ();
  26. defaultCell.table = this;
  27. defaultHeight = 20;
  28. defaultWidth = 80;
  29. cells = NULL;
  30. rowHeight = NULL;
  31. colWidth = NULL;
  32. this->rows = 0;
  33. this->cols = 0;
  34. SetRows (rows);
  35. SetCols (cols);
  36. focusRow = 0;
  37. focusCol = 0;
  38. m_bFocusFrame=1;
  39. m_nCurShow=-1;
  40. m_nticks=::GetTickCount ();
  41. m_mode=0;
  42. m_pComboBox=NULL;
  43. }
  44. XTable::~XTable()
  45. {
  46. if(cells)delete [] cells;
  47. if(rowHeight)delete [] rowHeight;
  48. if(colWidth)delete [] colWidth;
  49. }
  50. // creates the control - use like any other window create control
  51. BOOL XTable::Create(const RECT& rect, CWnd* pParentWnd, UINT nID, DWORD dwStyle)
  52. {
  53. ASSERT(pParentWnd->GetSafeHwnd());
  54. if (!CWnd::Create(XTABLE_CLASSNAME, NULL, dwStyle, rect, pParentWnd, nID))
  55. return FALSE;
  56. return TRUE;
  57. }
  58. int XTable::ToXML (CMarkup& markup)
  59. {
  60. markup.AddChildElem ("table");
  61. markup.AddChildAttr("border", "1");
  62. markup.IntoElem ();
  63. for (int i = 0; i < GetRows (); i ++)
  64. {
  65. markup.AddChildElem ("tr");
  66. markup.IntoElem();
  67. for (int j = 0; j < GetCols (); j ++)
  68. {
  69. XCell* cell = GetCells (i, j);
  70. if (cell->colSpan > 0 && cell->rowSpan > 0)
  71. {
  72. markup.AddChildElem ("td");
  73. if (cell->colSpan == 1 && i == 0)
  74. markup.AddChildAttr ("width", GetColWidth (j));
  75. if (cell->rowSpan == 1 && j == 0)
  76. markup.AddChildAttr ("height", GetRowHeight (i));
  77. cell->ToXML (markup);
  78. }
  79. }
  80. markup.OutOfElem();
  81. }
  82. markup.OutOfElem();
  83. return 0;
  84. }
  85. int XTable::FromXML (CMarkup& markup)
  86. {
  87. markup.IntoElem ();
  88. int maxCol = 0;
  89. int maxRow = 0;
  90. int row = 0;
  91. int col = 0;
  92. SetCols (MAX_COLS);
  93. SetRows (MAX_ROWS);
  94. while (markup.FindChildElem("tr"))
  95. {
  96. markup.IntoElem();
  97. col = 0;
  98. while (markup.FindChildElem("td"))
  99. {
  100. XCell* cell;
  101. while (true)
  102. {
  103. cell = GetCells (row, col);
  104. if (!cell)
  105. break;
  106. if (cell->colSpan >= 1 && cell->rowSpan >= 1)
  107. break;
  108. col ++;
  109. }
  110. cell->FromXML (markup);
  111. if (cell->colSpan > 1 || cell->rowSpan > 1)
  112. JoinCells (row, col, row+cell->rowSpan-1, col+cell->colSpan-1);
  113. if (cell->colSpan == 1 && markup.GetChildAttr("width") != "")
  114. {
  115. int width = atoi (markup.GetChildAttr("width"));
  116. if (row == 0 || width > GetColWidth(col))
  117. SetColWidth (col, width);
  118. }
  119. if (cell->rowSpan == 1 && markup.GetChildAttr("height") != "")
  120. {
  121. int height = atoi (markup.GetChildAttr("height"));
  122. if (col == 0 || height > GetRowHeight(row))
  123. SetRowHeight (row, height);
  124. }
  125. col += cell->colSpan;
  126. if (col > maxCol) maxCol = col;
  127. if (row + cell->rowSpan > maxRow) maxRow = row + cell->rowSpan;
  128. }
  129. markup.OutOfElem();
  130. row ++;
  131. }
  132. markup.OutOfElem();
  133. SetRows (maxRow);
  134. SetCols (maxCol);
  135. return 0;
  136. }
  137. int XTable::SetRows(int newRows)
  138. {
  139. if (rows < 0 || rows > MAX_ROWS) return -1;
  140. if (rows == newRows) return 0;
  141. int cellsSize = cols * rows;
  142. XCell* newCells = cells;
  143. int* newRowHeight = new int [newRows];
  144. if ( rows < newRows)
  145. {
  146. if (cellsSize < newRows * cols)
  147. {
  148. cellsSize *= 2;
  149. if (cellsSize < newRows * cols)
  150. cellsSize = newRows * cols;
  151. newCells = new XCell [cellsSize];
  152. //复制旧数据
  153. for (int i = 0; i < rows; i++)
  154. {
  155. for(int j = 0; j < cols ; j++)
  156. {
  157. newCells [i * cols +j] = cells [i * cols +j];
  158. }
  159. newRowHeight [i] = rowHeight [i];
  160. }
  161. }
  162. //初始化新数据
  163. for (int i = rows; i < newRows; i++)
  164. {
  165. for (int j = 0; j < cols; j++)
  166. {
  167. newCells [i * cols + j] = defaultCell;
  168. newCells [i * cols + j].SetSpan (1, 1);
  169. }
  170. newRowHeight [i] = defaultHeight;
  171. }
  172. delete [] rowHeight;
  173. rowHeight = newRowHeight;
  174. }
  175. else
  176. {
  177. if (cellsSize > newRows * cols * 2)
  178. {
  179. cellsSize = newRows * cols;
  180. newCells = new XCell [cellsSize];
  181. }
  182. //复制数据
  183. for (int i = 0; i < newRows; i ++)
  184. {
  185. for (int j = 0; j < cols; j++)
  186. newCells [i * cols + j] = cells[i * cols +j];
  187. }
  188. }
  189. if (newCells != cells)
  190. {
  191. delete [] cells;
  192. cells = newCells;
  193. }
  194. rows = newRows;
  195. return 0;
  196. }
  197. int XTable::GetRows()
  198. {
  199. return rows;
  200. }
  201. int XTable::SetCols(int newCols)
  202. {
  203. if (newCols < 0 || newCols > MAX_COLS) return -1;
  204. if (this->cols == newCols) return 0;
  205. int cellsSize = cols * rows;
  206. XCell* newCells = cells;
  207. int* newColWidth = new int [newCols];
  208. if ( cols < newCols)
  209. {
  210. if (cellsSize < newCols * rows)
  211. {
  212. cellsSize *= 2;
  213. if (cellsSize < newCols * rows)
  214. cellsSize = newCols * rows;
  215. newCells = new XCell [cellsSize];
  216. //复制旧数据
  217. for (int i = 0; i < rows; i++)
  218. {
  219. for(int j = 0; j < cols ; j++)
  220. {
  221. newCells [i * newCols +j] = cells [i * cols +j];
  222. newColWidth[j] = colWidth [j];
  223. }
  224. }
  225. }
  226. //初始化新数据
  227. for (int i = 0; i < rows; i++)
  228. {
  229. for (int j = cols; j < newCols; j++)
  230. {
  231. newCells [i * newCols + j] = defaultCell;
  232. newCells [i * newCols + j].SetSpan (1, 1);
  233. newColWidth[j] = defaultWidth;
  234. }
  235. }
  236. delete [] colWidth;
  237. colWidth = newColWidth;
  238. }
  239. else
  240. {
  241. if (cellsSize > newCols * rows * 2)
  242. {
  243. cellsSize = newCols * rows;
  244. newCells = new XCell [cellsSize];
  245. }
  246. //复制数据
  247. for (int i = 0; i < rows; i ++)
  248. {
  249. for (int j = 0; j < newCols; j++)
  250. newCells [i * newCols + j] = cells[i * cols +j];
  251. }
  252. }
  253. if (newCells != cells)
  254. {
  255. delete [] cells;
  256. cells = newCells;
  257. }
  258. cols = newCols;
  259. return 0;
  260. }
  261. int XTable::GetCols()
  262. {
  263. return cols;
  264. }
  265. int XTable::JoinCells (int startRow, int startCol, int endRow, int endCol)
  266. {
  267. if (startRow < 0 || startRow >= rows) return -1;
  268. if (endRow < 0 || startRow >= rows) return -1;
  269. if (startCol < 0 || startCol >= cols) return -1;
  270. if (endCol < 0 || endCol >= cols) return -1;
  271. if (startRow > endRow || startCol > endCol) return -1;
  272. for (int i = startRow; i <= endRow; i++)
  273. {
  274. for (int j = startCol; j <=endCol; j++)
  275. {
  276. cells [i * cols + j].SetSpan(0,0);
  277. }
  278. }
  279. cells [startRow * cols + startCol].SetSpan(endRow - startRow+1, endCol - startCol+1);
  280. return 0;
  281. }
  282. int XTable::UnjoinCells (int row, int col)
  283. {
  284. if (row < 0 || row >= this->rows) return -1;
  285. if (col < 0 || col >= this->cols) return -1;
  286. if (cells [row * cols + col].rowSpan <= 1 && cells [row * cols + col].colSpan <= 1 ) return -1;
  287. for (int i = row; i <= row + cells [row * cols + col].rowSpan; i++)
  288. {
  289. for (int j = col; j <= cells [row * cols + col].colSpan; j++)
  290. {
  291. cells[i*cols+j] = defaultCell;
  292. cells [i * cols + j].SetSpan(1,1);
  293. }
  294. }
  295. return 0;
  296. }
  297. int XTable::SetRowHeight(int row, int height)
  298. {
  299. rowHeight [row] = height;
  300. return 0;
  301. }
  302. int XTable::GetRowHeight(int row)
  303. {
  304. return rowHeight [row];
  305. }
  306. int XTable::SetColWidth(int col, int width)
  307. {
  308. colWidth [col] = width;
  309. return 0;
  310. }
  311. int XTable::GetColWidth(int col)
  312. {
  313. return colWidth [col];
  314. }
  315. int XTable::GetRowsHeight(int startRow, int endRow)
  316. {
  317. if (startRow < 0 || startRow >= rows) return -1;
  318. if (endRow < 0 || endRow >= rows) return -1;
  319. if (startRow > endRow) return -1;
  320. int height = 0;
  321. for (int i = startRow; i <= endRow; i++)
  322. {
  323. height += rowHeight[i];
  324. }
  325. return height;
  326. }
  327. int XTable::GetColsWidth(int startCol, int endCol)
  328. {
  329. if (startCol < 0 || startCol >= cols) return -1;
  330. if (endCol < 0 || endCol >= cols) return -1;
  331. if (startCol > endCol) return -1;
  332. int width = 0;
  333. for (int i = startCol; i <= endCol; i++)
  334. {
  335. width += colWidth[i];
  336. }
  337. return width;
  338. }
  339. int XTable::SetCells(int row, int col, XCell& cell)
  340. {
  341. cells[row * cols + col] = cell;
  342. return 0;
  343. }
  344. XCell* XTable::GetCells(int row, int col)
  345. {
  346. return &cells [row * cols + col];
  347. }
  348. int XTable::SetText(int row, int col, CString str)
  349. {
  350. XCell* cell = GetCells (row, col);
  351. if (!cell) return -1;
  352. return cell->SetText (str);
  353. }
  354. CString XTable::GetText(int row, int col)
  355. {
  356. return cells[row * cols + col].GetText();
  357. }
  358. int XTable::SetTextColor(int row, int col, COLORREF color)
  359. {
  360. cells[row * cols + col].SetTextColor(color);
  361. return 0;
  362. }
  363. COLORREF XTable::GetTextColor(int row, int col)
  364. {
  365. return cells[row * cols + col].GetTextColor();
  366. }
  367. int XTable::SetTextFont(int row, int col, CFont& font)
  368. {
  369. cells[row * cols + col].SetTextFont(&font);
  370. return 0;
  371. }
  372. CFont* XTable::GetTextFont(int row, int col)
  373. {
  374. return cells[row * cols + col].GetTextFont();
  375. }
  376. int XTable::SetTextFontSize(int row, int col, int size)
  377. {
  378. cells[row * cols + col].SetTextFontSize(size);
  379. return 0;
  380. }
  381. int XTable::GetTextFontSize(int row, int col)
  382. {
  383. return cells[row * cols + col].GetTextFontSize();
  384. }
  385. int XTable::SetOverlap (int row, int col, bool enable)
  386. {
  387. XCell* cell = GetCells (row, col);
  388. if (!cell) return -1;
  389. return cell->SetOverlap (enable);
  390. }
  391. bool XTable::GetOverlap (int row, int col)
  392. {
  393. XCell* cell = GetCells (row, col);
  394. if (!cell) return false;
  395. return cell->GetOverlap ();
  396. }
  397. int XTable::SetAlignment (int row, int col, int align)
  398. {
  399. XCell* cell = GetCells (row, col);
  400. if (!cell) return -1;
  401. return cell->SetAlignment (align);
  402. }
  403. int XTable::GetAlignment (int row, int col)
  404. {
  405. XCell* cell = GetCells (row, col);
  406. if (!cell) return -1;
  407. return cell->GetAlignment ();
  408. }
  409. int XTable::SetWordbreak (int row, int col, bool wordbreak)
  410. {
  411. XCell* cell = GetCells (row, col);
  412. if (!cell) return -1;
  413. return cell->SetWordbreak (wordbreak);
  414. }
  415. bool XTable::GetWordbreak (int row, int col)
  416. {
  417. XCell* cell = GetCells (row, col);
  418. if (!cell) return false;
  419. return cell->GetWordbreak ();
  420. }
  421. int XTable::SetBackColor(int row, int col, COLORREF color)
  422. {
  423. cells[row * cols + col].SetBackColor(color);
  424. return 0;
  425. }
  426. COLORREF XTable::GetBackColor(int row, int col)
  427. {
  428. return cells[row * cols + col].GetBackColor();
  429. }
  430. int XTable::SetBackMode(int row, int col, int mode)
  431. {
  432. cells[row * cols + col].SetBackMode(mode);
  433. return 0;
  434. }
  435. int XTable::GetBackMode(int row, int col)
  436. {
  437. return cells[row * cols + col].GetBackMode();
  438. }
  439. RECT XTable::GetRect(int row, int col)
  440. {
  441. RECT rect;
  442. try
  443. {
  444. int rowSpan = GetCells(row, col)->rowSpan;
  445. int colSpan = GetCells(row, col)->colSpan;
  446. rect.top = GetRowsHeight(0, row-1);
  447. rect.left = GetColsWidth(0, col-1);
  448. rect.bottom = rect.top + GetRowsHeight (row, row + rowSpan-1);
  449. rect.right = rect.left + GetColsWidth (col, col + colSpan-1);
  450. }
  451. catch(...)
  452. {
  453. }
  454. return rect;
  455. }
  456. bool XTable::HitTest (CPoint point, int& row, int& col)
  457. {
  458. try
  459. {
  460. for (int i= 0; i < rows; i++)
  461. {
  462. for(int j=0; j < rows; j++)
  463. {
  464. RECT rect = GetRect (i,j);
  465. if (rect.top <= point.y && rect.bottom > point.y && rect.left <= point.x && rect.right > point.x)
  466. {
  467. row = i;
  468. col = j;
  469. return true;
  470. }
  471. }
  472. }
  473. }
  474. catch(...)
  475. {
  476. }
  477. return false;
  478. }
  479. void XTable::OnDraw(CDC* pDC)
  480. {
  481. static bool lock = false;
  482. if (lock) return;
  483. if (!::IsWindow(m_hWnd)) return;
  484. lock = true;
  485. Draw (pDC);
  486. lock = false;
  487. }
  488. int XTable::Draw(CDC* pDC)
  489. {
  490. try
  491. {
  492. for (int i = 0; i < rows; i++)
  493. {
  494. for (int j = 0; j < cols; j++)
  495. {
  496. XCell& cell = cells[i*cols+j];
  497. if (cell.colSpan !=0 && cell.rowSpan != 0)
  498. {
  499. RECT rect = GetRect(i,j);
  500. if (cell.GetOverlap())
  501. {
  502. RECT textRect = GetRect(i,j);
  503. cell.CalcTextRect(pDC, &textRect);
  504. if (textRect.right > rect.right)
  505. {
  506. for (j = j+1; j < cols; j ++)
  507. {
  508. if (cells[i*cols+j].text != "")
  509. break;
  510. rect.right += colWidth [j];
  511. if (rect.right > textRect.right)
  512. break;
  513. }
  514. j --;
  515. }
  516. }
  517. cell.Draw(pDC,rect);
  518. }
  519. }
  520. }
  521. if (focusCol && m_bFocusFrame && focusRow < rows && focusCol < cols) //**
  522. {
  523. RECT rect = GetRect (focusRow, 1);
  524. RECT rect2 = GetRect (focusRow, cols-1);
  525. RECT rect3=rect;
  526. if(rect2.right>rect3.right)
  527. rect3.right =rect2.right ;
  528. GetCells (focusRow, focusCol)->DrawHitBorder(pDC, rect3, RGB(255, 0, 20));
  529. }
  530. }
  531. catch(...)
  532. {
  533. }
  534. return 0;
  535. }
  536. // XTable message handlers
  537. void XTable::OnPaint()
  538. {
  539. CPaintDC dc(this); // device context for painting
  540. CMemDC MemDC(&dc);
  541. OnDraw(&MemDC);
  542. }
  543. BOOL XTable::OnEraseBkgnd(CDC* pDC)
  544. {
  545. return TRUE;
  546. }
  547. void XTable::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
  548. {
  549. CPoint point;
  550. RECT rect = GetRect(focusRow,focusCol);
  551. point.x = rect.left;
  552. point.y = rect.top;
  553. switch (nChar)
  554. {
  555. case VK_DOWN:
  556. point.y =rect.bottom + 1;
  557. break;
  558. case VK_UP:
  559. point.y =point.y -2;
  560. break;
  561. case VK_LEFT:
  562. point.x = point.x - 2;
  563. break;
  564. case VK_RIGHT:
  565. point.x =rect.right + 1;
  566. break;
  567. default:
  568. return ;
  569. }
  570. HitTest (point,focusRow,focusCol);
  571. Invalidate();
  572. CWnd::OnKeyDown(nChar, nRepCnt, nFlags);
  573. }
  574. void XTable::OnLButtonDown(UINT nFlags, CPoint point)
  575. {
  576. ::PostMessage(this->GetSafeHwnd(),WM_USER_EDIT_END,1,1);
  577. if(!m_bFocusFrame)return;
  578. HitTest (point,focusRow,focusCol);
  579. SetFocus ();
  580. Invalidate();
  581. CWnd::OnLButtonDown(nFlags, point);
  582. }
  583. void XTable::OnEditEnd(WPARAM wParam,LPARAM lParam)
  584. {
  585. if(m_nCurShow==-1)return;
  586. int nAdd=0;
  587. if(m_mode==4)nAdd=1;
  588. if(m_nCurShow==0)
  589. {
  590. if(wParam == TRUE)
  591. {
  592. CString strText(_T(""));
  593. m_edit.GetWindowText(strText);
  594. DWORD dwData = m_edit.GetCtrlData();
  595. int nItem= dwData>>16;
  596. int nIndex = dwData&0x0000ffff;
  597. CString oldtext=GetText(nItem,nIndex);
  598. SetText(nItem,nIndex,strText);
  599. AddName(nItem,11+nAdd, g_user.name);
  600. if(nIndex==9+nAdd)
  601. {
  602. if(atoi(GetText(nItem,9+nAdd))>0 )
  603. {
  604. SetBackColor (nItem,9+nAdd, RGB(255,0,0));
  605. }
  606. else SetBackColor (nItem,9+nAdd, RGB(0,255,0));
  607. }
  608. if(nIndex==12+nAdd)
  609. {
  610. if(GetText(nItem,12+nAdd)=="未到" )
  611. {
  612. SetBackColor (nItem,12+nAdd, RGB(255,0,0));
  613. }
  614. else
  615. SetBackColor (nItem,12+nAdd, RGB(0,255,0));
  616. }
  617. if(oldtext!=strText)
  618. Save(nItem);
  619. }
  620. m_edit.ShowWindow(SW_HIDE); m_nCurShow=-1; CalRowHeight();
  621. }
  622. else if(m_nCurShow==1)
  623. {
  624. if(wParam == TRUE)
  625. {
  626. CString strText(_T(""));
  627. m_combobox.GetWindowText(strText);
  628. if(strText.IsEmpty ())
  629. {
  630. m_combobox.ShowWindow(SW_HIDE); m_nCurShow=-1;
  631. return;
  632. }
  633. int pos=m_combobox.GetCurSel ();
  634. if(pos==-1)
  635. {
  636. m_combobox.ShowWindow(SW_HIDE); m_nCurShow=-1;
  637. DWORD dwData = m_combobox.GetCtrlData();
  638. int nItem= dwData>>16;
  639. int nIndex = dwData&0x0000ffff;
  640. CString oldtext=GetText(nItem,nIndex);
  641. SetText(nItem,nIndex,strText);
  642. AddName(nItem,11+nAdd, g_user.name);
  643. SetText(nItem,12+nAdd,"未到");
  644. if(oldtext!=strText)
  645. Save(nItem);
  646. m_combobox.ShowWindow(SW_HIDE); m_nCurShow=-1; CalRowHeight();
  647. return;
  648. }
  649. if(m_acCombo.m_posarray.GetSize ()<=pos)
  650. {
  651. m_combobox.ShowWindow(SW_HIDE); m_nCurShow=-1;
  652. DWORD dwData = m_combobox.GetCtrlData();
  653. int nItem= dwData>>16;
  654. int nIndex = dwData&0x0000ffff;
  655. CString oldtext=GetText(nItem,nIndex);
  656. SetText(nItem,nIndex,strText);
  657. AddName(nItem,11+nAdd, g_user.name);
  658. SetText(nItem,12+nAdd,"未到");
  659. if(oldtext!=strText)
  660. Save(nItem);
  661. }
  662. else
  663. {
  664. int pos2=m_acCombo.m_posarray.ElementAt (pos);
  665. m_id=m_pClientArray->ElementAt (pos2).ElementAt (0);
  666. DWORD dwData = m_combobox.GetCtrlData();
  667. int nItem= dwData>>16;
  668. int nIndex = dwData&0x0000ffff;
  669. CString oldtext=GetText(nItem,nIndex);
  670. SetText(nItem,nIndex,strText);
  671. if(!m_pClientArray->ElementAt (pos2).ElementAt (3).IsEmpty ())
  672. SetText(nItem,2,m_pClientArray->ElementAt (pos2).ElementAt (3)+" "+m_pClientArray->ElementAt (pos2).ElementAt (4));
  673. else
  674. SetText(nItem,2,m_pClientArray->ElementAt (pos2).ElementAt (4));
  675. if(m_mode==4)
  676. {
  677. g_sendhead.bsql=0;
  678. CString filter="id='"+m_id+"' and kind<>'5'";
  679. g_sendhead.code[0]=56;
  680. g_sendhead.tabcount=1;
  681. g_bNoConnDlg=1;
  682. g_pMainWnd->ProcessChatMessageRequest2(filter); g_bNoConnDlg=0;
  683. if(g_bSendOK)
  684. {
  685. DataToArray(&g_List1array);
  686. CString str;
  687. for(int i=0; i<g_List1array.GetSize (); i++)
  688. { if(g_List1array.ElementAt (i).ElementAt (20)!="2")continue;
  689. str+=g_List1array.ElementAt (i).ElementAt (0);
  690. str+=",";
  691. }
  692. str.TrimRight (",");
  693. SetText(nItem,4,str);
  694. }
  695. }
  696. SetText(nItem,4+nAdd,m_pClientArray->ElementAt (pos2).ElementAt (5));
  697. SetText(nItem,5+nAdd,m_pClientArray->ElementAt (pos2).ElementAt (6));
  698. SetText(nItem,6+nAdd,m_pClientArray->ElementAt (pos2).ElementAt (7));
  699. SetText(nItem,7+nAdd,m_pClientArray->ElementAt (pos2).ElementAt (8));
  700. SetText(nItem,8+nAdd,m_pClientArray->ElementAt (pos2).ElementAt (9));
  701. SetText(nItem,9+nAdd,m_pClientArray->ElementAt (pos2).ElementAt (10));
  702. if(atoi(GetText(nItem,9+nAdd))>0 )
  703. {
  704. SetBackColor (nItem,9+nAdd, RGB(255,0,0));
  705. }
  706. else SetBackColor (nItem,9+nAdd, RGB(0,255,0));
  707. if(!m_pClientArray->ElementAt (pos2).ElementAt (11).IsEmpty ())
  708. SetText(nItem,10+nAdd,"服装:"+m_pClientArray->ElementAt (pos2).ElementAt (11));
  709. AddName(nItem,11+nAdd, g_user.name);
  710. SetText(nItem,12+nAdd,"未到");
  711. if(oldtext!=strText)
  712. Save(nItem);
  713. }
  714. }
  715. m_combobox.ShowWindow(SW_HIDE); m_nCurShow=-1; CalRowHeight();
  716. }
  717. else if(m_nCurShow==2)
  718. {
  719. if(wParam == TRUE)
  720. {
  721. CString strText(_T(""));
  722. m_combobox2.GetWindowText(strText);
  723. DWORD dwData = m_combobox2.GetCtrlData();
  724. int nItem= dwData>>16;
  725. int nIndex = dwData&0x0000ffff;
  726. CString oldtext=GetText(nItem,nIndex);
  727. SetText(nItem,nIndex,strText);
  728. // SetText(nItem,11+nAdd, g_user.name);
  729. AddName(nItem,11+nAdd, g_user.name);
  730. if(nIndex==12+nAdd)
  731. {
  732. if(GetText(nItem,12+nAdd)=="未到" )
  733. {
  734. SetBackColor (nItem,12+nAdd, RGB(255,0,0));
  735. }
  736. else
  737. SetBackColor (nItem,12+nAdd, RGB(0,255,0));
  738. }
  739. if(oldtext!=strText)
  740. Save(nItem);
  741. //Invalidate();
  742. }
  743. m_combobox2.ShowWindow(SW_HIDE); m_nCurShow=-1; CalRowHeight();
  744. }
  745. else if(m_nCurShow==3)
  746. {
  747. if(wParam == TRUE)
  748. {
  749. CString strText(_T(""));
  750. m_pComboBox->GetWindowText(strText);
  751. DWORD dwData = m_pComboBox->GetCtrlData();
  752. int nItem= dwData>>16;
  753. int nIndex = dwData&0x0000ffff;
  754. CString oldtext=GetText(nItem,nIndex);
  755. SetText(nItem,nIndex,strText);
  756. AddName(nItem,11+nAdd, g_user.name);
  757. if(nIndex==12+nAdd)
  758. {
  759. if(GetText(nItem,12+nAdd)=="未到" )
  760. {
  761. SetBackColor (nItem,12+nAdd, RGB(255,0,0));
  762. }
  763. else
  764. SetBackColor (nItem,12+nAdd, RGB(0,255,0));
  765. }
  766. if(oldtext!=strText)
  767. Save(nItem);
  768. //Invalidate();
  769. }
  770. m_pComboBox->ShowWindow(SW_HIDE); m_nCurShow=-1; CalRowHeight();
  771. }
  772. }
  773. void XTable::ShowEdit(BOOL bShow,int nItem,int nIndex,CRect rcCtrl)
  774. {
  775. try
  776. {
  777. if(m_edit.m_hWnd == NULL)
  778. {
  779. m_edit.Create(ES_AUTOHSCROLL|WS_CHILD|ES_LEFT|ES_WANTRETURN|WS_BORDER,CRect(0,0,0,0),this,IDC_EDIT1);
  780. m_edit.ShowWindow(SW_HIDE);
  781. CFont tpFont;
  782. tpFont.CreateStockObject(DEFAULT_GUI_FONT);
  783. m_edit.SetFont(&tpFont);
  784. tpFont.DeleteObject();
  785. }
  786. if(bShow == TRUE)
  787. {
  788. CString strItem = GetText(nItem,nIndex);
  789. m_edit.MoveWindow(rcCtrl);
  790. m_edit.ShowWindow(SW_SHOW);
  791. m_edit.SetWindowText(strItem);
  792. ::SetFocus(m_edit.GetSafeHwnd());
  793. m_edit.SetSel(-1);
  794. m_edit.SetCtrlData(MAKEWPARAM(nIndex,nItem));
  795. }
  796. else
  797. m_edit.ShowWindow(SW_HIDE);
  798. }
  799. catch(...)
  800. {
  801. }
  802. }
  803. void XTable::ShowSearchClientComboBox(BOOL bShow,int nItem,int nIndex,CRect rcCtrl)
  804. {
  805. try
  806. {
  807. if(m_combobox.m_hWnd == NULL)
  808. {
  809. m_combobox.Create(WS_VSCROLL|WS_CHILD|CBS_DROPDOWN,CRect(0,0,0,0),this,100);
  810. m_combobox.ShowWindow(SW_HIDE);
  811. m_acCombo.m_mode =1;
  812. m_acCombo.Init(&m_combobox);
  813. m_acCombo.m_pArray=m_pClientArray;
  814. m_combobox.SetFocus ();
  815. }
  816. if(bShow == TRUE)
  817. {
  818. CString strItem = GetText(nItem,nIndex);
  819. rcCtrl.bottom+=300;
  820. m_combobox.MoveWindow(rcCtrl);
  821. m_combobox.ShowWindow(SW_SHOW);
  822. m_combobox.SetWindowText(strItem);
  823. ::SetFocus(m_combobox.GetSafeHwnd());
  824. m_combobox.SetCtrlData(MAKEWPARAM(nIndex,nItem));
  825. }
  826. else
  827. m_combobox.ShowWindow(SW_HIDE);
  828. }
  829. catch(...)
  830. {
  831. }
  832. }
  833. void XTable::ShowSearchClientComboBoxTime(BOOL bShow,int nItem,int nIndex,int type,CRect rcCtrl)
  834. {
  835. if(type>=2 && type<=4)
  836. {
  837. m_nCurShow=3;
  838. ShowSearchClientComboBoxTree( bShow, nItem, nIndex, type, rcCtrl);
  839. return;
  840. }
  841. try
  842. {
  843. if(m_combobox2.m_hWnd == NULL)
  844. {
  845. m_combobox2.Create(WS_VSCROLL|WS_CHILD|CBS_DROPDOWN,CRect(0,0,0,0),this,100);
  846. m_combobox2.ShowWindow(SW_HIDE);
  847. m_combobox2.SetFocus ();
  848. }
  849. m_combobox2.ResetContent ();
  850. if(type==0)
  851. {
  852. m_combobox2.AddString ("9:00");
  853. m_combobox2.AddString ("9:30");
  854. m_combobox2.AddString ("10:00");
  855. m_combobox2.AddString ("10:30");
  856. m_combobox2.AddString ("11:00");
  857. m_combobox2.AddString ("11:30");
  858. m_combobox2.AddString ("12:00");
  859. m_combobox2.AddString ("13:00");
  860. m_combobox2.AddString ("14:00");
  861. m_combobox2.AddString ("15:00");
  862. m_combobox2.AddString ("16:00");
  863. m_combobox2.AddString ("17:00");
  864. m_combobox2.AddString ("18:00");
  865. m_combobox2.AddString ("19:00");
  866. m_combobox2.AddString ("20:00");
  867. m_combobox2.AddString ("21:00");
  868. }
  869. else if(type==1)
  870. {
  871. for(int i=0; i<pTxtypearray->GetSize (); i++)
  872. m_combobox2.AddString (pTxtypearray->ElementAt (i).ElementAt (0));
  873. }
  874. else if(type==2)
  875. {
  876. for(int ii=0; ii<g_userarray.GetSize (); ii++)
  877. {
  878. if("摄影部"== g_userarray.ElementAt (ii).ElementAt(2) )
  879. m_combobox2.AddString ( g_userarray.ElementAt (ii).ElementAt(1) );
  880. }
  881. }
  882. else if(type==3)
  883. {
  884. for(int ii=0; ii<g_userarray.GetSize (); ii++)
  885. {
  886. if("化妆部"== g_userarray.ElementAt (ii).ElementAt(2) )
  887. m_combobox2.AddString ( g_userarray.ElementAt (ii).ElementAt(1) );
  888. }
  889. }
  890. else if(type==4)
  891. {
  892. for(int ii=0; ii<g_userarray.GetSize (); ii++)
  893. {
  894. // if("化妆部"== g_userarray.ElementAt (ii).ElementAt(2) )
  895. m_combobox2.AddString ( g_userarray.ElementAt (ii).ElementAt(1) );
  896. }
  897. }
  898. else if(type==5)
  899. {
  900. m_combobox2.AddString ("未到");
  901. m_combobox2.AddString ("已到");
  902. }
  903. if(bShow == TRUE)
  904. {
  905. CString strItem = GetText(nItem,nIndex);
  906. rcCtrl.bottom+=300;
  907. m_combobox2.MoveWindow(rcCtrl);
  908. m_combobox2.ShowWindow(SW_SHOW);
  909. m_combobox2.SetWindowText(strItem);
  910. ::SetFocus(m_combobox2.GetSafeHwnd());
  911. m_combobox2.SetCtrlData(MAKEWPARAM(nIndex,nItem));
  912. }
  913. else
  914. m_combobox2.ShowWindow(SW_HIDE);
  915. }
  916. catch(...)
  917. {
  918. }
  919. }
  920. void XTable::ShowSearchClientComboBoxTree(BOOL bShow,int nItem,int nIndex,int type,CRect rcCtrl)
  921. {
  922. try
  923. {
  924. if(0)//m_pComboBox->m_hWnd == NULL)
  925. {
  926. m_pComboBox->Create(WS_VSCROLL|WS_CHILD|CBS_DROPDOWNLIST,CRect(0,0,100,100),this,100);
  927. m_pComboBox->ShowWindow(SW_HIDE);
  928. m_pComboBox->SetFocus ();
  929. }
  930. if(bShow == TRUE)
  931. {
  932. CString strItem = GetText(nItem,nIndex);
  933. rcCtrl.bottom+=300;
  934. ClientToScreen(rcCtrl);
  935. GetParent()->GetParent()->ScreenToClient(rcCtrl);
  936. m_pComboBox->MoveWindow(rcCtrl);
  937. m_pComboBox->ShowWindow(SW_SHOW);
  938. m_pComboBox->ResetContent();
  939. m_pComboBox->AddString(strItem);
  940. m_pComboBox->SetCurSel (0);
  941. ::SetFocus(m_pComboBox->GetSafeHwnd());
  942. m_pComboBox->SetCtrlData(MAKEWPARAM(nIndex,nItem));
  943. m_pComboBox->RefDroppedWidth();
  944. }
  945. else
  946. m_pComboBox->ShowWindow(SW_HIDE);
  947. }
  948. catch(...)
  949. {
  950. }
  951. }
  952. void XTable::OnLButtonDblClk(UINT nFlags, CPoint point)
  953. {
  954. try
  955. {
  956. if(!m_bFocusFrame)return;
  957. if(HitTest (point,focusRow,focusCol)==0)return;
  958. if(IsDateRow(focusRow))return;
  959. RECT rect = GetRect (focusRow,focusCol);
  960. if(focusCol==0)return;
  961. int nAdd=0;
  962. if(m_mode==10)
  963. {
  964. if(focusRow>0)
  965. {
  966. for(int i=0; i<focusRow; i++)
  967. {
  968. if(""==GetText(i,1))
  969. {
  970. AfxMessageBox("请从上方空白处开始填起!", MB_ICONINFORMATION);
  971. return;
  972. }
  973. }
  974. }
  975. if(focusCol==1)
  976. {
  977. // m_nCurShow=1;
  978. // ShowSearchClientComboBox(TRUE,focusRow,focusCol,rect);
  979. m_nCurShow=0;
  980. ShowEdit(TRUE,focusRow,focusCol,rect);
  981. }
  982. else if(""==GetText(focusRow,1))
  983. {
  984. AfxMessageBox("请先填写客人姓名!", MB_ICONINFORMATION);
  985. return;
  986. }
  987. if(focusCol==11+nAdd)return;
  988. if(focusCol==3)
  989. { m_nCurShow=2;
  990. ShowSearchClientComboBoxTime(TRUE,focusRow,focusCol,0,rect);
  991. }
  992. else if(focusCol==6+nAdd)
  993. { m_nCurShow=2;
  994. ShowSearchClientComboBoxTime(TRUE,focusRow,focusCol,2,rect);
  995. }
  996. else if(focusCol==7+nAdd)
  997. { m_nCurShow=2;
  998. ShowSearchClientComboBoxTime(TRUE,focusRow,focusCol,2,rect);
  999. }
  1000. else if(focusCol==8+nAdd)
  1001. { m_nCurShow=2;
  1002. ShowSearchClientComboBoxTime(TRUE,focusRow,focusCol,2,rect);
  1003. }
  1004. else if(focusCol==12+nAdd)
  1005. { m_nCurShow=2;
  1006. ShowSearchClientComboBoxTime(TRUE,focusRow,focusCol,5,rect);
  1007. }
  1008. else if(focusCol!=1)
  1009. { m_nCurShow=0;
  1010. ShowEdit(TRUE,focusRow,focusCol,rect);
  1011. }
  1012. }
  1013. else
  1014. {
  1015. if(m_mode==4)nAdd=1;
  1016. if(focusRow>0)
  1017. {
  1018. for(int i=0; i<focusRow; i++)
  1019. {
  1020. if(""==GetText(i,1))
  1021. {
  1022. AfxMessageBox("请从上方空白处开始填起!", MB_ICONINFORMATION);
  1023. return;
  1024. }
  1025. }
  1026. }
  1027. if(focusCol==1)
  1028. { m_nCurShow=1;
  1029. ShowSearchClientComboBox(TRUE,focusRow,focusCol,rect);
  1030. }
  1031. else if(""==GetText(focusRow,1))
  1032. {
  1033. AfxMessageBox("请先填写客人姓名!", MB_ICONINFORMATION);
  1034. return;
  1035. }
  1036. if(focusCol==11+nAdd)return;
  1037. if(focusCol==3)
  1038. { m_nCurShow=2;
  1039. ShowSearchClientComboBoxTime(TRUE,focusRow,focusCol,0,rect);
  1040. }
  1041. else if(focusCol==4+nAdd)
  1042. { m_nCurShow=2;
  1043. ShowSearchClientComboBoxTime(TRUE,focusRow,focusCol,1,rect);
  1044. }
  1045. else if(focusCol==6+nAdd)
  1046. { m_nCurShow=2;
  1047. ShowSearchClientComboBoxTime(TRUE,focusRow,focusCol,2,rect);
  1048. }
  1049. else if(focusCol==7+nAdd)
  1050. { m_nCurShow=2;
  1051. ShowSearchClientComboBoxTime(TRUE,focusRow,focusCol,3,rect);
  1052. }
  1053. else if(focusCol==8+nAdd)
  1054. { m_nCurShow=2;
  1055. ShowSearchClientComboBoxTime(TRUE,focusRow,focusCol,4,rect);
  1056. }
  1057. else if(focusCol==12+nAdd)
  1058. { m_nCurShow=2;
  1059. ShowSearchClientComboBoxTime(TRUE,focusRow,focusCol,5,rect);
  1060. }
  1061. else if(focusCol!=1)
  1062. { m_nCurShow=0;
  1063. ShowEdit(TRUE,focusRow,focusCol,rect);
  1064. }
  1065. }
  1066. }
  1067. catch(...)
  1068. {
  1069. }
  1070. CWnd::OnLButtonDown(nFlags, point);
  1071. }
  1072. BOOL XTable::RegisterWindowClass()
  1073. {
  1074. WNDCLASS wndcls;
  1075. HINSTANCE hInst = AfxGetInstanceHandle();
  1076. if (!(::GetClassInfo(hInst, XTABLE_CLASSNAME, &wndcls)))
  1077. {
  1078. // otherwise we need to register a new class
  1079. wndcls.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
  1080. wndcls.lpfnWndProc = ::DefWindowProc;
  1081. wndcls.cbClsExtra = wndcls.cbWndExtra = 0;
  1082. wndcls.hInstance = hInst;
  1083. wndcls.hIcon = NULL;
  1084. wndcls.hCursor = AfxGetApp()->LoadStandardCursor(IDC_ARROW);
  1085. wndcls.hbrBackground = (HBRUSH) (COLOR_3DFACE + 1);
  1086. wndcls.lpszMenuName = NULL;
  1087. wndcls.lpszClassName = XTABLE_CLASSNAME;
  1088. if (!AfxRegisterClass(&wndcls))
  1089. {
  1090. AfxThrowResourceException();
  1091. return FALSE;
  1092. }
  1093. }
  1094. return TRUE;
  1095. }
  1096. int XTable::Test2 ()
  1097. {
  1098. defaultHeight = 20;
  1099. CStringArray array;
  1100. if(m_mode==10)
  1101. {
  1102. array.Add ("姓名");
  1103. array.Add ("电话");
  1104. array.Add ("时间");
  1105. array.Add ("内容");
  1106. array.Add ("价格");
  1107. array.Add ("摄影");
  1108. array.Add ("化妆");
  1109. array.Add ("门市");
  1110. array.Add ("欠款");
  1111. array.Add ("备注");
  1112. array.Add ("录入");
  1113. array.Add ("是否到店");
  1114. }
  1115. else if(m_mode==4)
  1116. {
  1117. array.Add ("姓名");
  1118. array.Add ("电话");
  1119. array.Add ("时间");
  1120. array.Add ("婚庆内容");
  1121. array.Add ("类别");
  1122. array.Add ("价格");
  1123. array.Add ("摄影");
  1124. #ifdef CHILD_VERSION
  1125. array.Add ("引导");
  1126. #else
  1127. array.Add ("化妆");
  1128. #endif
  1129. array.Add ("门市");
  1130. array.Add ("欠款");
  1131. array.Add ("备注");
  1132. array.Add ("录入");
  1133. array.Add ("是否到店");
  1134. }
  1135. else
  1136. {
  1137. array.Add ("姓名");
  1138. array.Add ("电话");
  1139. array.Add ("时间");
  1140. array.Add ("类别");
  1141. array.Add ("价格");
  1142. array.Add ("摄影");
  1143. #ifdef CHILD_VERSION
  1144. array.Add ("引导");
  1145. #else
  1146. array.Add ("化妆");
  1147. #endif
  1148. array.Add ("门市");
  1149. array.Add ("欠款");
  1150. array.Add ("备注");
  1151. array.Add ("录入");
  1152. array.Add ("是否到店");
  1153. }
  1154. int cols=array.GetSize();
  1155. CRect rc;
  1156. GetClientRect(rc);
  1157. defaultWidth = (rc.Width()-10)/cols;
  1158. SetCols (1);
  1159. SetRows (2);
  1160. SetCols (cols+1);
  1161. COLORREF col1=RGB(0xC8, 0x96, 0x96);
  1162. COLORREF col2=RGB(0x64,0x96,0xC8);
  1163. int i = 0;
  1164. for (/*int*/ i = 0; i < 2; i ++)
  1165. SetBackColor (i, 0, col1);
  1166. for ( i = 0; i < cols+1; i ++)
  1167. SetBackColor (0, i, col1);
  1168. SetRowHeight (0, 10);
  1169. SetColWidth (0, 10);
  1170. for(i=0; i<cols; i++)
  1171. {
  1172. SetBackColor (1,i+1, col2);
  1173. SetText (1,i+1, array.ElementAt (i));
  1174. }
  1175. Invalidate();
  1176. return 0;
  1177. }
  1178. ///edit
  1179. XTableEdit::XTableEdit()
  1180. {
  1181. }
  1182. XTableEdit::~XTableEdit()
  1183. {
  1184. }
  1185. BEGIN_MESSAGE_MAP(XTableEdit, CEdit)
  1186. //{{AFX_MSG_MAP(XTableEdit)
  1187. ON_WM_KILLFOCUS()
  1188. ON_WM_SETFOCUS()
  1189. //}}AFX_MSG_MAP
  1190. END_MESSAGE_MAP()
  1191. /////////////////////////////////////////////////////////////////////////////
  1192. // XTableEdit message handlers
  1193. void XTableEdit::SetCtrlData(DWORD dwData)
  1194. {
  1195. m_dwData = dwData;
  1196. }
  1197. DWORD XTableEdit::GetCtrlData()
  1198. {
  1199. return m_dwData;
  1200. }
  1201. void XTableEdit::OnKillFocus(CWnd* pNewWnd)
  1202. {
  1203. CEdit::OnKillFocus(pNewWnd);
  1204. CWnd* pParent = this->GetParent();
  1205. ::PostMessage(pParent->GetSafeHwnd(),WM_USER_EDIT_END,m_bExchange,0);
  1206. }
  1207. BOOL XTableEdit::PreTranslateMessage(MSG* pMsg)
  1208. {
  1209. if(pMsg->message == WM_KEYDOWN)
  1210. {
  1211. if(pMsg->wParam == VK_RETURN)
  1212. {
  1213. CWnd* pParent = this->GetParent();
  1214. m_bExchange = TRUE;
  1215. ::PostMessage(pParent->GetSafeHwnd(),WM_USER_EDIT_END,m_bExchange,0);
  1216. }
  1217. else if(pMsg->wParam == VK_ESCAPE)
  1218. {
  1219. CWnd* pParent = this->GetParent();
  1220. m_bExchange = FALSE;
  1221. ::PostMessage(pParent->GetSafeHwnd(),WM_USER_EDIT_END,m_bExchange,0);
  1222. }
  1223. }
  1224. return CEdit::PreTranslateMessage(pMsg);
  1225. }
  1226. void XTableEdit::OnSetFocus(CWnd* pOldWnd)
  1227. {
  1228. CEdit::OnSetFocus(pOldWnd);
  1229. m_bExchange = TRUE;
  1230. }
  1231. XTableComboBox::XTableComboBox()
  1232. {
  1233. }
  1234. XTableComboBox::~XTableComboBox()
  1235. {
  1236. }
  1237. BEGIN_MESSAGE_MAP(XTableComboBox, CComboBox)
  1238. //{{AFX_MSG_MAP(XTableComboBox)
  1239. ON_WM_KILLFOCUS()
  1240. ON_WM_SETFOCUS()
  1241. ON_CONTROL_REFLECT(CBN_CLOSEUP, OnCloseup)
  1242. //}}AFX_MSG_MAP
  1243. END_MESSAGE_MAP()
  1244. /////////////////////////////////////////////////////////////////////////////
  1245. // XTableComboBox message handlers
  1246. void XTableComboBox::SetCtrlData(DWORD dwData)
  1247. {
  1248. m_dwData = dwData;
  1249. }
  1250. DWORD XTableComboBox::GetCtrlData()
  1251. {
  1252. return m_dwData;
  1253. }
  1254. void XTableComboBox::OnKillFocus(CWnd* pNewWnd)
  1255. {
  1256. CComboBox::OnKillFocus(pNewWnd);
  1257. /* CWnd* pParent = this->GetParent();
  1258. if(((XTable*)pParent)->m_nCurShow!=-1)
  1259. ::PostMessage(pParent->GetSafeHwnd(),WM_USER_EDIT_END,m_bExchange,1);*/
  1260. }
  1261. BOOL XTableComboBox::PreTranslateMessage(MSG* pMsg)
  1262. {
  1263. if(pMsg->message == WM_KEYDOWN)
  1264. {
  1265. if(pMsg->wParam == VK_RETURN)
  1266. {
  1267. CWnd* pParent = this->GetParent();
  1268. m_bExchange = TRUE;
  1269. ::PostMessage(pParent->GetSafeHwnd(),WM_USER_EDIT_END,m_bExchange,1);
  1270. }
  1271. else if(pMsg->wParam == VK_ESCAPE)
  1272. {
  1273. CWnd* pParent = this->GetParent();
  1274. m_bExchange = FALSE;
  1275. ::PostMessage(pParent->GetSafeHwnd(),WM_USER_EDIT_END,m_bExchange,1);
  1276. }
  1277. }
  1278. return CComboBox::PreTranslateMessage(pMsg);
  1279. }
  1280. void XTableComboBox::OnSetFocus(CWnd* pOldWnd)
  1281. {
  1282. CComboBox::OnSetFocus(pOldWnd);
  1283. m_bExchange = TRUE;
  1284. }
  1285. void XTableComboBox::OnCloseup()
  1286. {
  1287. // TODO: Add your control notification handler code here
  1288. CWnd* pParent = this->GetParent();
  1289. ::PostMessage(pParent->GetSafeHwnd(),WM_USER_EDIT_END,m_bExchange,1);
  1290. }
  1291. void XTable::CalRowHeight()
  1292. {
  1293. CString str; CPaintDC dc(this);
  1294. for(int i=0; i<GetRows(); i++)
  1295. {
  1296. SetRowHeight (i, 20);
  1297. for(int j=1; j<GetCols(); j++)
  1298. {
  1299. str=GetText(i, j);
  1300. RECT rect = GetRect(i,j);
  1301. RECT textRect=rect;
  1302. this->SetWordbreak (i, j, 0);
  1303. XCell* cell = GetCells (i, j);
  1304. cell->CalcTextRect(&dc, &textRect);
  1305. if (textRect.right > rect.right || textRect.bottom > rect.bottom)
  1306. {
  1307. this->SetWordbreak (i, j, 1);
  1308. textRect=rect;
  1309. cell->CalcTextRect(&dc, &textRect);
  1310. rect.bottom =textRect.bottom+2;
  1311. // if(rect.bottom-rect.top>100)rect.bottom=rect.top+100;
  1312. SetRowHeight (i, rect.bottom-rect.top);
  1313. }
  1314. }
  1315. }
  1316. Invalidate();
  1317. }
  1318. void XTable::Save(int row)
  1319. {
  1320. if(m_mode==4)
  1321. {
  1322. Save2(row);return;
  1323. }
  1324. if(m_mode==10)
  1325. {
  1326. Save3(row);return;
  1327. }
  1328. if(IsHasRightsnew(2)==0)return;
  1329. if(::GetTickCount ()-m_nticks<1000)return;
  1330. m_nticks=::GetTickCount ();
  1331. int oldrow=row;
  1332. BOOL bFind=0;
  1333. for(int i=0; i<m_daterowposarray.GetSize (); i++)
  1334. {
  1335. if(row<m_daterowposarray.ElementAt (i))
  1336. {
  1337. row-=i;bFind=1;
  1338. break;
  1339. }
  1340. if(row==m_daterowposarray.ElementAt (i))
  1341. return;
  1342. }
  1343. if(bFind==0)row-=m_daterowposarray.GetSize ();
  1344. if(row>=m_pListArray->GetSize())//新预约
  1345. {
  1346. CString name=GetText(oldrow, 1);
  1347. CString phone=GetText(oldrow, 2);
  1348. CString time=GetText(oldrow, 3);
  1349. CString type=GetText(oldrow, 4);
  1350. CString price=GetText(oldrow, 5);
  1351. CString waiter1=GetText(oldrow, 6);
  1352. CString waiter2=GetText(oldrow, 7);
  1353. CString receptionist=GetText(oldrow, 8);
  1354. CString arrearage=GetText(oldrow, 9);
  1355. CString remark=GetText(oldrow, 10);
  1356. CString arrive=GetText(oldrow, 12);
  1357. CString timestamp=CTime::GetCurrentTime ().Format ("%Y%m%d%H%M%S");
  1358. CString str=CTime::GetCurrentTime ().Format ("%Y-%m-%d %H:%M:%S");
  1359. str.Replace("-", "");
  1360. str=str.Left(str.GetLength()-3);
  1361. CString clerk=GetText(oldrow, 11)+str;
  1362. CString date=((TodayForm2*)(GetParent()->GetParent()))->GetDate();
  1363. if(name.IsEmpty())return;
  1364. CString sql,sql2;
  1365. sql.Format ("insert into [todaytake]([name],[phone],[time],[type],[price],[waiter1],[waiter2],[receptionist],[arrearage],[remark],[clerk],[timestamp],[date],[mode],[arrive],[id])values('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%d','%s','%s')", name,phone,time,type,price,waiter1,waiter2,receptionist,arrearage,remark,clerk,timestamp,date,m_mode,arrive,m_id);
  1366. if(m_mode==0)
  1367. {
  1368. sql2.Format ("***update dindan set [time2]='%s' where [id]='%s'", date, m_id);
  1369. }
  1370. else if(m_mode==1)
  1371. {
  1372. sql2.Format ("***update dindan set [time4]='%s' where [id]='%s'", date, m_id);
  1373. }
  1374. else if(m_mode==2)
  1375. {
  1376. sql2.Format ("***update dindan set [time6]='%s' where [id]='%s'", date, m_id);
  1377. }
  1378. else if(m_mode==3)
  1379. {
  1380. sql2.Format ("***update dindan set [time5]='%s' where [id]='%s'", date, m_id);
  1381. }
  1382. sql+=sql2;
  1383. g_sendhead.bsql=1;
  1384. g_pMainWnd->ProcessChatMessageRequest2(sql); //if(g_bSendOK==0)return;
  1385. ((TodayForm2*)(GetParent()->GetParent()))->ReLoad1();
  1386. }
  1387. else
  1388. {
  1389. CString name=GetText(oldrow, 1);
  1390. CString phone=GetText(oldrow, 2);
  1391. CString time=GetText(oldrow, 3);
  1392. CString type=GetText(oldrow, 4);
  1393. CString price=GetText(oldrow, 5);
  1394. CString waiter1=GetText(oldrow, 6);
  1395. CString waiter2=GetText(oldrow, 7);
  1396. CString receptionist=GetText(oldrow, 8);
  1397. CString arrearage=GetText(oldrow, 9);
  1398. CString remark=GetText(oldrow, 10);
  1399. CString clerk=GetText(oldrow, 11);
  1400. CString arrive=GetText(oldrow, 12);
  1401. CString timestamp=m_pListArray->ElementAt(row).ElementAt(13);
  1402. if(name.IsEmpty())return;
  1403. CString sql;
  1404. sql.Format ("update [todaytake] set [name]='%s',[phone]='%s',[time]='%s',[type]='%s',[price]='%s',[waiter1]='%s',[waiter2]='%s',[receptionist]='%s',[arrearage]='%s',[remark]='%s',[clerk]='%s',[arrive]='%s' where [timestamp]='%s'", name,phone,time,type,price,waiter1,waiter2,receptionist,arrearage,remark,clerk,arrive,timestamp);
  1405. if(IsHasRights2new(31)==0)
  1406. sql.Format ("update [todaytake] set [name]='%s',[time]='%s',[type]='%s',[waiter1]='%s',[waiter2]='%s',[receptionist]='%s',[arrearage]='%s',[remark]='%s',[clerk]='%s',[arrive]='%s' where [timestamp]='%s'", name,time,type,waiter1,waiter2,receptionist,arrearage,remark,clerk,arrive,timestamp);
  1407. g_sendhead.bsql=1;
  1408. g_pMainWnd->ProcessChatMessageRequest2(sql);
  1409. }
  1410. }
  1411. void XTable::Save2(int row)
  1412. {
  1413. if(IsHasRightsnew(2)==0)return;
  1414. if(::GetTickCount ()-m_nticks<1000)return;
  1415. m_nticks=::GetTickCount ();
  1416. int oldrow=row;
  1417. BOOL bFind=0;
  1418. for(int i=0; i<m_daterowposarray.GetSize (); i++)
  1419. {
  1420. if(row<m_daterowposarray.ElementAt (i))
  1421. {
  1422. row-=i;bFind=1;
  1423. break;
  1424. }
  1425. if(row==m_daterowposarray.ElementAt (i))
  1426. return;
  1427. }
  1428. if(bFind==0)row-=m_daterowposarray.GetSize ();
  1429. if(row>=m_pListArray->GetSize())//新预约
  1430. {
  1431. CString name=GetText(oldrow, 1);
  1432. CString phone=GetText(oldrow, 2);
  1433. CString time=GetText(oldrow, 3);
  1434. CString content=GetText(oldrow, 4);
  1435. CString type=GetText(oldrow, 5);
  1436. CString price=GetText(oldrow, 6);
  1437. CString waiter1=GetText(oldrow, 7);
  1438. CString waiter2=GetText(oldrow, 8);
  1439. CString receptionist=GetText(oldrow, 9);
  1440. CString arrearage=GetText(oldrow, 10);
  1441. CString remark=GetText(oldrow, 11);
  1442. CString str=CTime::GetCurrentTime ().Format ("%Y-%m-%d %H:%M:%S");
  1443. str.Replace("-", "");
  1444. str=str.Left(str.GetLength()-3);
  1445. CString clerk=GetText(oldrow, 12)+str;
  1446. CString arrive=GetText(oldrow, 13);
  1447. CString timestamp=CTime::GetCurrentTime ().Format ("%Y%m%d%H%M%S");
  1448. CString date=((TodayForm2*)(GetParent()->GetParent()))->GetDate();
  1449. if(name.IsEmpty())return;
  1450. CString sql;
  1451. sql.Format ("insert into [todaytake]([name],[phone],[time],[type],[price],[waiter1],[waiter2],[receptionist],[arrearage],[remark],[clerk],[timestamp],[date],[mode],[content],[arrive],[id])values('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%d','%s','%s','%s')", name,phone,time,type,price,waiter1,waiter2,receptionist,arrearage,remark,clerk,timestamp,date,m_mode,content,arrive,m_id);
  1452. g_sendhead.bsql=1;
  1453. g_pMainWnd->ProcessChatMessageRequest2(sql); //if(g_bSendOK==0)return;
  1454. ((TodayForm2*)(GetParent()->GetParent()))->ReLoad1();
  1455. }
  1456. else
  1457. {
  1458. CString name=GetText(oldrow, 1);
  1459. CString phone=GetText(oldrow, 2);
  1460. CString time=GetText(oldrow, 3);
  1461. CString content=GetText(oldrow, 4);
  1462. CString type=GetText(oldrow, 5);
  1463. CString price=GetText(oldrow, 6);
  1464. CString waiter1=GetText(oldrow, 7);
  1465. CString waiter2=GetText(oldrow, 8);
  1466. CString receptionist=GetText(oldrow, 9);
  1467. CString arrearage=GetText(oldrow, 10);
  1468. CString remark=GetText(oldrow, 11);
  1469. CString clerk=GetText(oldrow, 12);
  1470. CString arrive=GetText(oldrow, 13);
  1471. CString timestamp=m_pListArray->ElementAt(row).ElementAt(14);
  1472. if(name.IsEmpty())return;
  1473. CString sql;
  1474. sql.Format ("update [todaytake] set [name]='%s',[phone]='%s',[time]='%s',[type]='%s',[price]='%s',[waiter1]='%s',[waiter2]='%s',[receptionist]='%s',[arrearage]='%s',[remark]='%s',[clerk]='%s',[content]='%s',[arrive]='%s' where [timestamp]='%s'", name,phone,time,type,price,waiter1,waiter2,receptionist,arrearage,remark,clerk,content,arrive,timestamp);
  1475. if(IsHasRights2new(31)==0)
  1476. sql.Format ("update [todaytake] set [name]='%s',[time]='%s',[type]='%s',[waiter1]='%s',[waiter2]='%s',[receptionist]='%s',[arrearage]='%s',[remark]='%s',[clerk]='%s',[content]='%s',[arrive]='%s' where [timestamp]='%s'", name,time,type,waiter1,waiter2,receptionist,arrearage,remark,clerk,content,arrive,timestamp);
  1477. g_sendhead.bsql=1;
  1478. g_pMainWnd->ProcessChatMessageRequest2(sql);
  1479. }
  1480. }
  1481. void XTable::Save3(int row)
  1482. {
  1483. if(IsHasRightsnew(2)==0)return;
  1484. if(::GetTickCount ()-m_nticks<1000)return;
  1485. m_nticks=::GetTickCount ();
  1486. int oldrow=row;
  1487. BOOL bFind=0;
  1488. for(int i=0; i<m_daterowposarray.GetSize (); i++)
  1489. {
  1490. if(row<m_daterowposarray.ElementAt (i))
  1491. {
  1492. row-=i;bFind=1;
  1493. break;
  1494. }
  1495. if(row==m_daterowposarray.ElementAt (i))
  1496. return;
  1497. }
  1498. if(bFind==0)row-=m_daterowposarray.GetSize ();
  1499. if(row>=m_pListArray->GetSize())//新预约
  1500. {
  1501. CString name=GetText(oldrow, 1);
  1502. CString phone=GetText(oldrow, 2);
  1503. CString time=GetText(oldrow, 3);
  1504. CString content=GetText(oldrow, 4);
  1505. CString price=GetText(oldrow, 5);
  1506. CString waiter1=GetText(oldrow, 6);
  1507. CString waiter2=GetText(oldrow, 7);
  1508. CString receptionist=GetText(oldrow, 8);
  1509. CString arrearage=GetText(oldrow, 9);
  1510. CString remark=GetText(oldrow, 10);
  1511. CString str=CTime::GetCurrentTime ().Format ("%Y-%m-%d %H:%M:%S");
  1512. str.Replace("-", "");
  1513. str=str.Left(str.GetLength()-3);
  1514. CString clerk=GetText(oldrow, 11)+str;
  1515. CString arrive=GetText(oldrow, 12);
  1516. CString timestamp=CTime::GetCurrentTime ().Format ("%Y%m%d%H%M%S");
  1517. CString date=((TodayForm*)(GetParent()->GetParent()))->GetDate();
  1518. if(name.IsEmpty())return;
  1519. CString sql;
  1520. sql.Format ("insert into [todaytake]([name],[phone],[time],[price],[waiter1],[waiter2],[receptionist],[arrearage],[remark],[clerk],[timestamp],[date],[mode],[content],[arrive],[id])values('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%d','%s','%s','%s')", name,phone,time,price,waiter1,waiter2,receptionist,arrearage,remark,clerk,timestamp,date,m_mode,content,arrive,m_id);
  1521. g_sendhead.bsql=1;
  1522. g_pMainWnd->ProcessChatMessageRequest2(sql); //if(g_bSendOK==0)return;
  1523. ((TodayForm*)(GetParent()->GetParent()))->ReLoad1();
  1524. }
  1525. else
  1526. {
  1527. CString name=GetText(oldrow, 1);
  1528. CString phone=GetText(oldrow, 2);
  1529. CString time=GetText(oldrow, 3);
  1530. CString content=GetText(oldrow, 4);
  1531. CString price=GetText(oldrow, 5);
  1532. CString waiter1=GetText(oldrow, 6);
  1533. CString waiter2=GetText(oldrow, 7);
  1534. CString receptionist=GetText(oldrow, 8);
  1535. CString arrearage=GetText(oldrow, 9);
  1536. CString remark=GetText(oldrow, 10);
  1537. CString clerk=GetText(oldrow, 11);
  1538. CString arrive=GetText(oldrow, 12);
  1539. CString timestamp=m_pListArray->ElementAt(row).ElementAt(13);
  1540. if(name.IsEmpty())return;
  1541. CString sql;
  1542. sql.Format ("update [todaytake] set [name]='%s',[phone]='%s',[time]='%s',[price]='%s',[waiter1]='%s',[waiter2]='%s',[receptionist]='%s',[arrearage]='%s',[remark]='%s',[clerk]='%s',[content]='%s',[arrive]='%s' where [timestamp]='%s'", name,phone,time,price,waiter1,waiter2,receptionist,arrearage,remark,clerk,content,arrive,timestamp);
  1543. if(IsHasRights2new(31)==0)
  1544. sql.Format ("update [todaytake] set [name]='%s',[time]='%s',[waiter1]='%s',[waiter2]='%s',[receptionist]='%s',[arrearage]='%s',[remark]='%s',[clerk]='%s',[content]='%s',[arrive]='%s' where [timestamp]='%s'", name,time,waiter1,waiter2,receptionist,arrearage,remark,clerk,content,arrive,timestamp);
  1545. g_sendhead.bsql=1;
  1546. g_pMainWnd->ProcessChatMessageRequest2(sql);
  1547. }
  1548. }
  1549. void XTable::DeleteCur()
  1550. {
  1551. int row=focusRow;
  1552. CString name=GetText(row, 1);
  1553. BOOL bFind=0;
  1554. for(int i=0; i<m_daterowposarray.GetSize (); i++)
  1555. {
  1556. if(row<m_daterowposarray.ElementAt (i))
  1557. {
  1558. row-=i;bFind=1;
  1559. break;
  1560. }
  1561. if(row==m_daterowposarray.ElementAt (i))
  1562. return;
  1563. }
  1564. if(bFind==0)row-=m_daterowposarray.GetSize ();
  1565. if(row>=m_pListArray->GetSize())
  1566. return;
  1567. if(AfxMessageBox("确定删除客人"+name+"的预约资料吗?", MB_YESNO|MB_ICONINFORMATION)!=IDYES)return;
  1568. int size=m_pListArray->ElementAt(row).GetSize ();
  1569. CString timestamp=m_pListArray->ElementAt(row).ElementAt(size-2);
  1570. CString sql;
  1571. sql.Format ("delete from todaytake where [timestamp]='%s'", timestamp);
  1572. g_sendhead.bsql=1;
  1573. g_pMainWnd->ProcessChatMessageRequest2(sql);
  1574. if(m_mode==10)
  1575. ((TodayForm*)(GetParent()->GetParent()))->ReLoad1();
  1576. else
  1577. ((TodayForm2*)(GetParent()->GetParent()))->ReLoad1();
  1578. }
  1579. CString XTable::GetCurPhone(CString &name)
  1580. {
  1581. int row=focusRow;
  1582. name=GetText(row, 1);
  1583. return GetText(row, 2);
  1584. BOOL bFind=0;
  1585. for(int i=0; i<m_daterowposarray.GetSize (); i++)
  1586. {
  1587. if(row<m_daterowposarray.ElementAt (i))
  1588. {
  1589. row-=i;bFind=1;
  1590. break;
  1591. }
  1592. if(row==m_daterowposarray.ElementAt (i))
  1593. return "";
  1594. }
  1595. if(bFind==0)row-=m_daterowposarray.GetSize ();
  1596. if(row>=m_pListArray->GetSize())
  1597. return "";
  1598. int size=m_pListArray->ElementAt(row).GetSize ();
  1599. CString date=m_pListArray->ElementAt(row).ElementAt(size-3);
  1600. CString timestamp=m_pListArray->ElementAt(row).ElementAt(size-2);
  1601. CString id=m_pListArray->ElementAt(row).ElementAt(size-1);
  1602. }
  1603. void XTable::OtherDate()
  1604. {
  1605. int row=focusRow;
  1606. CString name=GetText(row, 1);
  1607. BOOL bFind=0;
  1608. for(int i=0; i<m_daterowposarray.GetSize (); i++)
  1609. {
  1610. if(row<m_daterowposarray.ElementAt (i))
  1611. {
  1612. row-=i;bFind=1;
  1613. break;
  1614. }
  1615. if(row==m_daterowposarray.ElementAt (i))
  1616. return;
  1617. }
  1618. if(bFind==0)row-=m_daterowposarray.GetSize ();
  1619. if(row>=m_pListArray->GetSize())
  1620. return;
  1621. int size=m_pListArray->ElementAt(row).GetSize ();
  1622. CString date=m_pListArray->ElementAt(row).ElementAt(size-3);
  1623. CString timestamp=m_pListArray->ElementAt(row).ElementAt(size-2);
  1624. CString id=m_pListArray->ElementAt(row).ElementAt(size-1);
  1625. InputDate dlg;
  1626. dlg.m_date =date;
  1627. dlg.m_name =name;
  1628. dlg.m_name =m_pListArray->ElementAt(row).ElementAt(0);
  1629. if(dlg.DoModal ()!=IDOK)return;
  1630. CString sql,sql2;
  1631. sql.Format ("update [todaytake] set [date]='%s' where [timestamp]='%s'", dlg.m_date, timestamp);
  1632. g_sendhead.bsql=1;
  1633. if(m_mode==0)
  1634. {
  1635. sql2.Format ("***update dindan set [time2]='%s' where [id]='%s'", dlg.m_date, id);
  1636. }
  1637. else if(m_mode==1)
  1638. {
  1639. sql2.Format ("***update dindan set [time4]='%s' where [id]='%s'", dlg.m_date, id);
  1640. }
  1641. else if(m_mode==2)
  1642. {
  1643. sql2.Format ("***update dindan set [time6]='%s' where [id]='%s'", dlg.m_date, id);
  1644. }
  1645. else if(m_mode==3)
  1646. {
  1647. sql2.Format ("***update dindan set [time5]='%s' where [id]='%s'", dlg.m_date, id);
  1648. }
  1649. sql+=sql2;
  1650. g_pMainWnd->ProcessChatMessageRequest2(sql);
  1651. if(m_mode==10)
  1652. ((TodayForm*)(GetParent()->GetParent()))->ReLoad1();
  1653. else
  1654. ((TodayForm2*)(GetParent()->GetParent()))->ReLoad1();
  1655. }
  1656. BOOL XTable::IsDateRow(int row)
  1657. {
  1658. try
  1659. {
  1660. for(int i=0; i<m_daterowposarray.GetSize (); i++)
  1661. {
  1662. if(row==m_daterowposarray.ElementAt (i))
  1663. return 1;
  1664. }
  1665. }
  1666. catch(...)
  1667. {
  1668. }
  1669. return 0;
  1670. }
  1671. CString XTable::GetWeek(CString date)
  1672. {
  1673. if(date.GetLength ()!=10)return "";
  1674. COleDateTime dtDay(atoi(date.Mid (0,4)),atoi(date.Mid (5,2)),atoi(date.Mid (8,2)), 0, 0, 0);
  1675. int nDayWeek = dtDay.GetDayOfWeek()-1; //得到星期几,1=Sunday, 2=Monday,
  1676. CString DayOfWeek[7]={"星期日","星期一","星期二","星期三","星期四","星期五","星期六"};
  1677. CString sdate;
  1678. if(nDayWeek>=0 && nDayWeek<=6)
  1679. sdate=DayOfWeek[nDayWeek];
  1680. else
  1681. sdate="无效日期";
  1682. return sdate;
  1683. }
  1684. int XTable::Test()
  1685. {
  1686. if(m_mode==10)
  1687. return Test3();
  1688. CStringArray array;
  1689. if(m_mode==4)
  1690. {
  1691. array.Add ("姓名");
  1692. array.Add ("电话");
  1693. array.Add ("时间");
  1694. array.Add ("婚庆内容");
  1695. array.Add ("类别");
  1696. array.Add ("价格");
  1697. array.Add ("摄影");
  1698. #ifdef CHILD_VERSION
  1699. array.Add ("引导");
  1700. #else
  1701. array.Add ("化妆");
  1702. #endif
  1703. array.Add ("门市");
  1704. array.Add ("欠款");
  1705. array.Add ("备注");
  1706. array.Add ("录入");
  1707. array.Add ("是否到店");
  1708. }
  1709. else
  1710. {
  1711. array.Add ("姓名");
  1712. array.Add ("电话");
  1713. array.Add ("时间");
  1714. array.Add ("类别");
  1715. array.Add ("价格");
  1716. array.Add ("摄影");
  1717. #ifdef CHILD_VERSION
  1718. array.Add ("引导");
  1719. #else
  1720. array.Add ("化妆");
  1721. #endif
  1722. array.Add ("门市");
  1723. array.Add ("欠款");
  1724. array.Add ("备注");
  1725. array.Add ("录入");
  1726. array.Add ("是否到店");
  1727. }
  1728. HidePrice();
  1729. int cols=array.GetSize();
  1730. int nAdd=0;
  1731. if(m_mode==4)nAdd=1;
  1732. CRect rc;
  1733. GetClientRect(rc);
  1734. defaultWidth = (rc.Width()-10)/cols;
  1735. int halfwid=defaultWidth;
  1736. SetCols (1);
  1737. SetRows (256);
  1738. SetCols (cols+1);
  1739. int i = 0;
  1740. for(/*int*/ i=0; i<rows; i++)
  1741. {
  1742. for(int j=0; j<cols; j++)
  1743. {
  1744. SetText (i, j+1, "");
  1745. }
  1746. }
  1747. COLORREF col1=RGB(0xC8, 0x96, 0x96);
  1748. COLORREF col2=RGB(0x64,0x96,0xC8);
  1749. COLORREF yellow=RGB(255,255,0);
  1750. COLORREF green=RGB(0,255,255);
  1751. for ( i = 0; i < 46; i ++)
  1752. SetBackColor (i, 0, col1);
  1753. SetColWidth ( 0, 10);
  1754. m_datearray.RemoveAll ();
  1755. m_daterowposarray.RemoveAll ();
  1756. int datesize=0;
  1757. int aa=0;
  1758. CString curdate;
  1759. CStringArray typearray;
  1760. CArray<int,int>typecountarray;
  1761. int pos;
  1762. int oldpos;
  1763. for(i=0; i<m_pListArray->GetSize()+datesize; i++)
  1764. {
  1765. if(m_pListArray->ElementAt(aa).ElementAt(12+nAdd)!=curdate && curdate!="")
  1766. {
  1767. //汇总行
  1768. CString str=" 今日预约: ";
  1769. CString temp;
  1770. for(int a=0; a<typearray.GetSize (); a++)
  1771. {
  1772. temp.Format ("%s:%d ", typearray.ElementAt (a), typecountarray.ElementAt (a));
  1773. str+=temp;
  1774. }
  1775. SetText (oldpos, 1, GetText(oldpos, 1)+str );
  1776. typearray.RemoveAll (); typecountarray.RemoveAll ();
  1777. }
  1778. if(::FindArray (&m_datearray, m_pListArray->ElementAt(aa).ElementAt(12+nAdd))==-1)
  1779. {
  1780. curdate=m_pListArray->ElementAt(aa).ElementAt(12+nAdd);
  1781. m_datearray.Add ( curdate );
  1782. m_daterowposarray.Add (i);
  1783. datesize=m_datearray.GetSize ();
  1784. JoinCells (i,1,i,12+nAdd);
  1785. SetAlignment (i,1,DT_CENTER);
  1786. SetBackColor (i,1, green);
  1787. SetText (i, 1, curdate+" "+GetWeek(curdate) );
  1788. oldpos=i;
  1789. continue;
  1790. }
  1791. pos=::FindArray (&typearray, m_pListArray->ElementAt(aa).ElementAt(3+nAdd));
  1792. if(pos==-1)
  1793. {
  1794. typearray.Add (m_pListArray->ElementAt(aa).ElementAt(3+nAdd));
  1795. typecountarray.Add (1);
  1796. }
  1797. else
  1798. {
  1799. int size=typecountarray.ElementAt (pos);
  1800. typecountarray.SetAt (pos, size+1);
  1801. }
  1802. for(int j=0; j<cols; j++)
  1803. {
  1804. SetText (i, j+1, m_pListArray->ElementAt(aa).ElementAt(j));
  1805. if(j==8+nAdd && atoi(m_pListArray->ElementAt(aa).ElementAt(j))>0 )
  1806. {
  1807. SetBackColor (i,j+1, RGB(255,0,0));
  1808. }
  1809. else if(j==8+nAdd)SetBackColor (i,j+1, RGB(0,255,0));
  1810. if(j==11+nAdd && m_pListArray->ElementAt(aa).ElementAt(j)=="未到" )
  1811. {
  1812. SetBackColor (i,j+1, RGB(255,0,0));
  1813. }
  1814. else if(j==11+nAdd)SetBackColor (i,j+1, RGB(0,255,0));
  1815. }
  1816. aa++;
  1817. }
  1818. if(m_pListArray->GetSize())
  1819. {
  1820. //汇总行
  1821. CString str=" 今日预约: ";
  1822. CString temp;
  1823. for(int a=0; a<typearray.GetSize (); a++)
  1824. {
  1825. temp.Format ("%s:%d ", typearray.ElementAt (a), typecountarray.ElementAt (a));
  1826. str+=temp;
  1827. }
  1828. SetText (oldpos, 1, GetText(oldpos, 1)+str );
  1829. }
  1830. CalRowHeight();
  1831. return 0;
  1832. JoinCells (3,5,4,6);
  1833. SetText (3,5, "This cell contains multiline text, which provides multiline edit.张三, 李四, 王五Using default font张三, 李四, 王五Using default font");
  1834. SetWordbreak (3,5,true);
  1835. return 0;
  1836. JoinCells (3,7,5,8);
  1837. SetText (3,7, "This cell contains multiline text, which provides multiline edit.");
  1838. SetWordbreak (3,7,true);
  1839. SetText (4,1, "You can even edit a long (cell overlapping) string.");
  1840. SetOverlap(4,1,true);
  1841. SetText (4,3, "Test");
  1842. JoinCells (5,1,6,2);
  1843. SetText (5,1, "Enter your name here.");
  1844. JoinCells (5,3,5,4);
  1845. SetText (5,3, "Enter your text here ...");
  1846. JoinCells (8,1,8,8);
  1847. SetBackColor (8,1, RGB(0x64,0x96,0xC8));
  1848. SetText (8,1, "Default edit controls also allow us to customize user's editing experience by:");
  1849. JoinCells (10,1,10,2);
  1850. SetBackColor (10,1, RGB(0xDC,0xC8,0xB4));
  1851. SetText (10,1, "Converting input to upper case:");
  1852. SetText (10,3, "TYPE HERE ...");
  1853. JoinCells (10,5,10,6);
  1854. SetBackColor (10,5, RGB(0xDC,0xC8,0xB4));
  1855. SetText (10,5, "Converting input to lower case:");
  1856. SetText (10,7, "type here ...");
  1857. JoinCells (11,1,11,2);
  1858. SetBackColor (11,1, RGB(0xDC,0xC8,0xB4));
  1859. SetText (11,1, "Allowing password input:");
  1860. SetText (11,3, "*********");
  1861. SetText (11,5, "Entered password was:*********");
  1862. SetOverlap(11,5,true);
  1863. JoinCells (12,1,12,2);
  1864. SetBackColor (12,1, RGB(0xDC,0xC8,0xB4));
  1865. SetText (12,1, "Allowing aligned input:");
  1866. SetText (12,3, "Left aligned");
  1867. SetText (12,5, "Centered");
  1868. SetAlignment (12,5,DT_CENTER);
  1869. SetText (12,7, "Right aligned");
  1870. SetAlignment (12,7,DT_RIGHT);
  1871. JoinCells (14,1,14,8);
  1872. SetBackColor (14,1, RGB(0x64,0x96,0xC8));
  1873. SetText (14,1, "Ultimate Grid allow us to process user's input with various notifications.");
  1874. JoinCells (16,1,16,5);
  1875. SetBackColor (16,1, RGB(0xDC,0xC8,0xB4));
  1876. SetText (16,1, "We can verify data it is entered, for example to limit number of char to 4:");
  1877. SetText (16,6, "<Type here>");
  1878. JoinCells (17,1,17,5);
  1879. SetBackColor (17,1, RGB(0xDC,0xC8,0xB4));
  1880. SetText (17,1, "or that the numeric value entered is under 500 (number < 500):");
  1881. SetText (17,6, "<Type here>");
  1882. JoinCells (18,1,18,5);
  1883. SetBackColor (18,1, RGB(0xDC,0xC8,0xB4));
  1884. SetText (18,1, "We can also test user's input after it is completed, or force user's input:");
  1885. SetText (18,6, "<Type here>");
  1886. JoinCells (20,1,20,8);
  1887. SetBackColor (20,1, RGB(0x64,0x96,0xC8));
  1888. SetText (20,1, "The Ultimate Grid also allows us to use other edit controls when needed:");
  1889. JoinCells (22,1,23,5);
  1890. SetBackColor (22,1, RGB(0xDC,0xC8,0xB4));
  1891. SetText (22,1, "Just by setting a mask on a cell, the grid will change edit controls to use a mask edit. By default Ultimate Grid creates an instance of CUGMEdit to use as mask edit control.");
  1892. SetWordbreak (22,1,true);
  1893. JoinCells (22,6,22,7);
  1894. SetText (22,6, "<Select mask>");
  1895. JoinCells (23,6,23,7);
  1896. SetText (23,6, "<Type here>");
  1897. JoinCells (25,1,27,5);
  1898. SetBackColor (25,1, RGB(0xDC,0xC8,0xB4));
  1899. SetText (25,1, "The Ultimate Grid 5 also comes with a set of advanced edit control previosly only found in Ultimate ToolBox. We can now easily incorporate powerful controls like COXMaskEdit, COXNumericEdit, and COXCurrencyEdit into our applications.");
  1900. SetWordbreak (25,1,true);
  1901. JoinCells (29,1,30,5);
  1902. SetBackColor (29,1, RGB(0xDC,0xC8,0xB4));
  1903. SetText (29,1, "The COXMaskEdit works very similarly to the default mask edit control, to use it just set a mask on a cell and inform the grid that you want to use different edit control.");
  1904. SetWordbreak (29,1,true);
  1905. JoinCells (29,6,29,8);
  1906. SetText (29,6, "<Select mask>");
  1907. JoinCells (30,6,30,8);
  1908. SetText (30,6, "<Type here>");
  1909. JoinCells (32,1,33,5);
  1910. SetBackColor (32,1, RGB(0xDC,0xC8,0xB4));
  1911. SetText (32,1, "The COXNumericEdit and COXCurrencyEdit on the other hand allow us to provide additional setup information that will drive the way the edit control will behave.");
  1912. SetWordbreak (32,1,true);
  1913. JoinCells (35,1,35,2);
  1914. SetBackColor (35,1, RGB(0xDC,0xC8,0xB4));
  1915. SetText (35,1, "Using COXNumericEdit:");
  1916. JoinCells (35,3,35,4);
  1917. SetText (35,3, "<Type here>");
  1918. JoinCells (35,5,35,6);
  1919. SetBackColor (35,5, RGB(0xDC,0xC8,0xB4));
  1920. SetText (35,5, "Using COXCurrencyEdit:");
  1921. JoinCells (35,7,35,8);
  1922. SetText (35,7, "<Type here>");
  1923. JoinCells (36,1,36,3);
  1924. SetBackColor (36,1, RGB(0x64,0x96,0xC8));
  1925. SetText (36,1, "Following are properties we can set.");
  1926. JoinCells (36,5,36,7);
  1927. SetBackColor (36,5, RGB(0x64,0x96,0xC8));
  1928. SetText (36,5, "Following are properties we can set.");
  1929. JoinCells (37,1,37,2);
  1930. SetBackColor (37,1, RGB(0xDC,0xC8,0xB4));
  1931. SetText (37,1, "Decimal digit count :");
  1932. JoinCells (37,5,37,6);
  1933. SetBackColor (37,5, RGB(0xDC,0xC8,0xB4));
  1934. SetText (37,5, "Decimal digit count :");
  1935. JoinCells (38,1,38,2);
  1936. SetBackColor (38,1, RGB(0xDC,0xC8,0xB4));
  1937. SetText (38,1, "Decimal Separator :");
  1938. JoinCells (38,5,38,6);
  1939. SetBackColor (38,5, RGB(0xDC,0xC8,0xB4));
  1940. SetText (38,5, "Decimal Separator :");
  1941. JoinCells (39,1,39,2);
  1942. SetBackColor (39,1, RGB(0xDC,0xC8,0xB4));
  1943. SetText (39,1, "Fractional digit count :");
  1944. JoinCells (39,5,39,6);
  1945. SetBackColor (39,5, RGB(0xDC,0xC8,0xB4));
  1946. SetText (39,5, "Fractional digit count :");
  1947. JoinCells (40,1,40,2);
  1948. SetBackColor (40,1, RGB(0xDC,0xC8,0xB4));
  1949. SetText (40,1, "Group Separator :");
  1950. JoinCells (40,5,40,6);
  1951. SetBackColor (40,5, RGB(0xDC,0xC8,0xB4));
  1952. SetText (40,5, "Group Separator :");
  1953. JoinCells (41,1,41,2);
  1954. SetBackColor (41,1, RGB(0xDC,0xC8,0xB4));
  1955. SetText (41,1, "Digits in group :");
  1956. JoinCells (41,5,41,6);
  1957. SetBackColor (41,5, RGB(0xDC,0xC8,0xB4));
  1958. SetText (41,5, "Digits in group :");
  1959. JoinCells (42,1,42,2);
  1960. SetBackColor (42,1, RGB(0xDC,0xC8,0xB4));
  1961. SetText (42,1, "Negative Format :");
  1962. JoinCells (42,5,42,6);
  1963. SetBackColor (42,5, RGB(0xDC,0xC8,0xB4));
  1964. SetText (42,5, "Positive Format :");
  1965. JoinCells (43,1,43,2);
  1966. SetBackColor (43,1, RGB(0xDC,0xC8,0xB4));
  1967. SetText (43,1, "Show leading zero :");
  1968. JoinCells (43,5,43,6);
  1969. SetBackColor (43,5, RGB(0xDC,0xC8,0xB4));
  1970. SetText (43,5, "Negative Format :");
  1971. JoinCells (44,5,44,6);
  1972. SetBackColor (44,5, RGB(0xDC,0xC8,0xB4));
  1973. SetText (44,5, "Currency name :");
  1974. JoinCells (45,5,45,6);
  1975. SetBackColor (45,5, RGB(0xDC,0xC8,0xB4));
  1976. SetText (45,5, "Show leading zero :");
  1977. return 0;
  1978. }
  1979. int XTable::Test3()
  1980. {
  1981. CStringArray array;
  1982. array.Add ("姓名");
  1983. array.Add ("电话");
  1984. array.Add ("时间");
  1985. array.Add ("内容");
  1986. array.Add ("价格");
  1987. array.Add ("摄影");
  1988. array.Add ("化妆");
  1989. array.Add ("门市");
  1990. array.Add ("欠款");
  1991. array.Add ("备注");
  1992. array.Add ("录入");
  1993. array.Add ("是否到店");
  1994. int cols=array.GetSize();
  1995. int nAdd=0;
  1996. CRect rc;
  1997. GetClientRect(rc);
  1998. defaultWidth = (rc.Width()-10)/cols;
  1999. int halfwid=defaultWidth;
  2000. SetCols (1);
  2001. SetRows (256);
  2002. SetCols (cols+1);
  2003. int i = 0;
  2004. for(/*int*/ i=0; i<rows; i++)
  2005. {
  2006. for(int j=0; j<cols; j++)
  2007. {
  2008. SetText (i, j+1, "");
  2009. }
  2010. }
  2011. COLORREF col1=RGB(0xC8, 0x96, 0x96);
  2012. COLORREF col2=RGB(0x64,0x96,0xC8);
  2013. COLORREF yellow=RGB(255,255,0);
  2014. COLORREF green=RGB(0,255,255);
  2015. for ( i = 0; i < 46; i ++)
  2016. SetBackColor (i, 0, col1);
  2017. SetColWidth ( 0, 10);
  2018. m_datearray.RemoveAll ();
  2019. m_daterowposarray.RemoveAll ();
  2020. int datesize=0;
  2021. int aa=0;
  2022. CString curdate;
  2023. CStringArray typearray;
  2024. CArray<int,int>typecountarray;
  2025. int pos;
  2026. int oldpos;
  2027. for(i=0; i<m_pListArray->GetSize()+datesize; i++)
  2028. {
  2029. if(m_pListArray->ElementAt(aa).ElementAt(12+nAdd)!=curdate && curdate!="")
  2030. {
  2031. //汇总行
  2032. CString str=" 今日预约: ";
  2033. CString temp;
  2034. for(int a=0; a<typearray.GetSize (); a++)
  2035. {
  2036. temp.Format ("%d ", typecountarray.ElementAt (a));
  2037. str+=temp;
  2038. }
  2039. SetText (oldpos, 1, GetText(oldpos, 1)+str );
  2040. typearray.RemoveAll (); typecountarray.RemoveAll ();
  2041. }
  2042. if(::FindArray (&m_datearray, m_pListArray->ElementAt(aa).ElementAt(12+nAdd))==-1)
  2043. {
  2044. curdate=m_pListArray->ElementAt(aa).ElementAt(12+nAdd);
  2045. m_datearray.Add ( curdate );
  2046. m_daterowposarray.Add (i);
  2047. datesize=m_datearray.GetSize ();
  2048. JoinCells (i,1,i,12+nAdd);
  2049. SetAlignment (i,1,DT_CENTER);
  2050. SetBackColor (i,1, green);
  2051. SetText (i, 1, curdate+" "+GetWeek(curdate) );
  2052. oldpos=i;
  2053. continue;
  2054. }
  2055. if(typearray.GetSize()==0)
  2056. {
  2057. typearray.Add ("");
  2058. typecountarray.Add (1);
  2059. }
  2060. else
  2061. {
  2062. int size=typecountarray.ElementAt (0);
  2063. typecountarray.SetAt (0, size+1);
  2064. }
  2065. for(int j=0; j<cols; j++)
  2066. {
  2067. SetText (i, j+1, m_pListArray->ElementAt(aa).ElementAt(j));
  2068. if(j==8+nAdd && atoi(m_pListArray->ElementAt(aa).ElementAt(j))>0 )
  2069. {
  2070. SetBackColor (i,j+1, RGB(255,0,0));
  2071. }
  2072. else if(j==8+nAdd)SetBackColor (i,j+1, RGB(0,255,0));
  2073. if(j==11+nAdd && m_pListArray->ElementAt(aa).ElementAt(j)=="未到" )
  2074. {
  2075. SetBackColor (i,j+1, RGB(255,0,0));
  2076. }
  2077. else if(j==11+nAdd)SetBackColor (i,j+1, RGB(0,255,0));
  2078. }
  2079. aa++;
  2080. }
  2081. if(m_pListArray->GetSize())
  2082. {
  2083. //汇总行
  2084. CString str=" 今日预约: ";
  2085. CString temp;
  2086. for(int a=0; a<typearray.GetSize (); a++)
  2087. {
  2088. temp.Format ("%d ", typecountarray.ElementAt (a));
  2089. str+=temp;
  2090. }
  2091. SetText (oldpos, 1, GetText(oldpos, 1)+str );
  2092. }
  2093. CalRowHeight();
  2094. return 0;
  2095. }
  2096. void XTable::ModeChange(int mode)
  2097. {
  2098. m_mode=mode;
  2099. }
  2100. void XTable::AddName(int row, int col, CString str)
  2101. {
  2102. CString oldtext=GetText(row,col);
  2103. if(oldtext.IsEmpty ())
  2104. {
  2105. SetText(row,col, str);
  2106. return;
  2107. }
  2108. if(oldtext.Find (str)!=-1)return;
  2109. SetText(row,col, oldtext+","+str);
  2110. }
  2111. //化妆师
  2112. void XTable::HidePrice()
  2113. {
  2114. if(m_mode!=4)
  2115. {
  2116. #ifdef LKAY_VERSION
  2117. if(IsHasRights2new(31))return;
  2118. for(int i=0; i< m_pListArray->GetSize (); i++)
  2119. {
  2120. m_pListArray->ElementAt (i).SetAt (1, "***");
  2121. m_pListArray->ElementAt (i).SetAt (4, "***");
  2122. }
  2123. #else
  2124. if(IsHasRights2new(31))return;
  2125. for(int i=0; i< m_pListArray->GetSize (); i++)
  2126. {
  2127. m_pListArray->ElementAt (i).SetAt (1, "***");
  2128. m_pListArray->ElementAt (i).SetAt (4, "***");
  2129. }
  2130. #endif
  2131. }
  2132. else
  2133. {
  2134. #ifdef LKAY_VERSION
  2135. if(IsHasRights2new(31))return;
  2136. for(int i=0; i< m_pListArray->GetSize (); i++)
  2137. {
  2138. m_pListArray->ElementAt (i).SetAt (1, "***");
  2139. m_pListArray->ElementAt (i).SetAt (4, "***");
  2140. }
  2141. #else
  2142. if(IsHasRights2new(31))return;
  2143. for(int i=0; i< m_pListArray->GetSize (); i++)
  2144. {
  2145. m_pListArray->ElementAt (i).SetAt (1, "***");
  2146. m_pListArray->ElementAt (i).SetAt (4, "***");
  2147. }
  2148. #endif
  2149. }
  2150. }