//ListCtrl
控件单击事件,重载函数
void
CContentsSubmitDlg::OnNMClickList1(NMHDR *pNMHDR, LRESULT *pResult)
{
POSITION pos=m_ListResult.GetFirstSelectedItemPosition();
CString content;
CString employee;
CString schedua;
CString datetime;
int nItem;
if(pos!=NULL)
{
while(pos)
{ nItem=m_ListResult.GetNextSelectedItem(pos);
content=m_ListResult.GetItemText(nItem,0);
schedua=m_ListResult.GetItemText(nItem,1);
datetime=m_ListResult.GetItemText(nItem,2);
employee=m_ListResult.GetItemText(nItem,3);
}
GetDlgItem(IDC_EDIT4)->SetWindowText(content);
GetDlgItem(IDC_EDIT5)->SetWindowText(schedua);
GetDlgItem(IDC_EDIT7)->SetWindowText(datetime);
}
*pResult = 0;
}
//ListCtrl
控件双击事件
void
CContentsSubmitDlg::OnNMDblclkList1(NMHDR *pNMHDR, LRESULT *pResult)
{
// CString s="
您双击了选择项";
// AfxMessageBox(s);
CString aa=(( CContentsSubmitApp *)AfxGetApp())->namelogin;
aa.TrimLeft(" ");
aa.TrimRight(" ");
aa.TrimRight(" ");
aa.TrimRight(" ");
aa.TrimRight("/t");
POSITION pos=m_ListResult.GetFirstSelectedItemPosition();
CString content;
CString employee;
int nItem;
if(pos!=NULL)
{
while(pos)
{ nItem=m_ListResult.GetNextSelectedItem(pos);
content=m_ListResult.GetItemText(nItem,0); employee=m_ListResult.GetItemText(nItem,3);
}
if(employee!=aa)
{ AfxMessageBox("
您不能删除别人的提报内容?",MB_OK); return; }
else
{ ADOconn m_conn; _bstr_t vSQL="";
CString s_Conn="Provider=SQLOLEDB;Server=10.128.128.221;Database=Eink;uid=stone;pwd=stone";
vSQL="delete contens where workcontents='"+content+"' and employee='"+employee+"'";
try
{ m_conn.OnInitADOConn(s_Conn);
UINT YORN=AfxMessageBox("
您确认删除该记录吗?",MB_YESNO);
if(YORN==IDYES)
{ m_conn.ExcuteSQL(vSQL); }
else { return; }
}
catch(...)
{ AfxMessageBox("
数据库删除错误",MB_OK); }
AfxMessageBox("
数据成功删除",MB_OK);
m_ListResult.DeleteItem(nItem);
} }
*pResult = 0;
}