1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554 |
- #include "stdafx.h"
- #include "YLGL.h"
- #include "XTable.h"
- #include "InputDate.h"
- #include "MemDC.h"
- #include "TodayForm2.h"
- #include "TodayForm.h"
- #define XTABLE_CLASSNAME _T("XTableCtrl")
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #endif
- IMPLEMENT_DYNAMIC(XTable, CWnd)
- BEGIN_MESSAGE_MAP(XTable, CWnd)
- ON_WM_PAINT()
- ON_WM_KEYDOWN()
- ON_WM_LBUTTONDOWN()
- ON_WM_LBUTTONDBLCLK()
- ON_MESSAGE(WM_USER_EDIT_END, OnEditEnd)
- ON_WM_ERASEBKGND()
- END_MESSAGE_MAP()
- XTable::XTable(int rows, int cols)
- {
- RegisterWindowClass();
- defaultCell.table = this;
- defaultHeight = 20;
- defaultWidth = 80;
- cells = NULL;
- rowHeight = NULL;
- colWidth = NULL;
- this->rows = 0;
- this->cols = 0;
- SetRows(rows);
- SetCols(cols);
- focusRow = 0;
- focusCol = 0;
- m_bFocusFrame = 1;
- m_nCurShow = -1;
- m_nticks = ::GetTickCount();
- m_mode = 0;
- m_pComboBox = NULL;
- }
- XTable::~XTable()
- {
- if (cells)delete[] cells;
- if (rowHeight)delete[] rowHeight;
- if (colWidth)delete[] colWidth;
- }
- BOOL XTable::Create(const RECT& rect, CWnd* pParentWnd, UINT nID, DWORD dwStyle)
- {
- ASSERT(pParentWnd->GetSafeHwnd());
- if (!CWnd::Create(XTABLE_CLASSNAME, NULL, dwStyle, rect, pParentWnd, nID))
- return FALSE;
- return TRUE;
- }
- int XTable::ToXML(CMarkup& markup)
- {
- markup.AddChildElem("table");
- markup.AddChildAttr("border", "1");
- markup.IntoElem();
- for (int i = 0; i < GetRows(); i++)
- {
- markup.AddChildElem("tr");
- markup.IntoElem();
- for (int j = 0; j < GetCols(); j++)
- {
- XCell* cell = GetCells(i, j);
- if (cell->colSpan > 0 && cell->rowSpan > 0)
- {
- markup.AddChildElem("td");
- if (cell->colSpan == 1 && i == 0)
- markup.AddChildAttr("width", GetColWidth(j));
- if (cell->rowSpan == 1 && j == 0)
- markup.AddChildAttr("height", GetRowHeight(i));
- cell->ToXML(markup);
- }
- }
- markup.OutOfElem();
- }
- markup.OutOfElem();
- return 0;
- }
- int XTable::FromXML(CMarkup& markup)
- {
- markup.IntoElem();
- int maxCol = 0;
- int maxRow = 0;
- int row = 0;
- int col = 0;
- SetCols(MAX_COLS);
- SetRows(MAX_ROWS);
- while (markup.FindChildElem("tr"))
- {
- markup.IntoElem();
- col = 0;
- while (markup.FindChildElem("td"))
- {
- XCell* cell;
- while (true)
- {
- cell = GetCells(row, col);
- if (!cell)
- break;
- if (cell->colSpan >= 1 && cell->rowSpan >= 1)
- break;
- col++;
- }
- cell->FromXML(markup);
- if (cell->colSpan > 1 || cell->rowSpan > 1)
- JoinCells(row, col, row + cell->rowSpan - 1, col + cell->colSpan - 1);
- if (cell->colSpan == 1 && markup.GetChildAttr("width") != "")
- {
- int width = atoi(markup.GetChildAttr("width"));
- if (row == 0 || width > GetColWidth(col))
- SetColWidth(col, width);
- }
- if (cell->rowSpan == 1 && markup.GetChildAttr("height") != "")
- {
- int height = atoi(markup.GetChildAttr("height"));
- if (col == 0 || height > GetRowHeight(row))
- SetRowHeight(row, height);
- }
- col += cell->colSpan;
- if (col > maxCol) maxCol = col;
- if (row + cell->rowSpan > maxRow) maxRow = row + cell->rowSpan;
- }
- markup.OutOfElem();
- row++;
- }
- markup.OutOfElem();
- SetRows(maxRow);
- SetCols(maxCol);
- return 0;
- }
- int XTable::SetRows(int newRows)
- {
- if (rows < 0 || rows > MAX_ROWS) return -1;
- if (rows == newRows) return 0;
- int cellsSize = cols * rows;
- XCell* newCells = cells;
- int* newRowHeight = new int[newRows];
- if (rows < newRows)
- {
- if (cellsSize < newRows * cols)
- {
- cellsSize *= 2;
- if (cellsSize < newRows * cols)
- cellsSize = newRows * cols;
- newCells = new XCell[cellsSize];
-
- for (int i = 0; i < rows; i++)
- {
- for (int j = 0; j < cols; j++)
- {
- newCells[i * cols + j] = cells[i * cols + j];
- }
- newRowHeight[i] = rowHeight[i];
- }
- }
-
- for (int i = rows; i < newRows; i++)
- {
- for (int j = 0; j < cols; j++)
- {
- newCells[i * cols + j] = defaultCell;
- newCells[i * cols + j].SetSpan(1, 1);
- }
- newRowHeight[i] = defaultHeight;
- }
- delete[] rowHeight;
- rowHeight = newRowHeight;
- }
- else
- {
- if (cellsSize > newRows * cols * 2)
- {
- cellsSize = newRows * cols;
- newCells = new XCell[cellsSize];
- }
-
- for (int i = 0; i < newRows; i++)
- {
- for (int j = 0; j < cols; j++)
- newCells[i * cols + j] = cells[i * cols + j];
- }
- }
- if (newCells != cells)
- {
- delete[] cells;
- cells = newCells;
- }
- rows = newRows;
- return 0;
- }
- int XTable::GetRows()
- {
- return rows;
- }
- int XTable::SetCols(int newCols)
- {
- if (newCols < 0 || newCols > MAX_COLS) return -1;
- if (this->cols == newCols) return 0;
- int cellsSize = cols * rows;
- XCell* newCells = cells;
- int* newColWidth = new int[newCols];
- if (cols < newCols)
- {
- if (cellsSize < newCols * rows)
- {
- cellsSize *= 2;
- if (cellsSize < newCols * rows)
- cellsSize = newCols * rows;
- newCells = new XCell[cellsSize];
-
- for (int i = 0; i < rows; i++)
- {
- for (int j = 0; j < cols; j++)
- {
- newCells[i * newCols + j] = cells[i * cols + j];
- newColWidth[j] = colWidth[j];
- }
- }
- }
-
- for (int i = 0; i < rows; i++)
- {
- for (int j = cols; j < newCols; j++)
- {
- newCells[i * newCols + j] = defaultCell;
- newCells[i * newCols + j].SetSpan(1, 1);
- newColWidth[j] = defaultWidth;
- }
- }
- delete[] colWidth;
- colWidth = newColWidth;
- }
- else
- {
- if (cellsSize > newCols * rows * 2)
- {
- cellsSize = newCols * rows;
- newCells = new XCell[cellsSize];
- }
-
- for (int i = 0; i < rows; i++)
- {
- for (int j = 0; j < newCols; j++)
- newCells[i * newCols + j] = cells[i * cols + j];
- }
- }
- if (newCells != cells)
- {
- delete[] cells;
- cells = newCells;
- }
- cols = newCols;
- return 0;
- }
- int XTable::GetCols()
- {
- return cols;
- }
- int XTable::JoinCells(int startRow, int startCol, int endRow, int endCol)
- {
- if (startRow < 0 || startRow >= rows) return -1;
- if (endRow < 0 || startRow >= rows) return -1;
- if (startCol < 0 || startCol >= cols) return -1;
- if (endCol < 0 || endCol >= cols) return -1;
- if (startRow > endRow || startCol > endCol) return -1;
- for (int i = startRow; i <= endRow; i++)
- {
- for (int j = startCol; j <= endCol; j++)
- {
- cells[i * cols + j].SetSpan(0, 0);
- }
- }
- cells[startRow * cols + startCol].SetSpan(endRow - startRow + 1, endCol - startCol + 1);
- return 0;
- }
- int XTable::UnjoinCells(int row, int col)
- {
- if (row < 0 || row >= this->rows) return -1;
- if (col < 0 || col >= this->cols) return -1;
- if (cells[row * cols + col].rowSpan <= 1 && cells[row * cols + col].colSpan <= 1) return -1;
- for (int i = row; i <= row + cells[row * cols + col].rowSpan; i++)
- {
- for (int j = col; j <= cells[row * cols + col].colSpan; j++)
- {
- cells[i*cols + j] = defaultCell;
- cells[i * cols + j].SetSpan(1, 1);
- }
- }
- return 0;
- }
- int XTable::SetRowHeight(int row, int height)
- {
- rowHeight[row] = height;
- return 0;
- }
- int XTable::GetRowHeight(int row)
- {
- return rowHeight[row];
- }
- int XTable::SetColWidth(int col, int width)
- {
- colWidth[col] = width;
- return 0;
- }
- int XTable::GetColWidth(int col)
- {
- return colWidth[col];
- }
- int XTable::GetRowsHeight(int startRow, int endRow)
- {
- if (startRow < 0 || startRow >= rows) return -1;
- if (endRow < 0 || endRow >= rows) return -1;
- if (startRow > endRow) return -1;
- int height = 0;
- for (int i = startRow; i <= endRow; i++)
- {
- height += rowHeight[i];
- }
- return height;
- }
- int XTable::GetColsWidth(int startCol, int endCol)
- {
- if (startCol < 0 || startCol >= cols) return -1;
- if (endCol < 0 || endCol >= cols) return -1;
- if (startCol > endCol) return -1;
- int width = 0;
- for (int i = startCol; i <= endCol; i++)
- {
- width += colWidth[i];
- }
- return width;
- }
- int XTable::SetCells(int row, int col, XCell& cell)
- {
- cells[row * cols + col] = cell;
- return 0;
- }
- XCell* XTable::GetCells(int row, int col)
- {
- return &cells[row * cols + col];
- }
- int XTable::SetText(int row, int col, CString str)
- {
- XCell* cell = GetCells(row, col);
- if (!cell) return -1;
- return cell->SetText(str);
- }
- CString XTable::GetText(int row, int col)
- {
- return cells[row * cols + col].GetText();
- }
- int XTable::SetTextColor(int row, int col, COLORREF color)
- {
- cells[row * cols + col].SetTextColor(color);
- return 0;
- }
- COLORREF XTable::GetTextColor(int row, int col)
- {
- return cells[row * cols + col].GetTextColor();
- }
- int XTable::SetTextFont(int row, int col, CFont& font)
- {
- cells[row * cols + col].SetTextFont(&font);
- return 0;
- }
- CFont* XTable::GetTextFont(int row, int col)
- {
- return cells[row * cols + col].GetTextFont();
- }
- int XTable::SetTextFontSize(int row, int col, int size)
- {
- cells[row * cols + col].SetTextFontSize(size);
- return 0;
- }
- int XTable::GetTextFontSize(int row, int col)
- {
- return cells[row * cols + col].GetTextFontSize();
- }
- int XTable::SetOverlap(int row, int col, bool enable)
- {
- XCell* cell = GetCells(row, col);
- if (!cell) return -1;
- return cell->SetOverlap(enable);
- }
- bool XTable::GetOverlap(int row, int col)
- {
- XCell* cell = GetCells(row, col);
- if (!cell) return false;
- return cell->GetOverlap();
- }
- int XTable::SetAlignment(int row, int col, int align)
- {
- XCell* cell = GetCells(row, col);
- if (!cell) return -1;
- return cell->SetAlignment(align);
- }
- int XTable::GetAlignment(int row, int col)
- {
- XCell* cell = GetCells(row, col);
- if (!cell) return -1;
- return cell->GetAlignment();
- }
- int XTable::SetWordbreak(int row, int col, bool wordbreak)
- {
- XCell* cell = GetCells(row, col);
- if (!cell) return -1;
- return cell->SetWordbreak(wordbreak);
- }
- bool XTable::GetWordbreak(int row, int col)
- {
- XCell* cell = GetCells(row, col);
- if (!cell) return false;
- return cell->GetWordbreak();
- }
- int XTable::SetBackColor(int row, int col, COLORREF color)
- {
- cells[row * cols + col].SetBackColor(color);
- return 0;
- }
- COLORREF XTable::GetBackColor(int row, int col)
- {
- return cells[row * cols + col].GetBackColor();
- }
- int XTable::SetBackMode(int row, int col, int mode)
- {
- cells[row * cols + col].SetBackMode(mode);
- return 0;
- }
- int XTable::GetBackMode(int row, int col)
- {
- return cells[row * cols + col].GetBackMode();
- }
- RECT XTable::GetRect(int row, int col)
- {
- RECT rect;
- try
- {
- int rowSpan = GetCells(row, col)->rowSpan;
- int colSpan = GetCells(row, col)->colSpan;
- rect.top = GetRowsHeight(0, row - 1);
- rect.left = GetColsWidth(0, col - 1);
- rect.bottom = rect.top + GetRowsHeight(row, row + rowSpan - 1);
- rect.right = rect.left + GetColsWidth(col, col + colSpan - 1);
- }
- catch (...)
- {
- }
- return rect;
- }
- bool XTable::HitTest(CPoint point, int& row, int& col)
- {
- try
- {
- for (int i = 0; i < rows; i++)
- {
- for (int j = 0; j < rows; j++)
- {
- RECT rect = GetRect(i, j);
- if (rect.top <= point.y && rect.bottom > point.y && rect.left <= point.x && rect.right > point.x)
- {
- row = i;
- col = j;
- return true;
- }
- }
- }
- }
- catch (...)
- {
- }
- return false;
- }
- void XTable::OnDraw(CDC* pDC)
- {
- static bool lock = false;
- if (lock) return;
- if (!::IsWindow(m_hWnd)) return;
- lock = true;
- Draw(pDC);
- lock = false;
- }
- int XTable::Draw(CDC* pDC)
- {
- try
- {
- for (int i = 0; i < rows; i++)
- {
- for (int j = 0; j < cols; j++)
- {
- XCell& cell = cells[i*cols + j];
- if (cell.colSpan != 0 && cell.rowSpan != 0)
- {
- RECT rect = GetRect(i, j);
- if (cell.GetOverlap())
- {
- RECT textRect = GetRect(i, j);
- cell.CalcTextRect(pDC, &textRect);
- if (textRect.right > rect.right)
- {
- for (j = j + 1; j < cols; j++)
- {
- if (cells[i*cols + j].text != "")
- break;
- rect.right += colWidth[j];
- if (rect.right > textRect.right)
- break;
- }
- j--;
- }
- }
- cell.Draw(pDC, rect);
- }
- }
- }
- if (focusCol && m_bFocusFrame && focusRow < rows && focusCol < cols)
- {
- RECT rect = GetRect(focusRow, 1);
- RECT rect2 = GetRect(focusRow, cols - 1);
- RECT rect3 = rect;
- if (rect2.right > rect3.right)
- rect3.right = rect2.right;
- GetCells(focusRow, focusCol)->DrawHitBorder(pDC, rect3, RGB(255, 0, 20));
- }
- }
- catch (...)
- {
- }
- return 0;
- }
- void XTable::OnPaint()
- {
- CPaintDC dc(this);
- CMemDC MemDC(&dc);
- OnDraw(&MemDC);
- }
- BOOL XTable::OnEraseBkgnd(CDC* pDC)
- {
- return TRUE;
- }
- void XTable::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
- {
- CPoint point;
- RECT rect = GetRect(focusRow, focusCol);
- point.x = rect.left;
- point.y = rect.top;
- switch (nChar)
- {
- case VK_DOWN:
- point.y = rect.bottom + 1;
- break;
- case VK_UP:
- point.y = point.y - 2;
- break;
- case VK_LEFT:
- point.x = point.x - 2;
- break;
- case VK_RIGHT:
- point.x = rect.right + 1;
- break;
- default:
- return;
- }
- HitTest(point, focusRow, focusCol);
- Invalidate();
- CWnd::OnKeyDown(nChar, nRepCnt, nFlags);
- }
- void XTable::OnLButtonDown(UINT nFlags, CPoint point)
- {
- ::PostMessage(this->GetSafeHwnd(), WM_USER_EDIT_END, 1, 1);
- if (!m_bFocusFrame)return;
- HitTest(point, focusRow, focusCol);
- SetFocus();
- Invalidate();
- CWnd::OnLButtonDown(nFlags, point);
- }
- void XTable::OnEditEnd(WPARAM wParam, LPARAM lParam)
- {
- if (m_nCurShow == -1)return;
- int nAdd = 0;
- if (m_mode == 4)nAdd = 1;
- if (m_nCurShow == 0)
- {
- if (wParam == TRUE)
- {
- CString strText(_T(""));
- m_edit.GetWindowText(strText);
- DWORD dwData = m_edit.GetCtrlData();
- int nItem = dwData >> 16;
- int nIndex = dwData & 0x0000ffff;
- CString oldtext = GetText(nItem, nIndex);
- SetText(nItem, nIndex, strText);
- AddName(nItem, 11 + nAdd, g_user.name);
- if (nIndex == 9 + nAdd)
- {
- if (atoi(GetText(nItem, 9 + nAdd)) > 0)
- {
- SetBackColor(nItem, 9 + nAdd, RGB(255, 0, 0));
- }
- else SetBackColor(nItem, 9 + nAdd, RGB(0, 255, 0));
- }
- if (nIndex == 12 + nAdd)
- {
- if (GetText(nItem, 12 + nAdd) == "未到")
- {
- SetBackColor(nItem, 12 + nAdd, RGB(255, 0, 0));
- }
- else
- SetBackColor(nItem, 12 + nAdd, RGB(0, 255, 0));
- }
- if (oldtext != strText)
- Save(nItem);
- }
- m_edit.ShowWindow(SW_HIDE); m_nCurShow = -1; CalRowHeight();
- }
- else if (m_nCurShow == 1)
- {
- if (wParam == TRUE)
- {
- CString strText(_T(""));
- m_combobox.GetWindowText(strText);
- if (strText.IsEmpty())
- {
- m_combobox.ShowWindow(SW_HIDE); m_nCurShow = -1;
- return;
- }
- int pos = m_combobox.GetCurSel();
- if (pos == -1)
- {
- m_combobox.ShowWindow(SW_HIDE); m_nCurShow = -1;
- DWORD dwData = m_combobox.GetCtrlData();
- int nItem = dwData >> 16;
- int nIndex = dwData & 0x0000ffff;
- CString oldtext = GetText(nItem, nIndex);
- SetText(nItem, nIndex, strText);
- AddName(nItem, 11 + nAdd, g_user.name);
- SetText(nItem, 12 + nAdd, "未到");
- if (oldtext != strText)
- Save(nItem);
- m_combobox.ShowWindow(SW_HIDE); m_nCurShow = -1; CalRowHeight();
- return;
- }
- if (m_acCombo.m_posarray.GetSize() <= pos)
- {
- m_combobox.ShowWindow(SW_HIDE); m_nCurShow = -1;
- DWORD dwData = m_combobox.GetCtrlData();
- int nItem = dwData >> 16;
- int nIndex = dwData & 0x0000ffff;
- CString oldtext = GetText(nItem, nIndex);
- SetText(nItem, nIndex, strText);
- AddName(nItem, 11 + nAdd, g_user.name);
- SetText(nItem, 12 + nAdd, "未到");
- if (oldtext != strText)
- Save(nItem);
- }
- else
- {
- int pos2 = m_acCombo.m_posarray.ElementAt(pos);
- m_id = m_pClientArray->ElementAt(pos2).ElementAt(0);
- DWORD dwData = m_combobox.GetCtrlData();
- int nItem = dwData >> 16;
- int nIndex = dwData & 0x0000ffff;
- CString oldtext = GetText(nItem, nIndex);
- SetText(nItem, nIndex, strText);
- if (!m_pClientArray->ElementAt(pos2).ElementAt(3).IsEmpty())
- SetText(nItem, 2, m_pClientArray->ElementAt(pos2).ElementAt(3) + " " + m_pClientArray->ElementAt(pos2).ElementAt(4));
- else
- SetText(nItem, 2, m_pClientArray->ElementAt(pos2).ElementAt(4));
- if (m_mode == 4)
- {
- g_sendhead.bsql = 0;
- CString filter = "id='" + m_id + "' and kind<>'5'";
- g_sendhead.code[0] = 56;
- g_sendhead.tabcount = 1;
- g_bNoConnDlg = 1;
- g_pMainWnd->ProcessChatMessageRequest2(filter); g_bNoConnDlg = 0;
- if (g_bSendOK)
- {
- DataToArray(&g_List1array);
- CString str;
- for (int i = 0; i < g_List1array.GetSize(); i++)
- {
- if (g_List1array.ElementAt(i).ElementAt(20) != "2")continue;
- str += g_List1array.ElementAt(i).ElementAt(0);
- str += ",";
- }
- str.TrimRight(",");
- SetText(nItem, 4, str);
- }
- }
- SetText(nItem, 4 + nAdd, m_pClientArray->ElementAt(pos2).ElementAt(5));
- SetText(nItem, 5 + nAdd, m_pClientArray->ElementAt(pos2).ElementAt(6));
- SetText(nItem, 6 + nAdd, m_pClientArray->ElementAt(pos2).ElementAt(7));
- SetText(nItem, 7 + nAdd, m_pClientArray->ElementAt(pos2).ElementAt(8));
- SetText(nItem, 8 + nAdd, m_pClientArray->ElementAt(pos2).ElementAt(9));
- SetText(nItem, 9 + nAdd, m_pClientArray->ElementAt(pos2).ElementAt(10));
- if (atoi(GetText(nItem, 9 + nAdd)) > 0)
- {
- SetBackColor(nItem, 9 + nAdd, RGB(255, 0, 0));
- }
- else SetBackColor(nItem, 9 + nAdd, RGB(0, 255, 0));
- if (!m_pClientArray->ElementAt(pos2).ElementAt(11).IsEmpty())
- SetText(nItem, 10 + nAdd, "服装:" + m_pClientArray->ElementAt(pos2).ElementAt(11));
- AddName(nItem, 11 + nAdd, g_user.name);
- SetText(nItem, 12 + nAdd, "未到");
- if (oldtext != strText)
- Save(nItem);
- }
- }
- m_combobox.ShowWindow(SW_HIDE); m_nCurShow = -1; CalRowHeight();
- }
- else if (m_nCurShow == 2)
- {
- if (wParam == TRUE)
- {
- CString strText(_T(""));
- m_combobox2.GetWindowText(strText);
- DWORD dwData = m_combobox2.GetCtrlData();
- int nItem = dwData >> 16;
- int nIndex = dwData & 0x0000ffff;
- CString oldtext = GetText(nItem, nIndex);
- SetText(nItem, nIndex, strText);
-
- AddName(nItem, 11 + nAdd, g_user.name);
- if (nIndex == 12 + nAdd)
- {
- if (GetText(nItem, 12 + nAdd) == "未到")
- {
- SetBackColor(nItem, 12 + nAdd, RGB(255, 0, 0));
- }
- else
- SetBackColor(nItem, 12 + nAdd, RGB(0, 255, 0));
- }
- if (oldtext != strText)
- Save(nItem);
-
- }
- m_combobox2.ShowWindow(SW_HIDE); m_nCurShow = -1; CalRowHeight();
- }
- else if (m_nCurShow == 3)
- {
- if (wParam == TRUE)
- {
- CString strText(_T(""));
- m_pComboBox->GetWindowText(strText);
- DWORD dwData = m_pComboBox->GetCtrlData();
- int nItem = dwData >> 16;
- int nIndex = dwData & 0x0000ffff;
- CString oldtext = GetText(nItem, nIndex);
- SetText(nItem, nIndex, strText);
- AddName(nItem, 11 + nAdd, g_user.name);
- if (nIndex == 12 + nAdd)
- {
- if (GetText(nItem, 12 + nAdd) == "未到")
- {
- SetBackColor(nItem, 12 + nAdd, RGB(255, 0, 0));
- }
- else
- SetBackColor(nItem, 12 + nAdd, RGB(0, 255, 0));
- }
- if (oldtext != strText)
- Save(nItem);
-
- }
- m_pComboBox->ShowWindow(SW_HIDE); m_nCurShow = -1; CalRowHeight();
- }
- }
- void XTable::ShowEdit(BOOL bShow, int nItem, int nIndex, CRect rcCtrl)
- {
- try
- {
- if (m_edit.m_hWnd == NULL)
- {
- m_edit.Create(ES_AUTOHSCROLL | WS_CHILD | ES_LEFT | ES_WANTRETURN | WS_BORDER, CRect(0, 0, 0, 0), this, IDC_EDIT1);
- m_edit.ShowWindow(SW_HIDE);
- CFont tpFont;
- tpFont.CreateStockObject(DEFAULT_GUI_FONT);
- m_edit.SetFont(&tpFont);
- tpFont.DeleteObject();
- }
- if (bShow == TRUE)
- {
- CString strItem = GetText(nItem, nIndex);
- m_edit.MoveWindow(rcCtrl);
- m_edit.ShowWindow(SW_SHOW);
- m_edit.SetWindowText(strItem);
- ::SetFocus(m_edit.GetSafeHwnd());
- m_edit.SetSel(-1);
- m_edit.SetCtrlData(MAKEWPARAM(nIndex, nItem));
- }
- else
- m_edit.ShowWindow(SW_HIDE);
- }
- catch (...)
- {
- }
- }
- void XTable::ShowSearchClientComboBox(BOOL bShow, int nItem, int nIndex, CRect rcCtrl)
- {
- try
- {
- if (m_combobox.m_hWnd == NULL)
- {
- m_combobox.Create(WS_VSCROLL | WS_CHILD | CBS_DROPDOWN, CRect(0, 0, 0, 0), this, 100);
- m_combobox.ShowWindow(SW_HIDE);
- m_acCombo.m_mode = 1;
- m_acCombo.Init(&m_combobox);
- m_acCombo.m_pArray = m_pClientArray;
- m_combobox.SetFocus();
- }
- if (bShow == TRUE)
- {
- CString strItem = GetText(nItem, nIndex);
- rcCtrl.bottom += 300;
- m_combobox.MoveWindow(rcCtrl);
- m_combobox.ShowWindow(SW_SHOW);
- m_combobox.SetWindowText(strItem);
- ::SetFocus(m_combobox.GetSafeHwnd());
- m_combobox.SetCtrlData(MAKEWPARAM(nIndex, nItem));
- }
- else
- m_combobox.ShowWindow(SW_HIDE);
- }
- catch (...)
- {
- }
- }
- void XTable::ShowSearchClientComboBoxTime(BOOL bShow, int nItem, int nIndex, int type, CRect rcCtrl)
- {
- if (type >= 2 && type <= 4)
- {
- m_nCurShow = 3;
- ShowSearchClientComboBoxTree(bShow, nItem, nIndex, type, rcCtrl);
- return;
- }
- try
- {
- if (m_combobox2.m_hWnd == NULL)
- {
- m_combobox2.Create(WS_VSCROLL | WS_CHILD | CBS_DROPDOWN, CRect(0, 0, 0, 0), this, 100);
- m_combobox2.ShowWindow(SW_HIDE);
- m_combobox2.SetFocus();
- }
- m_combobox2.ResetContent();
- if (type == 0)
- {
- m_combobox2.AddString("9:00");
- m_combobox2.AddString("9:30");
- m_combobox2.AddString("10:00");
- m_combobox2.AddString("10:30");
- m_combobox2.AddString("11:00");
- m_combobox2.AddString("11:30");
- m_combobox2.AddString("12:00");
- m_combobox2.AddString("13:00");
- m_combobox2.AddString("14:00");
- m_combobox2.AddString("15:00");
- m_combobox2.AddString("16:00");
- m_combobox2.AddString("17:00");
- m_combobox2.AddString("18:00");
- m_combobox2.AddString("19:00");
- m_combobox2.AddString("20:00");
- m_combobox2.AddString("21:00");
- }
- else if (type == 1)
- {
- for (int i = 0; i < pTxtypearray->GetSize(); i++)
- m_combobox2.AddString(pTxtypearray->ElementAt(i).ElementAt(0));
- }
- else if (type == 2)
- {
- for (int ii = 0; ii < g_userarray.GetSize(); ii++)
- {
- if ("摄影部" == g_userarray.ElementAt(ii).ElementAt(2))
- m_combobox2.AddString(g_userarray.ElementAt(ii).ElementAt(1));
- }
- }
- else if (type == 3)
- {
- for (int ii = 0; ii < g_userarray.GetSize(); ii++)
- {
- if ("化妆部" == g_userarray.ElementAt(ii).ElementAt(2))
- m_combobox2.AddString(g_userarray.ElementAt(ii).ElementAt(1));
- }
- }
- else if (type == 4)
- {
- for (int ii = 0; ii < g_userarray.GetSize(); ii++)
- {
-
- m_combobox2.AddString(g_userarray.ElementAt(ii).ElementAt(1));
- }
- }
- else if (type == 5)
- {
- m_combobox2.AddString("未到");
- m_combobox2.AddString("已到");
- }
- if (bShow == TRUE)
- {
- CString strItem = GetText(nItem, nIndex);
- rcCtrl.bottom += 300;
- m_combobox2.MoveWindow(rcCtrl);
- m_combobox2.ShowWindow(SW_SHOW);
- m_combobox2.SetWindowText(strItem);
- ::SetFocus(m_combobox2.GetSafeHwnd());
- m_combobox2.SetCtrlData(MAKEWPARAM(nIndex, nItem));
- }
- else
- m_combobox2.ShowWindow(SW_HIDE);
- }
- catch (...)
- {
- }
- }
- void XTable::ShowSearchClientComboBoxTree(BOOL bShow, int nItem, int nIndex, int type, CRect rcCtrl)
- {
- try
- {
- if (0)
- {
- m_pComboBox->Create(WS_VSCROLL | WS_CHILD | CBS_DROPDOWNLIST, CRect(0, 0, 100, 100), this, 100);
- m_pComboBox->ShowWindow(SW_HIDE);
- m_pComboBox->SetFocus();
- }
- if (bShow == TRUE)
- {
- CString strItem = GetText(nItem, nIndex);
- rcCtrl.bottom += 300;
- ClientToScreen(rcCtrl);
- GetParent()->GetParent()->ScreenToClient(rcCtrl);
- m_pComboBox->MoveWindow(rcCtrl);
- m_pComboBox->ShowWindow(SW_SHOW);
- m_pComboBox->ResetContent();
- m_pComboBox->AddString(strItem);
- m_pComboBox->SetCurSel(0);
- ::SetFocus(m_pComboBox->GetSafeHwnd());
- m_pComboBox->SetCtrlData(MAKEWPARAM(nIndex, nItem));
- m_pComboBox->RefDroppedWidth();
- }
- else
- m_pComboBox->ShowWindow(SW_HIDE);
- }
- catch (...)
- {
- }
- }
- void XTable::OnLButtonDblClk(UINT nFlags, CPoint point)
- {
- try
- {
- if (!m_bFocusFrame)return;
- if (HitTest(point, focusRow, focusCol) == 0)return;
- if (IsDateRow(focusRow))return;
- RECT rect = GetRect(focusRow, focusCol);
- if (focusCol == 0)return;
- int nAdd = 0;
- if (m_mode == 10)
- {
- if (focusRow > 0)
- {
- for (int i = 0; i < focusRow; i++)
- {
- if ("" == GetText(i, 1))
- {
- AfxMessageBox("请从上方空白处开始填起!", MB_ICONINFORMATION);
- return;
- }
- }
- }
- if (focusCol == 1)
- {
-
-
- m_nCurShow = 0;
- ShowEdit(TRUE, focusRow, focusCol, rect);
- }
- else if ("" == GetText(focusRow, 1))
- {
- AfxMessageBox("请先填写客人姓名!", MB_ICONINFORMATION);
- return;
- }
- if (focusCol == 11 + nAdd)return;
- if (focusCol == 3)
- {
- m_nCurShow = 2;
- ShowSearchClientComboBoxTime(TRUE, focusRow, focusCol, 0, rect);
- }
- else if (focusCol == 6 + nAdd)
- {
- m_nCurShow = 2;
- ShowSearchClientComboBoxTime(TRUE, focusRow, focusCol, 2, rect);
- }
- else if (focusCol == 7 + nAdd)
- {
- m_nCurShow = 2;
- ShowSearchClientComboBoxTime(TRUE, focusRow, focusCol, 2, rect);
- }
- else if (focusCol == 8 + nAdd)
- {
- m_nCurShow = 2;
- ShowSearchClientComboBoxTime(TRUE, focusRow, focusCol, 2, rect);
- }
- else if (focusCol == 12 + nAdd)
- {
- m_nCurShow = 2;
- ShowSearchClientComboBoxTime(TRUE, focusRow, focusCol, 5, rect);
- }
- else if (focusCol != 1)
- {
- m_nCurShow = 0;
- ShowEdit(TRUE, focusRow, focusCol, rect);
- }
- }
- else
- {
- if (m_mode == 4)nAdd = 1;
- if (focusRow > 0)
- {
- for (int i = 0; i < focusRow; i++)
- {
- if ("" == GetText(i, 1))
- {
- AfxMessageBox("请从上方空白处开始填起!", MB_ICONINFORMATION);
- return;
- }
- }
- }
- if (focusCol == 1)
- {
- m_nCurShow = 1;
- ShowSearchClientComboBox(TRUE, focusRow, focusCol, rect);
- }
- else if ("" == GetText(focusRow, 1))
- {
- AfxMessageBox("请先填写客人姓名!", MB_ICONINFORMATION);
- return;
- }
- if (focusCol == 11 + nAdd)return;
- if (focusCol == 3)
- {
- m_nCurShow = 2;
- ShowSearchClientComboBoxTime(TRUE, focusRow, focusCol, 0, rect);
- }
- else if (focusCol == 4 + nAdd)
- {
- m_nCurShow = 2;
- ShowSearchClientComboBoxTime(TRUE, focusRow, focusCol, 1, rect);
- }
- else if (focusCol == 6 + nAdd)
- {
- m_nCurShow = 2;
- ShowSearchClientComboBoxTime(TRUE, focusRow, focusCol, 2, rect);
- }
- else if (focusCol == 7 + nAdd)
- {
- m_nCurShow = 2;
- ShowSearchClientComboBoxTime(TRUE, focusRow, focusCol, 3, rect);
- }
- else if (focusCol == 8 + nAdd)
- {
- m_nCurShow = 2;
- ShowSearchClientComboBoxTime(TRUE, focusRow, focusCol, 4, rect);
- }
- else if (focusCol == 12 + nAdd)
- {
- m_nCurShow = 2;
- ShowSearchClientComboBoxTime(TRUE, focusRow, focusCol, 5, rect);
- }
- else if (focusCol != 1)
- {
- m_nCurShow = 0;
- ShowEdit(TRUE, focusRow, focusCol, rect);
- }
- }
- }
- catch (...)
- {
- }
- CWnd::OnLButtonDown(nFlags, point);
- }
- BOOL XTable::RegisterWindowClass()
- {
- WNDCLASS wndcls;
- HINSTANCE hInst = AfxGetInstanceHandle();
- if (!(::GetClassInfo(hInst, XTABLE_CLASSNAME, &wndcls)))
- {
-
- wndcls.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
- wndcls.lpfnWndProc = ::DefWindowProc;
- wndcls.cbClsExtra = wndcls.cbWndExtra = 0;
- wndcls.hInstance = hInst;
- wndcls.hIcon = NULL;
- wndcls.hCursor = AfxGetApp()->LoadStandardCursor(IDC_ARROW);
- wndcls.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
- wndcls.lpszMenuName = NULL;
- wndcls.lpszClassName = XTABLE_CLASSNAME;
- if (!AfxRegisterClass(&wndcls))
- {
- AfxThrowResourceException();
- return FALSE;
- }
- }
- return TRUE;
- }
- int XTable::Test2()
- {
- defaultHeight = 20;
- CStringArray array;
- if (m_mode == 10)
- {
- array.Add("姓名");
- array.Add("电话");
- array.Add("时间");
- array.Add("内容");
- array.Add("价格");
- array.Add("摄影");
- array.Add("化妆");
- array.Add("门市");
- array.Add("欠款");
- array.Add("备注");
- array.Add("录入");
- array.Add("是否到店");
- }
- else if (m_mode == 4)
- {
- array.Add("姓名");
- array.Add("电话");
- array.Add("时间");
- array.Add("婚庆内容");
- array.Add("类别");
- array.Add("价格");
- array.Add("摄影");
- #ifdef CHILD_VERSION
- array.Add("引导");
- #else
- array.Add ("化妆");
- #endif
- array.Add("门市");
- array.Add("欠款");
- array.Add("备注");
- array.Add("录入");
- array.Add("是否到店");
- }
- else
- {
- array.Add("姓名");
- array.Add("电话");
- array.Add("时间");
- array.Add("类别");
- array.Add("价格");
- array.Add("摄影");
- #ifdef CHILD_VERSION
- array.Add("引导");
- #else
- array.Add ("化妆");
- #endif
- array.Add("门市");
- array.Add("欠款");
- array.Add("备注");
- array.Add("录入");
- array.Add("是否到店");
- }
- int cols = array.GetSize();
- CRect rc;
- GetClientRect(rc);
- defaultWidth = (rc.Width() - 10) / cols;
- SetCols(1);
- SetRows(2);
- SetCols(cols + 1);
- COLORREF col1 = RGB(0xC8, 0x96, 0x96);
- COLORREF col2 = RGB(0x64, 0x96, 0xC8);
- for (int i = 0; i < 2; i++)
- SetBackColor(i, 0, col1);
- for (i = 0; i < cols + 1; i++)
- SetBackColor(0, i, col1);
- SetRowHeight(0, 10);
- SetColWidth(0, 10);
- for (i = 0; i < cols; i++)
- {
- SetBackColor(1, i + 1, col2);
- SetText(1, i + 1, array.ElementAt(i));
- }
- Invalidate();
- return 0;
- }
- XTableEdit::XTableEdit()
- {
- }
- XTableEdit::~XTableEdit()
- {
- }
- BEGIN_MESSAGE_MAP(XTableEdit, CEdit)
-
- ON_WM_KILLFOCUS()
- ON_WM_SETFOCUS()
-
- END_MESSAGE_MAP()
- void XTableEdit::SetCtrlData(DWORD dwData)
- {
- m_dwData = dwData;
- }
- DWORD XTableEdit::GetCtrlData()
- {
- return m_dwData;
- }
- void XTableEdit::OnKillFocus(CWnd* pNewWnd)
- {
- CEdit::OnKillFocus(pNewWnd);
- CWnd* pParent = this->GetParent();
- ::PostMessage(pParent->GetSafeHwnd(), WM_USER_EDIT_END, m_bExchange, 0);
- }
- BOOL XTableEdit::PreTranslateMessage(MSG* pMsg)
- {
- if (pMsg->message == WM_KEYDOWN)
- {
- if (pMsg->wParam == VK_RETURN)
- {
- CWnd* pParent = this->GetParent();
- m_bExchange = TRUE;
- ::PostMessage(pParent->GetSafeHwnd(), WM_USER_EDIT_END, m_bExchange, 0);
- }
- else if (pMsg->wParam == VK_ESCAPE)
- {
- CWnd* pParent = this->GetParent();
- m_bExchange = FALSE;
- ::PostMessage(pParent->GetSafeHwnd(), WM_USER_EDIT_END, m_bExchange, 0);
- }
- }
- return CEdit::PreTranslateMessage(pMsg);
- }
- void XTableEdit::OnSetFocus(CWnd* pOldWnd)
- {
- CEdit::OnSetFocus(pOldWnd);
- m_bExchange = TRUE;
- }
- XTableComboBox::XTableComboBox()
- {
- }
- XTableComboBox::~XTableComboBox()
- {
- }
- BEGIN_MESSAGE_MAP(XTableComboBox, CComboBox)
-
- ON_WM_KILLFOCUS()
- ON_WM_SETFOCUS()
- ON_CONTROL_REFLECT(CBN_CLOSEUP, OnCloseup)
-
- END_MESSAGE_MAP()
- void XTableComboBox::SetCtrlData(DWORD dwData)
- {
- m_dwData = dwData;
- }
- DWORD XTableComboBox::GetCtrlData()
- {
- return m_dwData;
- }
- void XTableComboBox::OnKillFocus(CWnd* pNewWnd)
- {
- CComboBox::OnKillFocus(pNewWnd);
-
- }
- BOOL XTableComboBox::PreTranslateMessage(MSG* pMsg)
- {
- if (pMsg->message == WM_KEYDOWN)
- {
- if (pMsg->wParam == VK_RETURN)
- {
- CWnd* pParent = this->GetParent();
- m_bExchange = TRUE;
- ::PostMessage(pParent->GetSafeHwnd(), WM_USER_EDIT_END, m_bExchange, 1);
- }
- else if (pMsg->wParam == VK_ESCAPE)
- {
- CWnd* pParent = this->GetParent();
- m_bExchange = FALSE;
- ::PostMessage(pParent->GetSafeHwnd(), WM_USER_EDIT_END, m_bExchange, 1);
- }
- }
- return CComboBox::PreTranslateMessage(pMsg);
- }
- void XTableComboBox::OnSetFocus(CWnd* pOldWnd)
- {
- CComboBox::OnSetFocus(pOldWnd);
- m_bExchange = TRUE;
- }
- void XTableComboBox::OnCloseup()
- {
-
- CWnd* pParent = this->GetParent();
- ::PostMessage(pParent->GetSafeHwnd(), WM_USER_EDIT_END, m_bExchange, 1);
- }
- void XTable::CalRowHeight()
- {
- CString str; CPaintDC dc(this);
- for (int i = 0; i < GetRows(); i++)
- {
- SetRowHeight(i, 20);
- for (int j = 1; j<GetCols(); j++)
- {
- str = GetText(i, j);
- RECT rect = GetRect(i, j);
- RECT textRect = rect;
- this->SetWordbreak(i, j, 0);
- XCell* cell = GetCells(i, j);
- cell->CalcTextRect(&dc, &textRect);
- if (textRect.right > rect.right || textRect.bottom > rect.bottom)
- {
- this->SetWordbreak(i, j, 1);
- textRect = rect;
- cell->CalcTextRect(&dc, &textRect);
- rect.bottom = textRect.bottom + 2;
-
- SetRowHeight(i, rect.bottom - rect.top);
- }
- }
- }
- Invalidate();
- }
- void XTable::Save(int row)
- {
- if (m_mode == 4)
- {
- Save2(row); return;
- }
- if (m_mode == 10)
- {
- Save3(row); return;
- }
- if (IsHasRightsnew(2) == 0)return;
- if (::GetTickCount() - m_nticks < 1000)return;
- m_nticks = ::GetTickCount();
- int oldrow = row;
- BOOL bFind = 0;
- for (int i = 0; i < m_daterowposarray.GetSize(); i++)
- {
- if (row < m_daterowposarray.ElementAt(i))
- {
- row -= i; bFind = 1;
- break;
- }
- if (row == m_daterowposarray.ElementAt(i))
- return;
- }
- if (bFind == 0)row -= m_daterowposarray.GetSize();
- if (row >= m_pListArray->GetSize())
- {
- CString name = GetText(oldrow, 1);
- CString phone = GetText(oldrow, 2);
- CString time = GetText(oldrow, 3);
- CString type = GetText(oldrow, 4);
- CString price = GetText(oldrow, 5);
- CString waiter1 = GetText(oldrow, 6);
- CString waiter2 = GetText(oldrow, 7);
- CString receptionist = GetText(oldrow, 8);
- CString arrearage = GetText(oldrow, 9);
- CString remark = GetText(oldrow, 10);
- CString arrive = GetText(oldrow, 12);
- CString timestamp = CTime::GetCurrentTime().Format("%Y%m%d%H%M%S");
- CString str = CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S");
- str.Replace("-", "");
- str = str.Left(str.GetLength() - 3);
- CString clerk = GetText(oldrow, 11) + str;
- CString date = ((TodayForm2*)(GetParent()->GetParent()))->GetDate();
- if (name.IsEmpty())return;
- CString sql, sql2;
- 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);
- if (m_mode == 0)
- {
- sql2.Format("***update dindan set [time2]='%s' where [id]='%s'", date, m_id);
- }
- else if (m_mode == 1)
- {
- sql2.Format("***update dindan set [time4]='%s' where [id]='%s'", date, m_id);
- }
- else if (m_mode == 2)
- {
- sql2.Format("***update dindan set [time6]='%s' where [id]='%s'", date, m_id);
- }
- else if (m_mode == 3)
- {
- sql2.Format("***update dindan set [time5]='%s' where [id]='%s'", date, m_id);
- }
- sql += sql2;
- g_sendhead.bsql = 1;
- g_pMainWnd->ProcessChatMessageRequest2(sql);
- ((TodayForm2*)(GetParent()->GetParent()))->ReLoad1();
- }
- else
- {
- CString name = GetText(oldrow, 1);
- CString phone = GetText(oldrow, 2);
- CString time = GetText(oldrow, 3);
- CString type = GetText(oldrow, 4);
- CString price = GetText(oldrow, 5);
- CString waiter1 = GetText(oldrow, 6);
- CString waiter2 = GetText(oldrow, 7);
- CString receptionist = GetText(oldrow, 8);
- CString arrearage = GetText(oldrow, 9);
- CString remark = GetText(oldrow, 10);
- CString clerk = GetText(oldrow, 11);
- CString arrive = GetText(oldrow, 12);
- CString timestamp = m_pListArray->ElementAt(row).ElementAt(13);
- if (name.IsEmpty())return;
- CString sql;
- 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);
- if (IsHasRights2new(31) == 0)
- 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);
- g_sendhead.bsql = 1;
- g_pMainWnd->ProcessChatMessageRequest2(sql);
- }
- }
- void XTable::Save2(int row)
- {
- if (IsHasRightsnew(2) == 0)return;
- if (::GetTickCount() - m_nticks < 1000)return;
- m_nticks = ::GetTickCount();
- int oldrow = row;
- BOOL bFind = 0;
- for (int i = 0; i < m_daterowposarray.GetSize(); i++)
- {
- if (row < m_daterowposarray.ElementAt(i))
- {
- row -= i; bFind = 1;
- break;
- }
- if (row == m_daterowposarray.ElementAt(i))
- return;
- }
- if (bFind == 0)row -= m_daterowposarray.GetSize();
- if (row >= m_pListArray->GetSize())
- {
- CString name = GetText(oldrow, 1);
- CString phone = GetText(oldrow, 2);
- CString time = GetText(oldrow, 3);
- CString content = GetText(oldrow, 4);
- CString type = GetText(oldrow, 5);
- CString price = GetText(oldrow, 6);
- CString waiter1 = GetText(oldrow, 7);
- CString waiter2 = GetText(oldrow, 8);
- CString receptionist = GetText(oldrow, 9);
- CString arrearage = GetText(oldrow, 10);
- CString remark = GetText(oldrow, 11);
- CString str = CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S");
- str.Replace("-", "");
- str = str.Left(str.GetLength() - 3);
- CString clerk = GetText(oldrow, 12) + str;
- CString arrive = GetText(oldrow, 13);
- CString timestamp = CTime::GetCurrentTime().Format("%Y%m%d%H%M%S");
- CString date = ((TodayForm2*)(GetParent()->GetParent()))->GetDate();
- if (name.IsEmpty())return;
- CString sql;
- 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);
- g_sendhead.bsql = 1;
- g_pMainWnd->ProcessChatMessageRequest2(sql);
- ((TodayForm2*)(GetParent()->GetParent()))->ReLoad1();
- }
- else
- {
- CString name = GetText(oldrow, 1);
- CString phone = GetText(oldrow, 2);
- CString time = GetText(oldrow, 3);
- CString content = GetText(oldrow, 4);
- CString type = GetText(oldrow, 5);
- CString price = GetText(oldrow, 6);
- CString waiter1 = GetText(oldrow, 7);
- CString waiter2 = GetText(oldrow, 8);
- CString receptionist = GetText(oldrow, 9);
- CString arrearage = GetText(oldrow, 10);
- CString remark = GetText(oldrow, 11);
- CString clerk = GetText(oldrow, 12);
- CString arrive = GetText(oldrow, 13);
- CString timestamp = m_pListArray->ElementAt(row).ElementAt(14);
- if (name.IsEmpty())return;
- CString sql;
- 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);
- if (IsHasRights2new(31) == 0)
- 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);
- g_sendhead.bsql = 1;
- g_pMainWnd->ProcessChatMessageRequest2(sql);
- }
- }
- void XTable::Save3(int row)
- {
- if (IsHasRightsnew(2) == 0)return;
- if (::GetTickCount() - m_nticks < 1000)return;
- m_nticks = ::GetTickCount();
- int oldrow = row;
- BOOL bFind = 0;
- for (int i = 0; i < m_daterowposarray.GetSize(); i++)
- {
- if (row < m_daterowposarray.ElementAt(i))
- {
- row -= i; bFind = 1;
- break;
- }
- if (row == m_daterowposarray.ElementAt(i))
- return;
- }
- if (bFind == 0)row -= m_daterowposarray.GetSize();
- if (row >= m_pListArray->GetSize())
- {
- CString name = GetText(oldrow, 1);
- CString phone = GetText(oldrow, 2);
- CString time = GetText(oldrow, 3);
- CString content = GetText(oldrow, 4);
- CString price = GetText(oldrow, 5);
- CString waiter1 = GetText(oldrow, 6);
- CString waiter2 = GetText(oldrow, 7);
- CString receptionist = GetText(oldrow, 8);
- CString arrearage = GetText(oldrow, 9);
- CString remark = GetText(oldrow, 10);
- CString str = CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S");
- str.Replace("-", "");
- str = str.Left(str.GetLength() - 3);
- CString clerk = GetText(oldrow, 11) + str;
- CString arrive = GetText(oldrow, 12);
- CString timestamp = CTime::GetCurrentTime().Format("%Y%m%d%H%M%S");
- CString date = ((TodayForm*)(GetParent()->GetParent()))->GetDate();
- if (name.IsEmpty())return;
- CString sql;
- 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);
- g_sendhead.bsql = 1;
- g_pMainWnd->ProcessChatMessageRequest2(sql);
- ((TodayForm*)(GetParent()->GetParent()))->ReLoad1();
- }
- else
- {
- CString name = GetText(oldrow, 1);
- CString phone = GetText(oldrow, 2);
- CString time = GetText(oldrow, 3);
- CString content = GetText(oldrow, 4);
- CString price = GetText(oldrow, 5);
- CString waiter1 = GetText(oldrow, 6);
- CString waiter2 = GetText(oldrow, 7);
- CString receptionist = GetText(oldrow, 8);
- CString arrearage = GetText(oldrow, 9);
- CString remark = GetText(oldrow, 10);
- CString clerk = GetText(oldrow, 11);
- CString arrive = GetText(oldrow, 12);
- CString timestamp = m_pListArray->ElementAt(row).ElementAt(13);
- if (name.IsEmpty())return;
- CString sql;
- 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);
- if (IsHasRights2new(31) == 0)
- 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);
- g_sendhead.bsql = 1;
- g_pMainWnd->ProcessChatMessageRequest2(sql);
- }
- }
- void XTable::DeleteCur()
- {
- int row = focusRow;
- CString name = GetText(row, 1);
- BOOL bFind = 0;
- for (int i = 0; i < m_daterowposarray.GetSize(); i++)
- {
- if (row < m_daterowposarray.ElementAt(i))
- {
- row -= i; bFind = 1;
- break;
- }
- if (row == m_daterowposarray.ElementAt(i))
- return;
- }
- if (bFind == 0)row -= m_daterowposarray.GetSize();
- if (row >= m_pListArray->GetSize())
- return;
- if (AfxMessageBox("确定删除客人" + name + "的预约资料吗?", MB_YESNO | MB_ICONINFORMATION) != IDYES)return;
- int size = m_pListArray->ElementAt(row).GetSize();
- CString timestamp = m_pListArray->ElementAt(row).ElementAt(size - 2);
- CString sql;
- sql.Format("delete from todaytake where [timestamp]='%s'", timestamp);
- g_sendhead.bsql = 1;
- g_pMainWnd->ProcessChatMessageRequest2(sql);
- if (m_mode == 10)
- ((TodayForm*)(GetParent()->GetParent()))->ReLoad1();
- else
- ((TodayForm2*)(GetParent()->GetParent()))->ReLoad1();
- }
- CString XTable::GetCurPhone(CString &name)
- {
- int row = focusRow;
- name = GetText(row, 1);
- return GetText(row, 2);
- BOOL bFind = 0;
- for (int i = 0; i < m_daterowposarray.GetSize(); i++)
- {
- if (row < m_daterowposarray.ElementAt(i))
- {
- row -= i; bFind = 1;
- break;
- }
- if (row == m_daterowposarray.ElementAt(i))
- return "";
- }
- if (bFind == 0)row -= m_daterowposarray.GetSize();
- if (row >= m_pListArray->GetSize())
- return "";
- int size = m_pListArray->ElementAt(row).GetSize();
- CString date = m_pListArray->ElementAt(row).ElementAt(size - 3);
- CString timestamp = m_pListArray->ElementAt(row).ElementAt(size - 2);
- CString id = m_pListArray->ElementAt(row).ElementAt(size - 1);
- }
- void XTable::OtherDate()
- {
- int row = focusRow;
- CString name = GetText(row, 1);
- BOOL bFind = 0;
- for (int i = 0; i < m_daterowposarray.GetSize(); i++)
- {
- if (row < m_daterowposarray.ElementAt(i))
- {
- row -= i; bFind = 1;
- break;
- }
- if (row == m_daterowposarray.ElementAt(i))
- return;
- }
- if (bFind == 0)row -= m_daterowposarray.GetSize();
- if (row >= m_pListArray->GetSize())
- return;
- int size = m_pListArray->ElementAt(row).GetSize();
- CString date = m_pListArray->ElementAt(row).ElementAt(size - 3);
- CString timestamp = m_pListArray->ElementAt(row).ElementAt(size - 2);
- CString id = m_pListArray->ElementAt(row).ElementAt(size - 1);
- InputDate dlg;
- dlg.m_date = date;
- dlg.m_name = name;
- dlg.m_name = m_pListArray->ElementAt(row).ElementAt(0);
- if (dlg.DoModal() != IDOK)return;
- CString sql, sql2;
- sql.Format("update [todaytake] set [date]='%s' where [timestamp]='%s'", dlg.m_date, timestamp);
- g_sendhead.bsql = 1;
- if (m_mode == 0)
- {
- sql2.Format("***update dindan set [time2]='%s' where [id]='%s'", dlg.m_date, id);
- }
- else if (m_mode == 1)
- {
- sql2.Format("***update dindan set [time4]='%s' where [id]='%s'", dlg.m_date, id);
- }
- else if (m_mode == 2)
- {
- sql2.Format("***update dindan set [time6]='%s' where [id]='%s'", dlg.m_date, id);
- }
- else if (m_mode == 3)
- {
- sql2.Format("***update dindan set [time5]='%s' where [id]='%s'", dlg.m_date, id);
- }
- sql += sql2;
- g_pMainWnd->ProcessChatMessageRequest2(sql);
- if (m_mode == 10)
- ((TodayForm*)(GetParent()->GetParent()))->ReLoad1();
- else
- ((TodayForm2*)(GetParent()->GetParent()))->ReLoad1();
- }
- BOOL XTable::IsDateRow(int row)
- {
- try
- {
- for (int i = 0; i < m_daterowposarray.GetSize(); i++)
- {
- if (row == m_daterowposarray.ElementAt(i))
- return 1;
- }
- }
- catch (...)
- {
- }
- return 0;
- }
- CString XTable::GetWeek(CString date)
- {
- if (date.GetLength() != 10)return "";
- COleDateTime dtDay(atoi(date.Mid(0, 4)), atoi(date.Mid(5, 2)), atoi(date.Mid(8, 2)), 0, 0, 0);
- int nDayWeek = dtDay.GetDayOfWeek() - 1;
- CString DayOfWeek[7] = { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
- CString sdate;
- if (nDayWeek >= 0 && nDayWeek <= 6)
- sdate = DayOfWeek[nDayWeek];
- else
- sdate = "无效日期";
- return sdate;
- }
- int XTable::Test()
- {
- if (m_mode == 10)
- return Test3();
- CStringArray array;
- if (m_mode == 4)
- {
- array.Add("姓名");
- array.Add("电话");
- array.Add("时间");
- array.Add("婚庆内容");
- array.Add("类别");
- array.Add("价格");
- array.Add("摄影");
- #ifdef CHILD_VERSION
- array.Add("引导");
- #else
- array.Add ("化妆");
- #endif
- array.Add("门市");
- array.Add("欠款");
- array.Add("备注");
- array.Add("录入");
- array.Add("是否到店");
- }
- else
- {
- array.Add("姓名");
- array.Add("电话");
- array.Add("时间");
- array.Add("类别");
- array.Add("价格");
- array.Add("摄影");
- #ifdef CHILD_VERSION
- array.Add("引导");
- #else
- array.Add ("化妆");
- #endif
- array.Add("门市");
- array.Add("欠款");
- array.Add("备注");
- array.Add("录入");
- array.Add("是否到店");
- }
- HidePrice();
- int cols = array.GetSize();
- int nAdd = 0;
- if (m_mode == 4)nAdd = 1;
- CRect rc;
- GetClientRect(rc);
- defaultWidth = (rc.Width() - 10) / cols;
- int halfwid = defaultWidth;
- SetCols(1);
- SetRows(256);
- SetCols(cols + 1);
- for (int i = 0; i < rows; i++)
- {
- for (int j = 0; j < cols; j++)
- {
- SetText(i, j + 1, "");
- }
- }
- COLORREF col1 = RGB(0xC8, 0x96, 0x96);
- COLORREF col2 = RGB(0x64, 0x96, 0xC8);
- COLORREF yellow = RGB(255, 255, 0);
- COLORREF green = RGB(0, 255, 255);
- for (i = 0; i < 46; i++)
- SetBackColor(i, 0, col1);
- SetColWidth(0, 10);
- m_datearray.RemoveAll();
- m_daterowposarray.RemoveAll();
- int datesize = 0;
- int aa = 0;
- CString curdate;
- CStringArray typearray;
- CArray<int, int>typecountarray;
- int pos;
- int oldpos;
- for (i = 0; i < m_pListArray->GetSize() + datesize; i++)
- {
- if (m_pListArray->ElementAt(aa).ElementAt(12 + nAdd) != curdate && curdate != "")
- {
-
- CString str = " 今日预约: ";
- CString temp;
- for (int a = 0; a < typearray.GetSize(); a++)
- {
- temp.Format("%s:%d ", typearray.ElementAt(a), typecountarray.ElementAt(a));
- str += temp;
- }
- SetText(oldpos, 1, GetText(oldpos, 1) + str);
- typearray.RemoveAll(); typecountarray.RemoveAll();
- }
- if (::FindArray(&m_datearray, m_pListArray->ElementAt(aa).ElementAt(12 + nAdd)) == -1)
- {
- curdate = m_pListArray->ElementAt(aa).ElementAt(12 + nAdd);
- m_datearray.Add(curdate);
- m_daterowposarray.Add(i);
- datesize = m_datearray.GetSize();
- JoinCells(i, 1, i, 12 + nAdd);
- SetAlignment(i, 1, DT_CENTER);
- SetBackColor(i, 1, green);
- SetText(i, 1, curdate + " " + GetWeek(curdate));
- oldpos = i;
- continue;
- }
- pos = ::FindArray(&typearray, m_pListArray->ElementAt(aa).ElementAt(3 + nAdd));
- if (pos == -1)
- {
- typearray.Add(m_pListArray->ElementAt(aa).ElementAt(3 + nAdd));
- typecountarray.Add(1);
- }
- else
- {
- int size = typecountarray.ElementAt(pos);
- typecountarray.SetAt(pos, size + 1);
- }
- for (int j = 0; j < cols; j++)
- {
- SetText(i, j + 1, m_pListArray->ElementAt(aa).ElementAt(j));
- if (j == 8 + nAdd && atoi(m_pListArray->ElementAt(aa).ElementAt(j)) > 0)
- {
- SetBackColor(i, j + 1, RGB(255, 0, 0));
- }
- else if (j == 8 + nAdd)SetBackColor(i, j + 1, RGB(0, 255, 0));
- if (j == 11 + nAdd && m_pListArray->ElementAt(aa).ElementAt(j) == "未到")
- {
- SetBackColor(i, j + 1, RGB(255, 0, 0));
- }
- else if (j == 11 + nAdd)SetBackColor(i, j + 1, RGB(0, 255, 0));
- }
- aa++;
- }
- if (m_pListArray->GetSize())
- {
-
- CString str = " 今日预约: ";
- CString temp;
- for (int a = 0; a < typearray.GetSize(); a++)
- {
- temp.Format("%s:%d ", typearray.ElementAt(a), typecountarray.ElementAt(a));
- str += temp;
- }
- SetText(oldpos, 1, GetText(oldpos, 1) + str);
- }
- CalRowHeight();
- return 0;
- JoinCells(3, 5, 4, 6);
- SetText(3, 5, "This cell contains multiline text, which provides multiline edit.张三, 李四, 王五Using default font张三, 李四, 王五Using default font");
- SetWordbreak(3, 5, true);
- return 0;
- JoinCells(3, 7, 5, 8);
- SetText(3, 7, "This cell contains multiline text, which provides multiline edit.");
- SetWordbreak(3, 7, true);
- SetText(4, 1, "You can even edit a long (cell overlapping) string.");
- SetOverlap(4, 1, true);
- SetText(4, 3, "Test");
- JoinCells(5, 1, 6, 2);
- SetText(5, 1, "Enter your name here.");
- JoinCells(5, 3, 5, 4);
- SetText(5, 3, "Enter your text here ...");
- JoinCells(8, 1, 8, 8);
- SetBackColor(8, 1, RGB(0x64, 0x96, 0xC8));
- SetText(8, 1, "Default edit controls also allow us to customize user's editing experience by:");
- JoinCells(10, 1, 10, 2);
- SetBackColor(10, 1, RGB(0xDC, 0xC8, 0xB4));
- SetText(10, 1, "Converting input to upper case:");
- SetText(10, 3, "TYPE HERE ...");
- JoinCells(10, 5, 10, 6);
- SetBackColor(10, 5, RGB(0xDC, 0xC8, 0xB4));
- SetText(10, 5, "Converting input to lower case:");
- SetText(10, 7, "type here ...");
- JoinCells(11, 1, 11, 2);
- SetBackColor(11, 1, RGB(0xDC, 0xC8, 0xB4));
- SetText(11, 1, "Allowing password input:");
- SetText(11, 3, "*********");
- SetText(11, 5, "Entered password was:*********");
- SetOverlap(11, 5, true);
- JoinCells(12, 1, 12, 2);
- SetBackColor(12, 1, RGB(0xDC, 0xC8, 0xB4));
- SetText(12, 1, "Allowing aligned input:");
- SetText(12, 3, "Left aligned");
- SetText(12, 5, "Centered");
- SetAlignment(12, 5, DT_CENTER);
- SetText(12, 7, "Right aligned");
- SetAlignment(12, 7, DT_RIGHT);
- JoinCells(14, 1, 14, 8);
- SetBackColor(14, 1, RGB(0x64, 0x96, 0xC8));
- SetText(14, 1, "Ultimate Grid allow us to process user's input with various notifications.");
- JoinCells(16, 1, 16, 5);
- SetBackColor(16, 1, RGB(0xDC, 0xC8, 0xB4));
- SetText(16, 1, "We can verify data it is entered, for example to limit number of char to 4:");
- SetText(16, 6, "<Type here>");
- JoinCells(17, 1, 17, 5);
- SetBackColor(17, 1, RGB(0xDC, 0xC8, 0xB4));
- SetText(17, 1, "or that the numeric value entered is under 500 (number < 500):");
- SetText(17, 6, "<Type here>");
- JoinCells(18, 1, 18, 5);
- SetBackColor(18, 1, RGB(0xDC, 0xC8, 0xB4));
- SetText(18, 1, "We can also test user's input after it is completed, or force user's input:");
- SetText(18, 6, "<Type here>");
- JoinCells(20, 1, 20, 8);
- SetBackColor(20, 1, RGB(0x64, 0x96, 0xC8));
- SetText(20, 1, "The Ultimate Grid also allows us to use other edit controls when needed:");
- JoinCells(22, 1, 23, 5);
- SetBackColor(22, 1, RGB(0xDC, 0xC8, 0xB4));
- 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.");
- SetWordbreak(22, 1, true);
- JoinCells(22, 6, 22, 7);
- SetText(22, 6, "<Select mask>");
- JoinCells(23, 6, 23, 7);
- SetText(23, 6, "<Type here>");
- JoinCells(25, 1, 27, 5);
- SetBackColor(25, 1, RGB(0xDC, 0xC8, 0xB4));
- 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.");
- SetWordbreak(25, 1, true);
- JoinCells(29, 1, 30, 5);
- SetBackColor(29, 1, RGB(0xDC, 0xC8, 0xB4));
- 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.");
- SetWordbreak(29, 1, true);
- JoinCells(29, 6, 29, 8);
- SetText(29, 6, "<Select mask>");
- JoinCells(30, 6, 30, 8);
- SetText(30, 6, "<Type here>");
- JoinCells(32, 1, 33, 5);
- SetBackColor(32, 1, RGB(0xDC, 0xC8, 0xB4));
- 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.");
- SetWordbreak(32, 1, true);
- JoinCells(35, 1, 35, 2);
- SetBackColor(35, 1, RGB(0xDC, 0xC8, 0xB4));
- SetText(35, 1, "Using COXNumericEdit:");
- JoinCells(35, 3, 35, 4);
- SetText(35, 3, "<Type here>");
- JoinCells(35, 5, 35, 6);
- SetBackColor(35, 5, RGB(0xDC, 0xC8, 0xB4));
- SetText(35, 5, "Using COXCurrencyEdit:");
- JoinCells(35, 7, 35, 8);
- SetText(35, 7, "<Type here>");
- JoinCells(36, 1, 36, 3);
- SetBackColor(36, 1, RGB(0x64, 0x96, 0xC8));
- SetText(36, 1, "Following are properties we can set.");
- JoinCells(36, 5, 36, 7);
- SetBackColor(36, 5, RGB(0x64, 0x96, 0xC8));
- SetText(36, 5, "Following are properties we can set.");
- JoinCells(37, 1, 37, 2);
- SetBackColor(37, 1, RGB(0xDC, 0xC8, 0xB4));
- SetText(37, 1, "Decimal digit count :");
- JoinCells(37, 5, 37, 6);
- SetBackColor(37, 5, RGB(0xDC, 0xC8, 0xB4));
- SetText(37, 5, "Decimal digit count :");
- JoinCells(38, 1, 38, 2);
- SetBackColor(38, 1, RGB(0xDC, 0xC8, 0xB4));
- SetText(38, 1, "Decimal Separator :");
- JoinCells(38, 5, 38, 6);
- SetBackColor(38, 5, RGB(0xDC, 0xC8, 0xB4));
- SetText(38, 5, "Decimal Separator :");
- JoinCells(39, 1, 39, 2);
- SetBackColor(39, 1, RGB(0xDC, 0xC8, 0xB4));
- SetText(39, 1, "Fractional digit count :");
- JoinCells(39, 5, 39, 6);
- SetBackColor(39, 5, RGB(0xDC, 0xC8, 0xB4));
- SetText(39, 5, "Fractional digit count :");
- JoinCells(40, 1, 40, 2);
- SetBackColor(40, 1, RGB(0xDC, 0xC8, 0xB4));
- SetText(40, 1, "Group Separator :");
- JoinCells(40, 5, 40, 6);
- SetBackColor(40, 5, RGB(0xDC, 0xC8, 0xB4));
- SetText(40, 5, "Group Separator :");
- JoinCells(41, 1, 41, 2);
- SetBackColor(41, 1, RGB(0xDC, 0xC8, 0xB4));
- SetText(41, 1, "Digits in group :");
- JoinCells(41, 5, 41, 6);
- SetBackColor(41, 5, RGB(0xDC, 0xC8, 0xB4));
- SetText(41, 5, "Digits in group :");
- JoinCells(42, 1, 42, 2);
- SetBackColor(42, 1, RGB(0xDC, 0xC8, 0xB4));
- SetText(42, 1, "Negative Format :");
- JoinCells(42, 5, 42, 6);
- SetBackColor(42, 5, RGB(0xDC, 0xC8, 0xB4));
- SetText(42, 5, "Positive Format :");
- JoinCells(43, 1, 43, 2);
- SetBackColor(43, 1, RGB(0xDC, 0xC8, 0xB4));
- SetText(43, 1, "Show leading zero :");
- JoinCells(43, 5, 43, 6);
- SetBackColor(43, 5, RGB(0xDC, 0xC8, 0xB4));
- SetText(43, 5, "Negative Format :");
- JoinCells(44, 5, 44, 6);
- SetBackColor(44, 5, RGB(0xDC, 0xC8, 0xB4));
- SetText(44, 5, "Currency name :");
- JoinCells(45, 5, 45, 6);
- SetBackColor(45, 5, RGB(0xDC, 0xC8, 0xB4));
- SetText(45, 5, "Show leading zero :");
- return 0;
- }
- int XTable::Test3()
- {
- CStringArray array;
- array.Add("姓名");
- array.Add("电话");
- array.Add("时间");
- array.Add("内容");
- array.Add("价格");
- array.Add("摄影");
- array.Add("化妆");
- array.Add("门市");
- array.Add("欠款");
- array.Add("备注");
- array.Add("录入");
- array.Add("是否到店");
- int cols = array.GetSize();
- int nAdd = 0;
- CRect rc;
- GetClientRect(rc);
- defaultWidth = (rc.Width() - 10) / cols;
- int halfwid = defaultWidth;
- SetCols(1);
- SetRows(256);
- SetCols(cols + 1);
- for (int i = 0; i < rows; i++)
- {
- for (int j = 0; j < cols; j++)
- {
- SetText(i, j + 1, "");
- }
- }
- COLORREF col1 = RGB(0xC8, 0x96, 0x96);
- COLORREF col2 = RGB(0x64, 0x96, 0xC8);
- COLORREF yellow = RGB(255, 255, 0);
- COLORREF green = RGB(0, 255, 255);
- for (i = 0; i < 46; i++)
- SetBackColor(i, 0, col1);
- SetColWidth(0, 10);
- m_datearray.RemoveAll();
- m_daterowposarray.RemoveAll();
- int datesize = 0;
- int aa = 0;
- CString curdate;
- CStringArray typearray;
- CArray<int, int>typecountarray;
- int pos;
- int oldpos;
- for (i = 0; i < m_pListArray->GetSize() + datesize; i++)
- {
- if (m_pListArray->ElementAt(aa).ElementAt(12 + nAdd) != curdate && curdate != "")
- {
-
- CString str = " 今日预约: ";
- CString temp;
- for (int a = 0; a < typearray.GetSize(); a++)
- {
- temp.Format("%d ", typecountarray.ElementAt(a));
- str += temp;
- }
- SetText(oldpos, 1, GetText(oldpos, 1) + str);
- typearray.RemoveAll(); typecountarray.RemoveAll();
- }
- if (::FindArray(&m_datearray, m_pListArray->ElementAt(aa).ElementAt(12 + nAdd)) == -1)
- {
- curdate = m_pListArray->ElementAt(aa).ElementAt(12 + nAdd);
- m_datearray.Add(curdate);
- m_daterowposarray.Add(i);
- datesize = m_datearray.GetSize();
- JoinCells(i, 1, i, 12 + nAdd);
- SetAlignment(i, 1, DT_CENTER);
- SetBackColor(i, 1, green);
- SetText(i, 1, curdate + " " + GetWeek(curdate));
- oldpos = i;
- continue;
- }
- if (typearray.GetSize() == 0)
- {
- typearray.Add("");
- typecountarray.Add(1);
- }
- else
- {
- int size = typecountarray.ElementAt(0);
- typecountarray.SetAt(0, size + 1);
- }
- for (int j = 0; j < cols; j++)
- {
- SetText(i, j + 1, m_pListArray->ElementAt(aa).ElementAt(j));
- if (j == 8 + nAdd && atoi(m_pListArray->ElementAt(aa).ElementAt(j)) > 0)
- {
- SetBackColor(i, j + 1, RGB(255, 0, 0));
- }
- else if (j == 8 + nAdd)SetBackColor(i, j + 1, RGB(0, 255, 0));
- if (j == 11 + nAdd && m_pListArray->ElementAt(aa).ElementAt(j) == "未到")
- {
- SetBackColor(i, j + 1, RGB(255, 0, 0));
- }
- else if (j == 11 + nAdd)SetBackColor(i, j + 1, RGB(0, 255, 0));
- }
- aa++;
- }
- if (m_pListArray->GetSize())
- {
-
- CString str = " 今日预约: ";
- CString temp;
- for (int a = 0; a < typearray.GetSize(); a++)
- {
- temp.Format("%d ", typecountarray.ElementAt(a));
- str += temp;
- }
- SetText(oldpos, 1, GetText(oldpos, 1) + str);
- }
- CalRowHeight();
- return 0;
- }
- void XTable::ModeChange(int mode)
- {
- m_mode = mode;
- }
- void XTable::AddName(int row, int col, CString str)
- {
- CString oldtext = GetText(row, col);
- if (oldtext.IsEmpty())
- {
- SetText(row, col, str);
- return;
- }
- if (oldtext.Find(str) != -1)return;
- SetText(row, col, oldtext + "," + str);
- }
- void XTable::HidePrice()
- {
- if (m_mode != 4)
- {
- #ifdef LKAY_VERSION
- if(IsHasRights2new(31))return;
- for(int i=0; i< m_pListArray->GetSize (); i++)
- {
- m_pListArray->ElementAt (i).SetAt (1, "***");
- m_pListArray->ElementAt (i).SetAt (4, "***");
- }
- #else
- if (IsHasRights2new(31))return;
- for (int i = 0; i < m_pListArray->GetSize(); i++)
- {
- m_pListArray->ElementAt(i).SetAt(1, "***");
- m_pListArray->ElementAt(i).SetAt(4, "***");
- }
- #endif
- }
- else
- {
- #ifdef LKAY_VERSION
- if(IsHasRights2new(31))return;
- for(int i=0; i< m_pListArray->GetSize (); i++)
- {
- m_pListArray->ElementAt (i).SetAt (1, "***");
- m_pListArray->ElementAt (i).SetAt (4, "***");
- }
- #else
- if (IsHasRights2new(31))return;
- for (int i = 0; i < m_pListArray->GetSize(); i++)
- {
- m_pListArray->ElementAt(i).SetAt(1, "***");
- m_pListArray->ElementAt(i).SetAt(4, "***");
- }
- #endif
- }
- }
|