📄 return.cpp
字号:
// Return.cpp : 实现文件
//
#include "stdafx.h"
#include "MyZone.h"
#include "Return.h"
#include ".\return.h"
// CReturn 对话框
IMPLEMENT_DYNAMIC(CReturn, CPropertyPage)
CReturn::CReturn()
: CPropertyPage(CReturn::IDD)
, m_Risbn(_T(""))
, m_Rdate(COleDateTime::GetCurrentTime())
{
}
CReturn::~CReturn()
{
}
void CReturn::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT1, m_Risbn);
DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER1, m_Rdate);
}
BEGIN_MESSAGE_MAP(CReturn, CPropertyPage)
ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
END_MESSAGE_MAP()
// CReturn 消息处理程序
void CReturn::OnBnClickedButton1()
{
// TODO: 在此添加控件通知处理程序代码
UpdateData();
COleDateTime m_Borrowdate;
int m_rrr;
CString str,m_amount,m_id,str1;
float i;
SetDlgItemText(IDC_EDIT2,theApp.m_Auserid);
if( m_Risbn == ""|| theApp.m_Auserid == "")
{
AfxMessageBox("用户名和ISBN不能为空!");
return;
}
else
//try
{
str1.Format("select * from Borrow where SID = '%s'and ISBN = '%s'",theApp.m_Auserid,m_Risbn);
theApp.m_pRecordsetborrow1->Open((LPCTSTR)str1,
theApp.m_pConnection.GetInterfacePtr(),
adOpenDynamic,adLockOptimistic,adCmdText);
//MessageBox("adfgdshgf");
while(!theApp.m_pRecordsetborrow1->adoEOF)
{
str = theApp.m_pRecordsetborrow1->GetCollect("ISBN");
//MessageBox(str);
if(m_Risbn==str)
{
m_Borrowdate = (COleDateTime)theApp.m_pRecordsetborrow1->GetCollect("Borrow_Date");
CString Rd;
Rd.Format("%d-%d-%d",m_Borrowdate.GetYear(),m_Borrowdate.GetMonth(),m_Borrowdate.GetDay());
//MessageBox(Rd);
m_rrr = m_Rdate.GetDayOfYear() - m_Borrowdate.GetDayOfYear();
i = (m_rrr-30)/2;
if(i>0)
{
m_amount.Format("!!!%f",i);
//MessageBox(m_amount);
}
else
{m_amount = "0";
//MessageBox(m_amount);
}
theApp.m_pRecordset->Open(_variant_t("select Reader_ID from Reader where SID ='"+theApp.m_Auserid+"'"),
theApp.m_pConnection.GetInterfacePtr(),
adOpenDynamic,adLockOptimistic,adCmdText);
m_id = theApp.m_pRecordset->GetCollect("Reader_ID");
//MessageBox(m_id);
CString aaa;
aaa.Format("%d-%d-%d",m_Rdate.GetYear(),m_Rdate.GetMonth(),m_Rdate.GetDay());
//MessageBox(aaa);
theApp.m_pRecordsetamount->AddNew();
theApp.m_pRecordsetamount->PutCollect("B_Date", _variant_t(Rd));
theApp.m_pRecordsetamount->PutCollect("R_Date", _variant_t(aaa));
theApp.m_pRecordsetamount->PutCollect("RAmount",_variant_t(m_amount));
theApp.m_pRecordsetamount->PutCollect("Reader_ID",_variant_t(m_id));
theApp.m_pRecordsetamount->Update();
AfxMessageBox("还书成功!");
theApp.m_pRecordsetamount->Close();
theApp.m_pRecordset->Close();
break;
}
theApp.m_pRecordsetborrow1->MoveNext();
}
if(theApp.m_pRecordsetborrow1->adoEOF)
{
theApp.m_pRecordsetborrow1->Close();
AfxMessageBox("没有此书,请重新输入!");
return;
}
/* }
catch(_com_error e){
CString errormessage;
errormessage.Format("数据库图书表项操作失败!\n%s",e.Description());
MessageBox(e.Description());
}*/
}
}
BOOL CReturn::OnInitDialog()
{
CPropertyPage::OnInitDialog();
// TODO: 在此添加额外的初始化
try
{
theApp.m_pRecordsetamount->Open(_variant_t("SELECT * FROM Amount"),
theApp.m_pConnection.GetInterfacePtr(),
adOpenDynamic,
adLockOptimistic,
adCmdText);
}
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
}
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -