📄 caredit.cpp
字号:
// CarEdit.cpp : 实现文件
//
#include "stdafx.h"
#include "ProjectManage.h"
#include "CarEdit.h"
// CCarEdit 对话框
IMPLEMENT_DYNAMIC(CCarEdit, CDialog)
CCarEdit::CCarEdit(CWnd* pParent /*=NULL*/)
: CDialog(CCarEdit::IDD, pParent)
{
}
CCarEdit::~CCarEdit()
{
}
void CCarEdit::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_EDIT2, txtLiChe);
}
BEGIN_MESSAGE_MAP(CCarEdit, CDialog)
ON_BN_CLICKED(IDC_BUTTON1, &CCarEdit::OnBnClickedButton1)
ON_BN_CLICKED(IDC_BUTTON3, &CCarEdit::OnBntDelete)
ON_BN_CLICKED(IDC_BUTTON2, &CCarEdit::OnBnClickedButton2)
END_MESSAGE_MAP()
// CCarEdit 消息处理程序
BOOL CCarEdit::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: 在此添加额外的初始化
CEdit* cPname=(CEdit*)this->GetDlgItem(IDC_EDIT1);
cPname->SetWindowTextA(theApp.ProjName);
if(SList!=NULL)
{
CEdit* number=(CEdit*)this->GetDlgItem(IDC_EDIT2);
number->SetWindowTextA(SList[2]);
CEdit* mBzfytxt=(CEdit*)this->GetDlgItem(IDC_EDIT3);
mBzfytxt->SetWindowTextA(SList[3]);
CEdit* otherfytxt=(CEdit*)this->GetDlgItem(IDC_EDIT4);
otherfytxt->SetWindowTextA(SList[4]);
/*CEdit* cdatetime=(CEdit*)this->GetDlgItem(IDC_DATETIMEPICKER1);
cdatetime->SetWindowTextA(SList[1]);*/
if(SList[1]!="")
{
COleDateTime dt;
dt.ParseDateTime(SList[1]);
CDateTimeCtrl* cdatetime=(CDateTimeCtrl*)this->GetDlgItem(IDC_DATETIMEPICKER1);
cdatetime->SetTime(dt);
}
}
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
void CCarEdit::OnBnClickedButton1()
{
// TODO: 在此添加控件通知处理程序代码
CString sql;
CString lc,ch,sj,sdatetime;
CEdit* number=(CEdit*)this->GetDlgItem(IDC_EDIT2);
number->GetWindowTextA(lc);
CEdit* mBzfytxt=(CEdit*)this->GetDlgItem(IDC_EDIT3);
mBzfytxt->GetWindowTextA(ch);
CEdit* otherfytxt=(CEdit*)this->GetDlgItem(IDC_EDIT4);
otherfytxt->GetWindowTextA(sj);
CEdit* cdatetime=(CEdit*)this->GetDlgItem(IDC_DATETIMEPICKER1);
cdatetime->GetWindowTextA(sdatetime);
try
{
sql="insert into CarCost(Milemeter,VehicleCode,Chauffeur,SDateTime,ProjID)Values("+lc+","+ch+",'"+sj+"','"+sdatetime+"',"+theApp.ProjID+")";
if(lc=="")
{
MessageBox("添加里程");
return;
}
if(ch=="")
{
ch="0";
}
if(sj=="")
{
sj="0";
}
if(this->m_Storage.ExecSql(sql))
{
MessageBox("添加成功");
}
}
catch(_com_error e)
{
MessageBox("添加失败,请检查数据格式");
}
}
void CCarEdit::OnBntDelete()
{
// TODO: 在此添加控件通知处理程序代码
CString sql;
sql="delete from CarCost where id="+SList[0];
if(MessageBox(_T("真的要删除吗?"),_T("删除询问"),MB_OKCANCEL|MB_ICONQUESTION)==IDOK)
{
if(this->m_Storage.ExecSql(sql))
{
AfxMessageBox("删除成功!");
this->OnCancel();
}
}
}
void CCarEdit::OnBnClickedButton2()
{
// TODO: 在此添加控件通知处理程序代码
CString sql;
CString lc,ch,sj,sdatetime;
CEdit* number=(CEdit*)this->GetDlgItem(IDC_EDIT2);
number->GetWindowTextA(lc);
CEdit* mBzfytxt=(CEdit*)this->GetDlgItem(IDC_EDIT3);
mBzfytxt->GetWindowTextA(ch);
CEdit* otherfytxt=(CEdit*)this->GetDlgItem(IDC_EDIT4);
otherfytxt->GetWindowTextA(sj);
CEdit* cdatetime=(CEdit*)this->GetDlgItem(IDC_DATETIMEPICKER1);
cdatetime->GetWindowTextA(sdatetime);
try
{
sql="update CarCost set Milemeter="+lc+",VehicleCode="+ch+",Chauffeur='"+sj+"',SDateTime='"+sdatetime+"',ProjID="+theApp.ProjID+" where id="+SList[0];
if(lc=="")
{
MessageBox("添加里程");
return;
}
if(ch=="")
{
ch="0";
}
if(sj=="")
{
sj="0";
}
if(this->m_Storage.ExecSql(sql))
{
MessageBox("修改成功");
}
}
catch(_com_error e)
{
MessageBox("修改失败,请检查数据格式");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -