// DlgUserManager.cpp : 实现文件 // #include "stdafx.h" #include "IDE.h" #include ".\dlgdateplan.h" // CDlgDatePlan 对话框 IMPLEMENT_DYNAMIC(CDlgDatePlan, CDialog) CDlgDatePlan::CDlgDatePlan(CWnd* pParent /*=NULL*/) : CDialog(CDlgDatePlan::IDD, pParent) { m_nPlanType = -1; m_strUid = ""; m_nVarID = 0; m_strUserID = ""; } CDlgDatePlan::~CDlgDatePlan() { } void CDlgDatePlan::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Control(pDX, IDC_HOURSSELECTOR, m_ocxHourSelector); } BEGIN_MESSAGE_MAP(CDlgDatePlan, CDialog) ON_BN_CLICKED(IDOK, OnBnClickedOk) ON_BN_CLICKED(IDCANCEL, OnBnClickedCancel) END_MESSAGE_MAP() // CDlgDatePlan 消息处理程序 BOOL CDlgDatePlan::OnInitDialog() { CDialog::OnInitDialog(); // TODO: 在此添加额外的初始化 m_ocxHourSelector.SetFocus(); COleSafeArray l_osaHours; DWORD numElements[] = {168}; l_osaHours.Create(VT_UI1, 1, numElements); unsigned char szArray[7][24]; long nPoint[1]={0}; memset(szArray, 0, sizeof(szArray) ); int nRet; return TRUE; // return TRUE unless you set the focus to a control // 异常: OCX 属性页应返回 FALSE } void CDlgDatePlan::DealArray(unsigned char nBuf[7][24]) { CString s,sTemp,str; CString sReport[500]; int nReportIndex = 0; for( int y=0; y<7; y++) { for(int x=0; x<24; x++) { if(nBuf[y][x] == 15) { sTemp.Format("%02d%02d",y,x); sReport[nReportIndex] = sTemp; for(int x1 = x+1; x1<24; x1++) { if(nBuf[y][x1] == 15) { sTemp.Format("%02d%02d",y,x1); sReport[nReportIndex] += sTemp; } else { x = x1; break; } if(nBuf[y][x1] == 15 && x1 == 23) { x = x1; break; } } s.Format("%s",sReport[nReportIndex]); //AfxMessageBox(s); nReportIndex++; str+=s; str+="\n"; } } } int nResultIndex = 0; int iSign = 0; CString sResult[500]; bool bFlag[500]; int i = 0,j = 0; for( i=0;i<500;i++ ) bFlag[i] = true; for( i=0;iDeleteDatePlan( m_nPlanType, (char *)(LPCTSTR)m_strUserID ); } else if( m_nPlanType == PLAN_TYPE_EQUIP ) { //CDBInterface::GetInstancePtr()->DeleteDatePlan( m_nPlanType, m_strUid, m_nVarID ); } for( int x=0; xInsertDatePlan( m_nPlanType, (char *)(LPCTSTR)m_strUserID, atoi(sHour1), atoi(sHour2), // atoi(sWeek1), atoi(sWeek2) ); } else if( m_nPlanType == PLAN_TYPE_EQUIP ) { // CDBInterface::GetInstancePtr()->InsertDatePlan( m_nPlanType, m_strUid, m_nVarID, atoi(sHour1), atoi(sHour2), // atoi(sWeek1), atoi(sWeek2) ); } } } bool CDlgDatePlan::CompareStr(CString str1, CString str2,int nSign) { bool bResult = false; if( atoi(str1.Mid(0,2)) == atoi(str2.Mid(0,2)) && atoi(str1.Mid(2,2))+nSign == atoi(str2.Mid(2,2)) ) bResult = true; if( atoi(str1.Mid(0,2))+nSign == atoi(str2.Mid(0,2)) && atoi(str1.Mid(2,2)) == atoi(str2.Mid(2,2)) ) bResult = true; return bResult; } void CDlgDatePlan::OnBnClickedOk() { // TODO: 在此添加控件通知处理程序代码 if( m_nPlanType == PLAN_TYPE_KG ) { CString s; m_sDoSetPlanTime = ""; COleSafeArray l_osaHours; l_osaHours = m_ocxHourSelector.GetHoursArray(); unsigned char cBits; long m = 0; // Load the Information from the Grid to an Array for( int x=0; x<7; x++) { for(int y=0; y<24; y++) { m = long(x*24+y); l_osaHours.GetElement(&m, &cBits); s.Format( "%d",cBits==0?0:1 ); m_sDoSetPlanTime += s; } } } else { COleSafeArray l_osaHours; unsigned char szArray[7][24]; l_osaHours = m_ocxHourSelector.GetHoursArray(); unsigned char cBits; long m = 0; // Load the Information from the Grid to an Array for( int x=0; x<7; x++) { for(int y=0; y<24; y++) { m = long(x*24+y); l_osaHours.GetElement(&m, &cBits); szArray[x][y]= cBits; } } DealArray(szArray); } OnOK(); } void CDlgDatePlan::OnBnClickedCancel() { // TODO: 在此添加控件通知处理程序代码 OnCancel(); }