📄 propadd1page.cpp
字号:
// PropAdd1Page.cpp : implementation file
//
#include "stdafx.h"
#include "FileMaSys.h"
#include "PropAdd1Page.h"
#include "AddSheet.h"
#include "ProManegeMode.h"
//#include <stdio.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "FileMaSys.h"
extern CFileMaSysApp theApp;
#define MAXPATH 100
/////////////////////////////////////////////////////////////////////////////
// CPropAdd1Page property page
IMPLEMENT_DYNCREATE(CPropAdd1Page, CPropertyPage)
CPropAdd1Page::CPropAdd1Page() : CPropertyPage(CPropAdd1Page::IDD)
{
//{{AFX_DATA_INIT(CPropAdd1Page)
m_ProID = _T("");
m_ProName = _T("");
m_ProLoc = _T("");
m_ProRemark = _T("");
//}}AFX_DATA_INIT
m_IDtrue=FALSE;
m_Nametrue=FALSE;
m_Loctrue=FALSE;
if (m_font.m_hObject==NULL)
{
m_font.CreatePointFont(100,"新宋体");
}
}
CPropAdd1Page::~CPropAdd1Page()
{
}
void CPropAdd1Page::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPropAdd1Page)
DDX_Control(pDX, IDC_BTN_BROFOLDER, m_BtnBrowseControl);
// DDX_Control(pDX, IDC_NAMETRUE, m_NameControl);
// DDX_Control(pDX, IDC_IDTRUE, m_IDStatic);
DDX_Text(pDX, IDC_EDIT_PROID, m_ProID);
DDX_Text(pDX, IDC_EDIT_PRONAME, m_ProName);
DDX_Text(pDX, IDC_EDIT_PROLOC, m_ProLoc);
DDX_Text(pDX, IDC_RICHEDIT_REMARK, m_ProRemark);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPropAdd1Page, CPropertyPage)
//{{AFX_MSG_MAP(CPropAdd1Page)
ON_EN_KILLFOCUS(IDC_EDIT_PROID, OnKillfocusEditProid)
ON_EN_KILLFOCUS(IDC_EDIT_PRONAME, OnKillfocusEditProname)
ON_BN_CLICKED(IDC_BTN_BROFOLDER, OnBtnBrofolder)
ON_EN_KILLFOCUS(IDC_EDIT_PROLOC, OnKillfocusEditProloc)
ON_EN_CHANGE(IDC_EDIT_PROID, OnChangeEditProid)
ON_WM_LBUTTONDOWN()
ON_EN_CHANGE(IDC_EDIT_PROLOC, OnChangeEditProloc)
ON_EN_CHANGE(IDC_EDIT_PRONAME, OnChangeEditProname)
ON_NOTIFY_EX(TTN_NEEDTEXT, 0, SetTipText)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPropAdd1Page message handlers
BOOL CPropAdd1Page::OnSetActive()
{
// TODO: Add your specialized code here and/or call the base class
((CAddSheet *)GetParent())->SetWizardButtons( PSWIZB_NEXT );
//设置浏览文件夹按钮
m_BtnBrowseControl.SetIcon(IDI_ICON_FOLDER);
m_BtnBrowseControl.DrawTransparent(TRUE);
m_BtnBrowseControl.SetColor(CButtonST::BTNST_COLOR_FG_IN,RGB(255,0,0));
m_BtnBrowseControl.SetAlign(CButtonST::ST_ALIGN_HORIZ);
//设置目录编辑框Tip
EnableToolTips(TRUE);
m_LocTipCtrl.Create(this);
m_LocTipCtrl.Activate(TRUE);
m_LocTipCtrl.AddTool(GetDlgItem(IDC_EDIT_PROLOC),LPSTR_TEXTCALLBACK);
return CPropertyPage::OnSetActive();
}
LRESULT CPropAdd1Page::OnWizardNext()
{
// TODO: Add your specialized code here and/or call the base class
if (!(m_IDtrue && m_Nametrue && m_Loctrue))
{
if (!m_IDtrue)
{
MessageBox("ID格式不正确或者ID已经存在");
}
else if (!m_Nametrue)
{
MessageBox("名字格式不正确或者名字已经存在");
}
else if (!m_Loctrue)
{
MessageBox("目录不正确");
}
return -1;
}
if (m_ListDir.m_hWnd!=NULL)
{
m_ListDir.DestroyWindow();
}
if (m_ListControl.m_hWnd!=NULL)
{
m_ListControl.DestroyWindow();
}
return CPropertyPage::OnWizardNext();
}
//判断项目ID是否正确
void CPropAdd1Page::OnKillfocusEditProid()
{
// TODO: Add your control notification handler code here
//测试是否项目已经存在
UpdateData(TRUE);
CString sql="select ProjectID From ProjectInfo Where ProjectID='"+m_ProID+"' ";
m_RecordInfo.CreateInstance("ADODB.Recordset");
m_RecordInfo->Open((_variant_t)sql,_variant_t((IDispatch *)theApp.m_pConnection,true),
adOpenDynamic,adLockOptimistic,adCmdText);
CString str1("项目ID已经存在");
CString str2("项目ID不能为空");
CString str3("项目ID可以使用");
HICON iconError=(HICON)LoadImage(AfxGetApp()->m_hInstance,MAKEINTRESOURCE(IDI_ICON_ERROR),
IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
HICON iconRight=(HICON)LoadImage(AfxGetApp()->m_hInstance,MAKEINTRESOURCE(IDI_ICON_RIGHT),
IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
if (m_ProID.IsEmpty())
{
m_IDtrue=FALSE;
SetStaticIconText(GetDlgItem(IDC_EDIT_PROID),str2,iconError,m_IDIcon,m_IDText);
}
else
{
if (m_RecordInfo->GetRecordCount()!=0)
{
m_IDtrue=FALSE;
SetStaticIconText(GetDlgItem(IDC_EDIT_PROID),str1,iconError,m_IDIcon,m_IDText);
}
else
{
m_IDtrue=TRUE;
SetStaticIconText(GetDlgItem(IDC_EDIT_PROID),str3,iconRight,m_IDIcon,m_IDText);
}
}
m_RecordInfo->Close();
}
//判断项目名字是否正确
void CPropAdd1Page::OnKillfocusEditProname()
{
// TODO: Add your control notification handler code here
//测试是否项目名已经存在
UpdateData(TRUE);
// const char *pStr=(LPCSTR)m_ProID;
CString sql="select ProjectName From ProjectInfo Where ProjectName='"+m_ProName+"' ";
m_RecordInfo.CreateInstance("ADODB.Recordset");
m_RecordInfo->Open((_variant_t)sql,_variant_t((IDispatch *)theApp.m_pConnection,true),
adOpenDynamic,adLockOptimistic,adCmdText);
CString str1("项目名称已经存在");
CString str2("项目名称不能为空");
CString str3("项目名称可以使用");
HICON iconError=(HICON)LoadImage(AfxGetApp()->m_hInstance,MAKEINTRESOURCE(IDI_ICON_ERROR),
IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
HICON iconRight=(HICON)LoadImage(AfxGetApp()->m_hInstance,MAKEINTRESOURCE(IDI_ICON_RIGHT),
IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
if (m_ProName.IsEmpty())
{
m_Nametrue=FALSE;
SetStaticIconText(GetDlgItem(IDC_EDIT_PRONAME),str2,iconError,m_NameIcon,m_NameText);
}
else
{
if (m_RecordInfo->GetRecordCount()!=0)
{
m_Nametrue=FALSE;
SetStaticIconText(GetDlgItem(IDC_EDIT_PRONAME),str1,iconError,m_NameIcon,m_NameText);
}
else
{
m_Nametrue=TRUE;
SetStaticIconText(GetDlgItem(IDC_EDIT_PRONAME),str3,iconRight,m_NameIcon,m_NameText);
}
}
m_RecordInfo->Close();
}
//选择路径
void CPropAdd1Page::OnBtnBrofolder()
{
// TODO: Add your control notification handler code here
//创建路径选择对话框 选择路径
char Buffer[MAXPATH];
BROWSEINFO bi;
bi.hwndOwner=this->m_hWnd;
bi.pidlRoot=NULL;
bi.pszDisplayName=Buffer;
bi.lpszTitle="选择路径";
bi.ulFlags=BIF_RETURNFSANCESTORS;
bi.lpfn=NULL;
bi.iImage=0;
LPITEMIDLIST pIDList=SHBrowseForFolder(&bi);
if (pIDList)
{
SHGetPathFromIDList(pIDList,Buffer);
m_ProLoc=Buffer;
UpdateData(FALSE);
}
m_Loctrue=TRUE;
CreateDirList(GetDlgItem(IDC_EDIT_PROLOC),m_ListDir);
}
void CPropAdd1Page::OnKillfocusEditProloc()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
CFileFind filedir;
if (!m_ProLoc.IsEmpty())
{
if (!filedir.FindFile(m_ProLoc))
{
MessageBox("目录不存在");
m_Loctrue=FALSE;
}
else
{
m_Loctrue=TRUE;
}
}
else
{
m_Loctrue=FALSE;
}
}
//DEL void CPropAdd1Page::CreateStaticText(CStatic &, CRect &rect, LPCSTR str)
//DEL {
//DEL
//DEL }
//当编辑框中内容改变时,动态生成列表框
void CPropAdd1Page::OnChangeEditProid()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CPropertyPage::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if (m_ProID.IsEmpty())
{
if (m_ListControl.m_hWnd!=NULL)
{
m_ListControl.DestroyWindow();
}
}
else
{
CString sql="select ProjectID From ProjectInfo Where ProjectID Like '"+m_ProID+"%' Order By ProjectTime";
m_RecordInfo.CreateInstance("ADODB.Recordset");
m_RecordInfo->Open((_variant_t)sql,_variant_t((IDispatch *)theApp.m_pConnection,true),
adOpenDynamic,adLockOptimistic,adCmdText);
long RecordCount=m_RecordInfo->GetRecordCount();
if (RecordCount!=0)
{
//创建列表框
CreateProList(GetDlgItem(IDC_EDIT_PROID),m_ListControl);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -