日期显示问题
头文件:class Cfrm_Cust : public CDialog
{
// Construction
public:
Cfrm_Cust(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(Cfrm_Cust)
enum { IDD = frm_Cust };
CButton m_chkLimit;
CButton m_chkCost;
CComboBox m_cboSex;
CComboBox m_cboCred;
CTreeCtrl m_Tree;
CString m_txtCustId;
CString m_txtName;
CString m_txtTelephone;
CString m_txtMobile;
CString m_txtLimitAmt;
CString m_txtExp;
CString m_txtEmail;
CString m_txtDisc;
CString m_txtCredNum;
CString m_txtCard;
CString m_txtBankNum;
CString m_txtBank;
CString m_txtAmt;
CString m_txtAddress;
COleDateTime m_DTPicker;此处是日期控件类型
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(Cfrm_Cust)
public:
virtual BOOL PreTranslateMessage(MSG* pMsg);
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(Cfrm_Cust)
virtual BOOL OnInitDialog();
afx_msg void OncmdNew();
afx_msg void OncmdClose();
afx_msg void OncmdPrint();
afx_msg void OncmdRewrite();
afx_msg void OncmdSave();
afx_msg void OnchkLimit();
afx_msg void OncmdDelete();
afx_msg void OnClicktreCust(NMHDR* pNMHDR, LRESULT* pResult);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
程序文件:
void Cfrm_Cust::OnClicktreCust(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
//******************************
CPoint point;
GetCursorPos(&point);//获得鼠标点击的位置
m_Tree.ScreenToClient(&point);//转化为客户坐标
UINT uFlags;
HTREEITEM CurrentItem;
CurrentItem=m_Tree.HitTest(point,&uFlags);//获得当前点击节点的ITEM
//HTREEITEM ParentItem=m_Tree.GetParentItem(CurrentItem);//获得该节点的父节点
CString CurrentStr=m_Tree.GetItemText(CurrentItem);//获得节点字符串
if ((UINT)CurrentStr.GetLength()!=0 && CurrentStr!="所有用户")
{
Controls_False();
CString strCustId,strSQL;
strCustId=CurrentStr.Left(CurrentStr.Find(' '));//取得CurrentStr中的住户编号
strSQL.Format("select * from uCust where fcustid=\'%s\'",strCustId);
int flag=mysql_real_query(pConn,(char*)(LPCTSTR)strSQL,(UINT)strSQL.GetLength());//如果查询成功,返回0。如果出现错误,返回非0值。
MYSQL_RES *result;
MYSQL_ROW row;
if(!(result=mysql_store_result(pConn)))//一次性传送结果
{
return;
}
else
{
for(int i=0;i<mysql_num_rows(result);i++)//获取行数
{
row = mysql_fetch_row(result);//从结果集中获取下一行,取得当前记录行
m_txtCustId=row[0];
m_txtName=row[1];
m_cboSex.SetCurSel(m_cboSex.FindString(0,row[2]));
m_cboCred.SetCurSel(m_cboCred.FindString(0,row[3]));
m_txtCredNum=row[4];
m_txtMobile=row[5];
m_txtTelephone=row[6];
m_txtAddress=row[7];
//m_DTPicker=row[8];
//m_DTPicker.COleDateTime(row[8]);
//m_DTPicker.SetStatus(&row[8]);
//m_DTPicker.Format("yyyy-MM-dd");这里如何把数据库表中的日期显示在控件上??
m_txtEmail=row[9];
m_txtBank=row[10];
m_txtBankNum=row[11];
m_txtAmt=row[12];
m_txtDisc=row[13];
m_txtLimitAmt=row[14];
m_chkLimit.SetCheck(atoi(row[15]));
if (strchr(row[16],'Y')!=0)//查找字符串中第一个出现的指定字符(如果找到指定的字符则返回该字符所在地址,否则返回0)
{
m_chkCost.SetCheck(1);
}
else
{
m_chkCost.SetCheck(0);
}
m_txtCard=row[17];
m_txtExp=row[18];
}
}
mysql_free_result(result);//释放结果集使用的内存
UpdateData(false);
}
//******************************
*pResult = 0;
}
软件界面: