⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 djt.cpp

📁 c++制作固定资产管理系统
💻 CPP
字号:
// Djt.cpp : implementation file
//

#include "stdafx.h"
#include "gdzc.h"
#include "Djt.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "ExternDllHeader.h"

/////////////////////////////////////////////////////////////////////////////
// CDjt dialog


CDjt::CDjt(CWnd* pParent /*=NULL*/)
	: CDialog(CDjt::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDjt)
	//}}AFX_DATA_INIT
}


void CDjt::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDjt)
	DDX_Control(pDX, IDC_DTDATE, m_DtDate);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDjt, CDialog)
	//{{AFX_MSG_MAP(CDjt)
	ON_BN_CLICKED(IDC_BUTJT, OnButjt)
	ON_BN_CLICKED(IDC_BUTEXIT, OnButexit)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDjt message handlers

void CDjt::OnOK() 
{
	// TODO: Add extra validation here
	
	//CDialog::OnOK();
}

void CDjt::OnButjt() 
{
	if(MessageBox("确定执行计提折旧吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)
		return;
	//筛选出可以计提的记录
	CString sSQL,sSQL1,sSQL2,sSQL3;
	sSQL1.Format("SELECT * FROM 固定资产信息表 WHERE 计提否=1");
	//筛选出不是本月新加入的设备
	CTime tTime,tTime2;
	this->m_DtDate.GetTime(tTime);
	int nYear,nMonth;
	nYear=tTime.GetYear();
	nMonth=tTime.GetMonth();
	tTime2=CTime(nYear,nMonth,1,0,0,0,-1);
	RxRecordset uRst;
	CString sID,sDepreciation,sOValue,sNetValue,sMeans,sEstimateUseTime,sUseTime,sDepreciationRate,sDepreciationMoney,sMonthRate,sMonthMoney,sDate;
	int nUseTime;
	CString sDate2;
	sDate2=CTimeToCString(tTime2);
	float nDepreciation,nNetValue;
	sDate=CTimeToCString(tTime);

	sSQL.Format("SELECT * FROM 计提表 WHERE YEAR(计提日期)=%d AND MONTH(计提日期)=%d",nYear,nMonth);
	uRst.Open(sSQL,adCmdText);
	if(uRst.GetRecordCount()>=1)
	{
		MessageBox("本月已经计提折旧过,无需要重复操作!","系统提示",MB_OK|MB_ICONSTOP);
		return;
	}

	sSQL2.Format("SELECT * FROM (%s) DERIVEDTBL WHERE 入账日期<='%s'",sSQL1,sDate2);
	//筛选出本月以前没有减少的设备
	sSQL3.Format("SELECT * FROM (%s) DERIVEDTBL WHERE 减少否!=1  OR 减少否=1 AND Year(入账日期)=%d AND Month(入账日期)=%d",sSQL2,nYear,nMonth);
	rst.Open(sSQL3,adCmdText);
	if(rst.GetRecordCount()<1)
	{
		MessageBox("本月没有可以折旧的固定资产,固定资产本月刚加入或上月已减少!","系统提示",MB_OK|MB_ICONSTOP);
		return;
	}
	for(int i=0;i<rst.GetRecordCount();i++)
	{
		rst.Move(i);
		sID=rst.GetFieldValue("编号");
		sEstimateUseTime=rst.GetFieldValue("预计使用月份");
		sUseTime=rst.GetFieldValue("已计提月份");
		if(sUseTime==sEstimateUseTime)
			continue;
		sDepreciationMoney=rst.GetFieldValue("月折旧额");
		sDepreciation=rst.GetFieldValue("累计折旧");
		sNetValue=rst.GetFieldValue("净值");
		sOValue=rst.GetFieldValue("入账原值");
		sMeans=rst.GetFieldValue("折旧方法");
		sDepreciationRate=rst.GetFieldValue("月折旧率");
		sDepreciationMoney=rst.GetFieldValue("月折旧额");
		//存入计提表
		sSQL.Format("INSERT INTO 计提表 VALUES('%s',%s,%s,%s,%s,%s,%s,'%s')",sID,sDepreciation,sNetValue,sUseTime,sMeans,sDepreciationRate,sDepreciationMoney,sDate);
		uRst.Open(sSQL,adCmdText);
		//更改已计提月份
		nUseTime=atoi(sUseTime)+1;
		//更改累计折旧
		nDepreciation=atof(sDepreciation)+atof(sDepreciationMoney);
		//计算出净值 
		nNetValue=atof(sOValue)-nDepreciation;
		sSQL.Format("UPDATE 固定资产信息表 SET 已计提月份=%d,累计折旧=%f,净值=%f WHERE 编号='%s'",nUseTime,nDepreciation,nNetValue,sID);
		uRst.Open(sSQL,adCmdText);
		this->UpdateWindow();
		//根据计提算法重表计算折旧金额
		sMonthRate=ado.FieldToOtherField("折旧算法表","编号",sMeans,"月折旧率",2);
		sMonthMoney=ado.FieldToOtherField("折旧算法表","编号",sMeans,"月折旧额",2);
		sSQL.Format("SELECT %s AS 折旧率,%s AS 折旧金额 FROM 固定资产信息表 WHERE 编号='%s'",sMonthRate,sMonthMoney,sID);
		uRst.Open(sSQL,adCmdText);
		if(uRst.GetRecordCount()<1)
		{
			MessageBox("本月没有可以折旧的固定资产,固定资产本月刚加入或上月已减少!","系统提示",MB_OK|MB_ICONSTOP);
			return;
		}
		sMonthRate=uRst.GetFieldValue("折旧率");
		sMonthMoney=uRst.GetFieldValue("折旧金额");	
		sSQL.Format("UPDATE  固定资产信息表 SET 月折旧率 =%s,月折旧额=%s WHERE 编号='%s'",sMonthRate,sMonthMoney,sID);
		uRst.Open(sSQL,adCmdText);
	}
	CString sMsg;
	sMsg.Format("计提成功!有%d条固定资产记录被计提折旧!",i);
	MessageBox(sMsg,"系统提示",MB_OK|MB_ICONINFORMATION);

}

void CDjt::OnButexit() 
{
	this->OnCancel();	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -