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

📄 inputdlg.cpp

📁 LibraryManageDM.rar 数据库设计图书馆管理系统
💻 CPP
字号:
// InputDlg.cpp : implementation file
//

#include "stdafx.h"
#include "LibraryManage.h"
#include "InputDlg.h"
#include "ReaderInfoSet.h"
#include "ReaderTypeSet.h"
#include "CommonFunc.h"
// CInputDlg dialog

IMPLEMENT_DYNAMIC(CInputDlg, CDialog)

CInputDlg::CInputDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CInputDlg::IDD, pParent)
    , strType_(_T(""))
    , dNumber_(0.0)
    , strType(_T(""))
    , strContent(_T(""))
    , strWindowTitle(_T(""))
    , strMarks(_T("备注说明"))
    , bModify_(FALSE)
    , strRemarks_(_T(""))
    , dPunish_(0.0)
    , dPunishLimit_(0.0)
    , bPunish_(FALSE)
{

}

CInputDlg::~CInputDlg()
{
}

void CInputDlg::DoDataExchange(CDataExchange* pDX)
{
    CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CInputDlg)
    DDX_Text(pDX, IDC_EDIT_TYPE, strType_);
    DDX_Text(pDX, IDC_EDIT_CONTENT, dNumber_);
    DDX_Control(pDX, IDC_EDIT_TYPE, ctrlType);
    DDX_Text(pDX, IDC_TYPE, strType);
    DDX_Text(pDX, IDC_CONTENT, strContent);
	DDX_Text(pDX, IDC_SMARK, strMarks);
    DDX_Text(pDX, IDC_EDIT_REMARKS, strRemarks_);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CInputDlg, CDialog)
	//{{AFX_MSG_MAP(CInputDlg)	
    ON_EN_CHANGE(IDC_EDIT_TYPE, OnEnChangeEditType)
    ON_BN_CLICKED(IDOK, OnBnClickedOk)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


BOOL CInputDlg::OnInitDialog()
{
    CDialog::OnInitDialog();

    // TODO:  Add extra initialization here
    SetWindowText(strWindowTitle);
    ctrlType.SetReadOnly(bModify_);
    if (bPunish_)
    {
        strRemarks_ = _T("0");
        GetDlgItem(IDC_EDIT_REMARKS)->EnableWindow(FALSE);
        GetDlgItem(IDOK)->EnableWindow(FALSE);
    }
    UpdateData(FALSE);
    return TRUE;  // return TRUE unless you set the focus to a control
    // EXCEPTION: OCX Property Pages should return FALSE
}

void CInputDlg::OnEnChangeEditType()
{
    // TODO:  If this is a RICHEDIT control, the control will not
    // send this notification unless you override the CDialog::OnInitDialog()
    // function and call CRichEditCtrl().SetEventMask()
    // with the ENM_CHANGE flag ORed into the mask.

    // TODO:  Add your control notification handler code here
    UpdateData();
    if (!bPunish_ || strType_.IsEmpty())return;
    QueryPunishInfo(strType_, dPunish_);
    strRemarks_.Format(_T("%f"), dPunish_);
    if (dPunish_)GetDlgItem(IDOK)->EnableWindow(TRUE);
    UpdateData(FALSE);
}

void CInputDlg::OnBnClickedOk()
{
    // TODO: Add your control notification handler code here
	UpdateData(TRUE);
	if (strType_.IsEmpty())
	{
		CString str;
		str.Format(_T("请输入%s"), strType);
		AfxMessageBox(str);
		return ;
	}
    if (bPunish_)
	{
		if (dNumber_ <= 0.0)
		{
			AfxMessageBox(_T("请输入缴纳数目!"));
			GetDlgItem(IDC_EDIT_CONTENT)->SetFocus();
			return;
		}
		else
		{
			//! 查询罚款记录
			QueryPunishInfo(strType_, dPunish_);
			
			//! 查询读者类型
			CString strReaderType;
			if (!QueryReaderType(strType_, strReaderType)) return;
			
			//! 查询罚款最大限额
			if (!QueryPunishLimit(strReaderType, dPunishLimit_))return ;
			
			if (dNumber_ - dPunish_ > 0)
			{
				CString str;
				str.Format(_T("找零%f"), dNumber_ - dPunish_);
				MessageBox(str, theApp.strSystemName, MB_ICONINFORMATION);
			}
			if (dPunish_ - dNumber_>= dPunishLimit_)
			{
				if (IDYES != MessageBox(_T("剩余的罚款依然会让您无法借书!\n\n确定只缴纳这么多?"), 
					theApp.strSystemName, MB_ICONINFORMATION | MB_YESNO))return;
			}
			
			//! 缴纳罚款
			if (UpdatePunishInfo(strType_, -dNumber_))
				MessageBox(_T("罚款缴纳成功!"), theApp.strSystemName);
		}
	}
	CDialog::OnOK();
}

⌨️ 快捷键说明

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