EquipmentDlg.cpp
上传用户:latoyin
上传日期:2017-10-19
资源大小:2882k
文件大小:9k
源码类别:

数据库系统

开发平台:

Visual C++

  1. // EquipmentDlg.cpp : implementation file
  2. #include "stdafx.h"
  3. #include "Equipment.h"
  4. #include "EquipmentDlg.h"
  5. #include "CustomBar.h"
  6. #include "EquipKind.h"
  7. #include "ReduceKinds.h"
  8. #include "AddKinds.h"
  9. #include "UseState.h"
  10. #include "AddEquip.h"
  11. #include "UpdateEquip.h"
  12. #include "DeleteEquipment.h"
  13. #include "ReduceEquip.h"
  14. #include "Depre.h"
  15. #include "UnDepre.h"
  16. #include "DataBackup.h"
  17. #include "DataRestore.h"
  18. #include "SysIni.h"
  19. #ifdef _DEBUG
  20. #define new DEBUG_NEW
  21. #undef THIS_FILE
  22. static char THIS_FILE[] = __FILE__;
  23. #endif
  24. const  panelnum = 6;
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CAboutDlg dialog used for App About
  27. extern CEquipmentApp theApp;
  28. class CAboutDlg : public CDialog
  29. {
  30. public:
  31. CAboutDlg();
  32. // Dialog Data
  33. //{{AFX_DATA(CAboutDlg)
  34. enum { IDD = IDD_ABOUTBOX };
  35. //}}AFX_DATA
  36. // ClassWizard generated virtual function overrides
  37. //{{AFX_VIRTUAL(CAboutDlg)
  38. protected:
  39. virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  40. //}}AFX_VIRTUAL
  41. // Implementation
  42. protected:
  43. HICON m_hIcon; 
  44. //{{AFX_MSG(CAboutDlg)
  45. virtual BOOL OnInitDialog();
  46. virtual void OnOK();
  47. //}}AFX_MSG
  48. DECLARE_MESSAGE_MAP()
  49. };
  50. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  51. {
  52. m_hIcon = AfxGetApp()->LoadIcon(IDI_ICON6);
  53. }
  54. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  55. {
  56. CDialog::DoDataExchange(pDX);
  57. //{{AFX_DATA_MAP(CAboutDlg)
  58. //}}AFX_DATA_MAP
  59. }
  60. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  61. //{{AFX_MSG_MAP(CAboutDlg)
  62. //}}AFX_MSG_MAP
  63. END_MESSAGE_MAP()
  64. /////////////////////////////////////////////////////////////////////////////
  65. // CEquipmentDlg dialog
  66. CEquipmentDlg::CEquipmentDlg(CWnd* pParent /*=NULL*/)
  67. : CDialog(CEquipmentDlg::IDD, pParent)
  68. {
  69. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINTITLE); //设置窗口图标
  70. toolbarcreated = false;
  71. }
  72. void CEquipmentDlg::DoDataExchange(CDataExchange* pDX)
  73. {
  74. CDialog::DoDataExchange(pDX);
  75. //{{AFX_DATA_MAP(CEquipmentDlg)
  76. //}}AFX_DATA_MAP
  77. }
  78. BEGIN_MESSAGE_MAP(CEquipmentDlg, CDialog)
  79. //{{AFX_MSG_MAP(CEquipmentDlg)
  80. ON_WM_SYSCOMMAND()
  81. ON_WM_PAINT()
  82. ON_WM_QUERYDRAGICON()
  83. ON_WM_SIZE()
  84. ON_COMMAND(IDS_ADDEQUIP, OnAddequip)
  85. ON_WM_CLOSE()
  86. ON_WM_TIMER()
  87. ON_WM_KEYDOWN()
  88. ON_COMMAND(IDS_EQUIPKIND, OnEquipkind)
  89. ON_COMMAND(IDS_ADDMODE, OnAddmode)
  90. ON_COMMAND(IDS_REDUSEMODE, OnRedusemode)
  91. ON_COMMAND(IDS_USESTATE, OnUsestate)
  92. ON_COMMAND(IDS_UPDATEEQUIP, OnUpdateequip)
  93. ON_COMMAND(IDS_DELETEEQUIP, OnDeleteequip)
  94. ON_COMMAND(IDS_REDUSEEQUIP, OnReduseequip)
  95. ON_COMMAND(IDS_DEPRECIATION, OnDepreciation)
  96. ON_COMMAND(IDS_CANCELDEPRE, OnCanceldepre)
  97. ON_COMMAND(ID_Calculator, OnCalculator)
  98. ON_COMMAND(ID_NOTE, OnNote)
  99. ON_COMMAND(ID_MENUABOUT, OnMenuabout)
  100. ON_COMMAND(IDS_BACKUP, OnBackup)
  101. ON_COMMAND(ID_MENUSYSINI, OnMenusysini)
  102. ON_COMMAND(IDS_Restore, OnRestore)
  103. ON_WM_CAPTURECHANGED()
  104. ON_WM_CANCELMODE()
  105. ON_COMMAND(ID_BUTTONCLOSE, OnButtonclose)
  106. //}}AFX_MSG_MAP
  107. END_MESSAGE_MAP()
  108. /////////////////////////////////////////////////////////////////////////////
  109. // CEquipmentDlg message handlers
  110. BOOL CEquipmentDlg::OnInitDialog()
  111. {
  112. CDialog::OnInitDialog();
  113. /******************************创建工具栏*********************************/
  114. toolbar.Create(TBSTYLE_FLAT|CCS_TOP|WS_CHILD|WS_VISIBLE|WS_BORDER|CCS_ADJUSTABLE|TBSTYLE_WRAPABLE,CRect(0,0,0,0),this,IDR_TOOLBAR1);
  115. //MouseMove = DoToolMouseMove;
  116. /******************************创建工具栏*********************************/
  117. /******************************创建状态栏*********************************/
  118. int panels[panelnum];//定义一个整型数组,记录状态栏每个面板的宽度
  119. CRect rect1;
  120. this->GetClientRect(&rect1);
  121. //this->GetClientRect()
  122. panels[0]= rect1.Width() / 9;
  123. panels[1]=rect1.Width() / 9*3;
  124. panels[2]=panels[1]+rect1.Width() / 9;
  125. panels[3]=panels[2]+rect1.Width() / 9*2;
  126. panels[4]=panels[3]+rect1.Width() / 9;
  127. panels[5]=2000;
  128. statusbar.Create(WS_CHILD|WS_VISIBLE|CCS_BOTTOM|SBARS_SIZEGRIP,rect1,this,ID_statusbar);
  129. statusbar.SetParts(panelnum,panels);//设置状态栏面板及宽度
  130. statusbar.SetText("提示",0,0);
  131. statusbar.SetText("公司",2,0);
  132. CString string;
  133. string.LoadString(IDS_COMPANY);
  134. statusbar.SetText(string,3,0);
  135. statusbar.SetText("系统时间",4,0);
  136. /******************************创建状态栏**********************************/
  137. this->UpdateWindow();
  138. toolbarcreated = true;
  139. SetIcon(m_hIcon, TRUE);// Set big icon
  140. SetIcon(m_hIcon, FALSE);// Set small icon
  141. SetWindowText("【资产设备管理系统】"); //设置窗口标题
  142. this->ShowWindow(SW_SHOWMAXIMIZED);
  143. this->SetTimer(12,1000,NULL);
  144. return TRUE;  // return TRUE  unless you set the focus to a control
  145. }
  146. void CEquipmentDlg::OnSysCommand(UINT nID, LPARAM lParam)
  147. {
  148. // if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  149. {
  150. // CAboutDlg dlgAbout;
  151. // dlgAbout.DoModal();
  152. }
  153. // else
  154. {
  155. CDialog::OnSysCommand(nID, lParam);
  156. }
  157. }
  158. // If you add a minimize button to your dialog, you will need the code below
  159. //  to draw the icon.  For MFC applications using the document/view model,
  160. //  this is automatically done for you by the framework.
  161. void CEquipmentDlg::OnPaint() 
  162. {
  163. CPaintDC dc(this);
  164. CDC MemDC;
  165. CBitmap bit;
  166. CRect rect;
  167. bit.LoadBitmap(IDB_BITMAP3);
  168. MemDC.CreateCompatibleDC(this->GetDC());
  169. MemDC.SelectObject(&bit);
  170. this->GetClientRect(&rect);
  171. dc.StretchBlt(0,0,rect.Width(),rect.Height(),&MemDC,0,0,1022,611,SRCCOPY);   
  172. MemDC.DeleteDC();
  173. ::DeleteObject(&bit);
  174. CDialog::OnPaint();
  175. }
  176. // The system calls this to obtain the cursor to display while the user drags
  177. //  the minimized window.
  178. HCURSOR CEquipmentDlg::OnQueryDragIcon()
  179. {
  180. return 0;//(HCURSOR) m_hIcon;
  181. }
  182. void CEquipmentDlg::OnSize(UINT nType, int cx, int cy) 
  183. {
  184. if (toolbarcreated)
  185. {
  186.      toolbar.AutoSize();
  187. CRect rect;
  188. this->GetClientRect(rect);
  189. statusbar.MoveWindow(rect,false);
  190. OnPaint();
  191. }
  192. CDialog::OnSize(nType, cx, cy);
  193. }
  194. void CEquipmentDlg::OnAddequip() 
  195. {
  196. CAddEquip addequip;
  197. addequip.DoModal();
  198. }
  199. void CEquipmentDlg::OnClose() 
  200. {
  201. if (MessageBox("确实要退出系统吗?","提示",MB_YESNO)!=IDNO)
  202. EndDialog(0);
  203. }
  204. void CEquipmentDlg::OnTimer(UINT nIDEvent) 
  205. {
  206. CTime t = CTime::GetCurrentTime();
  207. CString s = t.Format("%H:%M:%S");
  208. statusbar.SetText(s,5,0);
  209. CDialog::OnTimer(nIDEvent);
  210. }
  211. void CEquipmentDlg::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
  212. {
  213. // TODO: Add your message handler code here and/or call default
  214. // CDialog::OnKeyDown(nChar, nRepCnt, nFlags);
  215. }
  216. void CEquipmentDlg::Close()
  217. {
  218. //
  219. }
  220. BOOL CEquipmentDlg::PreTranslateMessage(MSG* pMsg) 
  221. {
  222. if ((pMsg->message == WM_KEYDOWN)&&(pMsg->wParam ==VK_ESCAPE))
  223. {
  224. PostMessage(WM_CLOSE);
  225. return true;
  226. }
  227. return CDialog::PreTranslateMessage(pMsg);
  228. }
  229. void CEquipmentDlg::OnEquipkind() 
  230. {
  231. CEquipKind EquipKind;
  232. EquipKind.DoModal();
  233. }
  234. void CEquipmentDlg::OnAddmode() 
  235. {
  236. CAddKinds addkinds;
  237. addkinds.DoModal();
  238. }
  239. void CEquipmentDlg::OnRedusemode() 
  240. {
  241. CReduceKinds reducekinds;
  242. reducekinds.DoModal();
  243. }
  244. void CEquipmentDlg::OnUsestate() 
  245. {
  246. CUseState usestate;
  247. usestate.DoModal();
  248. }
  249. void CEquipmentDlg::OnUpdateequip() 
  250. {
  251. CUpdateEquip * updateEquip;
  252. updateEquip = new CUpdateEquip();
  253. updateEquip->DoModal();
  254. delete(updateEquip);
  255. updateEquip = NULL;
  256. }
  257. void CEquipmentDlg::OnDeleteequip() 
  258. {
  259. CDeleteEquipment * deleteequipment;
  260. deleteequipment = new CDeleteEquipment();
  261. deleteequipment->DoModal();
  262. delete(deleteequipment);
  263. deleteequipment = NULL;
  264. }
  265. void CEquipmentDlg::OnReduseequip() 
  266. {
  267. CReduceEquip * reduceequip;
  268. reduceequip= new CReduceEquip();
  269. reduceequip->DoModal();
  270. delete(reduceequip);
  271. reduceequip = NULL;
  272. }
  273. void CEquipmentDlg::OnDepreciation() 
  274. {
  275. AfxInitRichEdit();
  276. CDepre * depre;
  277. depre = new CDepre();
  278. depre->DoModal();
  279. delete(depre);
  280. depre = NULL;
  281. }
  282. void CEquipmentDlg::OnCanceldepre() 
  283. {
  284. AfxInitRichEdit();
  285. CUnDepre * undepre;
  286. undepre = new CUnDepre();
  287. undepre->DoModal();
  288. delete (undepre);
  289. undepre = NULL;
  290. }
  291. void CEquipmentDlg::OnCalculator() 
  292. {
  293. ShellExecute(this->GetSafeHwnd(),"open" ,"calc.EXE",NULL,NULL,SW_SHOWNORMAL);
  294. }
  295. void CEquipmentDlg::OnNote() 
  296. {
  297. ShellExecute(this->GetSafeHwnd(),"open" ,"NOTEPAD.EXE",NULL,NULL,SW_MAXIMIZE);
  298. }
  299. BOOL CAboutDlg::OnInitDialog() 
  300. {
  301. CDialog::OnInitDialog();
  302. SetIcon(m_hIcon,true);
  303. return TRUE;  
  304. }
  305. void CEquipmentDlg::OnMenuabout() 
  306. {
  307. CAboutDlg * about;
  308. about = new CAboutDlg();
  309. about->DoModal();
  310. delete (about);
  311. about = NULL;
  312. }
  313. void CAboutDlg::OnOK() 
  314. {
  315. // TODO: Add extra validation here
  316. //CDialog::OnOK();
  317. }
  318. void CEquipmentDlg::OnBackup() 
  319. {
  320. CDataBackup * databackup;
  321. databackup= new CDataBackup();
  322. databackup->DoModal();
  323. delete(databackup);
  324. databackup = NULL;
  325. }
  326. void CEquipmentDlg::OnMenusysini() 
  327. {
  328. CSysIni * sysini;
  329. sysini= new CSysIni();
  330. sysini->DoModal();
  331. delete(sysini);
  332. sysini = NULL;
  333. }
  334. void CEquipmentDlg::OnRestore() 
  335. {
  336. CDataRestore * restore;
  337. restore= new CDataRestore();
  338. restore->DoModal();
  339. delete(restore);
  340. restore = NULL;
  341. }
  342. void CEquipmentDlg::OnButtonclose() 
  343. {
  344. PostMessage(WM_CLOSE,0,0);
  345. }
  346. void CEquipmentDlg::DoToolMouseMove(int strid)
  347. {
  348. CString str;
  349. int temp;
  350. temp = strid / 4; //每3个工具栏按钮间有1个分隔条
  351. str.LoadString(strid+IDS_EQUIPKIND-temp);
  352. statusbar.SetText(str,1,0);
  353. }