📄 databaseui.cpp
字号:
// DataBaseUI.cpp : implementation file
//
#include "stdafx.h"
#include "MoinorCentre.h"
#include "DataBaseUI.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDataBaseUI dialog
CDataBaseUI::CDataBaseUI(CWnd* pParent /*=NULL*/)
: CDialog(CDataBaseUI::IDD, pParent)
{
//{{AFX_DATA_INIT(CDataBaseUI)
m_siteid = 0;
m_sitename = _T("");
m_sitetablename = _T("");
m_ID = _T("");
//}}AFX_DATA_INIT
}
void CDataBaseUI::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDataBaseUI)
DDX_Control(pDX, IDC_COMB1, m_comb1);
DDX_Control(pDX, IDC_EDITTABLE, m_edit3);
DDX_Control(pDX, IDC_EDITNAME, m_edit2);
DDX_Control(pDX, IDC_EDITID, m_edit1);
DDX_Text(pDX, IDC_EDITID, m_siteid);
DDX_Text(pDX, IDC_EDITNAME, m_sitename);
DDX_Text(pDX, IDC_EDITTABLE, m_sitetablename);
DDX_CBString(pDX, IDC_COMB1, m_ID);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDataBaseUI, CDialog)
//{{AFX_MSG_MAP(CDataBaseUI)
ON_BN_CLICKED(IDC_OPENTABLE, OnOpentable)
ON_BN_CLICKED(IDC_ADD, OnAdd)
ON_BN_CLICKED(IDC_DEL, OnDel)
ON_BN_CLICKED(IDC_FINISH, OnFinish)
ON_BN_CLICKED(IDC_FORWAED, OnForwaed)
ON_BN_CLICKED(IDC_BACK, OnBack)
ON_WM_CTLCOLOR()
ON_WM_CLOSE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDataBaseUI message handlers
BOOL CDataBaseUI::OnInitDialog()
{
CDialog::OnInitDialog();
db.Open("port.mdb");
CDaoTableDef tb(&db);
tb.Open("site");
//CSiteRet rs;
rs.Open(&tb,dbOpenDynaset);
while(!rs.IsEOF())
{
CString id;
id.Format("%d",rs.m_SiteID);
m_comb1.AddString(id);
rs.MoveNext();
}
//rs.Close();
tb.Close();
//db.Close();
m_edit1.SetReadOnly();
m_edit2.SetReadOnly();
m_edit3.SetReadOnly();
rs.MoveFirst();
m_siteid=rs.m_SiteID;
m_sitename=rs.m_SiteName;
m_sitetablename=rs.m_SiteTable;
UpdateData(FALSE);
GetDlgItem(IDC_FINISH)->EnableWindow(FALSE);
beijing.Load(".//res//dd.bmp");
CRect ff;
GetWindowRect(ff);
beijing.ChangeImageSize(ff.Width(),ff.Height());
m_brush.CreateDIBPatternBrush(beijing.m_hDib,DIB_PAL_COLORS);
int IDIBUTTON[8]={IDC_FORWARD,IDC_BACK,IDC_OPENTABLE,IDC_ADD,IDC_DEL,IDC_FINISH,IDOK,IDCANCLE};
int IDICON[8]={IDI_FORWARD,IDI_BACKWARD,IDI_OPEN,IDI_ADD,IDI_DELETE,IDI_OK,IDI_OKQUITE,IDI_CANCLE};
for(int i=0;i<8;i++)
{
btn[i].SubclassDlgItem(IDIBUTTON[i],this);
btn[i].SetIcon(IDICON[i]);
btn[i].SetColor(CButtonST::BTNST_COLOR_FG_IN, RGB(66,153,124));
btn[i].SetColor(CButtonST::BTNST_COLOR_FG_OUT, RGB(66,153,124));
btn[i].DrawTransparent(TRUE);
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDataBaseUI::OnOpentable()
{
CDaoTableDef picsite(&db);
picsite.Open(m_sitetablename);
piclist.picrs.Open(&picsite,dbOpenDynaset);
picsite.Close();
piclist.Create(IDD_PICLIST,this);// TODO: Add your control notification handler code here
piclist.ShowWindow(SW_SHOW);
}
void CDataBaseUI::OnAdd()
{
m_edit1.SetReadOnly(FALSE);
m_edit2.SetReadOnly(FALSE);
m_edit3.SetReadOnly(FALSE);
GetDlgItem(IDC_FINISH)->EnableWindow(TRUE);
AfxMessageBox("请输入添加监控点的信息");
}
void CDataBaseUI::OnDel()
{
CString m;
m.Format("%s%d%s","确实要删除ID为",m_siteid,"的监控点吗");
int nchoice=AfxMessageBox(m,MB_YESNO);
if(nchoice=IDYES)
{ CString tablename=rs.m_SiteTable;
AfxMessageBox("kkkkkk");
db.DeleteTableDef(tablename);
rs.Delete();
CString str;
str.Format("%d",m_siteid);
int i=m_comb1.FindStringExact(-1,str);
m_comb1.DeleteString(i);
}
}
void CDataBaseUI::OnFinish()
{
rs.AddNew();
UpdateData();
rs.m_SiteID=m_siteid;
rs.m_SiteName=m_sitename;
rs.m_SiteTable=m_sitetablename;
rs.Update();
//rs.Close();
CDaoTableDef* ttb=new CDaoTableDef(&db);
ttb->Create(m_sitetablename);
ttb->CreateField(_T("DateAndTime"),dbDate,8);
ttb->CreateField(_T("picturepath"),dbText,50);
ttb->CreateField(_T("picdescribe"),dbText,50);
ttb->CreateField(_T("picleng"),dbLong,4);
ttb->CreateField(_T("picsize"),dbText,50);
ttb->CreateField(_T("dct"),dbLongBinary,0);
ttb->CreateField(_T("shape"),dbLongBinary,0);
ttb->CreateField(_T("color"),dbLongBinary,0);
ttb->CreateField(_T("texture"),dbLongBinary,0);
ttb->CreateField(_T("boatdetect"),dbLong,4);
ttb->CreateField(_T("happening"),dbText,0);
ttb->Append();
ttb->Close();
delete ttb;
//db.Close();
m_edit1.SetReadOnly();
m_edit2.SetReadOnly();
m_edit3.SetReadOnly();
GetDlgItem(IDC_FINISH)->EnableWindow(FALSE);
CString str;
str.Format("%d",m_siteid);
m_comb1.AddString(str);
}
void CDataBaseUI::OnCancel()
{m_brush.DeleteObject();
db.Close();
DestroyWindow();
}
void CDataBaseUI::OnOK()
{
// TODO: Add extra validation here
m_brush.DeleteObject();
db.Close();
DestroyWindow();
}
void CDataBaseUI::OnForwaed()
{
rs.MoveNext();
if(rs.IsEOF())
rs.MoveFirst();
m_siteid=rs.m_SiteID;
m_sitename=rs.m_SiteName;
m_sitetablename=rs.m_SiteTable;
UpdateData(FALSE);
this->Invalidate();
}
void CDataBaseUI::OnBack()
{
rs.MovePrev();
if(rs.IsBOF())
rs.MoveLast(); // TODO: Add your control notification handler code here
m_siteid=rs.m_SiteID;
m_sitename=rs.m_SiteName;
m_sitetablename=rs.m_SiteTable;
UpdateData(FALSE);
this->Invalidate();
}
HBRUSH CDataBaseUI::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if(nCtlColor==CTLCOLOR_DLG)
{
return m_brush;
}
if(nCtlColor == CTLCOLOR_STATIC)
{ pDC->SetBkMode(0);
pDC->SetTextColor(RGB(255,100,70));
hbr = (HBRUSH)::GetStockObject(NULL_BRUSH);
return hbr;
}
// TODO: Return a different brush if the default is not desired
return hbr;
}
void CDataBaseUI::OnClose()
{
m_brush.DeleteObject();
db.Close();
DestroyWindow();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -