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

📄 dadd.cpp

📁 c++制作固定资产管理系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
}

void CDAdd::Clear()
{
	m_EdtUseTime.SetWindowText("");
	m_EdtUnit.SetWindowText("");
	m_EdtSpec.SetWindowText("");
	m_EdtReMainsRate.SetWindowText("");
	m_EdtReMains.SetWindowText("");
	m_EdtOvalue.SetWindowText("");
	m_EdtNumber.SetWindowText("");
	m_EdtNetValue.SetWindowText("");
	m_EdtName.SetWindowText("");
	m_EdtEstimateUseTime.SetWindowText("");
	m_EdtDepreciationRate.SetWindowText("");
	m_EdtDepreciationMoney.SetWindowText("");
	m_EdtDepreciation.SetWindowText("");
	m_ComUseStatus.SetWindowText("");
	m_ComStyle.SetWindowText("");
	m_ComMeans.SetWindowText("");
	m_ComAddStyle.SetWindowText("");
	m_StaID.SetWindowText("ZC00000001");
	CTime time;
	time=time.GetCurrentTime();
	m_DtDate.SetTime(&time);
}

void CDAdd::OnButadd() 
{
	this->Clear();
	this->AddOrChange=1;
	CString sID;
	sID=ado.AutoNumber("固定资产信息表","编号","ZC",2);
	m_StaID.SetWindowText(sID);
	this->Enabled(true);
	m_DtDate.SetFocus();

}

void CDAdd::OnButchange() 
{
	this->AddOrChange=2;
	this->Enabled(true);
	m_DtDate.SetFocus();	
}

void CDAdd::OnButdelete() 
{
	if(MessageBox("删除后不可恢复!确定要删除此条固定资产记录吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)	
		return;
	CString sSQL,sID;
	this->m_StaID.GetWindowText(sID);
	sSQL.Format("DELETE FROM 固定资产信息表 WHERE 编号='%s'",sID);
	RxRecordset Delerst;
	Delerst.Open(sSQL,adCmdText);
	this->OnCancel();
}

void CDAdd::OnButsave() 
{
	if(MessageBox("确定要保存记录吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)	
		return;
	CString sSQL,sID,sName,sSpec,sUnit,sNumber,sStyle,sStyleID,sAddStyle,sAddStyleID,sUseStatus,sUseStatusID,sOvalue,sDepreciation,sNetValue,sReMainsRate,sReMains,sMeans,sMeansID,sEstimateUseTime,sUseTime,sDepreciationRate,sDepreciationMoney,sDate;
	CString slb,szt;
	int njt;
	m_StaID.GetWindowText(sID);
	m_EdtUseTime.GetWindowText(sUseTime);
	m_EdtUnit.GetWindowText(sUnit);
	m_EdtSpec.GetWindowText(sSpec);
	m_EdtReMainsRate.GetWindowText(sReMainsRate);
	m_EdtReMains.GetWindowText(sReMains);
	m_EdtOvalue.GetWindowText(sOvalue);
	m_EdtNumber.GetWindowText(sNumber);
	m_EdtNetValue.GetWindowText(sNetValue);
	m_EdtName.GetWindowText(sName);
	m_EdtEstimateUseTime.GetWindowText(sEstimateUseTime);
	m_EdtDepreciationRate.GetWindowText(sDepreciationRate);
	m_EdtDepreciationMoney.GetWindowText(sDepreciationMoney);
	m_EdtDepreciation.GetWindowText(sDepreciation);
	m_ComUseStatus.GetWindowText(sUseStatus);
	sUseStatusID=ado.FieldToOtherField("使用状况表","名称",sUseStatus,"编号",1);
	szt=ado.FieldToOtherField("使用状况表","名称",sUseStatus,"是否计提",1);
	m_ComStyle.GetWindowText(sStyle);
	sStyleID=ado.FieldToOtherField("类别表","名称",sStyle,"编号",1);
	slb=ado.FieldToOtherField("类别表","名称",sStyle,"是否计提",1);
	m_ComMeans.GetWindowText(sMeans);
	sMeansID=ado.FieldToOtherField("折旧算法表","名称",sMeans,"编号",1);
	m_ComAddStyle.GetWindowText(sAddStyle);
	sAddStyleID=ado.FieldToOtherField("增加方式表","名称",sAddStyle,"编号",1);
	CString sMsg,stip;
	if(szt=="1"&&slb=="1")
	{
		njt=1;
		stip="属于计提折旧的固定资产,\n在计提时将被操作,继续吗?";
	}
	else
	{
		njt=0;
		stip="不在计提折旧的固定资产范围内,\n在计提时不被操作,继续吗?";
	}
	CTime time;

	sMsg.Format("由于[ %s %s ]%s",sUseStatus,sStyle,stip);
	if(MessageBox(sMsg,"系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)	
	return;
	m_DtDate.GetTime(time);
	sDate=CTimeToCString(time);
	if(this->AddOrChange==1)//添加
	{
		sSQL.Format("INSERT INTO 固定资产信息表 VALUES('%s','%s','%s','%s',%s,%s,%s,%s,%s,%s,%s,%f,%s,%s,%s,%s,%f,%s,'%s',0,%d)",sID,sName,sSpec,sUnit,sNumber,sStyleID,sAddStyleID,sUseStatusID,sOvalue,sDepreciation,sNetValue,(float)atoi(sReMainsRate)/1000,sReMains,sMeansID,sEstimateUseTime,sUseTime,(float)atoi(sDepreciationRate)/1000,sDepreciationMoney,sDate,njt);	
		rst.Open(sSQL,adCmdText);
	}
	if(	this->AddOrChange==2)//修改
	{
		sSQL.Format("UPDATE 固定资产信息表 SET 名称='%s',规格型号='%s',单位='%s',数量='%s',类别=%s,增加方式=%s,使用状况=%s,入账原值=%s,累计折旧=%s,净值=%s WHERE 编号='%s'",sName,sSpec,sUnit,sNumber,sStyleID,sAddStyleID,sUseStatusID,sOvalue,sDepreciation,sNetValue,sID);	
		rst.Open(sSQL,adCmdText);
		sSQL.Format("UPDATE 固定资产信息表 SET 预计净残值率=%f,预计净残值=%s,折旧方法=%s,预计使用月份=%s,已计提月份=%s,月折旧率=%f,月折旧额=%s,入账日期='%s',计提否=%d WHERE 编号='%s'",(float)atoi(sReMainsRate)/1000,sReMains,sMeansID,sEstimateUseTime,sUseTime,(float)atoi(sDepreciationRate)/1000,sDepreciationMoney,sDate,njt,sID);	
		rst.Open(sSQL,adCmdText);
	}
	this->AddOrChange=0;
	this->Enabled(false);
	this->m_ButAdd.SetFocus();

}

void CDAdd::OnButundo() 
{		
	if(MessageBox("确定要撤消操作吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)	
		return;	
	this->Enabled(false);
	this->Clear();
	this->Display(m_sID);
	this->m_ButAdd.SetFocus();
}

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

void CDAdd::OnChangeEdtdepreciation() 
{
	CString sOvalue,sDepreciation,sNetValue;
	float fOvalue,fDepreciation,fNetValue;
	m_EdtOvalue.GetWindowText(sOvalue);
	this->m_EdtDepreciation.GetWindowText(sDepreciation);
	fOvalue=atof(sOvalue);
	fDepreciation=atof(sDepreciation);
	fNetValue=fOvalue-fDepreciation;
	sNetValue=Format(fNetValue,2);
	m_EdtNetValue.SetWindowText(sNetValue);
}

void CDAdd::OnChangeEdtovalue() 
{
	OnChangeEdtdepreciation();	
}

void CDAdd::OnChangeEdtremainsrate() 
{
	CString sReMainsRate,sReMains,sNetValue;
	float nReMainsRate,nNetValue;
	m_EdtReMainsRate.GetWindowText(sReMainsRate);
	m_EdtNetValue.GetWindowText(sNetValue);
	nNetValue=atof(sNetValue);
	nReMainsRate=atof(sReMainsRate)/1000;
	nNetValue=nNetValue*nReMainsRate;
	sReMains=Format(nNetValue,2);
	this->m_EdtReMains.SetWindowText(sReMains);
}	
void CDAdd::OnKillfocusCommeans() 
{
	CString sSQL,sID,sMeans,sMonthRate,sMonthMoney;
	m_ComMeans.GetWindowText(sMeans);
	m_StaID.GetWindowText(sID);
	sMonthRate=ado.FieldToOtherField("折旧算法表","名称",sMeans,"月折旧率",1);
	sMonthMoney=ado.FieldToOtherField("折旧算法表","名称",sMeans,"月折旧额",1);
	if(sMonthRate.IsEmpty()||sMonthMoney.IsEmpty())
		return;
	sSQL.Format("SELECT %s AS 折旧率,%s AS 折旧金额 FROM 临时表",sMonthRate,sMonthMoney);
	if(rst.Open(sSQL,adCmdText)==false)
		return;
	sMonthRate=rst.GetFieldValue("折旧率");
	sMonthMoney=rst.GetFieldValue("折旧金额");
	float fMonthRate=atof(sMonthRate)*1000;
	if(fMonthRate<1)
		fMonthRate=1;
	sMonthRate.Format("%d",(int)fMonthRate);
	sMonthMoney=Format(atof(sMonthMoney),2);
	m_EdtDepreciationRate.SetWindowText(sMonthRate);
	m_EdtDepreciationMoney.SetWindowText(sMonthMoney);
}

void CDAdd::OnSetfocusCommeans() 
{
	CString sSQL,sOvalue="0",sDepreciation="0",sNetValue="0",sReMainsRate="0",sReMains="0",sEstimateUseTime="0",sDepreciationMonth="0",sUseTime="0";
	m_EdtReMains.GetWindowText(sReMains);
	m_EdtOvalue.GetWindowText(sOvalue);
	m_EdtNetValue.GetWindowText(sNetValue);
	m_EdtReMainsRate.GetWindowText(sReMainsRate);
	m_EdtEstimateUseTime.GetWindowText(sEstimateUseTime);
	m_EdtDepreciation.GetWindowText(sDepreciation);
	sSQL.Format("DELETE FROM 临时表");
	rst.Open(sSQL,adCmdText);
	sSQL.Format("Insert into 临时表 values(%s,%s,%s,%f,%s,%s,%s,%s)",sOvalue,sDepreciation,sNetValue,atof(sReMainsRate)/1000,sReMains,sEstimateUseTime,sDepreciationMonth,sUseTime);
	rst.Open(sSQL,adCmdText);
}

void CDAdd::SetID(CString sID)
{
	this->m_sID=sID;
}

void CDAdd::OnEditchangeComusestatus() 
{
//CString UseStatus;
//	this->m_ComUseStatus(UseStatus);
	//if(UseStatus=="未使用"||UseStatus=="不需用"||UseStatus==""
}

⌨️ 快捷键说明

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