📄 stucharge.cpp
字号:
}
bool CStuCharge::notExist(CString str)
{
CString sql; //查询记录
sql.Format("select * from StuCharge where ChgID = '%s'",str);
theApp.record1->raw_Close();//关闭当前数据集
theApp.record1->CursorLocation = adUseClient;
theApp.record1->Open((_bstr_t)sql,theApp.connection.GetInterfacePtr(),adOpenKeyset,adLockOptimistic,adCmdText);
if(theApp.record1->RecordCount == 0)
return true;
return false;
}
void CStuCharge::OnStuchgitemsubmit()
{
// TODO: Add your control notification handler code here
UpdateData(true);
if(queryItem) //如果是查询
{
if(m_stuchgid.GetLength() == 0)
{
MessageBox("收费代号不能为空!");
m_ctrlstuchgid.SetFocus();
return;
}
if(notExist(m_stuchgid))
{
MessageBox("此收费项目不存在!");
m_ctrlstuchgid.SetFocus();
return;
}
CString sql; //查询记录
sql.Format("select * from stuCharge where ChgID = \'%s\' ",m_stuchgid);
theApp.record->raw_Close(); //关闭当前的数据集
theApp.record->CursorLocation = adUseClient;
try //捕捉异常
{
theApp.record->Open((_bstr_t)sql,theApp.connection.GetInterfacePtr(),adOpenKeyset,adLockPessimistic,adCmdText);
}
catch(_com_error & e)
{
AfxMessageBox(e.Description());
return; //捕捉到异常后就不在继续执行
}
if(theApp.record->RecordCount > 0) //非空集合
{
m_stuchggrid.SetRefDataSource((LPUNKNOWN)theApp.record->DataSource); //将查询结果显示到DataGrid控件
m_stuchggrid.Refresh();
}
MessageBox("成功查询!");
m_ctrlstuchgid.SetFocus();
}
if(deleteItem) //删除
{
if(m_stuchgid.GetLength() == 0)
{
MessageBox("收费代号不能为空!");
m_ctrlstuchgid.SetFocus();
return;
}
if(notExist(m_stuchgid))
{
MessageBox("此收费项目不存在!");
m_ctrlstuchgid.SetFocus();
return;
}
CString sql; //删除记录
sql.Format("delete StuCharge where ChgID = \'%s\' ",m_stuchgid);
theApp.record->raw_Close(); //关闭当前的数据集
theApp.record->CursorLocation = adUseClient;
try //捕捉异常
{
theApp.record->Open((_bstr_t)sql,theApp.connection.GetInterfacePtr(),adOpenKeyset,adLockPessimistic,adCmdText);
}
catch(_com_error & e)
{
AfxMessageBox(e.Description());
return; //捕捉到异常后就不在继续执行
}
RefreshInfo(); //刷新
MessageBox("删除成功!");
m_ctrlstuchgid.SetFocus();
}
if(insertItem) //插入
{
if(m_stuchgid.GetLength() == 0)
{
MessageBox("收费代号不能为空!");
m_ctrlstuchgid.SetFocus();
return;
}
if(m_stuchgcode.GetLength() == 0)
{
MessageBox("学生代号不能为空!");
m_ctrlstuchgcode.SetFocus();
return;
}
if(m_stuchgitem.GetLength() == 0)
{
MessageBox("收费项目代号不能为空!");
m_ctrlstuchgitem.SetFocus();
return;
}
if(m_stuchgtuition < 0)
{
MessageBox("学费不能为负!");
m_ctrlstuchgtuition.SetFocus();
return;
}
if(m_stuchgbook < 0)
{
MessageBox("书费不能为负!");
m_ctrlstuchgbook.SetFocus();
return;
}
if(m_stuchgdorm < 0)
{
MessageBox("住宿费不能为负!");
m_ctrlstuchgdorm.SetFocus();
return;
}
if(m_stuchgfile < 0)
{
MessageBox("资料费不能为负!");
m_ctrlstuchgfile.SetFocus();
return;
}
if(m_stuchgincid < 0)
{
MessageBox("杂费不能为负!");
m_ctrlstuchgincid.SetFocus();
return;
}
if(m_stuchginsur < 0)
{
MessageBox("保险费不能为负!");
m_ctrlstuchginsur.SetFocus();
return;
}
if(m_stuchgmac < 0)
{
MessageBox("机时费不能为负!");
m_ctrlstuchgmac.SetFocus();
return;
}
if(m_stuchgtatol < 0)
{
MessageBox("总费用不能为负!");
m_ctrlstuchgtatol.SetFocus();
return;
}
if(m_stuchgperson.GetLength() == 0)
{
MessageBox("收费人不能为空!");
m_ctrlstuchgperson.SetFocus();
return;
}
if(m_stuchgdate.GetLength() == 0)
{
MessageBox("收费日期不能为空!");
m_ctrlstuchgdate.SetFocus();
return;
}
if(!notExist(m_stuchgid))
{
MessageBox("收费代号已存在!");
m_ctrlstuchgid.SetFocus();
return;
}
CString sql; //查入记录
sql.Format("Insert into Stucharge values (\'%s\',\'%s\',\'%s\',%f,%f,%f,%f,%f,%f,%f,%f,\'%s\',\'%s\',\'%s\')",m_stuchgid,m_stuchgcode,m_stuchgitem,m_stuchgtuition,m_stuchgincid,m_stuchgmac,m_stuchginsur,m_stuchgdorm,m_stuchgbook,m_stuchgfile,m_stuchgtatol,m_stuchgperson,m_stuchgdate,m_stuchgdemo);
MessageBox(sql);
theApp.record->raw_Close(); //关闭当前的数据集
theApp.record->CursorLocation = adUseClient;
try //捕捉异常
{
theApp.record->Open((_bstr_t)sql,theApp.connection.GetInterfacePtr(),adOpenKeyset,adLockPessimistic,adCmdText);
}
catch(_com_error & e)
{
AfxMessageBox(e.Description());
return; //捕捉到异常后就不在继续执行
}
RefreshInfo(); //刷新
MessageBox("成功插入成功!");
m_ctrlstuchgid.SetFocus();
}
if(modifyItem) //修改
{
if(m_stuchgid.GetLength() == 0)
{
MessageBox("收费代号不能为空!");
m_ctrlstuchgid.SetFocus();
return;
}
/* if(m_stuchgcode.GetLength() == 0)
{
MessageBox("学生代号不能为空!");
m_ctrlstuchgcode.SetFocus();
return;
}
if(m_stuchgitem.GetLength() == 0)
{
MessageBox("收费项目代号不能为空!");
m_ctrlstuchgitem.SetFocus();
return;
}*/
if(m_stuchgtuition < 0)
{
MessageBox("学费不能为负!");
m_ctrlstuchgtuition.SetFocus();
return;
}
if(m_stuchgbook < 0)
{
MessageBox("书费不能为负!");
m_ctrlstuchgbook.SetFocus();
return;
}
if(m_stuchgdorm < 0)
{
MessageBox("住宿费不能为负!");
m_ctrlstuchgdorm.SetFocus();
return;
}
if(m_stuchgfile < 0)
{
MessageBox("资料费不能为负!");
m_ctrlstuchgfile.SetFocus();
return;
}
if(m_stuchgincid < 0)
{
MessageBox("杂费不能为负!");
m_ctrlstuchgincid.SetFocus();
return;
}
if(m_stuchginsur < 0)
{
MessageBox("保险费不能为负!");
m_ctrlstuchginsur.SetFocus();
return;
}
if(m_stuchgmac < 0)
{
MessageBox("机时费不能为负!");
m_ctrlstuchgmac.SetFocus();
return;
}
if(m_stuchgtatol < 0)
{
MessageBox("总费用不能为负!");
m_ctrlstuchgtatol.SetFocus();
return;
}
/* if(m_stuchgperson.GetLength() == 0)
{
MessageBox("收费人不能为空!");
m_ctrlstuchgperson.SetFocus();
return;
}
if(m_stuchgdate.GetLength() == 0)
{
MessageBox("收费日期不能为空!");
m_ctrlstuchgdate.SetFocus();
return;
}*/
if(notExist(m_stuchgid))
{
MessageBox("收费代号不存在!");
m_ctrlstuchgid.SetFocus();
return;
}
CString sql; //修改记录
sql.Format("Update Stucharge set Fact_Tuition=%f, Fact_Incidental =%f, Fact_MacTimeFee=%f,Fact_Insurance =%f,Fact_DormFee =%f,Fact_BookFee=%f,Fact_FileFee =%f,Fact_TotalFee =%f,Demo =\'%s\' where ChgID=\'%s\'",m_stuchgtuition,m_stuchgincid,m_stuchgmac,m_stuchginsur,m_stuchgdorm,m_stuchgbook,m_stuchgfile,m_stuchgtatol,m_stuchgdemo,m_stuchgid);
theApp.record->raw_Close(); //关闭当前的数据集
theApp.record->CursorLocation = adUseClient;
try //捕捉异常
{
theApp.record->Open((_bstr_t)sql,theApp.connection.GetInterfacePtr(),adOpenKeyset,adLockPessimistic,adCmdText);
}
catch(_com_error & e)
{
AfxMessageBox(e.Description());
return; //捕捉到异常后就不在继续执行
}
RefreshInfo(); //刷新
MessageBox("修改成功!");
m_ctrlstuchgid.SetFocus();
}
}
void CStuCharge::OnStuchgitemnew()
{
// TODO: Add your control notification handler code here
this->RefreshInfo(); //刷新
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -