XTable.cpp 59 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554
  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. {
  689. if (g_List1array.ElementAt(i).ElementAt(20) != "2")continue;
  690. str += g_List1array.ElementAt(i).ElementAt(0);
  691. str += ",";
  692. }
  693. str.TrimRight(",");
  694. SetText(nItem, 4, str);
  695. }
  696. }
  697. SetText(nItem, 4 + nAdd, m_pClientArray->ElementAt(pos2).ElementAt(5));
  698. SetText(nItem, 5 + nAdd, m_pClientArray->ElementAt(pos2).ElementAt(6));
  699. SetText(nItem, 6 + nAdd, m_pClientArray->ElementAt(pos2).ElementAt(7));
  700. SetText(nItem, 7 + nAdd, m_pClientArray->ElementAt(pos2).ElementAt(8));
  701. SetText(nItem, 8 + nAdd, m_pClientArray->ElementAt(pos2).ElementAt(9));
  702. SetText(nItem, 9 + nAdd, m_pClientArray->ElementAt(pos2).ElementAt(10));
  703. if (atoi(GetText(nItem, 9 + nAdd)) > 0)
  704. {
  705. SetBackColor(nItem, 9 + nAdd, RGB(255, 0, 0));
  706. }
  707. else SetBackColor(nItem, 9 + nAdd, RGB(0, 255, 0));
  708. if (!m_pClientArray->ElementAt(pos2).ElementAt(11).IsEmpty())
  709. SetText(nItem, 10 + nAdd, "服装:" + m_pClientArray->ElementAt(pos2).ElementAt(11));
  710. AddName(nItem, 11 + nAdd, g_user.name);
  711. SetText(nItem, 12 + nAdd, "未到");
  712. if (oldtext != strText)
  713. Save(nItem);
  714. }
  715. }
  716. m_combobox.ShowWindow(SW_HIDE); m_nCurShow = -1; CalRowHeight();
  717. }
  718. else if (m_nCurShow == 2)
  719. {
  720. if (wParam == TRUE)
  721. {
  722. CString strText(_T(""));
  723. m_combobox2.GetWindowText(strText);
  724. DWORD dwData = m_combobox2.GetCtrlData();
  725. int nItem = dwData >> 16;
  726. int nIndex = dwData & 0x0000ffff;
  727. CString oldtext = GetText(nItem, nIndex);
  728. SetText(nItem, nIndex, strText);
  729. // SetText(nItem,11+nAdd, g_user.name);
  730. AddName(nItem, 11 + nAdd, g_user.name);
  731. if (nIndex == 12 + nAdd)
  732. {
  733. if (GetText(nItem, 12 + nAdd) == "未到")
  734. {
  735. SetBackColor(nItem, 12 + nAdd, RGB(255, 0, 0));
  736. }
  737. else
  738. SetBackColor(nItem, 12 + nAdd, RGB(0, 255, 0));
  739. }
  740. if (oldtext != strText)
  741. Save(nItem);
  742. //Invalidate();
  743. }
  744. m_combobox2.ShowWindow(SW_HIDE); m_nCurShow = -1; CalRowHeight();
  745. }
  746. else if (m_nCurShow == 3)
  747. {
  748. if (wParam == TRUE)
  749. {
  750. CString strText(_T(""));
  751. m_pComboBox->GetWindowText(strText);
  752. DWORD dwData = m_pComboBox->GetCtrlData();
  753. int nItem = dwData >> 16;
  754. int nIndex = dwData & 0x0000ffff;
  755. CString oldtext = GetText(nItem, nIndex);
  756. SetText(nItem, nIndex, strText);
  757. AddName(nItem, 11 + nAdd, g_user.name);
  758. if (nIndex == 12 + nAdd)
  759. {
  760. if (GetText(nItem, 12 + nAdd) == "未到")
  761. {
  762. SetBackColor(nItem, 12 + nAdd, RGB(255, 0, 0));
  763. }
  764. else
  765. SetBackColor(nItem, 12 + nAdd, RGB(0, 255, 0));
  766. }
  767. if (oldtext != strText)
  768. Save(nItem);
  769. //Invalidate();
  770. }
  771. m_pComboBox->ShowWindow(SW_HIDE); m_nCurShow = -1; CalRowHeight();
  772. }
  773. }
  774. void XTable::ShowEdit(BOOL bShow, int nItem, int nIndex, CRect rcCtrl)
  775. {
  776. try
  777. {
  778. if (m_edit.m_hWnd == NULL)
  779. {
  780. m_edit.Create(ES_AUTOHSCROLL | WS_CHILD | ES_LEFT | ES_WANTRETURN | WS_BORDER, CRect(0, 0, 0, 0), this, IDC_EDIT1);
  781. m_edit.ShowWindow(SW_HIDE);
  782. CFont tpFont;
  783. tpFont.CreateStockObject(DEFAULT_GUI_FONT);
  784. m_edit.SetFont(&tpFont);
  785. tpFont.DeleteObject();
  786. }
  787. if (bShow == TRUE)
  788. {
  789. CString strItem = GetText(nItem, nIndex);
  790. m_edit.MoveWindow(rcCtrl);
  791. m_edit.ShowWindow(SW_SHOW);
  792. m_edit.SetWindowText(strItem);
  793. ::SetFocus(m_edit.GetSafeHwnd());
  794. m_edit.SetSel(-1);
  795. m_edit.SetCtrlData(MAKEWPARAM(nIndex, nItem));
  796. }
  797. else
  798. m_edit.ShowWindow(SW_HIDE);
  799. }
  800. catch (...)
  801. {
  802. }
  803. }
  804. void XTable::ShowSearchClientComboBox(BOOL bShow, int nItem, int nIndex, CRect rcCtrl)
  805. {
  806. try
  807. {
  808. if (m_combobox.m_hWnd == NULL)
  809. {
  810. m_combobox.Create(WS_VSCROLL | WS_CHILD | CBS_DROPDOWN, CRect(0, 0, 0, 0), this, 100);
  811. m_combobox.ShowWindow(SW_HIDE);
  812. m_acCombo.m_mode = 1;
  813. m_acCombo.Init(&m_combobox);
  814. m_acCombo.m_pArray = m_pClientArray;
  815. m_combobox.SetFocus();
  816. }
  817. if (bShow == TRUE)
  818. {
  819. CString strItem = GetText(nItem, nIndex);
  820. rcCtrl.bottom += 300;
  821. m_combobox.MoveWindow(rcCtrl);
  822. m_combobox.ShowWindow(SW_SHOW);
  823. m_combobox.SetWindowText(strItem);
  824. ::SetFocus(m_combobox.GetSafeHwnd());
  825. m_combobox.SetCtrlData(MAKEWPARAM(nIndex, nItem));
  826. }
  827. else
  828. m_combobox.ShowWindow(SW_HIDE);
  829. }
  830. catch (...)
  831. {
  832. }
  833. }
  834. void XTable::ShowSearchClientComboBoxTime(BOOL bShow, int nItem, int nIndex, int type, CRect rcCtrl)
  835. {
  836. if (type >= 2 && type <= 4)
  837. {
  838. m_nCurShow = 3;
  839. ShowSearchClientComboBoxTree(bShow, nItem, nIndex, type, rcCtrl);
  840. return;
  841. }
  842. try
  843. {
  844. if (m_combobox2.m_hWnd == NULL)
  845. {
  846. m_combobox2.Create(WS_VSCROLL | WS_CHILD | CBS_DROPDOWN, CRect(0, 0, 0, 0), this, 100);
  847. m_combobox2.ShowWindow(SW_HIDE);
  848. m_combobox2.SetFocus();
  849. }
  850. m_combobox2.ResetContent();
  851. if (type == 0)
  852. {
  853. m_combobox2.AddString("9:00");
  854. m_combobox2.AddString("9:30");
  855. m_combobox2.AddString("10:00");
  856. m_combobox2.AddString("10:30");
  857. m_combobox2.AddString("11:00");
  858. m_combobox2.AddString("11:30");
  859. m_combobox2.AddString("12:00");
  860. m_combobox2.AddString("13:00");
  861. m_combobox2.AddString("14:00");
  862. m_combobox2.AddString("15:00");
  863. m_combobox2.AddString("16:00");
  864. m_combobox2.AddString("17:00");
  865. m_combobox2.AddString("18:00");
  866. m_combobox2.AddString("19:00");
  867. m_combobox2.AddString("20:00");
  868. m_combobox2.AddString("21:00");
  869. }
  870. else if (type == 1)
  871. {
  872. for (int i = 0; i < pTxtypearray->GetSize(); i++)
  873. m_combobox2.AddString(pTxtypearray->ElementAt(i).ElementAt(0));
  874. }
  875. else if (type == 2)
  876. {
  877. for (int ii = 0; ii < g_userarray.GetSize(); ii++)
  878. {
  879. if ("摄影部" == g_userarray.ElementAt(ii).ElementAt(2))
  880. m_combobox2.AddString(g_userarray.ElementAt(ii).ElementAt(1));
  881. }
  882. }
  883. else if (type == 3)
  884. {
  885. for (int ii = 0; ii < g_userarray.GetSize(); ii++)
  886. {
  887. if ("化妆部" == g_userarray.ElementAt(ii).ElementAt(2))
  888. m_combobox2.AddString(g_userarray.ElementAt(ii).ElementAt(1));
  889. }
  890. }
  891. else if (type == 4)
  892. {
  893. for (int ii = 0; ii < g_userarray.GetSize(); ii++)
  894. {
  895. // if("化妆部"== g_userarray.ElementAt (ii).ElementAt(2) )
  896. m_combobox2.AddString(g_userarray.ElementAt(ii).ElementAt(1));
  897. }
  898. }
  899. else if (type == 5)
  900. {
  901. m_combobox2.AddString("未到");
  902. m_combobox2.AddString("已到");
  903. }
  904. if (bShow == TRUE)
  905. {
  906. CString strItem = GetText(nItem, nIndex);
  907. rcCtrl.bottom += 300;
  908. m_combobox2.MoveWindow(rcCtrl);
  909. m_combobox2.ShowWindow(SW_SHOW);
  910. m_combobox2.SetWindowText(strItem);
  911. ::SetFocus(m_combobox2.GetSafeHwnd());
  912. m_combobox2.SetCtrlData(MAKEWPARAM(nIndex, nItem));
  913. }
  914. else
  915. m_combobox2.ShowWindow(SW_HIDE);
  916. }
  917. catch (...)
  918. {
  919. }
  920. }
  921. void XTable::ShowSearchClientComboBoxTree(BOOL bShow, int nItem, int nIndex, int type, CRect rcCtrl)
  922. {
  923. try
  924. {
  925. if (0)//m_pComboBox->m_hWnd == NULL)
  926. {
  927. m_pComboBox->Create(WS_VSCROLL | WS_CHILD | CBS_DROPDOWNLIST, CRect(0, 0, 100, 100), this, 100);
  928. m_pComboBox->ShowWindow(SW_HIDE);
  929. m_pComboBox->SetFocus();
  930. }
  931. if (bShow == TRUE)
  932. {
  933. CString strItem = GetText(nItem, nIndex);
  934. rcCtrl.bottom += 300;
  935. ClientToScreen(rcCtrl);
  936. GetParent()->GetParent()->ScreenToClient(rcCtrl);
  937. m_pComboBox->MoveWindow(rcCtrl);
  938. m_pComboBox->ShowWindow(SW_SHOW);
  939. m_pComboBox->ResetContent();
  940. m_pComboBox->AddString(strItem);
  941. m_pComboBox->SetCurSel(0);
  942. ::SetFocus(m_pComboBox->GetSafeHwnd());
  943. m_pComboBox->SetCtrlData(MAKEWPARAM(nIndex, nItem));
  944. m_pComboBox->RefDroppedWidth();
  945. }
  946. else
  947. m_pComboBox->ShowWindow(SW_HIDE);
  948. }
  949. catch (...)
  950. {
  951. }
  952. }
  953. void XTable::OnLButtonDblClk(UINT nFlags, CPoint point)
  954. {
  955. try
  956. {
  957. if (!m_bFocusFrame)return;
  958. if (HitTest(point, focusRow, focusCol) == 0)return;
  959. if (IsDateRow(focusRow))return;
  960. RECT rect = GetRect(focusRow, focusCol);
  961. if (focusCol == 0)return;
  962. int nAdd = 0;
  963. if (m_mode == 10)
  964. {
  965. if (focusRow > 0)
  966. {
  967. for (int i = 0; i < focusRow; i++)
  968. {
  969. if ("" == GetText(i, 1))
  970. {
  971. AfxMessageBox("请从上方空白处开始填起!", MB_ICONINFORMATION);
  972. return;
  973. }
  974. }
  975. }
  976. if (focusCol == 1)
  977. {
  978. // m_nCurShow=1;
  979. // ShowSearchClientComboBox(TRUE,focusRow,focusCol,rect);
  980. m_nCurShow = 0;
  981. ShowEdit(TRUE, focusRow, focusCol, rect);
  982. }
  983. else if ("" == GetText(focusRow, 1))
  984. {
  985. AfxMessageBox("请先填写客人姓名!", MB_ICONINFORMATION);
  986. return;
  987. }
  988. if (focusCol == 11 + nAdd)return;
  989. if (focusCol == 3)
  990. {
  991. m_nCurShow = 2;
  992. ShowSearchClientComboBoxTime(TRUE, focusRow, focusCol, 0, rect);
  993. }
  994. else if (focusCol == 6 + nAdd)
  995. {
  996. m_nCurShow = 2;
  997. ShowSearchClientComboBoxTime(TRUE, focusRow, focusCol, 2, rect);
  998. }
  999. else if (focusCol == 7 + nAdd)
  1000. {
  1001. m_nCurShow = 2;
  1002. ShowSearchClientComboBoxTime(TRUE, focusRow, focusCol, 2, rect);
  1003. }
  1004. else if (focusCol == 8 + nAdd)
  1005. {
  1006. m_nCurShow = 2;
  1007. ShowSearchClientComboBoxTime(TRUE, focusRow, focusCol, 2, rect);
  1008. }
  1009. else if (focusCol == 12 + nAdd)
  1010. {
  1011. m_nCurShow = 2;
  1012. ShowSearchClientComboBoxTime(TRUE, focusRow, focusCol, 5, rect);
  1013. }
  1014. else if (focusCol != 1)
  1015. {
  1016. m_nCurShow = 0;
  1017. ShowEdit(TRUE, focusRow, focusCol, rect);
  1018. }
  1019. }
  1020. else
  1021. {
  1022. if (m_mode == 4)nAdd = 1;
  1023. if (focusRow > 0)
  1024. {
  1025. for (int i = 0; i < focusRow; i++)
  1026. {
  1027. if ("" == GetText(i, 1))
  1028. {
  1029. AfxMessageBox("请从上方空白处开始填起!", MB_ICONINFORMATION);
  1030. return;
  1031. }
  1032. }
  1033. }
  1034. if (focusCol == 1)
  1035. {
  1036. m_nCurShow = 1;
  1037. ShowSearchClientComboBox(TRUE, focusRow, focusCol, rect);
  1038. }
  1039. else if ("" == GetText(focusRow, 1))
  1040. {
  1041. AfxMessageBox("请先填写客人姓名!", MB_ICONINFORMATION);
  1042. return;
  1043. }
  1044. if (focusCol == 11 + nAdd)return;
  1045. if (focusCol == 3)
  1046. {
  1047. m_nCurShow = 2;
  1048. ShowSearchClientComboBoxTime(TRUE, focusRow, focusCol, 0, rect);
  1049. }
  1050. else if (focusCol == 4 + nAdd)
  1051. {
  1052. m_nCurShow = 2;
  1053. ShowSearchClientComboBoxTime(TRUE, focusRow, focusCol, 1, rect);
  1054. }
  1055. else if (focusCol == 6 + nAdd)
  1056. {
  1057. m_nCurShow = 2;
  1058. ShowSearchClientComboBoxTime(TRUE, focusRow, focusCol, 2, rect);
  1059. }
  1060. else if (focusCol == 7 + nAdd)
  1061. {
  1062. m_nCurShow = 2;
  1063. ShowSearchClientComboBoxTime(TRUE, focusRow, focusCol, 3, rect);
  1064. }
  1065. else if (focusCol == 8 + nAdd)
  1066. {
  1067. m_nCurShow = 2;
  1068. ShowSearchClientComboBoxTime(TRUE, focusRow, focusCol, 4, rect);
  1069. }
  1070. else if (focusCol == 12 + nAdd)
  1071. {
  1072. m_nCurShow = 2;
  1073. ShowSearchClientComboBoxTime(TRUE, focusRow, focusCol, 5, rect);
  1074. }
  1075. else if (focusCol != 1)
  1076. {
  1077. m_nCurShow = 0;
  1078. ShowEdit(TRUE, focusRow, focusCol, rect);
  1079. }
  1080. }
  1081. }
  1082. catch (...)
  1083. {
  1084. }
  1085. CWnd::OnLButtonDown(nFlags, point);
  1086. }
  1087. BOOL XTable::RegisterWindowClass()
  1088. {
  1089. WNDCLASS wndcls;
  1090. HINSTANCE hInst = AfxGetInstanceHandle();
  1091. if (!(::GetClassInfo(hInst, XTABLE_CLASSNAME, &wndcls)))
  1092. {
  1093. // otherwise we need to register a new class
  1094. wndcls.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
  1095. wndcls.lpfnWndProc = ::DefWindowProc;
  1096. wndcls.cbClsExtra = wndcls.cbWndExtra = 0;
  1097. wndcls.hInstance = hInst;
  1098. wndcls.hIcon = NULL;
  1099. wndcls.hCursor = AfxGetApp()->LoadStandardCursor(IDC_ARROW);
  1100. wndcls.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
  1101. wndcls.lpszMenuName = NULL;
  1102. wndcls.lpszClassName = XTABLE_CLASSNAME;
  1103. if (!AfxRegisterClass(&wndcls))
  1104. {
  1105. AfxThrowResourceException();
  1106. return FALSE;
  1107. }
  1108. }
  1109. return TRUE;
  1110. }
  1111. int XTable::Test2()
  1112. {
  1113. defaultHeight = 20;
  1114. CStringArray array;
  1115. if (m_mode == 10)
  1116. {
  1117. array.Add("姓名");
  1118. array.Add("电话");
  1119. array.Add("时间");
  1120. array.Add("内容");
  1121. array.Add("价格");
  1122. array.Add("摄影");
  1123. array.Add("化妆");
  1124. array.Add("门市");
  1125. array.Add("欠款");
  1126. array.Add("备注");
  1127. array.Add("录入");
  1128. array.Add("是否到店");
  1129. }
  1130. else if (m_mode == 4)
  1131. {
  1132. array.Add("姓名");
  1133. array.Add("电话");
  1134. array.Add("时间");
  1135. array.Add("婚庆内容");
  1136. array.Add("类别");
  1137. array.Add("价格");
  1138. array.Add("摄影");
  1139. #ifdef CHILD_VERSION
  1140. array.Add("引导");
  1141. #else
  1142. array.Add ("化妆");
  1143. #endif
  1144. array.Add("门市");
  1145. array.Add("欠款");
  1146. array.Add("备注");
  1147. array.Add("录入");
  1148. array.Add("是否到店");
  1149. }
  1150. else
  1151. {
  1152. array.Add("姓名");
  1153. array.Add("电话");
  1154. array.Add("时间");
  1155. array.Add("类别");
  1156. array.Add("价格");
  1157. array.Add("摄影");
  1158. #ifdef CHILD_VERSION
  1159. array.Add("引导");
  1160. #else
  1161. array.Add ("化妆");
  1162. #endif
  1163. array.Add("门市");
  1164. array.Add("欠款");
  1165. array.Add("备注");
  1166. array.Add("录入");
  1167. array.Add("是否到店");
  1168. }
  1169. int cols = array.GetSize();
  1170. CRect rc;
  1171. GetClientRect(rc);
  1172. defaultWidth = (rc.Width() - 10) / cols;
  1173. SetCols(1);
  1174. SetRows(2);
  1175. SetCols(cols + 1);
  1176. COLORREF col1 = RGB(0xC8, 0x96, 0x96);
  1177. COLORREF col2 = RGB(0x64, 0x96, 0xC8);
  1178. for (int i = 0; i < 2; i++)
  1179. SetBackColor(i, 0, col1);
  1180. for (i = 0; i < cols + 1; i++)
  1181. SetBackColor(0, i, col1);
  1182. SetRowHeight(0, 10);
  1183. SetColWidth(0, 10);
  1184. for (i = 0; i < cols; i++)
  1185. {
  1186. SetBackColor(1, i + 1, col2);
  1187. SetText(1, i + 1, array.ElementAt(i));
  1188. }
  1189. Invalidate();
  1190. return 0;
  1191. }
  1192. ///edit
  1193. XTableEdit::XTableEdit()
  1194. {
  1195. }
  1196. XTableEdit::~XTableEdit()
  1197. {
  1198. }
  1199. BEGIN_MESSAGE_MAP(XTableEdit, CEdit)
  1200. //{{AFX_MSG_MAP(XTableEdit)
  1201. ON_WM_KILLFOCUS()
  1202. ON_WM_SETFOCUS()
  1203. //}}AFX_MSG_MAP
  1204. END_MESSAGE_MAP()
  1205. /////////////////////////////////////////////////////////////////////////////
  1206. // XTableEdit message handlers
  1207. void XTableEdit::SetCtrlData(DWORD dwData)
  1208. {
  1209. m_dwData = dwData;
  1210. }
  1211. DWORD XTableEdit::GetCtrlData()
  1212. {
  1213. return m_dwData;
  1214. }
  1215. void XTableEdit::OnKillFocus(CWnd* pNewWnd)
  1216. {
  1217. CEdit::OnKillFocus(pNewWnd);
  1218. CWnd* pParent = this->GetParent();
  1219. ::PostMessage(pParent->GetSafeHwnd(), WM_USER_EDIT_END, m_bExchange, 0);
  1220. }
  1221. BOOL XTableEdit::PreTranslateMessage(MSG* pMsg)
  1222. {
  1223. if (pMsg->message == WM_KEYDOWN)
  1224. {
  1225. if (pMsg->wParam == VK_RETURN)
  1226. {
  1227. CWnd* pParent = this->GetParent();
  1228. m_bExchange = TRUE;
  1229. ::PostMessage(pParent->GetSafeHwnd(), WM_USER_EDIT_END, m_bExchange, 0);
  1230. }
  1231. else if (pMsg->wParam == VK_ESCAPE)
  1232. {
  1233. CWnd* pParent = this->GetParent();
  1234. m_bExchange = FALSE;
  1235. ::PostMessage(pParent->GetSafeHwnd(), WM_USER_EDIT_END, m_bExchange, 0);
  1236. }
  1237. }
  1238. return CEdit::PreTranslateMessage(pMsg);
  1239. }
  1240. void XTableEdit::OnSetFocus(CWnd* pOldWnd)
  1241. {
  1242. CEdit::OnSetFocus(pOldWnd);
  1243. m_bExchange = TRUE;
  1244. }
  1245. XTableComboBox::XTableComboBox()
  1246. {
  1247. }
  1248. XTableComboBox::~XTableComboBox()
  1249. {
  1250. }
  1251. BEGIN_MESSAGE_MAP(XTableComboBox, CComboBox)
  1252. //{{AFX_MSG_MAP(XTableComboBox)
  1253. ON_WM_KILLFOCUS()
  1254. ON_WM_SETFOCUS()
  1255. ON_CONTROL_REFLECT(CBN_CLOSEUP, OnCloseup)
  1256. //}}AFX_MSG_MAP
  1257. END_MESSAGE_MAP()
  1258. /////////////////////////////////////////////////////////////////////////////
  1259. // XTableComboBox message handlers
  1260. void XTableComboBox::SetCtrlData(DWORD dwData)
  1261. {
  1262. m_dwData = dwData;
  1263. }
  1264. DWORD XTableComboBox::GetCtrlData()
  1265. {
  1266. return m_dwData;
  1267. }
  1268. void XTableComboBox::OnKillFocus(CWnd* pNewWnd)
  1269. {
  1270. CComboBox::OnKillFocus(pNewWnd);
  1271. /* CWnd* pParent = this->GetParent();
  1272. if(((XTable*)pParent)->m_nCurShow!=-1)
  1273. ::PostMessage(pParent->GetSafeHwnd(),WM_USER_EDIT_END,m_bExchange,1);*/
  1274. }
  1275. BOOL XTableComboBox::PreTranslateMessage(MSG* pMsg)
  1276. {
  1277. if (pMsg->message == WM_KEYDOWN)
  1278. {
  1279. if (pMsg->wParam == VK_RETURN)
  1280. {
  1281. CWnd* pParent = this->GetParent();
  1282. m_bExchange = TRUE;
  1283. ::PostMessage(pParent->GetSafeHwnd(), WM_USER_EDIT_END, m_bExchange, 1);
  1284. }
  1285. else if (pMsg->wParam == VK_ESCAPE)
  1286. {
  1287. CWnd* pParent = this->GetParent();
  1288. m_bExchange = FALSE;
  1289. ::PostMessage(pParent->GetSafeHwnd(), WM_USER_EDIT_END, m_bExchange, 1);
  1290. }
  1291. }
  1292. return CComboBox::PreTranslateMessage(pMsg);
  1293. }
  1294. void XTableComboBox::OnSetFocus(CWnd* pOldWnd)
  1295. {
  1296. CComboBox::OnSetFocus(pOldWnd);
  1297. m_bExchange = TRUE;
  1298. }
  1299. void XTableComboBox::OnCloseup()
  1300. {
  1301. // TODO: Add your control notification handler code here
  1302. CWnd* pParent = this->GetParent();
  1303. ::PostMessage(pParent->GetSafeHwnd(), WM_USER_EDIT_END, m_bExchange, 1);
  1304. }
  1305. void XTable::CalRowHeight()
  1306. {
  1307. CString str; CPaintDC dc(this);
  1308. for (int i = 0; i < GetRows(); i++)
  1309. {
  1310. SetRowHeight(i, 20);
  1311. for (int j = 1; j<GetCols(); j++)
  1312. {
  1313. str = GetText(i, j);
  1314. RECT rect = GetRect(i, j);
  1315. RECT textRect = rect;
  1316. this->SetWordbreak(i, j, 0);
  1317. XCell* cell = GetCells(i, j);
  1318. cell->CalcTextRect(&dc, &textRect);
  1319. if (textRect.right > rect.right || textRect.bottom > rect.bottom)
  1320. {
  1321. this->SetWordbreak(i, j, 1);
  1322. textRect = rect;
  1323. cell->CalcTextRect(&dc, &textRect);
  1324. rect.bottom = textRect.bottom + 2;
  1325. // if(rect.bottom-rect.top>100)rect.bottom=rect.top+100;
  1326. SetRowHeight(i, rect.bottom - rect.top);
  1327. }
  1328. }
  1329. }
  1330. Invalidate();
  1331. }
  1332. void XTable::Save(int row)
  1333. {
  1334. if (m_mode == 4)
  1335. {
  1336. Save2(row); return;
  1337. }
  1338. if (m_mode == 10)
  1339. {
  1340. Save3(row); return;
  1341. }
  1342. if (IsHasRightsnew(2) == 0)return;
  1343. if (::GetTickCount() - m_nticks < 1000)return;
  1344. m_nticks = ::GetTickCount();
  1345. int oldrow = row;
  1346. BOOL bFind = 0;
  1347. for (int i = 0; i < m_daterowposarray.GetSize(); i++)
  1348. {
  1349. if (row < m_daterowposarray.ElementAt(i))
  1350. {
  1351. row -= i; bFind = 1;
  1352. break;
  1353. }
  1354. if (row == m_daterowposarray.ElementAt(i))
  1355. return;
  1356. }
  1357. if (bFind == 0)row -= m_daterowposarray.GetSize();
  1358. if (row >= m_pListArray->GetSize())//新预约
  1359. {
  1360. CString name = GetText(oldrow, 1);
  1361. CString phone = GetText(oldrow, 2);
  1362. CString time = GetText(oldrow, 3);
  1363. CString type = GetText(oldrow, 4);
  1364. CString price = GetText(oldrow, 5);
  1365. CString waiter1 = GetText(oldrow, 6);
  1366. CString waiter2 = GetText(oldrow, 7);
  1367. CString receptionist = GetText(oldrow, 8);
  1368. CString arrearage = GetText(oldrow, 9);
  1369. CString remark = GetText(oldrow, 10);
  1370. CString arrive = GetText(oldrow, 12);
  1371. CString timestamp = CTime::GetCurrentTime().Format("%Y%m%d%H%M%S");
  1372. CString str = CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S");
  1373. str.Replace("-", "");
  1374. str = str.Left(str.GetLength() - 3);
  1375. CString clerk = GetText(oldrow, 11) + str;
  1376. CString date = ((TodayForm2*)(GetParent()->GetParent()))->GetDate();
  1377. if (name.IsEmpty())return;
  1378. CString sql, sql2;
  1379. 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);
  1380. if (m_mode == 0)
  1381. {
  1382. sql2.Format("***update dindan set [time2]='%s' where [id]='%s'", date, m_id);
  1383. }
  1384. else if (m_mode == 1)
  1385. {
  1386. sql2.Format("***update dindan set [time4]='%s' where [id]='%s'", date, m_id);
  1387. }
  1388. else if (m_mode == 2)
  1389. {
  1390. sql2.Format("***update dindan set [time6]='%s' where [id]='%s'", date, m_id);
  1391. }
  1392. else if (m_mode == 3)
  1393. {
  1394. sql2.Format("***update dindan set [time5]='%s' where [id]='%s'", date, m_id);
  1395. }
  1396. sql += sql2;
  1397. g_sendhead.bsql = 1;
  1398. g_pMainWnd->ProcessChatMessageRequest2(sql); //if(g_bSendOK==0)return;
  1399. ((TodayForm2*)(GetParent()->GetParent()))->ReLoad1();
  1400. }
  1401. else
  1402. {
  1403. CString name = GetText(oldrow, 1);
  1404. CString phone = GetText(oldrow, 2);
  1405. CString time = GetText(oldrow, 3);
  1406. CString type = GetText(oldrow, 4);
  1407. CString price = GetText(oldrow, 5);
  1408. CString waiter1 = GetText(oldrow, 6);
  1409. CString waiter2 = GetText(oldrow, 7);
  1410. CString receptionist = GetText(oldrow, 8);
  1411. CString arrearage = GetText(oldrow, 9);
  1412. CString remark = GetText(oldrow, 10);
  1413. CString clerk = GetText(oldrow, 11);
  1414. CString arrive = GetText(oldrow, 12);
  1415. CString timestamp = m_pListArray->ElementAt(row).ElementAt(13);
  1416. if (name.IsEmpty())return;
  1417. CString sql;
  1418. 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);
  1419. if (IsHasRights2new(31) == 0)
  1420. 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);
  1421. g_sendhead.bsql = 1;
  1422. g_pMainWnd->ProcessChatMessageRequest2(sql);
  1423. }
  1424. }
  1425. void XTable::Save2(int row)
  1426. {
  1427. if (IsHasRightsnew(2) == 0)return;
  1428. if (::GetTickCount() - m_nticks < 1000)return;
  1429. m_nticks = ::GetTickCount();
  1430. int oldrow = row;
  1431. BOOL bFind = 0;
  1432. for (int i = 0; i < m_daterowposarray.GetSize(); i++)
  1433. {
  1434. if (row < m_daterowposarray.ElementAt(i))
  1435. {
  1436. row -= i; bFind = 1;
  1437. break;
  1438. }
  1439. if (row == m_daterowposarray.ElementAt(i))
  1440. return;
  1441. }
  1442. if (bFind == 0)row -= m_daterowposarray.GetSize();
  1443. if (row >= m_pListArray->GetSize())//新预约
  1444. {
  1445. CString name = GetText(oldrow, 1);
  1446. CString phone = GetText(oldrow, 2);
  1447. CString time = GetText(oldrow, 3);
  1448. CString content = GetText(oldrow, 4);
  1449. CString type = GetText(oldrow, 5);
  1450. CString price = GetText(oldrow, 6);
  1451. CString waiter1 = GetText(oldrow, 7);
  1452. CString waiter2 = GetText(oldrow, 8);
  1453. CString receptionist = GetText(oldrow, 9);
  1454. CString arrearage = GetText(oldrow, 10);
  1455. CString remark = GetText(oldrow, 11);
  1456. CString str = CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S");
  1457. str.Replace("-", "");
  1458. str = str.Left(str.GetLength() - 3);
  1459. CString clerk = GetText(oldrow, 12) + str;
  1460. CString arrive = GetText(oldrow, 13);
  1461. CString timestamp = CTime::GetCurrentTime().Format("%Y%m%d%H%M%S");
  1462. CString date = ((TodayForm2*)(GetParent()->GetParent()))->GetDate();
  1463. if (name.IsEmpty())return;
  1464. CString sql;
  1465. 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);
  1466. g_sendhead.bsql = 1;
  1467. g_pMainWnd->ProcessChatMessageRequest2(sql); //if(g_bSendOK==0)return;
  1468. ((TodayForm2*)(GetParent()->GetParent()))->ReLoad1();
  1469. }
  1470. else
  1471. {
  1472. CString name = GetText(oldrow, 1);
  1473. CString phone = GetText(oldrow, 2);
  1474. CString time = GetText(oldrow, 3);
  1475. CString content = GetText(oldrow, 4);
  1476. CString type = GetText(oldrow, 5);
  1477. CString price = GetText(oldrow, 6);
  1478. CString waiter1 = GetText(oldrow, 7);
  1479. CString waiter2 = GetText(oldrow, 8);
  1480. CString receptionist = GetText(oldrow, 9);
  1481. CString arrearage = GetText(oldrow, 10);
  1482. CString remark = GetText(oldrow, 11);
  1483. CString clerk = GetText(oldrow, 12);
  1484. CString arrive = GetText(oldrow, 13);
  1485. CString timestamp = m_pListArray->ElementAt(row).ElementAt(14);
  1486. if (name.IsEmpty())return;
  1487. CString sql;
  1488. 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);
  1489. if (IsHasRights2new(31) == 0)
  1490. 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);
  1491. g_sendhead.bsql = 1;
  1492. g_pMainWnd->ProcessChatMessageRequest2(sql);
  1493. }
  1494. }
  1495. void XTable::Save3(int row)
  1496. {
  1497. if (IsHasRightsnew(2) == 0)return;
  1498. if (::GetTickCount() - m_nticks < 1000)return;
  1499. m_nticks = ::GetTickCount();
  1500. int oldrow = row;
  1501. BOOL bFind = 0;
  1502. for (int i = 0; i < m_daterowposarray.GetSize(); i++)
  1503. {
  1504. if (row < m_daterowposarray.ElementAt(i))
  1505. {
  1506. row -= i; bFind = 1;
  1507. break;
  1508. }
  1509. if (row == m_daterowposarray.ElementAt(i))
  1510. return;
  1511. }
  1512. if (bFind == 0)row -= m_daterowposarray.GetSize();
  1513. if (row >= m_pListArray->GetSize())//新预约
  1514. {
  1515. CString name = GetText(oldrow, 1);
  1516. CString phone = GetText(oldrow, 2);
  1517. CString time = GetText(oldrow, 3);
  1518. CString content = GetText(oldrow, 4);
  1519. CString price = GetText(oldrow, 5);
  1520. CString waiter1 = GetText(oldrow, 6);
  1521. CString waiter2 = GetText(oldrow, 7);
  1522. CString receptionist = GetText(oldrow, 8);
  1523. CString arrearage = GetText(oldrow, 9);
  1524. CString remark = GetText(oldrow, 10);
  1525. CString str = CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S");
  1526. str.Replace("-", "");
  1527. str = str.Left(str.GetLength() - 3);
  1528. CString clerk = GetText(oldrow, 11) + str;
  1529. CString arrive = GetText(oldrow, 12);
  1530. CString timestamp = CTime::GetCurrentTime().Format("%Y%m%d%H%M%S");
  1531. CString date = ((TodayForm*)(GetParent()->GetParent()))->GetDate();
  1532. if (name.IsEmpty())return;
  1533. CString sql;
  1534. 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);
  1535. g_sendhead.bsql = 1;
  1536. g_pMainWnd->ProcessChatMessageRequest2(sql); //if(g_bSendOK==0)return;
  1537. ((TodayForm*)(GetParent()->GetParent()))->ReLoad1();
  1538. }
  1539. else
  1540. {
  1541. CString name = GetText(oldrow, 1);
  1542. CString phone = GetText(oldrow, 2);
  1543. CString time = GetText(oldrow, 3);
  1544. CString content = GetText(oldrow, 4);
  1545. CString price = GetText(oldrow, 5);
  1546. CString waiter1 = GetText(oldrow, 6);
  1547. CString waiter2 = GetText(oldrow, 7);
  1548. CString receptionist = GetText(oldrow, 8);
  1549. CString arrearage = GetText(oldrow, 9);
  1550. CString remark = GetText(oldrow, 10);
  1551. CString clerk = GetText(oldrow, 11);
  1552. CString arrive = GetText(oldrow, 12);
  1553. CString timestamp = m_pListArray->ElementAt(row).ElementAt(13);
  1554. if (name.IsEmpty())return;
  1555. CString sql;
  1556. 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);
  1557. if (IsHasRights2new(31) == 0)
  1558. 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);
  1559. g_sendhead.bsql = 1;
  1560. g_pMainWnd->ProcessChatMessageRequest2(sql);
  1561. }
  1562. }
  1563. void XTable::DeleteCur()
  1564. {
  1565. int row = focusRow;
  1566. CString name = GetText(row, 1);
  1567. BOOL bFind = 0;
  1568. for (int i = 0; i < m_daterowposarray.GetSize(); i++)
  1569. {
  1570. if (row < m_daterowposarray.ElementAt(i))
  1571. {
  1572. row -= i; bFind = 1;
  1573. break;
  1574. }
  1575. if (row == m_daterowposarray.ElementAt(i))
  1576. return;
  1577. }
  1578. if (bFind == 0)row -= m_daterowposarray.GetSize();
  1579. if (row >= m_pListArray->GetSize())
  1580. return;
  1581. if (AfxMessageBox("确定删除客人" + name + "的预约资料吗?", MB_YESNO | MB_ICONINFORMATION) != IDYES)return;
  1582. int size = m_pListArray->ElementAt(row).GetSize();
  1583. CString timestamp = m_pListArray->ElementAt(row).ElementAt(size - 2);
  1584. CString sql;
  1585. sql.Format("delete from todaytake where [timestamp]='%s'", timestamp);
  1586. g_sendhead.bsql = 1;
  1587. g_pMainWnd->ProcessChatMessageRequest2(sql);
  1588. if (m_mode == 10)
  1589. ((TodayForm*)(GetParent()->GetParent()))->ReLoad1();
  1590. else
  1591. ((TodayForm2*)(GetParent()->GetParent()))->ReLoad1();
  1592. }
  1593. CString XTable::GetCurPhone(CString &name)
  1594. {
  1595. int row = focusRow;
  1596. name = GetText(row, 1);
  1597. return GetText(row, 2);
  1598. BOOL bFind = 0;
  1599. for (int i = 0; i < m_daterowposarray.GetSize(); i++)
  1600. {
  1601. if (row < m_daterowposarray.ElementAt(i))
  1602. {
  1603. row -= i; bFind = 1;
  1604. break;
  1605. }
  1606. if (row == m_daterowposarray.ElementAt(i))
  1607. return "";
  1608. }
  1609. if (bFind == 0)row -= m_daterowposarray.GetSize();
  1610. if (row >= m_pListArray->GetSize())
  1611. return "";
  1612. int size = m_pListArray->ElementAt(row).GetSize();
  1613. CString date = m_pListArray->ElementAt(row).ElementAt(size - 3);
  1614. CString timestamp = m_pListArray->ElementAt(row).ElementAt(size - 2);
  1615. CString id = m_pListArray->ElementAt(row).ElementAt(size - 1);
  1616. }
  1617. void XTable::OtherDate()
  1618. {
  1619. int row = focusRow;
  1620. CString name = GetText(row, 1);
  1621. BOOL bFind = 0;
  1622. for (int i = 0; i < m_daterowposarray.GetSize(); i++)
  1623. {
  1624. if (row < m_daterowposarray.ElementAt(i))
  1625. {
  1626. row -= i; bFind = 1;
  1627. break;
  1628. }
  1629. if (row == m_daterowposarray.ElementAt(i))
  1630. return;
  1631. }
  1632. if (bFind == 0)row -= m_daterowposarray.GetSize();
  1633. if (row >= m_pListArray->GetSize())
  1634. return;
  1635. int size = m_pListArray->ElementAt(row).GetSize();
  1636. CString date = m_pListArray->ElementAt(row).ElementAt(size - 3);
  1637. CString timestamp = m_pListArray->ElementAt(row).ElementAt(size - 2);
  1638. CString id = m_pListArray->ElementAt(row).ElementAt(size - 1);
  1639. InputDate dlg;
  1640. dlg.m_date = date;
  1641. dlg.m_name = name;
  1642. dlg.m_name = m_pListArray->ElementAt(row).ElementAt(0);
  1643. if (dlg.DoModal() != IDOK)return;
  1644. CString sql, sql2;
  1645. sql.Format("update [todaytake] set [date]='%s' where [timestamp]='%s'", dlg.m_date, timestamp);
  1646. g_sendhead.bsql = 1;
  1647. if (m_mode == 0)
  1648. {
  1649. sql2.Format("***update dindan set [time2]='%s' where [id]='%s'", dlg.m_date, id);
  1650. }
  1651. else if (m_mode == 1)
  1652. {
  1653. sql2.Format("***update dindan set [time4]='%s' where [id]='%s'", dlg.m_date, id);
  1654. }
  1655. else if (m_mode == 2)
  1656. {
  1657. sql2.Format("***update dindan set [time6]='%s' where [id]='%s'", dlg.m_date, id);
  1658. }
  1659. else if (m_mode == 3)
  1660. {
  1661. sql2.Format("***update dindan set [time5]='%s' where [id]='%s'", dlg.m_date, id);
  1662. }
  1663. sql += sql2;
  1664. g_pMainWnd->ProcessChatMessageRequest2(sql);
  1665. if (m_mode == 10)
  1666. ((TodayForm*)(GetParent()->GetParent()))->ReLoad1();
  1667. else
  1668. ((TodayForm2*)(GetParent()->GetParent()))->ReLoad1();
  1669. }
  1670. BOOL XTable::IsDateRow(int row)
  1671. {
  1672. try
  1673. {
  1674. for (int i = 0; i < m_daterowposarray.GetSize(); i++)
  1675. {
  1676. if (row == m_daterowposarray.ElementAt(i))
  1677. return 1;
  1678. }
  1679. }
  1680. catch (...)
  1681. {
  1682. }
  1683. return 0;
  1684. }
  1685. CString XTable::GetWeek(CString date)
  1686. {
  1687. if (date.GetLength() != 10)return "";
  1688. COleDateTime dtDay(atoi(date.Mid(0, 4)), atoi(date.Mid(5, 2)), atoi(date.Mid(8, 2)), 0, 0, 0);
  1689. int nDayWeek = dtDay.GetDayOfWeek() - 1; //得到星期几,1=Sunday, 2=Monday,
  1690. CString DayOfWeek[7] = { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  1691. CString sdate;
  1692. if (nDayWeek >= 0 && nDayWeek <= 6)
  1693. sdate = DayOfWeek[nDayWeek];
  1694. else
  1695. sdate = "无效日期";
  1696. return sdate;
  1697. }
  1698. int XTable::Test()
  1699. {
  1700. if (m_mode == 10)
  1701. return Test3();
  1702. CStringArray array;
  1703. if (m_mode == 4)
  1704. {
  1705. array.Add("姓名");
  1706. array.Add("电话");
  1707. array.Add("时间");
  1708. array.Add("婚庆内容");
  1709. array.Add("类别");
  1710. array.Add("价格");
  1711. array.Add("摄影");
  1712. #ifdef CHILD_VERSION
  1713. array.Add("引导");
  1714. #else
  1715. array.Add ("化妆");
  1716. #endif
  1717. array.Add("门市");
  1718. array.Add("欠款");
  1719. array.Add("备注");
  1720. array.Add("录入");
  1721. array.Add("是否到店");
  1722. }
  1723. else
  1724. {
  1725. array.Add("姓名");
  1726. array.Add("电话");
  1727. array.Add("时间");
  1728. array.Add("类别");
  1729. array.Add("价格");
  1730. array.Add("摄影");
  1731. #ifdef CHILD_VERSION
  1732. array.Add("引导");
  1733. #else
  1734. array.Add ("化妆");
  1735. #endif
  1736. array.Add("门市");
  1737. array.Add("欠款");
  1738. array.Add("备注");
  1739. array.Add("录入");
  1740. array.Add("是否到店");
  1741. }
  1742. HidePrice();
  1743. int cols = array.GetSize();
  1744. int nAdd = 0;
  1745. if (m_mode == 4)nAdd = 1;
  1746. CRect rc;
  1747. GetClientRect(rc);
  1748. defaultWidth = (rc.Width() - 10) / cols;
  1749. int halfwid = defaultWidth;
  1750. SetCols(1);
  1751. SetRows(256);
  1752. SetCols(cols + 1);
  1753. for (int i = 0; i < rows; i++)
  1754. {
  1755. for (int j = 0; j < cols; j++)
  1756. {
  1757. SetText(i, j + 1, "");
  1758. }
  1759. }
  1760. COLORREF col1 = RGB(0xC8, 0x96, 0x96);
  1761. COLORREF col2 = RGB(0x64, 0x96, 0xC8);
  1762. COLORREF yellow = RGB(255, 255, 0);
  1763. COLORREF green = RGB(0, 255, 255);
  1764. for (i = 0; i < 46; i++)
  1765. SetBackColor(i, 0, col1);
  1766. SetColWidth(0, 10);
  1767. m_datearray.RemoveAll();
  1768. m_daterowposarray.RemoveAll();
  1769. int datesize = 0;
  1770. int aa = 0;
  1771. CString curdate;
  1772. CStringArray typearray;
  1773. CArray<int, int>typecountarray;
  1774. int pos;
  1775. int oldpos;
  1776. for (i = 0; i < m_pListArray->GetSize() + datesize; i++)
  1777. {
  1778. if (m_pListArray->ElementAt(aa).ElementAt(12 + nAdd) != curdate && curdate != "")
  1779. {
  1780. //汇总行
  1781. CString str = " 今日预约: ";
  1782. CString temp;
  1783. for (int a = 0; a < typearray.GetSize(); a++)
  1784. {
  1785. temp.Format("%s:%d ", typearray.ElementAt(a), typecountarray.ElementAt(a));
  1786. str += temp;
  1787. }
  1788. SetText(oldpos, 1, GetText(oldpos, 1) + str);
  1789. typearray.RemoveAll(); typecountarray.RemoveAll();
  1790. }
  1791. if (::FindArray(&m_datearray, m_pListArray->ElementAt(aa).ElementAt(12 + nAdd)) == -1)
  1792. {
  1793. curdate = m_pListArray->ElementAt(aa).ElementAt(12 + nAdd);
  1794. m_datearray.Add(curdate);
  1795. m_daterowposarray.Add(i);
  1796. datesize = m_datearray.GetSize();
  1797. JoinCells(i, 1, i, 12 + nAdd);
  1798. SetAlignment(i, 1, DT_CENTER);
  1799. SetBackColor(i, 1, green);
  1800. SetText(i, 1, curdate + " " + GetWeek(curdate));
  1801. oldpos = i;
  1802. continue;
  1803. }
  1804. pos = ::FindArray(&typearray, m_pListArray->ElementAt(aa).ElementAt(3 + nAdd));
  1805. if (pos == -1)
  1806. {
  1807. typearray.Add(m_pListArray->ElementAt(aa).ElementAt(3 + nAdd));
  1808. typecountarray.Add(1);
  1809. }
  1810. else
  1811. {
  1812. int size = typecountarray.ElementAt(pos);
  1813. typecountarray.SetAt(pos, size + 1);
  1814. }
  1815. for (int j = 0; j < cols; j++)
  1816. {
  1817. SetText(i, j + 1, m_pListArray->ElementAt(aa).ElementAt(j));
  1818. if (j == 8 + nAdd && atoi(m_pListArray->ElementAt(aa).ElementAt(j)) > 0)
  1819. {
  1820. SetBackColor(i, j + 1, RGB(255, 0, 0));
  1821. }
  1822. else if (j == 8 + nAdd)SetBackColor(i, j + 1, RGB(0, 255, 0));
  1823. if (j == 11 + nAdd && m_pListArray->ElementAt(aa).ElementAt(j) == "未到")
  1824. {
  1825. SetBackColor(i, j + 1, RGB(255, 0, 0));
  1826. }
  1827. else if (j == 11 + nAdd)SetBackColor(i, j + 1, RGB(0, 255, 0));
  1828. }
  1829. aa++;
  1830. }
  1831. if (m_pListArray->GetSize())
  1832. {
  1833. //汇总行
  1834. CString str = " 今日预约: ";
  1835. CString temp;
  1836. for (int a = 0; a < typearray.GetSize(); a++)
  1837. {
  1838. temp.Format("%s:%d ", typearray.ElementAt(a), typecountarray.ElementAt(a));
  1839. str += temp;
  1840. }
  1841. SetText(oldpos, 1, GetText(oldpos, 1) + str);
  1842. }
  1843. CalRowHeight();
  1844. return 0;
  1845. JoinCells(3, 5, 4, 6);
  1846. SetText(3, 5, "This cell contains multiline text, which provides multiline edit.张三, 李四, 王五Using default font张三, 李四, 王五Using default font");
  1847. SetWordbreak(3, 5, true);
  1848. return 0;
  1849. JoinCells(3, 7, 5, 8);
  1850. SetText(3, 7, "This cell contains multiline text, which provides multiline edit.");
  1851. SetWordbreak(3, 7, true);
  1852. SetText(4, 1, "You can even edit a long (cell overlapping) string.");
  1853. SetOverlap(4, 1, true);
  1854. SetText(4, 3, "Test");
  1855. JoinCells(5, 1, 6, 2);
  1856. SetText(5, 1, "Enter your name here.");
  1857. JoinCells(5, 3, 5, 4);
  1858. SetText(5, 3, "Enter your text here ...");
  1859. JoinCells(8, 1, 8, 8);
  1860. SetBackColor(8, 1, RGB(0x64, 0x96, 0xC8));
  1861. SetText(8, 1, "Default edit controls also allow us to customize user's editing experience by:");
  1862. JoinCells(10, 1, 10, 2);
  1863. SetBackColor(10, 1, RGB(0xDC, 0xC8, 0xB4));
  1864. SetText(10, 1, "Converting input to upper case:");
  1865. SetText(10, 3, "TYPE HERE ...");
  1866. JoinCells(10, 5, 10, 6);
  1867. SetBackColor(10, 5, RGB(0xDC, 0xC8, 0xB4));
  1868. SetText(10, 5, "Converting input to lower case:");
  1869. SetText(10, 7, "type here ...");
  1870. JoinCells(11, 1, 11, 2);
  1871. SetBackColor(11, 1, RGB(0xDC, 0xC8, 0xB4));
  1872. SetText(11, 1, "Allowing password input:");
  1873. SetText(11, 3, "*********");
  1874. SetText(11, 5, "Entered password was:*********");
  1875. SetOverlap(11, 5, true);
  1876. JoinCells(12, 1, 12, 2);
  1877. SetBackColor(12, 1, RGB(0xDC, 0xC8, 0xB4));
  1878. SetText(12, 1, "Allowing aligned input:");
  1879. SetText(12, 3, "Left aligned");
  1880. SetText(12, 5, "Centered");
  1881. SetAlignment(12, 5, DT_CENTER);
  1882. SetText(12, 7, "Right aligned");
  1883. SetAlignment(12, 7, DT_RIGHT);
  1884. JoinCells(14, 1, 14, 8);
  1885. SetBackColor(14, 1, RGB(0x64, 0x96, 0xC8));
  1886. SetText(14, 1, "Ultimate Grid allow us to process user's input with various notifications.");
  1887. JoinCells(16, 1, 16, 5);
  1888. SetBackColor(16, 1, RGB(0xDC, 0xC8, 0xB4));
  1889. SetText(16, 1, "We can verify data it is entered, for example to limit number of char to 4:");
  1890. SetText(16, 6, "<Type here>");
  1891. JoinCells(17, 1, 17, 5);
  1892. SetBackColor(17, 1, RGB(0xDC, 0xC8, 0xB4));
  1893. SetText(17, 1, "or that the numeric value entered is under 500 (number < 500):");
  1894. SetText(17, 6, "<Type here>");
  1895. JoinCells(18, 1, 18, 5);
  1896. SetBackColor(18, 1, RGB(0xDC, 0xC8, 0xB4));
  1897. SetText(18, 1, "We can also test user's input after it is completed, or force user's input:");
  1898. SetText(18, 6, "<Type here>");
  1899. JoinCells(20, 1, 20, 8);
  1900. SetBackColor(20, 1, RGB(0x64, 0x96, 0xC8));
  1901. SetText(20, 1, "The Ultimate Grid also allows us to use other edit controls when needed:");
  1902. JoinCells(22, 1, 23, 5);
  1903. SetBackColor(22, 1, RGB(0xDC, 0xC8, 0xB4));
  1904. 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.");
  1905. SetWordbreak(22, 1, true);
  1906. JoinCells(22, 6, 22, 7);
  1907. SetText(22, 6, "<Select mask>");
  1908. JoinCells(23, 6, 23, 7);
  1909. SetText(23, 6, "<Type here>");
  1910. JoinCells(25, 1, 27, 5);
  1911. SetBackColor(25, 1, RGB(0xDC, 0xC8, 0xB4));
  1912. 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.");
  1913. SetWordbreak(25, 1, true);
  1914. JoinCells(29, 1, 30, 5);
  1915. SetBackColor(29, 1, RGB(0xDC, 0xC8, 0xB4));
  1916. 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.");
  1917. SetWordbreak(29, 1, true);
  1918. JoinCells(29, 6, 29, 8);
  1919. SetText(29, 6, "<Select mask>");
  1920. JoinCells(30, 6, 30, 8);
  1921. SetText(30, 6, "<Type here>");
  1922. JoinCells(32, 1, 33, 5);
  1923. SetBackColor(32, 1, RGB(0xDC, 0xC8, 0xB4));
  1924. 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.");
  1925. SetWordbreak(32, 1, true);
  1926. JoinCells(35, 1, 35, 2);
  1927. SetBackColor(35, 1, RGB(0xDC, 0xC8, 0xB4));
  1928. SetText(35, 1, "Using COXNumericEdit:");
  1929. JoinCells(35, 3, 35, 4);
  1930. SetText(35, 3, "<Type here>");
  1931. JoinCells(35, 5, 35, 6);
  1932. SetBackColor(35, 5, RGB(0xDC, 0xC8, 0xB4));
  1933. SetText(35, 5, "Using COXCurrencyEdit:");
  1934. JoinCells(35, 7, 35, 8);
  1935. SetText(35, 7, "<Type here>");
  1936. JoinCells(36, 1, 36, 3);
  1937. SetBackColor(36, 1, RGB(0x64, 0x96, 0xC8));
  1938. SetText(36, 1, "Following are properties we can set.");
  1939. JoinCells(36, 5, 36, 7);
  1940. SetBackColor(36, 5, RGB(0x64, 0x96, 0xC8));
  1941. SetText(36, 5, "Following are properties we can set.");
  1942. JoinCells(37, 1, 37, 2);
  1943. SetBackColor(37, 1, RGB(0xDC, 0xC8, 0xB4));
  1944. SetText(37, 1, "Decimal digit count :");
  1945. JoinCells(37, 5, 37, 6);
  1946. SetBackColor(37, 5, RGB(0xDC, 0xC8, 0xB4));
  1947. SetText(37, 5, "Decimal digit count :");
  1948. JoinCells(38, 1, 38, 2);
  1949. SetBackColor(38, 1, RGB(0xDC, 0xC8, 0xB4));
  1950. SetText(38, 1, "Decimal Separator :");
  1951. JoinCells(38, 5, 38, 6);
  1952. SetBackColor(38, 5, RGB(0xDC, 0xC8, 0xB4));
  1953. SetText(38, 5, "Decimal Separator :");
  1954. JoinCells(39, 1, 39, 2);
  1955. SetBackColor(39, 1, RGB(0xDC, 0xC8, 0xB4));
  1956. SetText(39, 1, "Fractional digit count :");
  1957. JoinCells(39, 5, 39, 6);
  1958. SetBackColor(39, 5, RGB(0xDC, 0xC8, 0xB4));
  1959. SetText(39, 5, "Fractional digit count :");
  1960. JoinCells(40, 1, 40, 2);
  1961. SetBackColor(40, 1, RGB(0xDC, 0xC8, 0xB4));
  1962. SetText(40, 1, "Group Separator :");
  1963. JoinCells(40, 5, 40, 6);
  1964. SetBackColor(40, 5, RGB(0xDC, 0xC8, 0xB4));
  1965. SetText(40, 5, "Group Separator :");
  1966. JoinCells(41, 1, 41, 2);
  1967. SetBackColor(41, 1, RGB(0xDC, 0xC8, 0xB4));
  1968. SetText(41, 1, "Digits in group :");
  1969. JoinCells(41, 5, 41, 6);
  1970. SetBackColor(41, 5, RGB(0xDC, 0xC8, 0xB4));
  1971. SetText(41, 5, "Digits in group :");
  1972. JoinCells(42, 1, 42, 2);
  1973. SetBackColor(42, 1, RGB(0xDC, 0xC8, 0xB4));
  1974. SetText(42, 1, "Negative Format :");
  1975. JoinCells(42, 5, 42, 6);
  1976. SetBackColor(42, 5, RGB(0xDC, 0xC8, 0xB4));
  1977. SetText(42, 5, "Positive Format :");
  1978. JoinCells(43, 1, 43, 2);
  1979. SetBackColor(43, 1, RGB(0xDC, 0xC8, 0xB4));
  1980. SetText(43, 1, "Show leading zero :");
  1981. JoinCells(43, 5, 43, 6);
  1982. SetBackColor(43, 5, RGB(0xDC, 0xC8, 0xB4));
  1983. SetText(43, 5, "Negative Format :");
  1984. JoinCells(44, 5, 44, 6);
  1985. SetBackColor(44, 5, RGB(0xDC, 0xC8, 0xB4));
  1986. SetText(44, 5, "Currency name :");
  1987. JoinCells(45, 5, 45, 6);
  1988. SetBackColor(45, 5, RGB(0xDC, 0xC8, 0xB4));
  1989. SetText(45, 5, "Show leading zero :");
  1990. return 0;
  1991. }
  1992. int XTable::Test3()
  1993. {
  1994. CStringArray array;
  1995. array.Add("姓名");
  1996. array.Add("电话");
  1997. array.Add("时间");
  1998. array.Add("内容");
  1999. array.Add("价格");
  2000. array.Add("摄影");
  2001. array.Add("化妆");
  2002. array.Add("门市");
  2003. array.Add("欠款");
  2004. array.Add("备注");
  2005. array.Add("录入");
  2006. array.Add("是否到店");
  2007. int cols = array.GetSize();
  2008. int nAdd = 0;
  2009. CRect rc;
  2010. GetClientRect(rc);
  2011. defaultWidth = (rc.Width() - 10) / cols;
  2012. int halfwid = defaultWidth;
  2013. SetCols(1);
  2014. SetRows(256);
  2015. SetCols(cols + 1);
  2016. for (int i = 0; i < rows; i++)
  2017. {
  2018. for (int j = 0; j < cols; j++)
  2019. {
  2020. SetText(i, j + 1, "");
  2021. }
  2022. }
  2023. COLORREF col1 = RGB(0xC8, 0x96, 0x96);
  2024. COLORREF col2 = RGB(0x64, 0x96, 0xC8);
  2025. COLORREF yellow = RGB(255, 255, 0);
  2026. COLORREF green = RGB(0, 255, 255);
  2027. for (i = 0; i < 46; i++)
  2028. SetBackColor(i, 0, col1);
  2029. SetColWidth(0, 10);
  2030. m_datearray.RemoveAll();
  2031. m_daterowposarray.RemoveAll();
  2032. int datesize = 0;
  2033. int aa = 0;
  2034. CString curdate;
  2035. CStringArray typearray;
  2036. CArray<int, int>typecountarray;
  2037. int pos;
  2038. int oldpos;
  2039. for (i = 0; i < m_pListArray->GetSize() + datesize; i++)
  2040. {
  2041. if (m_pListArray->ElementAt(aa).ElementAt(12 + nAdd) != curdate && curdate != "")
  2042. {
  2043. //汇总行
  2044. CString str = " 今日预约: ";
  2045. CString temp;
  2046. for (int a = 0; a < typearray.GetSize(); a++)
  2047. {
  2048. temp.Format("%d ", typecountarray.ElementAt(a));
  2049. str += temp;
  2050. }
  2051. SetText(oldpos, 1, GetText(oldpos, 1) + str);
  2052. typearray.RemoveAll(); typecountarray.RemoveAll();
  2053. }
  2054. if (::FindArray(&m_datearray, m_pListArray->ElementAt(aa).ElementAt(12 + nAdd)) == -1)
  2055. {
  2056. curdate = m_pListArray->ElementAt(aa).ElementAt(12 + nAdd);
  2057. m_datearray.Add(curdate);
  2058. m_daterowposarray.Add(i);
  2059. datesize = m_datearray.GetSize();
  2060. JoinCells(i, 1, i, 12 + nAdd);
  2061. SetAlignment(i, 1, DT_CENTER);
  2062. SetBackColor(i, 1, green);
  2063. SetText(i, 1, curdate + " " + GetWeek(curdate));
  2064. oldpos = i;
  2065. continue;
  2066. }
  2067. if (typearray.GetSize() == 0)
  2068. {
  2069. typearray.Add("");
  2070. typecountarray.Add(1);
  2071. }
  2072. else
  2073. {
  2074. int size = typecountarray.ElementAt(0);
  2075. typecountarray.SetAt(0, size + 1);
  2076. }
  2077. for (int j = 0; j < cols; j++)
  2078. {
  2079. SetText(i, j + 1, m_pListArray->ElementAt(aa).ElementAt(j));
  2080. if (j == 8 + nAdd && atoi(m_pListArray->ElementAt(aa).ElementAt(j)) > 0)
  2081. {
  2082. SetBackColor(i, j + 1, RGB(255, 0, 0));
  2083. }
  2084. else if (j == 8 + nAdd)SetBackColor(i, j + 1, RGB(0, 255, 0));
  2085. if (j == 11 + nAdd && m_pListArray->ElementAt(aa).ElementAt(j) == "未到")
  2086. {
  2087. SetBackColor(i, j + 1, RGB(255, 0, 0));
  2088. }
  2089. else if (j == 11 + nAdd)SetBackColor(i, j + 1, RGB(0, 255, 0));
  2090. }
  2091. aa++;
  2092. }
  2093. if (m_pListArray->GetSize())
  2094. {
  2095. //汇总行
  2096. CString str = " 今日预约: ";
  2097. CString temp;
  2098. for (int a = 0; a < typearray.GetSize(); a++)
  2099. {
  2100. temp.Format("%d ", typecountarray.ElementAt(a));
  2101. str += temp;
  2102. }
  2103. SetText(oldpos, 1, GetText(oldpos, 1) + str);
  2104. }
  2105. CalRowHeight();
  2106. return 0;
  2107. }
  2108. void XTable::ModeChange(int mode)
  2109. {
  2110. m_mode = mode;
  2111. }
  2112. void XTable::AddName(int row, int col, CString str)
  2113. {
  2114. CString oldtext = GetText(row, col);
  2115. if (oldtext.IsEmpty())
  2116. {
  2117. SetText(row, col, str);
  2118. return;
  2119. }
  2120. if (oldtext.Find(str) != -1)return;
  2121. SetText(row, col, oldtext + "," + str);
  2122. }
  2123. //化妆师
  2124. void XTable::HidePrice()
  2125. {
  2126. if (m_mode != 4)
  2127. {
  2128. #ifdef LKAY_VERSION
  2129. if(IsHasRights2new(31))return;
  2130. for(int i=0; i< m_pListArray->GetSize (); i++)
  2131. {
  2132. m_pListArray->ElementAt (i).SetAt (1, "***");
  2133. m_pListArray->ElementAt (i).SetAt (4, "***");
  2134. }
  2135. #else
  2136. if (IsHasRights2new(31))return;
  2137. for (int i = 0; i < m_pListArray->GetSize(); i++)
  2138. {
  2139. m_pListArray->ElementAt(i).SetAt(1, "***");
  2140. m_pListArray->ElementAt(i).SetAt(4, "***");
  2141. }
  2142. #endif
  2143. }
  2144. else
  2145. {
  2146. #ifdef LKAY_VERSION
  2147. if(IsHasRights2new(31))return;
  2148. for(int i=0; i< m_pListArray->GetSize (); i++)
  2149. {
  2150. m_pListArray->ElementAt (i).SetAt (1, "***");
  2151. m_pListArray->ElementAt (i).SetAt (4, "***");
  2152. }
  2153. #else
  2154. if (IsHasRights2new(31))return;
  2155. for (int i = 0; i < m_pListArray->GetSize(); i++)
  2156. {
  2157. m_pListArray->ElementAt(i).SetAt(1, "***");
  2158. m_pListArray->ElementAt(i).SetAt(4, "***");
  2159. }
  2160. #endif
  2161. }
  2162. }