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

📄 updateequip.cpp

📁 软件提供了完善的资产及设备档案管理,支持资产及设备的增加、删除、修改、清理等基本管理环节。软件同时提供了资产及设备的借出与归还管理,资产及设备转移管理,资产及设备维修管理
💻 CPP
📖 第 1 页 / 共 2 页
字号:
		}
		else
			MessageBox("没有发现符合条件的数据","提示",64);		
	}
	else
		MessageBox("请设置查询条件","提示",64);	
}

BOOL CUpdateEquip::PreTranslateMessage(MSG* pMsg) 
{
	if (pMsg->message ==WM_KEYDOWN)
		if (pMsg->wParam ==13)
			pMsg->wParam = 9;	
	return CDialog::PreTranslateMessage(pMsg);
}

void CUpdateEquip::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult) 
{
	int row = list.GetSelectionMark();
	CString str;
	if (row !=-1)
	{	
		CWnd * temp;
		temp = this;
		for (int i= 0;i<16;i++)
		{
			temp = this->GetNextDlgTabItem(temp);
			str =list.GetItemText(row,i+1); //对于表格list,0对应于编号,
			temp->SetWindowText(str);
		}	
		//对于折旧方法和入账日期单独赋值
		str = list.GetItemText(row,14);
		if (str == "平均年限法1")
			depremethod.SetCurSel(0);
		else
			depremethod.SetCurSel(1);
		str = list.GetItemText(row,11);
		CTime t ;
		t = theApp.StrToTime(str);
		regdate.SetTime(&t);
		//显示资产编号
		str = list.GetItemText(row,0);
		equipid.SetWindowText(str);
	}
	*pResult = 0;
}

void CUpdateEquip::OnChangeSourcevalue() 
{
	CString temp1,temp2;
	sourcevalue.GetWindowText(temp1);
	addupdepre.GetWindowText(temp2);
	if ((temp1.IsEmpty())|(temp2.IsEmpty())) //如果入账原值或累计折旧为空,净值为空
	{
		purevalue.SetWindowText("");
	}
	else
	{
		float source,add,netvalue;
		source = atof(temp1);
		add = atof(temp2);
		netvalue = source-add;
		CString temp3;
		temp3.Format("%f",netvalue);
		purevalue.SetWindowText(temp3);
	}
	OnChangePrepurserate();//计算预计净残值	
}

void CUpdateEquip::OnChangeAddupdepre() 
{
	OnChangeSourcevalue(); //调用入账原值改变时的事件
}

void CUpdateEquip::OnChangePurevalue() 
{
	//月折旧额 =( 入账原值-累计折旧-预计净残值)/(预计使用月份-已计提月份)
	CString c_temp1,c_temp2,c_temp3,c_temp4,c_temp5;
	sourcevalue.GetWindowText(c_temp1);
	addupdepre.GetWindowText(c_temp2);
	prepurevalue.GetWindowText(c_temp3);
	preusemonth.GetWindowText(c_temp4);
	depremonth.GetWindowText(c_temp5);
	if (c_temp1.IsEmpty()|c_temp2.IsEmpty()|c_temp3.IsEmpty()|c_temp4.IsEmpty()|c_temp5.IsEmpty())
	{
		monthdeprevalue.SetWindowText("");
	}
	else
	{
		float f_value1,f_value2,f_value3,f_value4,f_value5,f_value;
		f_value1 = atof(c_temp1);
		f_value2 = atof(c_temp2);
		f_value3 = atof(c_temp3);
		f_value4 = atof(c_temp4);
		f_value5 = atof(c_temp5);
		f_value = (f_value1-f_value2-f_value3)/(f_value4-f_value5);
		CString temp;
		temp.Format("%f",f_value);
		monthdeprevalue.SetWindowText(temp);
	}	
}

void CUpdateEquip::OnChangePrepurserate() 
{
	CString temp1,temp2;
	prepurerate.GetWindowText(temp1); //获得净残值率
	sourcevalue.GetWindowText(temp2);//获入账原值
	if ((temp1.IsEmpty())|(temp2.IsEmpty())) //如果净值或净残值率为空,清空净残值
	{
		prepurevalue.SetWindowText("");		
	}
	else
	{
		float netrate,value,netvalue;
		netrate = atof(temp1);
		value = atof(temp2);
		//净残值 = 入账原值 * 净残值率
		netvalue = value * netrate;
		CString temp3;
		temp3.Format("%f",netvalue);
		prepurevalue.SetWindowText(temp3);	
	}
	OnChangePreusemonth();//计算月折旧率	
}

void CUpdateEquip::OnChangePreusemonth() 
{
	CString temp1,temp2;
	preusemonth.GetWindowText(temp1); //获得预计使用月份
	prepurerate.GetWindowText(temp2);//获得净残值率
	if ((temp1.IsEmpty())|(temp2.IsEmpty())) //如果预计使用月份或净残值率为空,清空月折旧率
	{
		monthdeprerate.SetWindowText("");		
	}
	else
	{
		float monthrate,value,monthvalue;
		monthvalue = atof(temp1);
		value = atof(temp2);
		//月折旧率 = (1 - 净残值率)/预计使用月份
		monthrate = (1- value)/(monthvalue);
		CString temp3;
		temp3.Format("%f",monthrate);
		monthdeprerate.SetWindowText(temp3);	
	}	
}

void CUpdateEquip::OnChangeDepremonth() 
{
	if (depremethod.GetCurSel()==1)//平均年限法2
		OnChangePurevalue();	
}

void CUpdateEquip::OnSelchangeDepremethod() 
{
	if (depremethod.GetCurSel()==-1)
		monthdeprevalue.SetWindowText("");
	else if (depremethod.GetCurSel()==0) //平均年限法1
	{
		CString value1,value2;
		sourcevalue.GetWindowText(value1);//获取入账原值
		monthdeprerate.GetWindowText(value2);
		if ((value1.IsEmpty())|(value2.IsEmpty())) //如果入账原值或月折旧率为空,月折旧额为空
			monthdeprevalue.SetWindowText("");
		else //计算月折旧额
		{
			//月折旧额 = 入账原值*月折旧率
			float m_value,m_rate,s_value;
			m_rate = atof(value2);
			s_value = atof(value1);
			m_value = s_value * m_rate;
			CString c_value;
			c_value.Format("%f",m_value);
			monthdeprevalue.SetWindowText(c_value);
		}
	}
	else //平均年限法2
	{		
		OnChangePurevalue(); //调用预计净残值改变时的事件		
	}	
}

void CUpdateEquip::OnChangeMonthdeprerate() 
{
	OnSelchangeDepremethod() ;	
}

void CUpdateEquip::OnButtonupdate() 
{
	CString id;
	equipid.GetWindowText(id);
	if (!id.IsEmpty())
	{
		if(!InfoIsNull())
		{
			if(!IsNegative())
			{
				if (MessageBox("确实要修改资产信息吗?","提示",MB_YESNO)==IDYES)
				{
					float f_sourcevalue,f_addupdepre,f_netvalue,f_prenetrate,f_prenetvalue,f_premonth,f_month,f_deprevalue,f_deprerate;
					CTime t;
					regdate.GetTime(t);
					CString arrays[16];		
					CWnd * temp;
					temp = this;
					for (int i= 0;i<16;i++)
					{
						temp = this->GetNextDlgTabItem(temp);
						temp->GetWindowText(arrays[i]);
					}
					f_sourcevalue = atof(arrays[3]);
					f_addupdepre = atof(arrays[4]);
					f_netvalue = atof(arrays[5]);
					f_prenetrate = atof(arrays[8]);
					f_prenetvalue = atof(arrays[9]);
					f_premonth = atoi(arrays[11]);
					f_month = atoi(arrays[12]);
					f_deprerate = atof(arrays[14]);
					f_deprevalue = atof(arrays[15]);			
					CString sql;
					sql.Format("update tb_equipmentinfo set name = '%s',kinds = '%s',addkind = '%s',sourcevalue = %f,depreciation = %f ,netvalue= %f,spec = '%s',usestate = '%s',prenetvaluerate = %f,prenetvalue = %f,regdate = '%s',preusemonth = %f,depreciationmonth = %f,depremethod = '%s',monthdeprerate = %f,monthdeprevalue = %f,enabled = %d where equipmentid = '%s' ",arrays[0],arrays[1],arrays[2],f_sourcevalue,f_addupdepre,f_netvalue,arrays[6],arrays[7],f_prenetrate,f_prenetvalue,arrays[10],f_premonth,f_month,arrays[13],f_deprerate,f_deprevalue,0,id);
					try
					{
						theApp.datamanage->ExecSQL(sql);
						MessageBox("修改成功","提示",64);
					}
					catch(...)
					{
						MessageBox("修改失败","提示",64);
					}
					OnButtonrefresh() ;
				}
			}
			else
				MessageBox("资产信息不能出现负数","提示",64);
		}
		else
			MessageBox("资产信息不能为空","提示",64);
	}
	else
		MessageBox("资产编号不能为空","提示",64);	
}

bool CUpdateEquip::InfoIsNull()
{
	CWnd * temp;
	temp = this;
	for (int i= 0;i<16;i++)
	{
		temp = this->GetNextDlgTabItem(temp);
		CString str;
		temp->GetWindowText(str);
		if (str.IsEmpty())
		{
			return true;	
		}
	}
	return false;
}

bool CUpdateEquip::IsNegative()
{
	CString c_value1,c_value2,c_value3,c_value4,c_value5,c_value6,c_value7,c_value8;
	float f_value1,f_value2,f_value3,f_value4,f_value5,f_value6,f_value7,f_value8;
	sourcevalue.GetWindowText(c_value1);//入账原值
	addupdepre.GetWindowText(c_value2);//累计折旧
	purevalue.GetWindowText(c_value3);//净值
	prepurevalue.GetWindowText(c_value4);//净残值率
	preusemonth.GetWindowText(c_value5);//预计使用月份
	depremonth.GetWindowText(c_value6);//已计提月份
	monthdeprerate.GetWindowText(c_value7);//月折旧率
	monthdeprevalue.GetWindowText(c_value8); //月折旧额
	f_value1 = atof(c_value1);
	f_value2 = atof(c_value2);
	f_value3 = atof(c_value3);
	f_value4 = atof(c_value4);
	f_value5 = atof(c_value5);
	f_value6 = atof(c_value6);
	f_value7 = atof(c_value7);
	f_value8 = atof(c_value8);
	if ((f_value1 <0)|(f_value2<0)|(f_value3<0)|(f_value4 <0)|(f_value5 <0)|(f_value6 <0)|(f_value7 <0))
		return true;
	else
		return false;
}

void CUpdateEquip::OnButtonclose() 
{
	EndDialog(0);	
}

⌨️ 快捷键说明

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