?? 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 Id,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(0);
vIndex = long(1);
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(120);
vIndex = long(2);
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(120);
vIndex = long(3);
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(100);
vIndex = long(4);
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(80);
vIndex = long(5);
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(80);
vIndex = long(6);
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(80);
}
void CDiscountDlg::AllDiscountRecords()
{
// 所有已經折舊的資產信息
CString csql;
csql = "SELECT Id,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(0);
vIndex = long(1); // 資產編號
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(50);
vIndex = long(2); // 資產名稱
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(70);
vIndex = long(3); // 原值
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(50);
vIndex = long(4); // 殘值率
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(35);
vIndex = long(5); // 使用時間
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(60);
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(45);
vIndex = long(11); // 凈殘值
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(50);
vIndex = long(12); // 已折舊金額
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();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -