【VC开源代码栏目提醒】:网学会员鉴于大家对VC开源代码十分关注,论文会员在此为大家搜集整理了“DiscountDlg.cpp”一文,供大家参考学习
// DiscountDlg.cpp : implementation file
//
#include "stdafx.h"
#include "AssetsMan.h"
#include "DiscountDlg.h"
#include "columns.h"
#include "column.h"
#include "COMDEF.H"
#include "_recordset.h"
#include "Assets.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDiscountDlg dialog
CDiscountDlg::CDiscountDlg(CWnd* pParent /*=NULL*/)
: CDialog(CDiscountDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CDiscountDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CDiscountDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDiscountDlg)
DDX_Control(pDX, IDC_TYPE_COMBO, m_type);
DDX_Control(pDX, IDC_ADODC1, m_Adodc);
DDX_Control(pDX, IDC_DATAGRID1, m_DataGrid);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDiscountDlg, CDialog)
//{{AFX_MSG_MAP(CDiscountDlg)
ON_CBN_SELCHANGE(IDC_TYPE_COMBO, OnSelchangeTypeCombo)
ON_BN_CLICKED(IDC_DISCOUNT_BUTTON, OnDiscountButton)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDiscountDlg message handlers
void CDiscountDlg::DisInMonth()
{
// 需要计提折旧的资产信息:审核通过(IsAudit=1)、正在使用的(Status="使用中")
// 使用日期小于本月(UseDate<本月)
CString csql;
csql = "Select AId AS 资产编号,AName AS 资产名称,OrgPrice AS 原值,Ratio AS 残值率,";
csql += "UsedYear*12 AS 使用月份,OrgPrice*Ratio AS 净残值";
csql += " From Assets Where IsAudit=1 AND Status='使用中' AND UseDate<=GetDate()";
csql += " AND IsDiscount=0";
m_Adodc.SetRecordSource(csql);
m_Adodc.Refresh();
// 设置列宽度
_variant_t vIndex;
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);
vIndex = long(4);
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(80);
vIndex = long(5);
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(80);
}
void CDiscountDlg::AllDiscountRecords()
{
// 所有已经折旧的资产信息
CString csql;
csql = "SELECT AId AS 资产编号,AName AS 资产名称,OrgPrice AS 原值,Ratio AS 残值率,";
csql += "UseDate AS 使用时间, UsedYear AS 使用年限, UseMonth AS 使用月份,";
csql += "CcMonth AS 计提月份, RatioMonth AS 月折旧率, DisPerMonth AS 月折旧额,";
csql += "LastPrice AS 净残值, DisPrice AS 已折金额 FROM v_DisCount";
m_Adodc.SetRecordSource(csql);
m_Adodc.Refresh();
// 设置列宽度
_variant_t vIndex;
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);
}
BOOL CDiscountDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_type.SetCurSel(0); //设置查询类别为未折旧
DisInMonth(); //显示未折旧记录
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDiscountDlg::OnSelchangeTypeCombo()
{
// 当查询条件变更时执行不同的查询方法
if(m_type.GetCurSel()==0)
{
DisInMonth();
GetDlgItem(IDC_Discount)->EnableWindow(TRUE);
}
else
{
AllDiscountRecords();
GetDlgItem(IDC_Discount)->EnableWindow(FALSE);
}
}
void CDiscountDlg::OnDiscountButton()
{
CAssets cAst;
cAst.BeginDiscount(m_DataGrid.GetItem(0));
DisInMonth();
}
上一篇:
frmBirthRemind.frm
下一篇:
科研管理杂志简介