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

📄 dadd.cpp

📁 系统是最近修改的系统
💻 CPP
字号:
// DAdd.cpp : implementation file
//

#include "stdafx.h"
#include "gdzc.h"
#include "DAdd.h"

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


CDAdd::CDAdd(CWnd* pParent /*=NULL*/)
	: CDialog(CDAdd::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDAdd)
	//}}AFX_DATA_INIT
	m_font.CreatePointFont(200,"黑体",NULL);
}


void CDAdd::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDAdd)
	DDX_Control(pDX, IDC_XUHAO, m_Xuhao);
	DDX_Control(pDX, IDC_BUMEN, m_Bumen);
	DDX_Control(pDX, IDC_GUBIAN, m_Gubian);
	DDX_Control(pDX, IDC_CAIBIAN, m_Caibian);
	DDX_Control(pDX, IDC_ZHIBIAN, m_Zhibian);
	DDX_Control(pDX, IDC_EDTNAME, m_Name);
	DDX_Control(pDX, IDC_VALUE, m_Value);
	DDX_Control(pDX, IDC_NOWVALUE, m_NowValue);
	DDX_Control(pDX, IDC_NUM, m_Num);
	DDX_Control(pDX, IDC_DANWEI, m_Danwei);
	DDX_Control(pDX, IDC_USERID, m_UserId);
	DDX_Control(pDX, IDC_USER, m_User);
	DDX_Control(pDX, IDC_BEIZHU, m_Beizhu);
	DDX_Control(pDX, IDC_ZHUANGTAI, m_Zhuangtai);
    DDX_Control(pDX, IDC_POSITION, m_Position);
	DDX_Control(pDX, IDC_SUPPORT, m_Support);
	DDX_Control(pDX, IDC_BAOXIU, m_Baoxiu);

	DDX_Control(pDX, IDC_XINGHAO, m_Xinghao);
	DDX_Control(pDX, IDC_BUTUNDO, m_ButUndo);
	DDX_Control(pDX, IDC_BUTSAVE, m_ButSave);
	DDX_Control(pDX, IDC_BUTEXIT, m_ButExit);
	DDX_Control(pDX, IDC_BUTDELETE, m_BueDele);
	DDX_Control(pDX, IDC_BUTCHANGE, m_ButChange);
	DDX_Control(pDX, IDC_BUTADD, m_ButAdd);
	DDX_Control(pDX, IDC_STACAPTION, m_StaCaption);
	DDX_Control(pDX, IDC_DTDATE, m_DtDate);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDAdd, CDialog)
	//{{AFX_MSG_MAP(CDAdd)
	ON_WM_CTLCOLOR()
	ON_BN_CLICKED(IDC_BUTADD, OnButadd)
	ON_BN_CLICKED(IDC_BUTCHANGE, OnButchange)
	ON_BN_CLICKED(IDC_BUTDELETE, OnButdelete)
	ON_BN_CLICKED(IDC_BUTSAVE, OnButsave)
	ON_BN_CLICKED(IDC_BUTUNDO, OnButundo)
	ON_BN_CLICKED(IDC_BUTEXIT, OnButexit)
	ON_EN_CHANGE(IDC_EDTDEPRECIATION, OnChangeEdtdepreciation)
	ON_EN_CHANGE(IDC_EDTOVALUE, OnChangeEdtovalue)
	ON_EN_CHANGE(IDC_EDTREMAINSRATE, OnChangeEdtremainsrate)
	ON_CBN_KILLFOCUS(IDC_COMMEANS, OnKillfocusCommeans)
	ON_CBN_SETFOCUS(IDC_COMMEANS, OnSetfocusCommeans)
	ON_CBN_EDITCHANGE(IDC_COMUSESTATUS, OnEditchangeComusestatus)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDAdd message handlers

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

BOOL CDAdd::OnInitDialog() 
{

	CDialog::OnInitDialog();
	CString sSQL;
/*	rst.Open("使用状况表");
	this->m_ComUseStatus.SetRecordset(rst,"名称");
	rst.Open("增加方式表");
	this->m_ComAddStyle.SetRecordset(rst,"名称");
	rst.Open("类别表");
	this->m_ComStyle.SetRecordset(rst,"名称");
	rst.Open("折旧算法表");
	this->m_ComMeans.SetRecordset(rst,"名称");*/
	MessageBox(m_sID);
	if(m_sID.IsEmpty())
	{

		m_ButChange.EnableWindow(false);
		m_BueDele.EnableWindow(false);
		return true;
	}
	this->Display(m_sID);

/*	CString js=ado.FieldToOtherField("固定资产信息表","编号",m_sID,"减少否",1);
	if(js=="1")
	{
		this->m_StaICo.ShowWindow(SW_SHOW);
		this->m_StaIcoText.ShowWindow(SW_SHOW);
	}*/
	sSQL.Format("select * from 创维固定资产信息表  where 工号='%s'",m_sID); 
	
	// TODO: Add extra initialization here
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

HBRUSH CDAdd::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
	HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
/*、*	if(pWnd->GetSafeHwnd()==m_StaCaption.GetSafeHwnd())
		pDC->SelectObject(&m_font);
	if(pWnd->GetSafeHwnd()==this->m_StaIcoText.GetSafeHwnd())
		pDC->SetTextColor(RGB(255,0,0));*/
	// TODO: Return a different brush if the default is not desired
	return hbr;
}

BOOL CDAdd::DestroyWindow() 
{
/*	m_font.DeleteObject();	*/
	return CDialog::DestroyWindow();
}

void CDAdd::Display(CString sID)
{
	RxRecordset DspRst;
	CString sSQL;
    sSQL.Format("select * from 创维固定资产信息表  where 固定资产编码='%s'",m_sID); 
	if (true==DspRst.Open(sSQL,adCmdText))
	{
		MessageBox("ok");
	}
	else
		MessageBox("NULL");
	
	CString sXinghao,sXuhao,sBumen,sGubian,sCaibian,sZhibian,sName,sValue,sNowValue,sNum,sDanwei,sUser,sUserId,sBeizhu,sZhuangtai,sPosition,sSupport,sBaoxiu,sDate;

	sXuhao=DspRst.GetFieldValue("序号");
 	sBumen=DspRst.GetFieldValue("部门");
	sGubian=DspRst.GetFieldValue("固定资产编码");
	sCaibian=DspRst.GetFieldValue("财务编码");
	sZhibian=DspRst.GetFieldValue("制造编码");
	sName=DspRst.GetFieldValue("资产名称");
	sValue=DspRst.GetFieldValue("价值");
	sNowValue=DspRst.GetFieldValue("现价");
	sNum=DspRst.GetFieldValue("数量");
	sDanwei=DspRst.GetFieldValue("单位");
    sXinghao=DspRst.GetFieldValue("品牌型号");
	sUser=DspRst.GetFieldValue("使用人");
	sUserId=DspRst.GetFieldValue("工号");
	sBeizhu=DspRst.GetFieldValue("备注");
	sZhuangtai=DspRst.GetFieldValue("当前状态");
	sPosition=DspRst.GetFieldValue("资产所在地");
	sSupport=DspRst.GetFieldValue("供应商");
	sBaoxiu=DspRst.GetFieldValue("保修期限");
	sDate=DspRst.GetFieldValue("入帐日期");



	m_Xuhao.SetWindowText(sXuhao);
	m_Bumen.SetWindowText(sBumen);
	m_Gubian.SetWindowText(sGubian);
	m_Caibian.SetWindowText(sCaibian);
	m_Zhibian.SetWindowText(sZhibian);
	m_Name.SetWindowText(sName);	
	m_Value.SetWindowText(sValue);
	m_NowValue.SetWindowText(sNowValue);
	m_Num.SetWindowText(sNum);
	m_Danwei.SetWindowText(sDanwei);
	m_User.SetWindowText(sUser);
	m_UserId.SetWindowText(sUserId);
	m_Beizhu.SetWindowText(sBeizhu);
	m_Zhuangtai.SetWindowText(sZhuangtai);
    m_Position.SetWindowText(sPosition);
	m_Support.SetWindowText(sSupport);
	m_Baoxiu.SetWindowText(sBaoxiu);
	m_Xinghao.SetWindowText(sXinghao);
	CTime time;
	time=CStringTOCTime(sDate);
	m_DtDate.SetTime(&time);
	

}

void CDAdd::Enabled(bool bEnabled)
{
	m_Xuhao.EnableWindow(bEnabled);
	m_Bumen.EnableWindow(bEnabled);
	m_Gubian.EnableWindow(bEnabled);
	m_Caibian.EnableWindow(bEnabled);
	m_Zhibian.EnableWindow(bEnabled);
	m_Name.EnableWindow(bEnabled);
	m_User.EnableWindow(bEnabled);
	m_Num.EnableWindow(bEnabled);
	m_Danwei.EnableWindow(bEnabled);
	m_UserId.EnableWindow(bEnabled);
	m_Value.EnableWindow(bEnabled);
	m_Xinghao.EnableWindow(bEnabled);
	m_Beizhu.EnableWindow(bEnabled);
	m_Zhuangtai.EnableWindow(bEnabled);
	m_NowValue.EnableWindow(bEnabled);
    m_Position.EnableWindow(bEnabled);
	m_Support.EnableWindow(bEnabled);
	m_Baoxiu.EnableWindow(bEnabled);
	m_ButUndo.EnableWindow(bEnabled);
	m_ButSave.EnableWindow(bEnabled);
	m_ButExit.EnableWindow(!bEnabled);
	m_BueDele.EnableWindow(!bEnabled);
	m_ButChange.EnableWindow(!bEnabled);
	m_ButAdd.EnableWindow(!bEnabled);

}

void CDAdd::Clear()
{
	m_Xuhao.SetWindowText("");
	m_Bumen.SetWindowText("总裁办");
	m_Gubian.SetWindowText("SMC2007");
	m_Caibian.SetWindowText("");
	m_Zhibian.SetWindowText("");
	m_Name.SetWindowText("");	
	m_Value.SetWindowText("1000");
	m_NowValue.SetWindowText("100");
	m_Num.SetWindowText("1");
	m_Danwei.SetWindowText("台");
	m_User.SetWindowText("");
	m_UserId.SetWindowText("SMC00");
	m_Beizhu.SetWindowText("正常");
	m_Zhuangtai.SetWindowText("使用中");
    m_Position.SetWindowText("大厦");
	m_Support.SetWindowText("");
	m_Baoxiu.SetWindowText("1");
	CTime time;
	time=time.GetCurrentTime();
	m_DtDate.SetTime(&time);

}

void CDAdd::OnButadd() 
{
	this->Clear();
	this->AddOrChange=1;
	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_Gubian.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 sXinghao,sXuhao,sBumen,sGubian,sCaibian,sZhibian,sName,sValue,sNowValue,sNum,sDanwei,sUser,sUserId,sBeizhu,sZhuangtai,sPosition,sSupport,sBaoxiu,sDate;


	m_Xuhao.GetWindowText(sXuhao);
	m_Bumen.GetWindowText(sBumen);
	m_Gubian.GetWindowText(sGubian);
	m_Caibian.GetWindowText(sCaibian);
	m_Zhibian.GetWindowText(sZhibian);
	m_Name.GetWindowText(sName);
	m_Value.GetWindowText(sValue);
	m_NowValue.GetWindowText(sNowValue);
	m_Num.GetWindowText(sNum);
	m_Danwei.GetWindowText(sDanwei);
	m_User.GetWindowText(sUser);
	m_UserId.GetWindowText(sUserId);
	m_Beizhu.GetWindowText(sBeizhu);
	m_Zhuangtai.GetWindowText(sZhuangtai);
	m_Position.GetWindowText(sPosition);
	m_Support.GetWindowText(sSupport);
	m_Baoxiu.GetWindowText(sBaoxiu);
	m_Xinghao.GetWindowText(sXinghao);


	CTime time;
	CString sMsg,stip,sSQL;
//	sMsg.Format("由于[ %s %s ]%s",sUseStatus,sStyle,stip);
	if(MessageBox(sMsg,"系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)	
	return;
	m_DtDate.GetTime(time);
	sDate=CTimeToCString(time);
    MessageBox(sXinghao);
	if(this->AddOrChange==1)//添加
	{
		sSQL.Format("INSERT INTO 创维固定资产信息表 (序号,部门,固定资产编码,财务编码,制造编码,资产名称,数量,单位,品牌型号,价值,现价,使用人,工号,备注,当前状态,资产所在地,供应商,保修期限,入帐日期) VALUES('%s','%s','%s','%s','%s','%s',%s,'%s','%s',%s,%s,'%s','%s','%s','%s','%s','%s',%s,'%s')",sXuhao,sBumen,sGubian,sCaibian,sZhibian,sName,sNum,sDanwei,sXinghao,sValue,sNowValue,sUser,sUserId,sBeizhu,sZhuangtai,sPosition,sSupport,sBaoxiu,sDate);

		if (true==rst.Open(sSQL,adCmdText))
		{
			MessageBox("ok");
		}
		else
			MessageBox("gg");

	}
	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);	
        sSQL.Format("UPDATE 创维固定资产信息表 SET 部门='%s',使用人='%s',工号='%s',当前状态='%s',资产所在地='%s' WHERE 固定资产编码='%s'",sBumen,sUser,sUserId,sZhuangtai,sPosition,sGubian);                                                                            
		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 + -