123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769 |
- // XTable.cpp : implementation file
- #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") // Window class name
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #endif
- // XTable
- 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;
- }
- // creates the control - use like any other window create control
- 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.AddChildAttrib("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.AddChildAttrib("width", GetColWidth(j));
- if (cell->rowSpan == 1 && j == 0)
- markup.AddChildAttrib("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.GetChildAttrib("width") != "")
- {
- int width = atoi(markup.GetChildAttrib("width"));
- if (row == 0 || width > GetColWidth(col))
- SetColWidth(col, width);
- }
- if (cell->rowSpan == 1 && markup.GetChildAttrib("height") != "")
- {
- int height = atoi(markup.GetChildAttrib("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;
- }
- // XTable message handlers
- void XTable::OnPaint()
- {
- CPaintDC dc(this); // device context for painting
- 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);
- }
- #ifdef VC60
- 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);
- // SetText(nItem,11+nAdd, g_user.name);
- 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);
- //Invalidate();
- }
- 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);
- //Invalidate();
- }
- m_pComboBox->ShowWindow(SW_HIDE); m_nCurShow = -1; CalRowHeight();
- }
- }
- #else
- LRESULT XTable::OnEditEnd(WPARAM wParam, LPARAM lParam)
- {
- if (m_nCurShow == -1)return 0;
- 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 0;
- }
- 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 0;
- }
- 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);
- // SetText(nItem,11+nAdd, g_user.name);
- 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);
- //Invalidate();
- }
- 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);
- //Invalidate();
- }
- m_pComboBox->ShowWindow(SW_HIDE); m_nCurShow = -1; CalRowHeight();
- }
- return 0;
- }
- #endif
- 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++)
- {
- // if("化妆部"== g_userarray.ElementAt (ii).ElementAt(2) )
- 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->m_hWnd == NULL)
- {
- 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=1;
- // ShowSearchClientComboBox(TRUE,focusRow,focusCol,rect);
- 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)))
- {
- // otherwise we need to register a new class
- 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);
- int i = 0;
- for ( 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;
- }
- ///edit
- XTableEdit::XTableEdit()
- {
- }
- XTableEdit::~XTableEdit()
- {
- }
- BEGIN_MESSAGE_MAP(XTableEdit, CEdit)
- //{{AFX_MSG_MAP(XTableEdit)
- ON_WM_KILLFOCUS()
- ON_WM_SETFOCUS()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // XTableEdit message handlers
- 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)
- //{{AFX_MSG_MAP(XTableComboBox)
- ON_WM_KILLFOCUS()
- ON_WM_SETFOCUS()
- ON_CONTROL_REFLECT(CBN_CLOSEUP, OnCloseup)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // XTableComboBox message handlers
- void XTableComboBox::SetCtrlData(DWORD dwData)
- {
- m_dwData = dwData;
- }
- DWORD XTableComboBox::GetCtrlData()
- {
- return m_dwData;
- }
- void XTableComboBox::OnKillFocus(CWnd* pNewWnd)
- {
- CComboBox::OnKillFocus(pNewWnd);
- /* CWnd* pParent = this->GetParent();
- if(((XTable*)pParent)->m_nCurShow!=-1)
- ::PostMessage(pParent->GetSafeHwnd(),WM_USER_EDIT_END,m_bExchange,1);*/
- }
- 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()
- {
- // TODO: Add your control notification handler code here
- 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;
- // if(rect.bottom-rect.top>100)rect.bottom=rect.top+100;
- 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); //if(g_bSendOK==0)return;
- ((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); //if(g_bSendOK==0)return;
- ((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); //if(g_bSendOK==0)return;
- ((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; //得到星期几,1=Sunday, 2=Monday,
- 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);
- int i = 0;
- for ( 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);
- int i = 0;
- for ( 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
- }
- }
|