16,472
社区成员
发帖
与我相关
我的任务
分享
void CPageVisit::OnKillfocusEdit()
{
if (haveeditcreate == true)//如果之前创建了编辑框就销毁掉
{
destroyEdit(&m_visitplan, &m_Edit, e_Item, e_SubItem);//销毁单元格编辑框对象
haveeditcreate = false;
CString bvcontent,bvdate,bvplan;
bvcontent=m_visitplan.GetItemText(e_Item,e_SubItem);
bvplan=m_visitplan.GetItemText(e_Item,e_SubItem-1);
CTime date;
m_visitdate.GetTime(date);
bvdate=date.Format(_T("%Y/%m/%d"));//获得回访日期
if(!bvcontent.IsEmpty())
{
//更新VISITRECORDDT表
CBackVisitApp* app=(CBackVisitApp*)AfxGetApp();
sqlite3* conn = NULL;
if (sqlite3_open((LPSTR)(LPCTSTR)app->m_dbfname,&conn)!=SQLITE_OK)
{
sqlite3_close(conn);
MessageBox(_T("数据库打开失败!"));
return;
}
sqlite3_stmt *stmt;
char sqlupdate[400];
sprintf(sqlupdate,"UPDATE VISITRECORDDT SET BVCONTENT='%s' WHERE ID='%s' AND BVDATE='%s' AND BVPLAN='%s'",bvcontent,m_id[e_Item],bvdate,bvplan);
int len = strlen(sqlupdate);
if (sqlite3_prepare_v2(conn,sqlupdate,len,&stmt,NULL) != SQLITE_OK)
{
if(stmt)
sqlite3_finalize(stmt);
//CString err=sqlite3_errmsg(conn);
sqlite3_close(conn);
return ;
}
if (sqlite3_step(stmt) != SQLITE_DONE) {
sqlite3_finalize(stmt);
sqlite3_close(conn);
return;
}
sqlite3_finalize(stmt);
sqlite3_close(conn);
MessageBox(_T("更新成功!"));
}
}