📄 progressmanamgedlg.cpp
字号:
}
void CProgressManamgeDlg::copyDateFromDlgDate(DlgDate &dlgDate){
m_sDatetime = dlgDate.m_sDatetime;
m_sOpration = dlgDate.m_sOpration;
m_sPlan = dlgDate.m_sPlan;
m_sSetup = dlgDate.m_sSetup;
m_sFact =dlgDate.m_sFact;
m_sDiviation = dlgDate.m_sDiviation;
year = dlgDate.year;
mouth =dlgDate.mouth;
day = dlgDate.day;
date = dlgDate.date;
hour = dlgDate.hour;
second = dlgDate.second;
minute = dlgDate.minute;
perSetup = dlgDate.perSetup;
perFact = dlgDate.perFact;
titleColor = dlgDate.titleColor;
}
void CProgressManamgeDlg::copyDataToDlgDate(DlgDate &dlgDate){
dlgDate.m_sDatetime =m_sDatetime;
dlgDate.m_sDiviation = m_sDiviation;
dlgDate.m_sFact = m_sFact;
dlgDate.m_sOpration = m_sOpration;
dlgDate.m_sPlan = m_sPlan;
dlgDate.m_sSetup = m_sSetup;
dlgDate.year =year;
dlgDate.mouth = mouth;
dlgDate.day=day;
dlgDate.date = date;
dlgDate.hour = hour;
dlgDate.minute = minute;
dlgDate.second = second;
dlgDate.perSetup=perSetup;
dlgDate.perFact = perFact;
dlgDate.titleColor = titleColor;
}
void CProgressManamgeDlg::initMyData(){
m_sDatetime = _T("");
m_sDiviation = _T("");
m_sFact = _T("");
m_sOpration = _T("");
m_sPlan = _T("");
m_sSetup =_T("");
perFact= _T("");
perSetup = _T("");
m_showState.SetIcon(nomalIcon);
CTime t = CTime::GetCurrentTime();
year = t.GetYear();
mouth = t.GetMonth();
day = t.GetDay();
hour = t.GetHour();
minute = t.GetMinute();
second = t.GetSecond();
setDateString();
CTim
}
/*void CProgressManamgeDlg::OnRadio2()
{
progressRadioChange(IDC_RADIO2);
}
void CProgressManamgeDlg::OnRadio3()
{
progressRadioChange(IDC_RADIO3);
}
void CProgressManamgeDlg::OnRadio4()
{
progressRadioChange(IDC_RADIO4);
}
*/
int CProgressManamgeDlg::getMatchIdByDirectory(UCHAR &directory)
{
/* int matchId= 0;
switch(directory)
{
case 0:
matchId=IDC_RADIO1;
break;
case 1:
matchId=IDC_RADIO2;
break;
case 2:
matchId=IDC_RADIO3;
break;
case 3:
matchId=IDC_RADIO4;
break;
}
return matchId;
*/
return directory+1;
}
int CProgressManamgeDlg::getDirectoryByMatchId(const int &directory)
{
/* int matchId= 0;
switch(directory)
{
case IDC_RADIO1:
matchId=0;
break;
case IDC_RADIO2:
matchId=1;
break;
case IDC_RADIO3:
matchId=2;
break;
case IDC_RADIO4:
matchId=3;
break;
}
return matchId;
*/
return directory-1;
}
void CProgressManamgeDlg::saveOldData(){
map<int,DlgDate>::iterator it = matchineData.find(recentMatchine);
DlgDate oldDlgDate;
copyDataToDlgDate(oldDlgDate);
matchineData[recentMatchine]=oldDlgDate;
}
void CProgressManamgeDlg::processPerFact(){
CByteArray bety;
int index;
UCHAR affix =0 ;
bety.SetSize(sendDataLength);
bety.SetAt(0,perFactDownSendPrefix);
UCHAR matchinetemp= getDirectoryByMatchId(recentMatchine);
bety.SetAt(1,matchinetemp);
// bety.SetAt(2,0);
// bety.SetAt(3,0);
int byteIndex=2;
for(index=0;index<4-perFact.GetLength();index++){
bety.SetAt(byteIndex,0);
byteIndex++;
}
for(index =0; index<perFact.GetLength();index++){
bety.SetAt(byteIndex,Hex2Char(perFact.GetAt(index)));
byteIndex++;
//affix += Hex2Char(m_sFact.GetAt(index));
}
for(index = 6;index<sendDataLength-1;index++){
bety.SetAt(index,0);
}
affix = computeAffix(bety);
bety.SetAt(sendDataLength-1,affix);
m_ctrlMSComm.SetOutput(COleVariant(bety));
CString temp;
temp.Format("%d",recentMatchine);
m_sOpration += "向";
m_sOpration += temp;
m_sOpration += "号看板发送'实际新值数据'。";
m_sOpration += "\r\n";
UpdateData(FALSE);
}
void CProgressManamgeDlg::processPerSetup(){
CByteArray bety;
int index;
UCHAR affix =0 ;
bety.SetSize(sendDataLength);
bety.SetAt(0,perSetupDownSendPrefix);
UCHAR matchinetemp= getDirectoryByMatchId(recentMatchine);
bety.SetAt(1,matchinetemp);
// bety.SetAt(2,0);
// bety.SetAt(3,0);
int byteIndex=2;
for(index=0;index<4-perSetup.GetLength();index++){
bety.SetAt(byteIndex,0);
byteIndex++;
}
for(index =0; index<perSetup.GetLength();index++){
bety.SetAt(byteIndex,Hex2Char(perSetup.GetAt(index)));
byteIndex++;
//affix += Hex2Char(m_sFact.GetAt(index));
}
for(index = 6;index<sendDataLength-1;index++){
bety.SetAt(index,0);
}
affix = computeAffix(bety);
bety.SetAt(sendDataLength-1,affix);
m_ctrlMSComm.SetOutput(COleVariant(bety));
CString temp;
temp.Format("%d",recentMatchine);
m_sOpration += "向";
m_sOpration += temp;
m_sOpration += "号看板发送'设定新值数据'。";
m_sOpration += "\r\n";
UpdateData(FALSE);
}
void CProgressManamgeDlg::changeShowIcon(){
if(atoi(m_sDiviation)>0)
m_showState.SetIcon(greenIcon);
else if(atoi(m_sDiviation)<0)
m_showState.SetIcon(redIcon);
else if (atoi(m_sFact) == atoi(m_sPlan))
{
m_showState.SetIcon(yellowIcon);
}
else{
m_showState.SetIcon(nomalIcon);
}
}
void CProgressManamgeDlg::OnSelchangeComboCom()
{
m_Combo_Com.GetLBText(m_Combo_Com.GetCurSel(),m_strCom);
}
void CProgressManamgeDlg::setStaticStyle(){
CWnd *pWnd=GetDlgItem(IDC_STATIC_PLAN);
// CDC *pDC=pWnd->GetDC();
CFont m_Font;
LOGFONT logFont;
logFont.lfHeight = 20;
logFont.lfWidth = 0;
logFont.lfEscapement = 0;
logFont.lfOrientation = 0;
logFont.lfWeight = FW_NORMAL;
logFont.lfItalic = 0;
logFont.lfUnderline = 0;
logFont.lfStrikeOut = 0;
logFont.lfCharSet = GB2312_CHARSET;
logFont.lfOutPrecision = OUT_DEFAULT_PRECIS;
logFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
logFont.lfQuality = PROOF_QUALITY;
logFont.lfPitchAndFamily = VARIABLE_PITCH | FF_ROMAN;
strcpy(logFont.lfFaceName, "隶书");
m_Font.CreateFontIndirect(&logFont);
//CClientDC dc(this);
//CFont *oldfont=pDC->SelectObject(&m_Font);
pWnd->SetFont(&m_Font,TRUE);
// m_Font.Detach();
// m_Font.DeleteObject();
// pDC->SelectObject(oldfont);
// pWnd->ReleaseDC(pDC);
/* CFont m_Font;
m_Font.CreateFont(19, 0, 0, 0, FW_BOLD, FALSE, FALSE, 0,
ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY, FF_SWISS, "隶书");
CStatic *m_static1=(CStatic *)GetDlgItem(IDC_STATIC_PLAN);
m_static1->SetFont(&m_Font);*/
CStatic* m_static1=(CStatic *)GetDlgItem(IDC_STATIC_SETUP);
m_static1->SetFont(&m_Font);
m_static1=(CStatic *)GetDlgItem(IDC_STATIC_FACT);
m_static1->SetFont(&m_Font);
m_static1=(CStatic *)GetDlgItem(IDC_STATIC_DIVATION);
m_static1->SetFont(&m_Font);
m_static1=(CStatic *)GetDlgItem(IDC_STATIC_DATETIME);
m_static1->SetFont(&m_Font);
m_Font.Detach();
}
HBRUSH CProgressManamgeDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
switch(pWnd->GetDlgCtrlID())
{
case IDC_STATIC_DATETIME:
case IDC_STATIC_FACT:
case IDC_STATIC_SETUP:
case IDC_STATIC_PLAN:
case IDC_STATIC_DIVATION:
{
pDC->SetTextColor(RGB(255,52,52));
/*CFont m_Font;
m_Font.CreateFont(20, 0, 0, 0, 1000, FALSE, FALSE, 0,
ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY, FF_SWISS, "隶书");
pWnd->SetFont(&m_Font,TRUE);
m_Font.Detach();*/
break;
}
default:
break;
}
/* if(pWnd->GetDlgCtrlID() == IDC_STATIC_DATETIME){
pDC->SetTextColor(RGB(255,0,0));
}*/
return hbr;
}
/*void CProgressManamgeDlg::OnEditchangeComboBoardChoice()
{
// TODO: Add your control notification handler code here
}*/
void CProgressManamgeDlg::OnSelchangeComboBoardChoice()
{
CString tempString;
m_boardChoice.GetLBText(m_boardChoice.GetCurSel(),tempString);
if(tempString.IsEmpty()){
return;
}
CString indexString = tempString.Right(tempString.GetLength()-4);
if (indexString.IsEmpty())
{
return;
}
// MessageBox(tempString+":"+indexString);
progressBoardChange(atoi(indexString));
}
void CProgressManamgeDlg::OnButtonDump()
{
CString pathSelected;
CFileDialog dlg(FALSE,"xls","result");
if (dlg.DoModal() == IDOK)
{
pathSelected = dlg.GetPathName();
// MessageBox(pathSelected);
CSpreadSheet SS(pathSelected, "TestSheet");
CStringArray sampleArray,testRow;
SS.BeginTransaction();
// 加入标题
sampleArray.RemoveAll();
sampleArray.Add("看板");
sampleArray.Add("计划");
sampleArray.Add("设定原来数据");
sampleArray.Add("设定新值数据");
sampleArray.Add("实际原来数据");
sampleArray.Add("实际新值数据");
sampleArray.Add("差");
sampleArray.Add("日期时间");
SS.AddHeaders(sampleArray);
/* sampleArray.RemoveAll();
sampleArray.Add("test");
sampleArray.Add("test");
sampleArray.Add("test");
sampleArray.Add("test");
sampleArray.Add("test");
sampleArray.Add("test");
sampleArray.Add("test");
sampleArray.Add("test");
SS.AddRow(sampleArray);
*/
for (map<int,DlgDate>::iterator it = matchineData.begin();it != matchineData.end(); it++)
{
int index = it->first;
CString tempIndex;
tempIndex.Format("%d",index);
sampleArray.RemoveAll();
sampleArray.Add(tempIndex);
if(index != recentMatchine){
DlgDate dlgDate = it->second;
sampleArray.Add(dlgDate.m_sPlan);
sampleArray.Add(dlgDate.m_sSetup);
sampleArray.Add(dlgDate.perSetup);
sampleArray.Add(dlgDate.m_sFact);
sampleArray.Add(dlgDate.perFact);
sampleArray.Add(dlgDate.m_sDiviation);
sampleArray.Add(dlgDate.m_sDatetime);
}
else{
sampleArray.Add(m_sPlan);
sampleArray.Add(m_sSetup);
sampleArray.Add(perSetup);
sampleArray.Add(m_sFact);
sampleArray.Add(perFact);
sampleArray.Add(m_sDiviation);
sampleArray.Add(m_sDatetime);
}
SS.AddRow(sampleArray);
}
map<int,DlgDate>::iterator it1 = matchineData.find(recentMatchine);
if(it1==matchineData.end()){
CString tempIndex;
tempIndex.Format("%d",recentMatchine);
sampleArray.RemoveAll();
sampleArray.Add(tempIndex);
sampleArray.Add(m_sPlan);
sampleArray.Add(m_sSetup);
sampleArray.Add(perSetup);
sampleArray.Add(m_sFact);
sampleArray.Add(perFact);
sampleArray.Add(m_sDiviation);
sampleArray.Add(m_sDatetime);
SS.AddRow(sampleArray);
}
SS.Commit();
AfxMessageBox("文件写入成功!");
}
/* CString pathSelected;
CFileDialog dlg(FALSE,"xls","result");
if (dlg.DoModal() == IDOK)
{
pathSelected = dlg.GetPathName();
CSpreadSheet SS(pathSelected, "TestSheet");
CStringArray sampleArray, testRow;
SS.BeginTransaction();
// 加入标题
sampleArray.RemoveAll();
sampleArray.Add("看板");
sampleArray.Add("计划");
sampleArray.Add("设定原来数据");
sampleArray.Add("设定新值数据");
sampleArray.Add("实际原来数据");
sampleArray.Add("实际新值数据");
sampleArray.Add("差");
sampleArray.Add("日期时间");
SS.AddHeaders(sampleArray);
// 加入数据
/* CString strName[] = {"徐景周","徐志慧","郭徽","牛英俊","朱小鹏"};
CString strAge[] = {"27","23","28","27","26"};
for(int i = 0; i < sizeof(strName)/sizeof(CString); i++)
{
sampleArray.RemoveAll();
sampleArray.Add(strName[i]);
sampleArray.Add(strAge[i]);
SS.AddRow(sampleArray);
}
// 初始化测试行数据,进行添加、插入及替换数据操作演示
for (int k = 1; k <= 2; k++)
{
testRow.Add("Test");
}
SS.AddRow(testRow); // 添加到尾部
SS.AddRow(testRow, 2); // 插入新行到第二行
SS.AddRow(testRow, 6, true); // 替换原第四行来新的内容
SS.Commit();
// if(m_Check.GetCheck())
// SS.Convert(";"); // 将原Excel文件转换为用分号分隔的文本,并另存为同名文本文件
AfxMessageBox("文件写入成功!");
}*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -