?? caredit.cpp
字號(hào):
// CarEdit.cpp : 實(shí)現(xiàn)文件
//
#include "stdafx.h"
#include "ProjectManage.h"
#include "CarEdit.h"
// CCarEdit 對(duì)話框
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 屬性頁(yè)應(yīng)返回 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("添加失敗,請(qǐng)檢查數(shù)據(jù)格式");
}
}
void CCarEdit::OnBntDelete()
{
// TODO: 在此添加控件通知處理程序代碼
CString sql;
sql="delete from CarCost where id="+SList[0];
if(MessageBox(_T("真的要?jiǎng)h除嗎?"),_T("刪除詢問(wèn)"),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("修改失敗,請(qǐng)檢查數(shù)據(jù)格式");
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -