XTable.cpp 58 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539
  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. for (int i = 0; i < 2; i ++)
  1164. SetBackColor (i, 0, col1);
  1165. for ( i = 0; i < cols+1; i ++)
  1166. SetBackColor (0, i, col1);
  1167. SetRowHeight (0, 10);
  1168. SetColWidth (0, 10);
  1169. for(i=0; i<cols; i++)
  1170. {
  1171. SetBackColor (1,i+1, col2);
  1172. SetText (1,i+1, array.ElementAt (i));
  1173. }
  1174. Invalidate();
  1175. return 0;
  1176. }
  1177. ///edit
  1178. XTableEdit::XTableEdit()
  1179. {
  1180. }
  1181. XTableEdit::~XTableEdit()
  1182. {
  1183. }
  1184. BEGIN_MESSAGE_MAP(XTableEdit, CEdit)
  1185. //{{AFX_MSG_MAP(XTableEdit)
  1186. ON_WM_KILLFOCUS()
  1187. ON_WM_SETFOCUS()
  1188. //}}AFX_MSG_MAP
  1189. END_MESSAGE_MAP()
  1190. /////////////////////////////////////////////////////////////////////////////
  1191. // XTableEdit message handlers
  1192. void XTableEdit::SetCtrlData(DWORD dwData)
  1193. {
  1194. m_dwData = dwData;
  1195. }
  1196. DWORD XTableEdit::GetCtrlData()
  1197. {
  1198. return m_dwData;
  1199. }
  1200. void XTableEdit::OnKillFocus(CWnd* pNewWnd)
  1201. {
  1202. CEdit::OnKillFocus(pNewWnd);
  1203. CWnd* pParent = this->GetParent();
  1204. ::PostMessage(pParent->GetSafeHwnd(),WM_USER_EDIT_END,m_bExchange,0);
  1205. }
  1206. BOOL XTableEdit::PreTranslateMessage(MSG* pMsg)
  1207. {
  1208. if(pMsg->message == WM_KEYDOWN)
  1209. {
  1210. if(pMsg->wParam == VK_RETURN)
  1211. {
  1212. CWnd* pParent = this->GetParent();
  1213. m_bExchange = TRUE;
  1214. ::PostMessage(pParent->GetSafeHwnd(),WM_USER_EDIT_END,m_bExchange,0);
  1215. }
  1216. else if(pMsg->wParam == VK_ESCAPE)
  1217. {
  1218. CWnd* pParent = this->GetParent();
  1219. m_bExchange = FALSE;
  1220. ::PostMessage(pParent->GetSafeHwnd(),WM_USER_EDIT_END,m_bExchange,0);
  1221. }
  1222. }
  1223. return CEdit::PreTranslateMessage(pMsg);
  1224. }
  1225. void XTableEdit::OnSetFocus(CWnd* pOldWnd)
  1226. {
  1227. CEdit::OnSetFocus(pOldWnd);
  1228. m_bExchange = TRUE;
  1229. }
  1230. XTableComboBox::XTableComboBox()
  1231. {
  1232. }
  1233. XTableComboBox::~XTableComboBox()
  1234. {
  1235. }
  1236. BEGIN_MESSAGE_MAP(XTableComboBox, CComboBox)
  1237. //{{AFX_MSG_MAP(XTableComboBox)
  1238. ON_WM_KILLFOCUS()
  1239. ON_WM_SETFOCUS()
  1240. ON_CONTROL_REFLECT(CBN_CLOSEUP, OnCloseup)
  1241. //}}AFX_MSG_MAP
  1242. END_MESSAGE_MAP()
  1243. /////////////////////////////////////////////////////////////////////////////
  1244. // XTableComboBox message handlers
  1245. void XTableComboBox::SetCtrlData(DWORD dwData)
  1246. {
  1247. m_dwData = dwData;
  1248. }
  1249. DWORD XTableComboBox::GetCtrlData()
  1250. {
  1251. return m_dwData;
  1252. }
  1253. void XTableComboBox::OnKillFocus(CWnd* pNewWnd)
  1254. {
  1255. CComboBox::OnKillFocus(pNewWnd);
  1256. /* CWnd* pParent = this->GetParent();
  1257. if(((XTable*)pParent)->m_nCurShow!=-1)
  1258. ::PostMessage(pParent->GetSafeHwnd(),WM_USER_EDIT_END,m_bExchange,1);*/
  1259. }
  1260. BOOL XTableComboBox::PreTranslateMessage(MSG* pMsg)
  1261. {
  1262. if(pMsg->message == WM_KEYDOWN)
  1263. {
  1264. if(pMsg->wParam == VK_RETURN)
  1265. {
  1266. CWnd* pParent = this->GetParent();
  1267. m_bExchange = TRUE;
  1268. ::PostMessage(pParent->GetSafeHwnd(),WM_USER_EDIT_END,m_bExchange,1);
  1269. }
  1270. else if(pMsg->wParam == VK_ESCAPE)
  1271. {
  1272. CWnd* pParent = this->GetParent();
  1273. m_bExchange = FALSE;
  1274. ::PostMessage(pParent->GetSafeHwnd(),WM_USER_EDIT_END,m_bExchange,1);
  1275. }
  1276. }
  1277. return CComboBox::PreTranslateMessage(pMsg);
  1278. }
  1279. void XTableComboBox::OnSetFocus(CWnd* pOldWnd)
  1280. {
  1281. CComboBox::OnSetFocus(pOldWnd);
  1282. m_bExchange = TRUE;
  1283. }
  1284. void XTableComboBox::OnCloseup()
  1285. {
  1286. // TODO: Add your control notification handler code here
  1287. CWnd* pParent = this->GetParent();
  1288. ::PostMessage(pParent->GetSafeHwnd(),WM_USER_EDIT_END,m_bExchange,1);
  1289. }
  1290. void XTable::CalRowHeight()
  1291. {
  1292. CString str; CPaintDC dc(this);
  1293. for(int i=0; i<GetRows(); i++)
  1294. {
  1295. SetRowHeight (i, 20);
  1296. for(int j=1; j<GetCols(); j++)
  1297. {
  1298. str=GetText(i, j);
  1299. RECT rect = GetRect(i,j);
  1300. RECT textRect=rect;
  1301. this->SetWordbreak (i, j, 0);
  1302. XCell* cell = GetCells (i, j);
  1303. cell->CalcTextRect(&dc, &textRect);
  1304. if (textRect.right > rect.right || textRect.bottom > rect.bottom)
  1305. {
  1306. this->SetWordbreak (i, j, 1);
  1307. textRect=rect;
  1308. cell->CalcTextRect(&dc, &textRect);
  1309. rect.bottom =textRect.bottom+2;
  1310. // if(rect.bottom-rect.top>100)rect.bottom=rect.top+100;
  1311. SetRowHeight (i, rect.bottom-rect.top);
  1312. }
  1313. }
  1314. }
  1315. Invalidate();
  1316. }
  1317. void XTable::Save(int row)
  1318. {
  1319. if(m_mode==4)
  1320. {
  1321. Save2(row);return;
  1322. }
  1323. if(m_mode==10)
  1324. {
  1325. Save3(row);return;
  1326. }
  1327. if(IsHasRightsnew(2)==0)return;
  1328. if(::GetTickCount ()-m_nticks<1000)return;
  1329. m_nticks=::GetTickCount ();
  1330. int oldrow=row;
  1331. BOOL bFind=0;
  1332. for(int i=0; i<m_daterowposarray.GetSize (); i++)
  1333. {
  1334. if(row<m_daterowposarray.ElementAt (i))
  1335. {
  1336. row-=i;bFind=1;
  1337. break;
  1338. }
  1339. if(row==m_daterowposarray.ElementAt (i))
  1340. return;
  1341. }
  1342. if(bFind==0)row-=m_daterowposarray.GetSize ();
  1343. if(row>=m_pListArray->GetSize())//新预约
  1344. {
  1345. CString name=GetText(oldrow, 1);
  1346. CString phone=GetText(oldrow, 2);
  1347. CString time=GetText(oldrow, 3);
  1348. CString type=GetText(oldrow, 4);
  1349. CString price=GetText(oldrow, 5);
  1350. CString waiter1=GetText(oldrow, 6);
  1351. CString waiter2=GetText(oldrow, 7);
  1352. CString receptionist=GetText(oldrow, 8);
  1353. CString arrearage=GetText(oldrow, 9);
  1354. CString remark=GetText(oldrow, 10);
  1355. CString arrive=GetText(oldrow, 12);
  1356. CString timestamp=CTime::GetCurrentTime ().Format ("%Y%m%d%H%M%S");
  1357. CString str=CTime::GetCurrentTime ().Format ("%Y-%m-%d %H:%M:%S");
  1358. str.Replace("-", "");
  1359. str=str.Left(str.GetLength()-3);
  1360. CString clerk=GetText(oldrow, 11)+str;
  1361. CString date=((TodayForm2*)(GetParent()->GetParent()))->GetDate();
  1362. if(name.IsEmpty())return;
  1363. CString sql,sql2;
  1364. 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);
  1365. if(m_mode==0)
  1366. {
  1367. sql2.Format ("***update dindan set [time2]='%s' where [id]='%s'", date, m_id);
  1368. }
  1369. else if(m_mode==1)
  1370. {
  1371. sql2.Format ("***update dindan set [time4]='%s' where [id]='%s'", date, m_id);
  1372. }
  1373. else if(m_mode==2)
  1374. {
  1375. sql2.Format ("***update dindan set [time6]='%s' where [id]='%s'", date, m_id);
  1376. }
  1377. else if(m_mode==3)
  1378. {
  1379. sql2.Format ("***update dindan set [time5]='%s' where [id]='%s'", date, m_id);
  1380. }
  1381. sql+=sql2;
  1382. g_sendhead.bsql=1;
  1383. g_pMainWnd->ProcessChatMessageRequest2(sql); //if(g_bSendOK==0)return;
  1384. ((TodayForm2*)(GetParent()->GetParent()))->ReLoad1();
  1385. }
  1386. else
  1387. {
  1388. CString name=GetText(oldrow, 1);
  1389. CString phone=GetText(oldrow, 2);
  1390. CString time=GetText(oldrow, 3);
  1391. CString type=GetText(oldrow, 4);
  1392. CString price=GetText(oldrow, 5);
  1393. CString waiter1=GetText(oldrow, 6);
  1394. CString waiter2=GetText(oldrow, 7);
  1395. CString receptionist=GetText(oldrow, 8);
  1396. CString arrearage=GetText(oldrow, 9);
  1397. CString remark=GetText(oldrow, 10);
  1398. CString clerk=GetText(oldrow, 11);
  1399. CString arrive=GetText(oldrow, 12);
  1400. CString timestamp=m_pListArray->ElementAt(row).ElementAt(13);
  1401. if(name.IsEmpty())return;
  1402. CString sql;
  1403. 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);
  1404. if(IsHasRights2new(31)==0)
  1405. 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);
  1406. g_sendhead.bsql=1;
  1407. g_pMainWnd->ProcessChatMessageRequest2(sql);
  1408. }
  1409. }
  1410. void XTable::Save2(int row)
  1411. {
  1412. if(IsHasRightsnew(2)==0)return;
  1413. if(::GetTickCount ()-m_nticks<1000)return;
  1414. m_nticks=::GetTickCount ();
  1415. int oldrow=row;
  1416. BOOL bFind=0;
  1417. for(int i=0; i<m_daterowposarray.GetSize (); i++)
  1418. {
  1419. if(row<m_daterowposarray.ElementAt (i))
  1420. {
  1421. row-=i;bFind=1;
  1422. break;
  1423. }
  1424. if(row==m_daterowposarray.ElementAt (i))
  1425. return;
  1426. }
  1427. if(bFind==0)row-=m_daterowposarray.GetSize ();
  1428. if(row>=m_pListArray->GetSize())//新预约
  1429. {
  1430. CString name=GetText(oldrow, 1);
  1431. CString phone=GetText(oldrow, 2);
  1432. CString time=GetText(oldrow, 3);
  1433. CString content=GetText(oldrow, 4);
  1434. CString type=GetText(oldrow, 5);
  1435. CString price=GetText(oldrow, 6);
  1436. CString waiter1=GetText(oldrow, 7);
  1437. CString waiter2=GetText(oldrow, 8);
  1438. CString receptionist=GetText(oldrow, 9);
  1439. CString arrearage=GetText(oldrow, 10);
  1440. CString remark=GetText(oldrow, 11);
  1441. CString str=CTime::GetCurrentTime ().Format ("%Y-%m-%d %H:%M:%S");
  1442. str.Replace("-", "");
  1443. str=str.Left(str.GetLength()-3);
  1444. CString clerk=GetText(oldrow, 12)+str;
  1445. CString arrive=GetText(oldrow, 13);
  1446. CString timestamp=CTime::GetCurrentTime ().Format ("%Y%m%d%H%M%S");
  1447. CString date=((TodayForm2*)(GetParent()->GetParent()))->GetDate();
  1448. if(name.IsEmpty())return;
  1449. CString sql;
  1450. 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);
  1451. g_sendhead.bsql=1;
  1452. g_pMainWnd->ProcessChatMessageRequest2(sql); //if(g_bSendOK==0)return;
  1453. ((TodayForm2*)(GetParent()->GetParent()))->ReLoad1();
  1454. }
  1455. else
  1456. {
  1457. CString name=GetText(oldrow, 1);
  1458. CString phone=GetText(oldrow, 2);
  1459. CString time=GetText(oldrow, 3);
  1460. CString content=GetText(oldrow, 4);
  1461. CString type=GetText(oldrow, 5);
  1462. CString price=GetText(oldrow, 6);
  1463. CString waiter1=GetText(oldrow, 7);
  1464. CString waiter2=GetText(oldrow, 8);
  1465. CString receptionist=GetText(oldrow, 9);
  1466. CString arrearage=GetText(oldrow, 10);
  1467. CString remark=GetText(oldrow, 11);
  1468. CString clerk=GetText(oldrow, 12);
  1469. CString arrive=GetText(oldrow, 13);
  1470. CString timestamp=m_pListArray->ElementAt(row).ElementAt(14);
  1471. if(name.IsEmpty())return;
  1472. CString sql;
  1473. 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);
  1474. if(IsHasRights2new(31)==0)
  1475. 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);
  1476. g_sendhead.bsql=1;
  1477. g_pMainWnd->ProcessChatMessageRequest2(sql);
  1478. }
  1479. }
  1480. void XTable::Save3(int row)
  1481. {
  1482. if(IsHasRightsnew(2)==0)return;
  1483. if(::GetTickCount ()-m_nticks<1000)return;
  1484. m_nticks=::GetTickCount ();
  1485. int oldrow=row;
  1486. BOOL bFind=0;
  1487. for(int i=0; i<m_daterowposarray.GetSize (); i++)
  1488. {
  1489. if(row<m_daterowposarray.ElementAt (i))
  1490. {
  1491. row-=i;bFind=1;
  1492. break;
  1493. }
  1494. if(row==m_daterowposarray.ElementAt (i))
  1495. return;
  1496. }
  1497. if(bFind==0)row-=m_daterowposarray.GetSize ();
  1498. if(row>=m_pListArray->GetSize())//新预约
  1499. {
  1500. CString name=GetText(oldrow, 1);
  1501. CString phone=GetText(oldrow, 2);
  1502. CString time=GetText(oldrow, 3);
  1503. CString content=GetText(oldrow, 4);
  1504. CString price=GetText(oldrow, 5);
  1505. CString waiter1=GetText(oldrow, 6);
  1506. CString waiter2=GetText(oldrow, 7);
  1507. CString receptionist=GetText(oldrow, 8);
  1508. CString arrearage=GetText(oldrow, 9);
  1509. CString remark=GetText(oldrow, 10);
  1510. CString str=CTime::GetCurrentTime ().Format ("%Y-%m-%d %H:%M:%S");
  1511. str.Replace("-", "");
  1512. str=str.Left(str.GetLength()-3);
  1513. CString clerk=GetText(oldrow, 11)+str;
  1514. CString arrive=GetText(oldrow, 12);
  1515. CString timestamp=CTime::GetCurrentTime ().Format ("%Y%m%d%H%M%S");
  1516. CString date=((TodayForm*)(GetParent()->GetParent()))->GetDate();
  1517. if(name.IsEmpty())return;
  1518. CString sql;
  1519. 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);
  1520. g_sendhead.bsql=1;
  1521. g_pMainWnd->ProcessChatMessageRequest2(sql); //if(g_bSendOK==0)return;
  1522. ((TodayForm*)(GetParent()->GetParent()))->ReLoad1();
  1523. }
  1524. else
  1525. {
  1526. CString name=GetText(oldrow, 1);
  1527. CString phone=GetText(oldrow, 2);
  1528. CString time=GetText(oldrow, 3);
  1529. CString content=GetText(oldrow, 4);
  1530. CString price=GetText(oldrow, 5);
  1531. CString waiter1=GetText(oldrow, 6);
  1532. CString waiter2=GetText(oldrow, 7);
  1533. CString receptionist=GetText(oldrow, 8);
  1534. CString arrearage=GetText(oldrow, 9);
  1535. CString remark=GetText(oldrow, 10);
  1536. CString clerk=GetText(oldrow, 11);
  1537. CString arrive=GetText(oldrow, 12);
  1538. CString timestamp=m_pListArray->ElementAt(row).ElementAt(13);
  1539. if(name.IsEmpty())return;
  1540. CString sql;
  1541. 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);
  1542. if(IsHasRights2new(31)==0)
  1543. 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);
  1544. g_sendhead.bsql=1;
  1545. g_pMainWnd->ProcessChatMessageRequest2(sql);
  1546. }
  1547. }
  1548. void XTable::DeleteCur()
  1549. {
  1550. int row=focusRow;
  1551. CString name=GetText(row, 1);
  1552. BOOL bFind=0;
  1553. for(int i=0; i<m_daterowposarray.GetSize (); i++)
  1554. {
  1555. if(row<m_daterowposarray.ElementAt (i))
  1556. {
  1557. row-=i;bFind=1;
  1558. break;
  1559. }
  1560. if(row==m_daterowposarray.ElementAt (i))
  1561. return;
  1562. }
  1563. if(bFind==0)row-=m_daterowposarray.GetSize ();
  1564. if(row>=m_pListArray->GetSize())
  1565. return;
  1566. if(AfxMessageBox("确定删除客人"+name+"的预约资料吗?", MB_YESNO|MB_ICONINFORMATION)!=IDYES)return;
  1567. int size=m_pListArray->ElementAt(row).GetSize ();
  1568. CString timestamp=m_pListArray->ElementAt(row).ElementAt(size-2);
  1569. CString sql;
  1570. sql.Format ("delete from todaytake where [timestamp]='%s'", timestamp);
  1571. g_sendhead.bsql=1;
  1572. g_pMainWnd->ProcessChatMessageRequest2(sql);
  1573. if(m_mode==10)
  1574. ((TodayForm*)(GetParent()->GetParent()))->ReLoad1();
  1575. else
  1576. ((TodayForm2*)(GetParent()->GetParent()))->ReLoad1();
  1577. }
  1578. CString XTable::GetCurPhone(CString &name)
  1579. {
  1580. int row=focusRow;
  1581. name=GetText(row, 1);
  1582. return GetText(row, 2);
  1583. BOOL bFind=0;
  1584. for(int i=0; i<m_daterowposarray.GetSize (); i++)
  1585. {
  1586. if(row<m_daterowposarray.ElementAt (i))
  1587. {
  1588. row-=i;bFind=1;
  1589. break;
  1590. }
  1591. if(row==m_daterowposarray.ElementAt (i))
  1592. return "";
  1593. }
  1594. if(bFind==0)row-=m_daterowposarray.GetSize ();
  1595. if(row>=m_pListArray->GetSize())
  1596. return "";
  1597. int size=m_pListArray->ElementAt(row).GetSize ();
  1598. CString date=m_pListArray->ElementAt(row).ElementAt(size-3);
  1599. CString timestamp=m_pListArray->ElementAt(row).ElementAt(size-2);
  1600. CString id=m_pListArray->ElementAt(row).ElementAt(size-1);
  1601. }
  1602. void XTable::OtherDate()
  1603. {
  1604. int row=focusRow;
  1605. CString name=GetText(row, 1);
  1606. BOOL bFind=0;
  1607. for(int i=0; i<m_daterowposarray.GetSize (); i++)
  1608. {
  1609. if(row<m_daterowposarray.ElementAt (i))
  1610. {
  1611. row-=i;bFind=1;
  1612. break;
  1613. }
  1614. if(row==m_daterowposarray.ElementAt (i))
  1615. return;
  1616. }
  1617. if(bFind==0)row-=m_daterowposarray.GetSize ();
  1618. if(row>=m_pListArray->GetSize())
  1619. return;
  1620. int size=m_pListArray->ElementAt(row).GetSize ();
  1621. CString date=m_pListArray->ElementAt(row).ElementAt(size-3);
  1622. CString timestamp=m_pListArray->ElementAt(row).ElementAt(size-2);
  1623. CString id=m_pListArray->ElementAt(row).ElementAt(size-1);
  1624. InputDate dlg;
  1625. dlg.m_date =date;
  1626. dlg.m_name =name;
  1627. dlg.m_name =m_pListArray->ElementAt(row).ElementAt(0);
  1628. if(dlg.DoModal ()!=IDOK)return;
  1629. CString sql,sql2;
  1630. sql.Format ("update [todaytake] set [date]='%s' where [timestamp]='%s'", dlg.m_date, timestamp);
  1631. g_sendhead.bsql=1;
  1632. if(m_mode==0)
  1633. {
  1634. sql2.Format ("***update dindan set [time2]='%s' where [id]='%s'", dlg.m_date, id);
  1635. }
  1636. else if(m_mode==1)
  1637. {
  1638. sql2.Format ("***update dindan set [time4]='%s' where [id]='%s'", dlg.m_date, id);
  1639. }
  1640. else if(m_mode==2)
  1641. {
  1642. sql2.Format ("***update dindan set [time6]='%s' where [id]='%s'", dlg.m_date, id);
  1643. }
  1644. else if(m_mode==3)
  1645. {
  1646. sql2.Format ("***update dindan set [time5]='%s' where [id]='%s'", dlg.m_date, id);
  1647. }
  1648. sql+=sql2;
  1649. g_pMainWnd->ProcessChatMessageRequest2(sql);
  1650. if(m_mode==10)
  1651. ((TodayForm*)(GetParent()->GetParent()))->ReLoad1();
  1652. else
  1653. ((TodayForm2*)(GetParent()->GetParent()))->ReLoad1();
  1654. }
  1655. BOOL XTable::IsDateRow(int row)
  1656. {
  1657. try
  1658. {
  1659. for(int i=0; i<m_daterowposarray.GetSize (); i++)
  1660. {
  1661. if(row==m_daterowposarray.ElementAt (i))
  1662. return 1;
  1663. }
  1664. }
  1665. catch(...)
  1666. {
  1667. }
  1668. return 0;
  1669. }
  1670. CString XTable::GetWeek(CString date)
  1671. {
  1672. if(date.GetLength ()!=10)return "";
  1673. COleDateTime dtDay(atoi(date.Mid (0,4)),atoi(date.Mid (5,2)),atoi(date.Mid (8,2)), 0, 0, 0);
  1674. int nDayWeek = dtDay.GetDayOfWeek()-1; //得到星期几,1=Sunday, 2=Monday,
  1675. CString DayOfWeek[7]={"星期日","星期一","星期二","星期三","星期四","星期五","星期六"};
  1676. CString sdate;
  1677. if(nDayWeek>=0 && nDayWeek<=6)
  1678. sdate=DayOfWeek[nDayWeek];
  1679. else
  1680. sdate="无效日期";
  1681. return sdate;
  1682. }
  1683. int XTable::Test()
  1684. {
  1685. if(m_mode==10)
  1686. return Test3();
  1687. CStringArray array;
  1688. if(m_mode==4)
  1689. {
  1690. array.Add ("姓名");
  1691. array.Add ("电话");
  1692. array.Add ("时间");
  1693. array.Add ("婚庆内容");
  1694. array.Add ("类别");
  1695. array.Add ("价格");
  1696. array.Add ("摄影");
  1697. #ifdef CHILD_VERSION
  1698. array.Add ("引导");
  1699. #else
  1700. array.Add ("化妆");
  1701. #endif
  1702. array.Add ("门市");
  1703. array.Add ("欠款");
  1704. array.Add ("备注");
  1705. array.Add ("录入");
  1706. array.Add ("是否到店");
  1707. }
  1708. else
  1709. {
  1710. array.Add ("姓名");
  1711. array.Add ("电话");
  1712. array.Add ("时间");
  1713. array.Add ("类别");
  1714. array.Add ("价格");
  1715. array.Add ("摄影");
  1716. #ifdef CHILD_VERSION
  1717. array.Add ("引导");
  1718. #else
  1719. array.Add ("化妆");
  1720. #endif
  1721. array.Add ("门市");
  1722. array.Add ("欠款");
  1723. array.Add ("备注");
  1724. array.Add ("录入");
  1725. array.Add ("是否到店");
  1726. }
  1727. HidePrice();
  1728. int cols=array.GetSize();
  1729. int nAdd=0;
  1730. if(m_mode==4)nAdd=1;
  1731. CRect rc;
  1732. GetClientRect(rc);
  1733. defaultWidth = (rc.Width()-10)/cols;
  1734. int halfwid=defaultWidth;
  1735. SetCols (1);
  1736. SetRows (256);
  1737. SetCols (cols+1);
  1738. for(int i=0; i<rows; i++)
  1739. {
  1740. for(int j=0; j<cols; j++)
  1741. {
  1742. SetText (i, j+1, "");
  1743. }
  1744. }
  1745. COLORREF col1=RGB(0xC8, 0x96, 0x96);
  1746. COLORREF col2=RGB(0x64,0x96,0xC8);
  1747. COLORREF yellow=RGB(255,255,0);
  1748. COLORREF green=RGB(0,255,255);
  1749. for ( i = 0; i < 46; i ++)
  1750. SetBackColor (i, 0, col1);
  1751. SetColWidth ( 0, 10);
  1752. m_datearray.RemoveAll ();
  1753. m_daterowposarray.RemoveAll ();
  1754. int datesize=0;
  1755. int aa=0;
  1756. CString curdate;
  1757. CStringArray typearray;
  1758. CArray<int,int>typecountarray;
  1759. int pos;
  1760. int oldpos;
  1761. for(i=0; i<m_pListArray->GetSize()+datesize; i++)
  1762. {
  1763. if(m_pListArray->ElementAt(aa).ElementAt(12+nAdd)!=curdate && curdate!="")
  1764. {
  1765. //汇总行
  1766. CString str=" 今日预约: ";
  1767. CString temp;
  1768. for(int a=0; a<typearray.GetSize (); a++)
  1769. {
  1770. temp.Format ("%s:%d ", typearray.ElementAt (a), typecountarray.ElementAt (a));
  1771. str+=temp;
  1772. }
  1773. SetText (oldpos, 1, GetText(oldpos, 1)+str );
  1774. typearray.RemoveAll (); typecountarray.RemoveAll ();
  1775. }
  1776. if(::FindArray (&m_datearray, m_pListArray->ElementAt(aa).ElementAt(12+nAdd))==-1)
  1777. {
  1778. curdate=m_pListArray->ElementAt(aa).ElementAt(12+nAdd);
  1779. m_datearray.Add ( curdate );
  1780. m_daterowposarray.Add (i);
  1781. datesize=m_datearray.GetSize ();
  1782. JoinCells (i,1,i,12+nAdd);
  1783. SetAlignment (i,1,DT_CENTER);
  1784. SetBackColor (i,1, green);
  1785. SetText (i, 1, curdate+" "+GetWeek(curdate) );
  1786. oldpos=i;
  1787. continue;
  1788. }
  1789. pos=::FindArray (&typearray, m_pListArray->ElementAt(aa).ElementAt(3+nAdd));
  1790. if(pos==-1)
  1791. {
  1792. typearray.Add (m_pListArray->ElementAt(aa).ElementAt(3+nAdd));
  1793. typecountarray.Add (1);
  1794. }
  1795. else
  1796. {
  1797. int size=typecountarray.ElementAt (pos);
  1798. typecountarray.SetAt (pos, size+1);
  1799. }
  1800. for(int j=0; j<cols; j++)
  1801. {
  1802. SetText (i, j+1, m_pListArray->ElementAt(aa).ElementAt(j));
  1803. if(j==8+nAdd && atoi(m_pListArray->ElementAt(aa).ElementAt(j))>0 )
  1804. {
  1805. SetBackColor (i,j+1, RGB(255,0,0));
  1806. }
  1807. else if(j==8+nAdd)SetBackColor (i,j+1, RGB(0,255,0));
  1808. if(j==11+nAdd && m_pListArray->ElementAt(aa).ElementAt(j)=="未到" )
  1809. {
  1810. SetBackColor (i,j+1, RGB(255,0,0));
  1811. }
  1812. else if(j==11+nAdd)SetBackColor (i,j+1, RGB(0,255,0));
  1813. }
  1814. aa++;
  1815. }
  1816. if(m_pListArray->GetSize())
  1817. {
  1818. //汇总行
  1819. CString str=" 今日预约: ";
  1820. CString temp;
  1821. for(int a=0; a<typearray.GetSize (); a++)
  1822. {
  1823. temp.Format ("%s:%d ", typearray.ElementAt (a), typecountarray.ElementAt (a));
  1824. str+=temp;
  1825. }
  1826. SetText (oldpos, 1, GetText(oldpos, 1)+str );
  1827. }
  1828. CalRowHeight();
  1829. return 0;
  1830. JoinCells (3,5,4,6);
  1831. SetText (3,5, "This cell contains multiline text, which provides multiline edit.张三, 李四, 王五Using default font张三, 李四, 王五Using default font");
  1832. SetWordbreak (3,5,true);
  1833. return 0;
  1834. JoinCells (3,7,5,8);
  1835. SetText (3,7, "This cell contains multiline text, which provides multiline edit.");
  1836. SetWordbreak (3,7,true);
  1837. SetText (4,1, "You can even edit a long (cell overlapping) string.");
  1838. SetOverlap(4,1,true);
  1839. SetText (4,3, "Test");
  1840. JoinCells (5,1,6,2);
  1841. SetText (5,1, "Enter your name here.");
  1842. JoinCells (5,3,5,4);
  1843. SetText (5,3, "Enter your text here ...");
  1844. JoinCells (8,1,8,8);
  1845. SetBackColor (8,1, RGB(0x64,0x96,0xC8));
  1846. SetText (8,1, "Default edit controls also allow us to customize user's editing experience by:");
  1847. JoinCells (10,1,10,2);
  1848. SetBackColor (10,1, RGB(0xDC,0xC8,0xB4));
  1849. SetText (10,1, "Converting input to upper case:");
  1850. SetText (10,3, "TYPE HERE ...");
  1851. JoinCells (10,5,10,6);
  1852. SetBackColor (10,5, RGB(0xDC,0xC8,0xB4));
  1853. SetText (10,5, "Converting input to lower case:");
  1854. SetText (10,7, "type here ...");
  1855. JoinCells (11,1,11,2);
  1856. SetBackColor (11,1, RGB(0xDC,0xC8,0xB4));
  1857. SetText (11,1, "Allowing password input:");
  1858. SetText (11,3, "*********");
  1859. SetText (11,5, "Entered password was:*********");
  1860. SetOverlap(11,5,true);
  1861. JoinCells (12,1,12,2);
  1862. SetBackColor (12,1, RGB(0xDC,0xC8,0xB4));
  1863. SetText (12,1, "Allowing aligned input:");
  1864. SetText (12,3, "Left aligned");
  1865. SetText (12,5, "Centered");
  1866. SetAlignment (12,5,DT_CENTER);
  1867. SetText (12,7, "Right aligned");
  1868. SetAlignment (12,7,DT_RIGHT);
  1869. JoinCells (14,1,14,8);
  1870. SetBackColor (14,1, RGB(0x64,0x96,0xC8));
  1871. SetText (14,1, "Ultimate Grid allow us to process user's input with various notifications.");
  1872. JoinCells (16,1,16,5);
  1873. SetBackColor (16,1, RGB(0xDC,0xC8,0xB4));
  1874. SetText (16,1, "We can verify data it is entered, for example to limit number of char to 4:");
  1875. SetText (16,6, "<Type here>");
  1876. JoinCells (17,1,17,5);
  1877. SetBackColor (17,1, RGB(0xDC,0xC8,0xB4));
  1878. SetText (17,1, "or that the numeric value entered is under 500 (number < 500):");
  1879. SetText (17,6, "<Type here>");
  1880. JoinCells (18,1,18,5);
  1881. SetBackColor (18,1, RGB(0xDC,0xC8,0xB4));
  1882. SetText (18,1, "We can also test user's input after it is completed, or force user's input:");
  1883. SetText (18,6, "<Type here>");
  1884. JoinCells (20,1,20,8);
  1885. SetBackColor (20,1, RGB(0x64,0x96,0xC8));
  1886. SetText (20,1, "The Ultimate Grid also allows us to use other edit controls when needed:");
  1887. JoinCells (22,1,23,5);
  1888. SetBackColor (22,1, RGB(0xDC,0xC8,0xB4));
  1889. 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.");
  1890. SetWordbreak (22,1,true);
  1891. JoinCells (22,6,22,7);
  1892. SetText (22,6, "<Select mask>");
  1893. JoinCells (23,6,23,7);
  1894. SetText (23,6, "<Type here>");
  1895. JoinCells (25,1,27,5);
  1896. SetBackColor (25,1, RGB(0xDC,0xC8,0xB4));
  1897. 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.");
  1898. SetWordbreak (25,1,true);
  1899. JoinCells (29,1,30,5);
  1900. SetBackColor (29,1, RGB(0xDC,0xC8,0xB4));
  1901. 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.");
  1902. SetWordbreak (29,1,true);
  1903. JoinCells (29,6,29,8);
  1904. SetText (29,6, "<Select mask>");
  1905. JoinCells (30,6,30,8);
  1906. SetText (30,6, "<Type here>");
  1907. JoinCells (32,1,33,5);
  1908. SetBackColor (32,1, RGB(0xDC,0xC8,0xB4));
  1909. 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.");
  1910. SetWordbreak (32,1,true);
  1911. JoinCells (35,1,35,2);
  1912. SetBackColor (35,1, RGB(0xDC,0xC8,0xB4));
  1913. SetText (35,1, "Using COXNumericEdit:");
  1914. JoinCells (35,3,35,4);
  1915. SetText (35,3, "<Type here>");
  1916. JoinCells (35,5,35,6);
  1917. SetBackColor (35,5, RGB(0xDC,0xC8,0xB4));
  1918. SetText (35,5, "Using COXCurrencyEdit:");
  1919. JoinCells (35,7,35,8);
  1920. SetText (35,7, "<Type here>");
  1921. JoinCells (36,1,36,3);
  1922. SetBackColor (36,1, RGB(0x64,0x96,0xC8));
  1923. SetText (36,1, "Following are properties we can set.");
  1924. JoinCells (36,5,36,7);
  1925. SetBackColor (36,5, RGB(0x64,0x96,0xC8));
  1926. SetText (36,5, "Following are properties we can set.");
  1927. JoinCells (37,1,37,2);
  1928. SetBackColor (37,1, RGB(0xDC,0xC8,0xB4));
  1929. SetText (37,1, "Decimal digit count :");
  1930. JoinCells (37,5,37,6);
  1931. SetBackColor (37,5, RGB(0xDC,0xC8,0xB4));
  1932. SetText (37,5, "Decimal digit count :");
  1933. JoinCells (38,1,38,2);
  1934. SetBackColor (38,1, RGB(0xDC,0xC8,0xB4));
  1935. SetText (38,1, "Decimal Separator :");
  1936. JoinCells (38,5,38,6);
  1937. SetBackColor (38,5, RGB(0xDC,0xC8,0xB4));
  1938. SetText (38,5, "Decimal Separator :");
  1939. JoinCells (39,1,39,2);
  1940. SetBackColor (39,1, RGB(0xDC,0xC8,0xB4));
  1941. SetText (39,1, "Fractional digit count :");
  1942. JoinCells (39,5,39,6);
  1943. SetBackColor (39,5, RGB(0xDC,0xC8,0xB4));
  1944. SetText (39,5, "Fractional digit count :");
  1945. JoinCells (40,1,40,2);
  1946. SetBackColor (40,1, RGB(0xDC,0xC8,0xB4));
  1947. SetText (40,1, "Group Separator :");
  1948. JoinCells (40,5,40,6);
  1949. SetBackColor (40,5, RGB(0xDC,0xC8,0xB4));
  1950. SetText (40,5, "Group Separator :");
  1951. JoinCells (41,1,41,2);
  1952. SetBackColor (41,1, RGB(0xDC,0xC8,0xB4));
  1953. SetText (41,1, "Digits in group :");
  1954. JoinCells (41,5,41,6);
  1955. SetBackColor (41,5, RGB(0xDC,0xC8,0xB4));
  1956. SetText (41,5, "Digits in group :");
  1957. JoinCells (42,1,42,2);
  1958. SetBackColor (42,1, RGB(0xDC,0xC8,0xB4));
  1959. SetText (42,1, "Negative Format :");
  1960. JoinCells (42,5,42,6);
  1961. SetBackColor (42,5, RGB(0xDC,0xC8,0xB4));
  1962. SetText (42,5, "Positive Format :");
  1963. JoinCells (43,1,43,2);
  1964. SetBackColor (43,1, RGB(0xDC,0xC8,0xB4));
  1965. SetText (43,1, "Show leading zero :");
  1966. JoinCells (43,5,43,6);
  1967. SetBackColor (43,5, RGB(0xDC,0xC8,0xB4));
  1968. SetText (43,5, "Negative Format :");
  1969. JoinCells (44,5,44,6);
  1970. SetBackColor (44,5, RGB(0xDC,0xC8,0xB4));
  1971. SetText (44,5, "Currency name :");
  1972. JoinCells (45,5,45,6);
  1973. SetBackColor (45,5, RGB(0xDC,0xC8,0xB4));
  1974. SetText (45,5, "Show leading zero :");
  1975. return 0;
  1976. }
  1977. int XTable::Test3()
  1978. {
  1979. CStringArray array;
  1980. array.Add ("姓名");
  1981. array.Add ("电话");
  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. int cols=array.GetSize();
  1993. int nAdd=0;
  1994. CRect rc;
  1995. GetClientRect(rc);
  1996. defaultWidth = (rc.Width()-10)/cols;
  1997. int halfwid=defaultWidth;
  1998. SetCols (1);
  1999. SetRows (256);
  2000. SetCols (cols+1);
  2001. for(int i=0; i<rows; i++)
  2002. {
  2003. for(int j=0; j<cols; j++)
  2004. {
  2005. SetText (i, j+1, "");
  2006. }
  2007. }
  2008. COLORREF col1=RGB(0xC8, 0x96, 0x96);
  2009. COLORREF col2=RGB(0x64,0x96,0xC8);
  2010. COLORREF yellow=RGB(255,255,0);
  2011. COLORREF green=RGB(0,255,255);
  2012. for ( i = 0; i < 46; i ++)
  2013. SetBackColor (i, 0, col1);
  2014. SetColWidth ( 0, 10);
  2015. m_datearray.RemoveAll ();
  2016. m_daterowposarray.RemoveAll ();
  2017. int datesize=0;
  2018. int aa=0;
  2019. CString curdate;
  2020. CStringArray typearray;
  2021. CArray<int,int>typecountarray;
  2022. int pos;
  2023. int oldpos;
  2024. for(i=0; i<m_pListArray->GetSize()+datesize; i++)
  2025. {
  2026. if(m_pListArray->ElementAt(aa).ElementAt(12+nAdd)!=curdate && curdate!="")
  2027. {
  2028. //汇总行
  2029. CString str=" 今日预约: ";
  2030. CString temp;
  2031. for(int a=0; a<typearray.GetSize (); a++)
  2032. {
  2033. temp.Format ("%d ", typecountarray.ElementAt (a));
  2034. str+=temp;
  2035. }
  2036. SetText (oldpos, 1, GetText(oldpos, 1)+str );
  2037. typearray.RemoveAll (); typecountarray.RemoveAll ();
  2038. }
  2039. if(::FindArray (&m_datearray, m_pListArray->ElementAt(aa).ElementAt(12+nAdd))==-1)
  2040. {
  2041. curdate=m_pListArray->ElementAt(aa).ElementAt(12+nAdd);
  2042. m_datearray.Add ( curdate );
  2043. m_daterowposarray.Add (i);
  2044. datesize=m_datearray.GetSize ();
  2045. JoinCells (i,1,i,12+nAdd);
  2046. SetAlignment (i,1,DT_CENTER);
  2047. SetBackColor (i,1, green);
  2048. SetText (i, 1, curdate+" "+GetWeek(curdate) );
  2049. oldpos=i;
  2050. continue;
  2051. }
  2052. if(typearray.GetSize()==0)
  2053. {
  2054. typearray.Add ("");
  2055. typecountarray.Add (1);
  2056. }
  2057. else
  2058. {
  2059. int size=typecountarray.ElementAt (0);
  2060. typecountarray.SetAt (0, size+1);
  2061. }
  2062. for(int j=0; j<cols; j++)
  2063. {
  2064. SetText (i, j+1, m_pListArray->ElementAt(aa).ElementAt(j));
  2065. if(j==8+nAdd && atoi(m_pListArray->ElementAt(aa).ElementAt(j))>0 )
  2066. {
  2067. SetBackColor (i,j+1, RGB(255,0,0));
  2068. }
  2069. else if(j==8+nAdd)SetBackColor (i,j+1, RGB(0,255,0));
  2070. if(j==11+nAdd && m_pListArray->ElementAt(aa).ElementAt(j)=="未到" )
  2071. {
  2072. SetBackColor (i,j+1, RGB(255,0,0));
  2073. }
  2074. else if(j==11+nAdd)SetBackColor (i,j+1, RGB(0,255,0));
  2075. }
  2076. aa++;
  2077. }
  2078. if(m_pListArray->GetSize())
  2079. {
  2080. //汇总行
  2081. CString str=" 今日预约: ";
  2082. CString temp;
  2083. for(int a=0; a<typearray.GetSize (); a++)
  2084. {
  2085. temp.Format ("%d ", typecountarray.ElementAt (a));
  2086. str+=temp;
  2087. }
  2088. SetText (oldpos, 1, GetText(oldpos, 1)+str );
  2089. }
  2090. CalRowHeight();
  2091. return 0;
  2092. }
  2093. void XTable::ModeChange(int mode)
  2094. {
  2095. m_mode=mode;
  2096. }
  2097. void XTable::AddName(int row, int col, CString str)
  2098. {
  2099. CString oldtext=GetText(row,col);
  2100. if(oldtext.IsEmpty ())
  2101. {
  2102. SetText(row,col, str);
  2103. return;
  2104. }
  2105. if(oldtext.Find (str)!=-1)return;
  2106. SetText(row,col, oldtext+","+str);
  2107. }
  2108. //化妆师
  2109. void XTable::HidePrice()
  2110. {
  2111. if(m_mode!=4)
  2112. {
  2113. #ifdef LKAY_VERSION
  2114. if(IsHasRights2new(31))return;
  2115. for(int i=0; i< m_pListArray->GetSize (); i++)
  2116. {
  2117. m_pListArray->ElementAt (i).SetAt (1, "***");
  2118. m_pListArray->ElementAt (i).SetAt (4, "***");
  2119. }
  2120. #else
  2121. if(IsHasRights2new(31))return;
  2122. for(int i=0; i< m_pListArray->GetSize (); i++)
  2123. {
  2124. m_pListArray->ElementAt (i).SetAt (1, "***");
  2125. m_pListArray->ElementAt (i).SetAt (4, "***");
  2126. }
  2127. #endif
  2128. }
  2129. else
  2130. {
  2131. #ifdef LKAY_VERSION
  2132. if(IsHasRights2new(31))return;
  2133. for(int i=0; i< m_pListArray->GetSize (); i++)
  2134. {
  2135. m_pListArray->ElementAt (i).SetAt (1, "***");
  2136. m_pListArray->ElementAt (i).SetAt (4, "***");
  2137. }
  2138. #else
  2139. if(IsHasRights2new(31))return;
  2140. for(int i=0; i< m_pListArray->GetSize (); i++)
  2141. {
  2142. m_pListArray->ElementAt (i).SetAt (1, "***");
  2143. m_pListArray->ElementAt (i).SetAt (4, "***");
  2144. }
  2145. #endif
  2146. }
  2147. }