XTable.cpp 65 KB

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