固定资产管理系统

固定资产管理系统

ID:1464155

大小:639.50 KB

页数:41页

时间:2017-11-11

上传者:U-251
固定资产管理系统_第1页
固定资产管理系统_第2页
固定资产管理系统_第3页
固定资产管理系统_第4页
固定资产管理系统_第5页
资源描述:

《固定资产管理系统》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库

目录一.摘要21.背景说明22.设计目的23.需求分析2二.固定资产管理系统概述31.设计内容32.设计特点3三.固定资产管理系统数据库分析与设计31.系统的功能模块图32.数据库结构设计43.概念模型设计(E-R图)6四.窗体实现与设计81.登陆界面82.主界面103.部门信息管理界面154.资产类别管理界面185.固定资产信息编辑界面206.固定资产信息管理界面247.固定资产分配界面288.固定资产变更界面309.固定资产折旧界面3210.固定资产报废界面3511.用户管理界面3712.修改密码界面39五.结论与体会4141 一.摘要1.背景说明随着社会经济的不断发展,企业规模越来越大,资产越来越多,资产管理就显得非常困难。固定资产成为每个企业不可缺少的重要部分,加强固定资产管理,可以优化企业资源配置,本系统适用与中小型企业及政府机关、学校等。主要维护固定资产的登记、清理、借出和还入、维修、折旧等信息,实现设备的日常管理功能,通过一系列查询功能,可方便获知每一件固定资产的状态及当前所处位置,具有操作简单,界面友善,灵活性好,系统安全性高,运行稳定等特点,保证了企业中的每一件物品发挥其最大效力。2.设计目的在程序设计中,可以用两种方法解决问题:一是传统的结构化程序设计方法,二是更先进的面向对象程序设计方法。在结构化程序设计中关键是如何将问题域中的行为(即操作)抽取出来,作为C++程序中的函数。由于多个函数均需要访问某些数据,这些数据常被设计为全局变量。而在面向对象程序设计中关键是如何将问题域中的实体(即日常所见的概念)抽取出来,作为C++程序中的类,而属性与行为作为类的两类要素通常是必不可少的,甚至还应考虑类必须满足的约束。3.需求分析基本信息的添加、修改、删除和查询。基本信息包括部门信息和固定资产类型信息。 资产信息管理包括固定资产的录入、分配、变更、折旧和报废等功能。统计查询功能包括部门资产统计表和分类资产统计表。 41 二.固定资产管理系统概述1.设计内容(1)系统信息设置模块:包括部门管理,类别管理和退出系统(2)固定资产管理模块理模块,包括信息编辑,资产分配,资产变更,资产折旧,资产报废等(3)系统用户管理模块,包括用户管理和修改密码2.设计特点后台数据库使用SQLServer,前台开发工具使用VisualC++。 本系统采用目前比较流行的ADO数据访问技术,并将每个数据库表的字段和操作封装到类中,从而成功地将面向对象的程序设计思想应用到数据库应用程序设计中。这也是本系统的特色和优势。 三.固定资产管理系统数据库分析与设计1.系统的功能模块图图2.1固定资产管理系统功能模块示意图41 2.数据库结构设计数据库中包含6个表,即部门信息表Departments、资产分类信息表Types、资产信息表Assets、资产分配表Distribute、设备报废表Discard和用户信息表Users等。表Assets列名数据类型允许为空Aidvarchar(30)不允许Anamevarchar(50)不允许TypeIdint允许Modelvarchar(30)允许Producervarchar(100)允许UseDatevarchar(20)允许UsedYearint允许OrgPricedecimal(15,2)允许Ratiodecimal(7,5)允许Statusvarchar(30)允许AddWayvarchar(30)允许IsAuditint允许PostDateVarchar(20)允许IsDiscounttinyint允许表Departments列名数据类型允许为空DepIdint不允许DepNamevarchar(40)不允许41 表Discard列名数据类型允许为空Aidvarchar(30)允许DSumfloat允许Reasonvarchar(200)允许CreateDatevarchar(30)允许EmpNamevarchar(40)允许Checkervarchar(40)允许CheckDatevarchar(40)允许StatusChar(4)允许表Distribute列名数据类型允许为空Aidvarchar(30)允许DepIdint允许EmpNamevarchar(50)允许CreateDatevarchar(30)允许表Types列名数据类型允许为空TypeIdint不允许TypeNamevarchar(30)不允许表Users列名数据类型允许为空UseraNamevarchar(40)不允许EmpNamevarchar(40)允许UserPwdvarchar(40)允许UserTypevarchar(20)允许41 3.概念模型设计(E-R图)资产编号固定资产资产名称类型状态型号生产厂商使用日期使用年限用户用户名用户密码用户类别41 部门部门名称负责人部门固定资产管理1m固定资产变更分配折旧报废部门用户创建日期残值率使用月份报废原因状态mnmnmn41 四.窗体实现与设计1.登陆界面代码设计#include"stdafx.h"#include"AssetsMan.h"#include"LoginDlg.h"#include"Users.h"#ifdef_DEBUG#definenewDEBUG_NEW#undefTHIS_FILEstaticcharTHIS_FILE[]=__FILE__;#endifCLoginDlg::CLoginDlg(CWnd*pParent/*=NULL*/):CDialog(CLoginDlg::IDD,pParent){count=0;m_Pwd=_T("");m_UserName=_T("");voidCLoginDlg::DoDataExchange(CDataExchange*pDX){CDialog::DoDataExchange(pDX);DDX_Text(pDX,IDC_PWD_EDIT,m_Pwd);DDX_Text(pDX,IDC_USERNAME_EDIT,m_UserName);41 }BEGIN_MESSAGE_MAP(CLoginDlg,CDialog)ON_EN_CHANGE(IDC_USERNAME_EDIT,&CLoginDlg::OnEnChangeUsernameEdit)ON_EN_CHANGE(IDC_PWD_EDIT,&CLoginDlg::OnEnChangePwdEdit)END_MESSAGE_MAP()voidCLoginDlg::OnOK(){UpdateData(TRUE);if(m_UserName==""){MessageBox("请输入用户名?");return;}if(m_Pwd==""){MessageBox("请输入密码");return;}CUsersuser;user.GetData(m_UserName);if(user.UserPwd!=m_Pwd){MessageBox("用户信息不正确,无法登录!");count++;if(count>=3){MessageBox("已经连续3次登录失败,将退出系统");OnCancel();}return;}CDialog::OnOK();}voidCLoginDlg::OnEnChangeUsernameEdit(){}voidCLoginDlg::OnEnChangePwdEdit(){}41 2.主界面代码设计#include"stdafx.h"#include"AssetsMan.h"#include"Assets.h"#include"ADOConn.h"#ifdef_DEBUG#undefTHIS_FILEstaticcharTHIS_FILE[]=__FILE__;#definenewDEBUG_NEW#endifCAssets::CAssets(){Aid="";Aname="";Model="";Producer="";UsedYear=1;OrgPrice=0;Ratio=0;Status="未使用";AddWay="";IsAudit=0;41 IsDiscount=0;}CAssets::~CAssets(){}voidCAssets::sql_Insert(){try{ADOConnm_AdoConn;CStringcSql,cDate,cOrgPrc,cRatio,cTypeId,cYear;_bstr_tbSql;cOrgPrc.Format("%f",OrgPrice);cRatio.Format("%f",Ratio);cTypeId.Format("%d",TypeId);cYear.Format("%d",UsedYear);CTimet=CTime::GetCurrentTime();cDate.Format(_T("%04d-%02d-%02d"),t.GetYear(),t.GetMonth(),t.GetDay());cSql="InsertIntoAssets(Aid,Aname,TypeId,Model,Producer,";cSql+="UseDate,UsedYear,OrgPrice,Ratio,";cSql+="Status,AddWay,IsAudit,PostDate,IsDiscount)Values('";cSql+=Aid+"','"+Aname+"',"+cTypeId+",'"+Model+"','"+Producer+"','";cSql+=UseDate+"',"+cYear+","+cOrgPrc+",";cSql+=cRatio+",'未使用','"+AddWay+"',0,'"+cDate+"',0)";bSql=(LPCTSTR)(_bstr_t)cSql;m_AdoConn.ExecuteSQL(bSql);m_AdoConn.ExitConnect();}catch(_com_errore){AfxMessageBox(e.Description());}}voidCAssets::sql_Update(CStringcId){try{ADOConnm_AdoConn;CStringcDate,cOrgPrc,cRatio,cTypeId,cYear;_bstr_tbSql;cOrgPrc.Format("%f",OrgPrice);cRatio.Format("%f",Ratio);41 cTypeId.Format("%d",TypeId);cYear.Format("%d",UsedYear);CTimet=CTime::GetCurrentTime();cDate.Format(_T("%04d-%02d-%02d"),t.GetYear(),t.GetMonth(),t.GetDay());bSql="UpdateAssetsSetAid='"+Aid+"',Aname='"+Aname+"',"+"TypeId="+cTypeId+",Model='"+Model+"',Producer='"+Producer+"',"+"UseDate='"+UseDate+"',UsedYear="+cYear+",OrgPrice="+cOrgPrc+","+"Ratio="+cRatio+",AddWay='"+AddWay+"',"+"PostDate='"+cDate+"'WhereAid='"+cId+"'";m_AdoConn.ExecuteSQL(bSql);m_AdoConn.ExitConnect();}catch(_com_errore){AfxMessageBox(e.Description());}}voidCAssets::sql_Delete(CStringcId){try{ADOConnm_AdoConn;_bstr_tbSql;bSql="DeleteFromAssetsWhereAid='"+cId+"'";m_AdoConn.ExecuteSQL(bSql);m_AdoConn.ExitConnect();}catch(_com_errore){AfxMessageBox(e.Description());}}voidCAssets::sql_Change(CStringcId){try{ADOConnm_AdoConn;CStringcRatio,cYear;_bstr_tbSql;cRatio.Format("%f",Ratio);cYear.Format("%d",UsedYear);bSql="UpdateAssetsSetUsedYear="+cYear+",Ratio="+cRatio+","41 +"IsAudit=2WhereAid='"+cId+"'";m_AdoConn.ExecuteSQL(bSql);m_AdoConn.ExitConnect();}catch(_com_errore){AfxMessageBox(e.Description());}}voidCAssets::sql_Audit(CStringcId){try{ADOConnm_AdoConn;_bstr_tbSql;bSql="UpdateAssetsSetIsAudit=1WhereAid='"+cId+"'";m_AdoConn.ExecuteSQL(bSql);m_AdoConn.ExitConnect();}catch(_com_errore){AfxMessageBox(e.Description());}}voidCAssets::sql_Status(CStringcId){try{ADOConnm_AdoConn;_bstr_tbSql;bSql="UpdateAssetsSetStatus='"+Status+"'WhereAid='"+cId+"'";m_AdoConn.ExecuteSQL(bSql);m_AdoConn.ExitConnect();}catch(_com_errore){AfxMessageBox(e.Description());}}41 intCAssets::HaveAid(CStringcAid){try{longlRscnt=0;_RecordsetPtrm_pRecordset;ADOConnm_AdoConn;_bstr_tbSQL;bSQL="Select*FromAssetsWhereAid='"+cAid+"'";m_pRecordset=m_AdoConn.GetRecordSet(bSQL);if(m_pRecordset->adoEOF)return-1;elsereturn1;m_AdoConn.ExitConnect();}catch(_com_errore){AfxMessageBox(e.Description());}return-1;}intCAssets::HaveName(CStringcAname){try{longlRscnt=0;_RecordsetPtrm_pRecordset;ADOConnm_AdoConn;_bstr_tbSQL;bSQL="Select*FromAssetsWhereAname='"+cAname+"'";m_pRecordset=m_AdoConn.GetRecordSet(bSQL);if(m_pRecordset->adoEOF)return-1;elsereturn1;m_AdoConn.ExitConnect();}41 catch(_com_errore){AfxMessageBox(e.Description());}return-1;}voidCAssets::BeginDiscount(CStringcId){try{ADOConnm_AdoConn;_bstr_tbSql;bSql="UpdateAssetsSetIsDiscount=1WhereAid='"+cId+"'";m_AdoConn.ExecuteSQL(bSql);m_AdoConn.ExitConnect();}catch(_com_errore){AfxMessageBox(e.Description());}}3.部门信息管理界面代码设计41 #include"stdafx.h"#include"AssetsMan.h"#include"DeptDlg.h"#include"Departments.h"#ifdef_DEBUG#definenewDEBUG_NEW#undefTHIS_FILEstaticcharTHIS_FILE[]=__FILE__;#endifCDeptDlg::CDeptDlg(CWnd*pParent/*=NULL*/):CDialog(CDeptDlg::IDD,pParent){m_DeptName=_T("");}voidCDeptDlg::DoDataExchange(CDataExchange*pDX){CDialog::DoDataExchange(pDX);DDX_Control(pDX,IDC_ADODC1,m_AdoDept);DDX_Text(pDX,IDC_EDIT1,m_DeptName);DDX_Control(pDX,IDC_DATALIST1,m_DataDept);}BEGIN_MESSAGE_MAP(CDeptDlg,CDialog)ON_BN_CLICKED(IDC_ADD_BUTTON,OnAddButton)ON_BN_CLICKED(IDC_MODI_BUTTON,OnModiButton)ON_BN_CLICKED(IDC_DEL_BUTTON,OnDelButton)ON_EN_CHANGE(IDC_EDIT1,&CDeptDlg::OnEnChangeEdit1)END_MESSAGE_MAP()BEGIN_EVENTSINK_MAP(CDeptDlg,CDialog)ON_EVENT(CDeptDlg,IDC_DATALIST1,-600/*Click*/,OnClickDatalist1,VTS_NONE)END_EVENTSINK_MAP()voidCDeptDlg::OnClickDatalist1(){m_DeptName=m_DataDept.GetText();cDepId=m_DataDept.GetBoundText();cDepNameOld=m_DataDept.GetText();UpdateData(FALSE);}voidCDeptDlg::OnAddButton(){UpdateData(TRUE);if(m_DeptName==""){41 MessageBox("请输入部门名称");return;}CDepartmentscDep;cDep.DepName=m_DeptName;if(cDep.HaveName(m_DeptName)==1)MessageBox("已经存在此部门信息!");else{cDep.sql_Insert();m_AdoDept.Refresh();}}voidCDeptDlg::OnModiButton(){UpdateData(TRUE);if(m_DataDept.GetText()==""){MessageBox("请选择要修改的部门名称");return;}if(m_DeptName==""){MessageBox("请输入部门名称");return;}if(cDepNameOld!=m_DeptName){CDepartmentscDept;cDept.DepName=m_DeptName;if(cDept.HaveName(m_DeptName)==1)MessageBox("新的部门名称已经存在");else{cDept.sql_Update(cDepId);m_AdoDept.Refresh();}}}voidCDeptDlg::OnDelButton(){if(m_DataDept.GetText()==""){MessageBox("请选择要删除的部门名称");41 return;}CDepartmentscDep;cDep.sql_Delete(cDepId);m_AdoDept.Refresh();}voidCDeptDlg::OnEnChangeEdit1(){}4.资产类别管理界面代码设计#include"stdafx.h"#include"AssetsMan.h"#include"TypeDlg.h"#include"Types.h"#ifdef_DEBUG#definenewDEBUG_NEW#undefTHIS_FILEstaticcharTHIS_FILE[]=__FILE__;#endifCTypeDlg::CTypeDlg(CWnd*pParent/*=NULL*/):CDialog(CTypeDlg::IDD,pParent){m_TypeName=_T("");}voidCTypeDlg::DoDataExchange(CDataExchange*pDX){CDialog::DoDataExchange(pDX);DDX_Control(pDX,IDC_ADODC1,m_AdoType);DDX_Control(pDX,IDC_DATALIST1,m_DataType);41 DDX_Text(pDX,IDC_EDIT1,m_TypeName);}BEGIN_MESSAGE_MAP(CTypeDlg,CDialog)ON_BN_CLICKED(IDC_ADD_BUTTON,OnAddButton)ON_BN_CLICKED(IDC_MODI_BUTTON,OnModiButton)ON_BN_CLICKED(IDC_DEL_BUTTON,OnDelButton)END_MESSAGE_MAP()BEGIN_EVENTSINK_MAP(CTypeDlg,CDialog)ON_EVENT(CTypeDlg,IDC_DATALIST1,-600/*Click*/,OnClickDatalist1,VTS_NONE)END_EVENTSINK_MAP()voidCTypeDlg::OnClickDatalist1(){m_TypeName=m_DataType.GetText();cTypeId=m_DataType.GetBoundText();cTypeNameOld=m_DataType.GetText();UpdateData(FALSE);}voidCTypeDlg::OnAddButton(){UpdateData(TRUE);if(m_TypeName==""){MessageBox("请输入类别名称");return;}CTypesobj;obj.TypeName=m_TypeName;if(obj.HaveName(m_TypeName)==1)MessageBox("此类别名称已经存在!");else{obj.sql_Insert();m_AdoType.Refresh();}}voidCTypeDlg::OnModiButton(){UpdateData(TRUE);if(m_DataType.GetText()==""){MessageBox("请选择要修改的类别名称");41 return;}if(m_TypeName==""){MessageBox("请输入类别名称");return;}if(cTypeNameOld!=m_TypeName){CTypesobj;obj.TypeName=m_TypeName;if(obj.HaveName(m_TypeName)==1)MessageBox("此类别名称已经存在!");else{obj.sql_Update(cTypeId);m_AdoType.Refresh();}}}voidCTypeDlg::OnDelButton(){CTypesobj;obj.sql_Delete(cTypeId);m_AdoType.Refresh();}5.固定资产信息编辑界面代码设计41 #include"stdafx.h"#include"AssetsMan.h"#include"AssetsEditDlg.h"#include"Assets.h"#ifdef_DEBUG#definenewDEBUG_NEW#undefTHIS_FILEstaticcharTHIS_FILE[]=__FILE__;#endifCAssetsEditDlg::CAssetsEditDlg(CWnd*pParent/*=NULL*/):CDialog(CAssetsEditDlg::IDD,pParent){m_Aid=_T("");m_Aname=_T("");m_Model=_T("");m_Producer=_T("");m_RepPerson=_T("");m_UseYear=0;m_OrgPrice=0.0f;m_Ratio=0.0f;m_PostDate=_T("");m_UseDate=COleDateTime::GetCurrentTime();m_Status=_T("");}voidCAssetsEditDlg::DoDataExchange(CDataExchange*pDX){CDialog::DoDataExchange(pDX);DDX_Control(pDX,IDC_ADDWAY_COMBO,m_AddWay);DDX_Control(pDX,IDC_ADODC1,m_adodc1);DDX_Text(pDX,IDC_AID_EDIT,m_Aid);DDX_Text(pDX,IDC_ANAME_EDIT,m_Aname);DDX_Control(pDX,IDC_TYPE_DATACOMBO,m_Type);DDX_Text(pDX,IDC_MODEL_EDIT,m_Model);DDX_Text(pDX,IDC_PRODUCER_EDIT,m_Producer);DDX_Text(pDX,IDC_USEYEAR_EDIT,m_UseYear);DDX_Text(pDX,IDC_ORGPRICE_EDIT,m_OrgPrice);DDX_Text(pDX,IDC_RATIO_EDIT,m_Ratio);DDX_Text(pDX,IDC_POSTDATE_STATIC,m_PostDate);DDX_DateTimeCtrl(pDX,IDC_USEDATE,m_UseDate);DDX_Text(pDX,IDC_STATUS_EDIT,m_Status);}BEGIN_MESSAGE_MAP(CAssetsEditDlg,CDialog)41 ON_EN_CHANGE(IDC_AID_EDIT,&CAssetsEditDlg::OnEnChangeAidEdit)END_MESSAGE_MAP()BOOLCAssetsEditDlg::OnInitDialog(){CDialog::OnInitDialog();if(cAid==""){CTimet=CTime::GetCurrentTime();CStringcDate;cDate.Format(_T("%04d-%02d-%02d"),t.GetYear(),t.GetMonth(),t.GetDay());m_PostDate=cDate;m_UseDate.SetDate(t.GetYear(),t.GetMonth(),t.GetDay());m_AddWay.SetCurSel(0);}else{CStringcItem;cItem="";for(inti=0;iShowWindow(SW_HIDE);RefreshData();returnTRUE;/}voidCAssetsSelectDlg::OnSelchangeTypeCombo(){41 intiSel;iSel=m_type.GetCurSel();m_search.SetText("");if(iSel==1){m_Adodc2.SetRecordSource("SELECT*FROMTypes");m_Adodc2.Refresh();m_search.SetListField("TypeName");m_search.SetBoundColumn("TypeId");m_search.Refresh();GetDlgItem(IDC_SEARCH_DATACOMBO)->ShowWindow(SW_SHOW);}else{GetDlgItem(IDC_SEARCH_DATACOMBO)->ShowWindow(SW_HIDE);}UpdateData(FALSE);RefreshData();}BEGIN_EVENTSINK_MAP(CAssetsSelectDlg,CDialog)ON_EVENT(CAssetsSelectDlg,IDC_SEARCH_DATACOMBO,-600/*Click*/,OnClickSearchDatacombo,VTS_I2)END_EVENTSINK_MAP()voidCAssetsSelectDlg::OnClickSearchDatacombo(shortArea){cSearchValue=m_search.GetBoundText();RefreshData();}voidCAssetsSelectDlg::OnOK(){AssetsId=m_DataGrid.GetItem(0);AssetsName=m_DataGrid.GetItem(1);CDialog::OnOK();}41 7.固定资产分配界面代码设计#include"stdafx.h"#include"AssetsMan.h"#include"DistributeEditDlg.h"#include"AssetsSelectDlg.h"#include"Distribute.h"#include"Assets.h"#ifdef_DEBUG#definenewDEBUG_NEW#undefTHIS_FILEstaticcharTHIS_FILE[]=__FILE__;#endifCDistributeEditDlg::CDistributeEditDlg(CWnd*pParent/*=NULL*/):CDialog(CDistributeEditDlg::IDD,pParent){m_assets=_T("");m_name=_T("");m_date=COleDateTime::GetCurrentTime();m_aid=_T("");}voidCDistributeEditDlg::DoDataExchange(CDataExchange*pDX){CDialog::DoDataExchange(pDX);DDX_Control(pDX,IDC_ADODC1,m_adodc);DDX_Text(pDX,IDC_ASSETS_EDIT,m_assets);DDX_Control(pDX,IDC_DATACOMBO1,m_dep);DDX_Text(pDX,IDC_NAME_EDIT,m_name);DDX_DateTimeCtrl(pDX,IDC_DATETIMEPICKER1,m_date);DDX_Text(pDX,IDC_AID_EDIT,m_aid);}41 BEGIN_MESSAGE_MAP(CDistributeEditDlg,CDialog)ON_BN_CLICKED(IDC_BUTTON1,OnButton1)ON_EN_CHANGE(IDC_NAME_EDIT,&CDistributeEditDlg::OnEnChangeNameEdit)END_MESSAGE_MAP()BOOLCDistributeEditDlg::OnInitDialog(){CDialog::OnInitDialog();if(cAid==""){CTimet=CTime::GetCurrentTime();m_date.SetDate(t.GetYear(),t.GetMonth(),t.GetDay());}else{m_dep.SetBoundText(cDepId);COleVariantvtime(cDate);vtime.ChangeType(VT_DATE);COleDateTimetime4(vtime);m_date.SetDate(time4.GetYear(),time4.GetMonth(),time4.GetDay());GetDlgItem(IDC_BUTTON1)->EnableWindow(FALSE);}UpdateData(FALSE);returnTRUE;}voidCDistributeEditDlg::OnButton1(){UpdateData(TRUE);CAssetsSelectDlgdlg;dlg.flag=1;if(dlg.DoModal()==IDOK){m_assets=dlg.AssetsName;m_aid=dlg.AssetsId;UpdateData(FALSE);}}voidCDistributeEditDlg::OnOK(){UpdateData(TRUE);if(m_dep.GetBoundText()==""){MessageBox("请选择部门");41 return;}if(m_aid==""){MessageBox("请选择固定资产");return;}if(m_name==""){MessageBox("请输入负责人");return;}CDistributedis;dis.DepId=atoi(m_dep.GetBoundText());dis.EmpName=m_name;dis.Aid=m_aid;dis.CreateDate=m_date.Format("%Y-%m-%d");if(cAid=="")dis.sql_Insert();elsedis.sql_Update(cAid);CDialog::OnOK();}voidCDistributeEditDlg::OnEnChangeNameEdit(){}8.固定资产变更界面代码设计#include"stdafx.h"#include"AssetsMan.h"41 #include"AssetsChgEditDlg.h"#include"Assets.h"#include"Distribute.h"#ifdef_DEBUG#definenewDEBUG_NEW#undefTHIS_FILEstaticcharTHIS_FILE[]=__FILE__;#endifCAssetsChgEditDlg::CAssetsChgEditDlg(CWnd*pParent/*=NULL*/):CDialog(CAssetsChgEditDlg::IDD,pParent){m_aid=_T("");m_aname=_T("");m_name=_T("");m_ratio=_T("");m_useyear=_T("");}voidCAssetsChgEditDlg::DoDataExchange(CDataExchange*pDX){CDialog::DoDataExchange(pDX);DDX_Control(pDX,IDC_ADODC1,m_adodc);DDX_Text(pDX,IDC_AID_EDIT,m_aid);DDX_Text(pDX,IDC_ANAME_EDIT,m_aname);DDX_Control(pDX,IDC_DATACOMBO1,m_dep);DDX_Text(pDX,IDC_NAME_EDIT,m_name);DDX_Text(pDX,IDC_RATIO_EDIT,m_ratio);DDX_Text(pDX,IDC_USEYEAR_EDIT,m_useyear);}BEGIN_MESSAGE_MAP(CAssetsChgEditDlg,CDialog)ON_EN_CHANGE(IDC_USEYEAR_EDIT,&CAssetsChgEditDlg::OnEnChangeUseyearEdit)END_MESSAGE_MAP()BOOLCAssetsChgEditDlg::OnInitDialog(){CDialog::OnInitDialog();if(cDepId!="0")m_dep.SetBoundText(cDepId);returnTRUE;}voidCAssetsChgEditDlg::OnOK(){UpdateData(TRUE);if(m_aid==""){MessageBox("请输入固定资产编号");return;41 }if(m_aname==""){MessageBox("请输入固定资产名称");return;}if(m_dep.GetBoundText()==""){MessageBox("请选择固定资产类别");return;}CAssetsast;ast.UsedYear=atoi(m_useyear);ast.Ratio=atof(m_ratio);ast.sql_Change(m_aid);CDistributedis;dis.DepId=atoi(m_dep.GetBoundText());dis.EmpName=m_name;CTimet=CTime::GetCurrentTime();dis.CreateDate.Format(_T("%04d-%02d-%02d"),t.GetYear(),t.GetMonth(),t.GetDay());dis.sql_Update(m_aid);CDialog::OnOK();}voidCAssetsChgEditDlg::OnEnChangeUseyearEdit(){}9.固定资产折旧界面代码设计#include"stdafx.h"#include"AssetsMan.h"#include"DiscountDlg.h"41 #include"columns.h"#include"column.h"#include"COMDEF.H"#include"_recordset.h"#include"Assets.h"#ifdef_DEBUG#definenewDEBUG_NEW#undefTHIS_FILEstaticcharTHIS_FILE[]=__FILE__;#endifCDiscountDlg::CDiscountDlg(CWnd*pParent/*=NULL*/):CDialog(CDiscountDlg::IDD,pParent){}voidCDiscountDlg::DoDataExchange(CDataExchange*pDX){CDialog::DoDataExchange(pDX);DDX_Control(pDX,IDC_TYPE_COMBO,m_type);DDX_Control(pDX,IDC_ADODC1,m_Adodc);DDX_Control(pDX,IDC_DATAGRID1,m_DataGrid);}BEGIN_MESSAGE_MAP(CDiscountDlg,CDialog)ON_CBN_SELCHANGE(IDC_TYPE_COMBO,OnSelchangeTypeCombo)ON_BN_CLICKED(IDC_DISCOUNT_BUTTON,OnDiscountButton)END_MESSAGE_MAP()voidCDiscountDlg::DisInMonth(){CStringcsql;csql="SelectAIdAS资产编号ANameAS资产名称,OrgPriceAS原值RatioAS残值率,";csql+="UsedYear*12AS使用月份Y,OrgPrice*RatioAS净残值";csql+="FromAssetsWhereIsAudit=1ANDStatus='使用中D'ANDUseDate<=GetDate()";csql+="ANDIsDiscount=0";m_Adodc.SetRecordSource(csql);m_Adodc.Refresh();_variant_tvIndex;vIndex=long(0);m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(120);vIndex=long(1);m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(120);vIndex=long(2);m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(100);vIndex=long(3);m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(80);41 vIndex=long(4);m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(80);vIndex=long(5);m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(80);}voidCDiscountDlg::AllDiscountRecords(){CStringcsql;csql="SELECTAIdAS资产编号,ANameAS资产名称,OrgPriceAS原-值,RatioAS残值率,";csql+="UseDateAS使用时间,UsedYearAS使用年限T,UseMonthAS使用月份Y,";csql+="CcMonthAS计提月份Y,RatioMonthAS月折?旧率,DisPerMonthAS月折旧额,";csql+="LastPriceAS净残值,DisPriceAS已折金额?FROMv_DisCount";m_Adodc.SetRecordSource(csql);m_Adodc.Refresh();_variant_tvIndex;vIndex=long(0);m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(50);vIndex=long(1);m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(70);vIndex=long(2);m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(50);vIndex=long(3);m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(35);vIndex=long(4);m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(60);vIndex=long(5);m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(45);vIndex=long(6);m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(45);vIndex=long(7);m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(45);vIndex=long(8);m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(45);vIndex=long(9);m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(45);vIndex=long(10);m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(50);vIndex=long(11);m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(50);}BOOLCDiscountDlg::OnInitDialog(){CDialog::OnInitDialog();m_type.SetCurSel(0);41 DisInMonth();returnTRUE;}voidCDiscountDlg::OnSelchangeTypeCombo(){if(m_type.GetCurSel()==0){DisInMonth();GetDlgItem(IDC_Discount)->EnableWindow(TRUE);}else{AllDiscountRecords();GetDlgItem(IDC_Discount)->EnableWindow(FALSE);}}voidCDiscountDlg::OnDiscountButton(){CAssetscAst;cAst.BeginDiscount(m_DataGrid.GetItem(0));DisInMonth();}10.固定资产报废界面代码设计#include"stdafx.h"#include"AssetsMan.h"#include"DiscardEditDlg.h"#include"Discard.h"#ifdef_DEBUG#definenewDEBUG_NEW#undefTHIS_FILEstaticcharTHIS_FILE[]=__FILE__;41 #endifCDiscardEditDlg::CDiscardEditDlg(CWnd*pParent/*=NULL*/):CDialog(CDiscardEditDlg::IDD,pParent){m_aid=_T("");m_aname=_T("");m_createdate=_T("");m_dsum=0.0f;m_empname=_T("");m_reason=_T("");}voidCDiscardEditDlg::DoDataExchange(CDataExchange*pDX){CDialog::DoDataExchange(pDX);DDX_Text(pDX,IDC_AID_EDIT,m_aid);DDX_Text(pDX,IDC_ANAME_EDIT,m_aname);DDX_Text(pDX,IDC_CREATEDATE_EDIT,m_createdate);DDX_Text(pDX,IDC_DSUM_EDIT,m_dsum);DDX_Text(pDX,IDC_EMPNAME_EDIT,m_empname);DDX_Text(pDX,IDC_REASON_EDIT,m_reason);}BEGIN_MESSAGE_MAP(CDiscardEditDlg,CDialog)ON_EN_CHANGE(IDC_DSUM_EDIT,&CDiscardEditDlg::OnEnChangeDsumEdit)END_MESSAGE_MAP()voidCDiscardEditDlg::OnOK(){UpdateData(TRUE);if(m_dsum<0){MessageBox("请输入折算金额");return;}if(m_reason==""){MessageBox("请输入报废原因");return;}CDiscarddis;dis.Aid=m_aid;dis.DSum=m_dsum;dis.Reason=m_reason;dis.EmpName=m_empname;dis.CreateDate=m_createdate;dis.sql_Insert();41 CDialog::OnOK();}voidCDiscardEditDlg::OnEnChangeDsumEdit(){}11.用户管理界面代码设计#definenewDEBUG_NEW#undefTHIS_FILEstaticcharTHIS_FILE[]=__FILE__;#endifCUserManDlg::CUserManDlg(CWnd*pParent/*=NULL*/):CDialog(CUserManDlg::IDD,pParent){}voidCUserManDlg::DoDataExchange(CDataExchange*pDX){CDialog::DoDataExchange(pDX);DDX_Control(pDX,IDC_ADODC1,m_adodc);DDX_Control(pDX,IDC_DATALIST1,m_datalist);}BEGIN_MESSAGE_MAP(CUserManDlg,CDialog)ON_BN_CLICKED(IDC_ADD_BUTTON,OnAddButton)ON_BN_CLICKED(IDC_MODI_BUTTON,OnModiButton)ON_BN_CLICKED(IDC_DEL_BUTTON,OnDelButton)END_MESSAGE_MAP()voidCUserManDlg::OnAddButton(){CUserEditDlgdlg;dlg.iUserType=2;if(dlg.DoModal()==IDOK)41 m_adodc.Refresh();}voidCUserManDlg::OnModiButton(){if(m_datalist.GetText()==""){MessageBox("请选择用户");return;}if(curUser.UserName!="Admin"&&curUser.UserName!=m_datalist.GetText()&&m_datalist.GetBoundText()=="1"){MessageBox("只能对普通用户进行密码复位?");return;}if(MessageBox("是否对当前用户进行密码复位","请确认",MB_YESNO)==IDYES){CUsersusr;usr.UserPwd="111111";usr.sql_updatePwd(m_datalist.GetText());MessageBox("密码已经复位");}}voidCUserManDlg::OnDelButton(){if(m_datalist.GetText()==""){MessageBox("请选择用户");return;}if(curUser.UserName!="Admin"&&m_datalist.GetBoundText()=="1"){MessageBox("只能删¦除普通用户");return;}if(m_datalist.GetText()=="Admin"){MessageBox("不能删除Admin用户");return;}if(MessageBox("是否删除当前用户","请确认",MB_YESNO)==IDYES){CUsersusr;usr.sql_delete(m_datalist.GetText());41 m_adodc.Refresh();}}12.修改密码界面代码设计#include"stdafx.h"#include"AssetsMan.h"#include"ChangePwdDlg.h"#ifdef_DEBUG#definenewDEBUG_NEW#undefTHIS_FILEstaticcharTHIS_FILE[]=__FILE__;#endifCChangePwdDlg::CChangePwdDlg(CWnd*pParent/*=NULL*/):CDialog(CChangePwdDlg::IDD,pParent){m_NewPwd1=_T("");m_NewPwd2=_T("");m_OldPwd=_T("");m_UserName=_T("");}voidCChangePwdDlg::DoDataExchange(CDataExchange*pDX){CDialog::DoDataExchange(pDX);DDX_Text(pDX,IDC_NEWPWD1_EDIT,m_NewPwd1);DDX_Text(pDX,IDC_NEWPWD2_EDIT,m_NewPwd2);DDX_Text(pDX,IDC_OLDPWD_EDIT,m_OldPwd);DDX_Text(pDX,IDC_USERNAME_STATIC,m_UserName);41 BEGIN_MESSAGE_MAP(CChangePwdDlg,CDialog)ON_BN_CLICKED(IDOK,&CChangePwdDlg::OnBnClickedOk)END_MESSAGE_MAP()voidCChangePwdDlg::OnOK(){UpdateData(TRUE);if(m_OldPwd==""){MessageBox("请输入旧密码");return;}if(m_NewPwd1==""){MessageBox("请输入新密码");return;}if(m_NewPwd1!=m_NewPwd2){MessageBox("两次输入的新密码不同");return;}CUsersuser;user.GetData(m_UserName);if(user.UserPwd!=m_OldPwd){MessageBox("用户密码不正确!");return;}user.UserPwd=m_NewPwd1;user.sql_updatePwd(m_UserName);MessageBox("密码修改成功,下次登录请使用新密码");CDialog::OnOK();}voidCChangePwdDlg::OnBnClickedOk(){CDialog::OnOK();}四.结论与体会41 通过本次课程设计,对数据库的认识加深了,对编程和MFCSQLServer2000的功能有了更深层次的认识和学习。虽然在课设过程中遇到了很多这样那样的问题,但是通过和别人的讨论,上网查资料以及在图书馆翻阅资料都解决了。课设完成后感觉获取信息的能力对于我们很重要,通过课设我也提高了自己的这方面的能力。在开发过程当中,我学到很多,明白了做任何事情都要有始有终,要敢于同困难作斗争,要养成独立思考的习惯。在以后的工作和生活当中,我将继续发扬这些好的作风。参考文献[1]谭浩强.C++程序设计.北京:清华大学出版社[M].2004-11[2]伍红兵.VisualC++编程深入引导[M].北京:水利水电出版社,2005-4-1[3]陶宏才.数据库原理及设计.清华大学出版社[4]赵杰,杨丽丽.数据库原理和应用[M].北京:人民邮电出版社,2002:42-46.41

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。
关闭