【VC开源代码栏目提醒】:本文主要为网学会员提供DataYG.cpp,希望对需要DataYG.cpp网友有所帮助,学习一下!
// DataYG.cpp: implementation of the CDataYG class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "a1.h"
#include "DataYG.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CDataYG::CDataYG()
{
m_pstrlistFields_Names=new CStringList[2];
m_sTableName="tabyginfo";
m_sKeyField="yg_id";
m_pstrlistFields_Names[0].AddTail("yg_id"); m_pstrlistFields_Names[1].AddTail("员工编号");
m_pstrlistFields_Names[0].AddTail("yg_name"); m_pstrlistFields_Names[1].AddTail("员工");
m_pstrlistFields_Names[0].AddTail("sex"); m_pstrlistFields_Names[1].AddTail("员工性别");
m_pstrlistFields_Names[0].AddTail("sort"); m_pstrlistFields_Names[1].AddTail("员工类别");
m_pstrlistFields_Names[0].AddTail("position"); m_pstrlistFields_Names[1].AddTail("职务");
m_pstrlistFields_Names[0].AddTail("rq"); m_pstrlistFields_Names[1].AddTail("聘用日期");
m_pstrlistFields_Names[0].AddTail("salary"); m_pstrlistFields_Names[1].AddTail("薪金");
m_pstrlistFields_Names[0].AddTail("memo"); m_pstrlistFields_Names[1].AddTail("备注");
this->data.yg_id="";
this->data.yg_name="";
this->data.memo="";
this->data.position="";
this->data.rq="";
this->data.salary=0.0;
this->data.sex="";
this->data.sort="";
}
CDataYG::~CDataYG()
{
delete [] m_pstrlistFields_Names;
}
bool CDataYG::InsertCurValue()
{
if(this->IsCurValueIn())
{
AfxMessageBox("无法插入,有此字段");
return false;
}
CString sql;
sql.Format("insert into %s(yg_id,yg_name,sex,sort,position,rq,salary,memo) values('%s','%s','%s','%s','%s',#%s#,%f,'%s')"
,this->m_sTableName,data.yg_id,data.yg_name,data.sex,data.sort,data.position,data.rq,data.salary,data.memo);
return m_runsql.RunSQL(sql);
}
bool CDataYG::UpdateCurValue()
{
if(!this->IsCurValueIn())
{
AfxMessageBox("无法更新,没有此字段");
return false;
}
CString sql;
sql.Format("update %s set yg_name='%s',sex='%s',sort='%s',position='%s',rq=#%s#,salary=%f,memo='%s' where %s = '%s'"
,this->m_sTableName,data.yg_name,data.sex,data.sort,data.position,data.rq,data.salary,data.memo,this->m_sKeyField,this->data.yg_id);
return m_runsql.RunSQL(sql);
}
bool CDataYG::DeleteCurValue()
{
if(!IsCurValueIn())
{
AfxMessageBox("无法删除,没有此字段");
return false;
}
CString sql;
_variant_t value;
CString yg_name;
sql.Format("select * from tabyginfo where yg_id = '%s'",data.yg_id);
if(!m_runsql.CheckSQLResult(sql))return false;
value=m_runsql.m_recordset->GetCollect("yg_name");
sql.Format("delete * from %s where %s = '%s'",
this->m_sTableName,this->m_sKeyField,this->data.yg_id);
m_runsql.RunSQL(sql);
yg_name=(char*)(_bstr_t)value;
sql.Format("update tabck set yg_id='' where yg_id='%s'",data.yg_id);
if(!m_runsql.RunSQL(sql))return false;
this->data=data_yg();
return true;
}
bool CDataYG::IsCurValueIn()
{
CString sql;
sql.Format("select * from %s where %s = '%s'",this->m_sTableName,this->m_sKeyField,this->data.yg_id);
return this->m_runsql.CheckSQLResult(sql);
}
上一篇:
DataXS.cpp
下一篇:
基于web二手汽车交易管理系统(含录像)