我想将一些信息加入到数据库表中去,下面是两个函数,
我感觉好像没问题,但当我输入正确的值时,系统却提示我
CHECKIN 只读,我怎么改,谢谢各位!急--在线等
void CCheckInDlg::OnConfirm()
{
// TODO: Add your control notification handler code here
//签到用户确认信息
CEdit *pEditFirst=(CEdit*)GetDlgItem(IDC_EDIT_EPLOYEEID);
CEdit *pEditSecond=(CEdit*)GetDlgItem(IDC_EDIT_EMPLOYEEIDAGAIN); this->UpdateData(TRUE);
CCheckRecordset rsCheck;
CConfigRecordset rsConfig;
CEmployeeRecordset rsEmployee; //获取时间
CTime CheckInTime = CTime::GetCurrentTime();
CTime TodayTime = CTime::GetCurrentTime();
//判断输入框是否为空
if (m_strEmployeeID == "")
{
MessageBox("第一个员工输入框不能为空!","提示",MB_ICONINFORMATION);
pEditFirst->SetFocus();
return;
}
else if (m_strEmployeeIDAgain == "")
{
MessageBox("第二个员工输入框不能为空!","提示",MB_ICONINFORMATION);
pEditSecond->SetFocus();
return;
}
else
{
//判断输入的员工号是否正确
if (m_strEmployeeID==m_strEmployeeIDAgain)
{
if (rsEmployee.IsValidEmployee(m_strEmployeeIDAgain))
{
if (rsCheck.IsTodayChecked(TodayTime,m_strEmployeeID))
{
MessageBox("今天这个员工已经签到!","提示",MB_ICONINFORMATION);
}
else
{
//从系统表中取出公司规定的上班时间
CTime RegularTime;
if (!(rsConfig.GetRegularTime(RegularTime)))
{
MessageBox("签到失败!","签到错误",MB_ICONINFORMATION);
}
//根据签到时间和tbConfig表中获取的公司上班时间
//以及浮动时间来计算
int State = this->GetCheckState(CheckInTime,RegularTime);
//将员工签到记录增加到tbCheckIn表中
if (rsCheck.AddCheckRecord(m_strEmployeeID,CheckInTime,State))
{
MessageBox("签到成功!","提示",MB_ICONINFORMATION);
}
else
{
MessageBox("签到失败!","提示",MB_ICONINFORMATION);
}
}
}
else//输入员工号不正确
{
::MessageBox(NULL,"输入员工号不正确,请重新输入!","提示"
,MB_ICONINFORMATION);
}
}
else//第一次和第二次输入不同
{
::MessageBox(NULL,"两次输入的员工号不相同,请重新输入!","提示"
,MB_ICONINFORMATION);
}
pEditFirst->SetWindowText("");
pEditSecond->SetWindowText("");
pEditFirst->SetFocus();
}
}bool CCheckRecordset::AddCheckRecord(CString EmployID, CTime &CheckTime, int state)
{
try
{
if (!this->IsOpen())
{
this->Open();
}
}
catch(CDBException *e)
{
AfxMessageBox(e->m_strError);
return false;
} try
{
//利用CRecordset 的RFX机制实现记录字段的赋值
//当CRecordset::Update()函数被调用后,
//CCheckRecordset::DoFieldExchange()函数被调用
//记录字段和类成员变量的值进行交换
this->AddNew();
this->m_EmployeeID = EmployID;
this->m_CheckInTime = CheckTime;
this->m_State = state;
this->Update();
return true;
}
catch(CDBException *e)
{
AfxMessageBox(e->m_strError);
return false;
}
}
我感觉好像没问题,但当我输入正确的值时,系统却提示我
CHECKIN 只读,我怎么改,谢谢各位!急--在线等
void CCheckInDlg::OnConfirm()
{
// TODO: Add your control notification handler code here
//签到用户确认信息
CEdit *pEditFirst=(CEdit*)GetDlgItem(IDC_EDIT_EPLOYEEID);
CEdit *pEditSecond=(CEdit*)GetDlgItem(IDC_EDIT_EMPLOYEEIDAGAIN); this->UpdateData(TRUE);
CCheckRecordset rsCheck;
CConfigRecordset rsConfig;
CEmployeeRecordset rsEmployee; //获取时间
CTime CheckInTime = CTime::GetCurrentTime();
CTime TodayTime = CTime::GetCurrentTime();
//判断输入框是否为空
if (m_strEmployeeID == "")
{
MessageBox("第一个员工输入框不能为空!","提示",MB_ICONINFORMATION);
pEditFirst->SetFocus();
return;
}
else if (m_strEmployeeIDAgain == "")
{
MessageBox("第二个员工输入框不能为空!","提示",MB_ICONINFORMATION);
pEditSecond->SetFocus();
return;
}
else
{
//判断输入的员工号是否正确
if (m_strEmployeeID==m_strEmployeeIDAgain)
{
if (rsEmployee.IsValidEmployee(m_strEmployeeIDAgain))
{
if (rsCheck.IsTodayChecked(TodayTime,m_strEmployeeID))
{
MessageBox("今天这个员工已经签到!","提示",MB_ICONINFORMATION);
}
else
{
//从系统表中取出公司规定的上班时间
CTime RegularTime;
if (!(rsConfig.GetRegularTime(RegularTime)))
{
MessageBox("签到失败!","签到错误",MB_ICONINFORMATION);
}
//根据签到时间和tbConfig表中获取的公司上班时间
//以及浮动时间来计算
int State = this->GetCheckState(CheckInTime,RegularTime);
//将员工签到记录增加到tbCheckIn表中
if (rsCheck.AddCheckRecord(m_strEmployeeID,CheckInTime,State))
{
MessageBox("签到成功!","提示",MB_ICONINFORMATION);
}
else
{
MessageBox("签到失败!","提示",MB_ICONINFORMATION);
}
}
}
else//输入员工号不正确
{
::MessageBox(NULL,"输入员工号不正确,请重新输入!","提示"
,MB_ICONINFORMATION);
}
}
else//第一次和第二次输入不同
{
::MessageBox(NULL,"两次输入的员工号不相同,请重新输入!","提示"
,MB_ICONINFORMATION);
}
pEditFirst->SetWindowText("");
pEditSecond->SetWindowText("");
pEditFirst->SetFocus();
}
}bool CCheckRecordset::AddCheckRecord(CString EmployID, CTime &CheckTime, int state)
{
try
{
if (!this->IsOpen())
{
this->Open();
}
}
catch(CDBException *e)
{
AfxMessageBox(e->m_strError);
return false;
} try
{
//利用CRecordset 的RFX机制实现记录字段的赋值
//当CRecordset::Update()函数被调用后,
//CCheckRecordset::DoFieldExchange()函数被调用
//记录字段和类成员变量的值进行交换
this->AddNew();
this->m_EmployeeID = EmployID;
this->m_CheckInTime = CheckTime;
this->m_State = state;
this->Update();
return true;
}
catch(CDBException *e)
{
AfxMessageBox(e->m_strError);
return false;
}
}
解决方案 »
- VC6中的hTreeItem=m_Mytree.InsertItem(&TreeCtrlItem) 出错
- 这种泡泡窗口是肿么弄出来的 ???!!!!!
- COM客户端的CoGetClassObject总是出错,郁闷,高分求助
- 乱码问题
- 如何得到后台程序窗口上 某点的颜色值?
- ACE到底要如何开始学习呀。哪里有这样的资料下载呢?
- 怎样用VC实现给一些信息网站发布信息?
- com简单问题
- VC读写Excel的入门级问题*********,不管问题解决与否,晚上9点结贴!!!!!!!!
- 如何在控件中实现打印和打印预览?请高手指点!!!
- 怎样用程序去控制任务栏的小喇叭的出现、隐藏和失效?(失效就是双击小喇叭时没反应)
- 来学习~!!散分表示下~~HOHO~~!
void CCheckInDlg::OnConfirm()
{
// TODO: Add your control notification handler code here
//签到用户确认信息
CEdit *pEditFirst=(CEdit*)GetDlgItem(IDC_EDIT_EPLOYEEID);
CEdit *pEditSecond=(CEdit*)GetDlgItem(IDC_EDIT_EMPLOYEEIDAGAIN); this->UpdateData(TRUE);
CCheckRecordset rsCheck;
CConfigRecordset rsConfig;
CEmployeeRecordset rsEmployee; //获取时间
CTime CheckInTime = CTime::GetCurrentTime();
CTime TodayTime = CTime::GetCurrentTime();
//判断输入框是否为空
if (m_strEmployeeID == "")
{
MessageBox("第一个员工输入框不能为空!","提示",MB_ICONINFORMATION);
pEditFirst->SetFocus();
return;
}
else if (m_strEmployeeIDAgain == "")
{
MessageBox("第二个员工输入框不能为空!","提示",MB_ICONINFORMATION);
pEditSecond->SetFocus();
return;
}
else
{
//判断输入的员工号是否正确
if (m_strEmployeeID==m_strEmployeeIDAgain)
{
if (rsEmployee.IsValidEmployee(m_strEmployeeIDAgain))
{
if (rsCheck.IsTodayChecke(TodayTime,m_strEmployeeID))
{
MessageBox("今天这个员工已
经!","提",MB_ICONINFORMATION);
}
else
{
//从系统表中取出公司规定的上班时间
CTime RegularTime;
if (!(rsConfig.GetRegularTime(RegularTime)))
{
MessageBox("签到失败!","签到错
误",MB_ICONINFORMATION);
}
//根据签到时间和tbConfig表中获取的公司上班时间
//以及浮动时间来计算
int State = this->GetCheckState
(CheckInTime,RegularTime);
//将员工签到记录增加到tbCheckIn表中
if (rsCheck.AddCheckRecord
(m_strEmployeeID,CheckInTime,State))
{
MessageBox("签到成功!","提
示",MB_ICONINFORMATION);
}
else
{
MessageBox("签到失败!","提
示",MB_ICONINFORMATION);
}
}
}
else//输入员工号不正确
{
::MessageBox(NULL,"输入员工号不正确,请重新输入!","提示"
,MB_ICONINFORMATION);
}
}
else//第一次和第二次输入不同
{
::MessageBox(NULL,"两次输入的员工号不相同,请重新输入!","提示"
,MB_ICONINFORMATION);
}
pEditFirst->SetWindowText("");
pEditSecond->SetWindowText("");
pEditFirst->SetFocus();
}
}bool CCheckRecordset::AddCheckRecord(CString EmployID, CTime &CheckTime, int state)
{
try
{
if (!this->IsOpen())
{
this->Open();
}
}
catch(CDBException *e)
{
AfxMessageBox(e->m_strError);
return false;
} try
{
//利用CRecordset 的RFX机制实现记录字段的赋值
//当CRecordset::Update()函数被调用后,
//CCheckRecordset::DoFieldExchange()函数被调用
//记录字段和类成员变量的值进行交换
this->AddNew();
this->m_EmployeeID = EmployID;
this->m_CheckInTime = CheckTime;
this->m_State = state;
this->Update();
return true;
}
catch(CDBException *e)
{
AfxMessageBox(e->m_strError);
return false;
}
}
这个函数里出的问题
CheckInTime
这两个字段是组合主键