yangjiajie0110
yangjiajie0110
2015-04-20 05:26

vc++6.0 MFC SQL2005,我想通过按不同的按钮向数据库中插入不同数值

  • mfc
  • sql

void CAttendance::OnCapture(BOOL ActionResult, const VARIANT FAR& ATemplate)
{
if (Identify == 0)//比对指纹(1:N)
{

    if (Identifys(m_zkeng.GetTemplateAsString()))
    {
        InsertCheck(m_zkeng.GetTemplateAsString());
        MessageBox("考勤成功!");
    }
    else
        MessageBox("考勤失败,请再次按压指纹!");
}
if (IdentifyType != 0)
    IdentifyType = 0;

}

void CAttendance::InsertCheck(CString Templage)//向数据库插入数据
{
CTime time = CTime::GetCurrentTime();
CString SQL = "Select top 2 * From Check";
CADODataSet dataset;
dataset.SetConnection(::GetConnection());
dataset.Open(SQL);
dataset.AddNew();
dataset.SetFieldValue("Name",(_variant_t)m_PersonName);
dataset.SetFieldValue("checkdate",(_bstr_t)time.Format("%Y-%m-%d"));

if(OnStartClass())
    dataset.SetFieldValue("checktype",(_bstr_t)"正点上课");
else
    if(OnLater())
        dataset.SetFieldValue("checktype",(_bstr_t)"迟到");
    else
        if(OnFinshClass())
            dataset.SetFieldValue("checktype",(_bstr_t)"正点下课");



dataset.SetFieldValue("checktime",(_bstr_t)time.Format("%H:%M:%S"));
dataset.Save();

}

void CAttendance::OnLater() //BUTTON迟到
{
if (m_zkeng.GetIsRegister())
m_zkeng.CancelEnroll();
Identify = 0;

}

void CAttendance::OnFinshClass() //BUTTON下课
{
if (m_zkeng.GetIsRegister())
m_zkeng.CancelEnroll();
Identify = 0;

}

void CAttendance::OnStartClass() //BUTTON上课
{
if (m_zkeng.GetIsRegister())
m_zkeng.CancelEnroll();
Identify = 0;

    这是我自己写的可惜不对
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

4条回答