📄 baseinfo.cpp
字号:
catch(_com_error e)
{
CString errormessage;
MessageBox("读取类别子树出错!");
}
UpdateData();
}
void CBaseInfo::SelectRegion(CString sID,CComboBox& ctr)
{
CString sql,cmod_name,curID;
_RecordsetPtr m_pTRecordset;
sql="select mod_id,mod_name from RegionTree where mod_parent="+sID+"";
try
{
m_pTRecordset.CreateInstance("ADODB.Recordset");
m_pTRecordset->Open((_variant_t)sql,_variant_t((IDispatch*)theApp.m_pDBCon->GetActiveConnection(),true),adOpenDynamic,adLockOptimistic,adCmdText);
m_pTRecordset->MoveFirst();
if(!m_pTRecordset->adoEOF)
{
while(!m_pTRecordset->adoEOF)
{
curID= VariantToCString(m_pTRecordset->GetCollect("mod_id"));
cmod_name=VariantToCString(m_pTRecordset->GetCollect("mod_name"));
ctr.AddString(cmod_name);
if (!m_pTRecordset->adoEOF)
m_pTRecordset->MoveNext();
}
}
m_pTRecordset->Close();
}
catch(_com_error e)
{
CString errormessage;
MessageBox("读取类别子树出错!");
}
}
void CBaseInfo::OnCbnSelchangeCombo5()
{
// TODO: 在此添加控件通知处理程序代码
UpdateData();
AreaComb.ResetContent();
CString sql,Name,curID;
_RecordsetPtr m_pTRecordset;
if( m_RegionIndex < 0 ) return;
RegionComb.GetLBText(m_RegionIndex,Name);
sql="select mod_id,mod_name from RegionTree where mod_name='"+Name+"'";
try
{
m_pTRecordset.CreateInstance("ADODB.Recordset");
m_pTRecordset->Open((_variant_t)sql,_variant_t((IDispatch*)theApp.m_pDBCon->GetActiveConnection(),true),adOpenDynamic,adLockOptimistic,adCmdText);
m_pTRecordset->MoveFirst();
if(!m_pTRecordset->adoEOF)
{
while(!m_pTRecordset->adoEOF)
{
curID= VariantToCString(m_pTRecordset->GetCollect("mod_id"));
mComb.SetWindowTextA(curID);
SelectRegion(curID,AreaComb);
if (!m_pTRecordset->adoEOF)
m_pTRecordset->MoveNext();
}
}
m_pTRecordset->Close();
}
catch(_com_error e)
{
CString errormessage;
MessageBox("读取类别子树出错!");
}
UpdateData();
}
void CBaseInfo::OnCbnSelchangeCombo4()
{
// TODO: 在此添加控件通知处理程序代码
UpdateData();
CString sql,Name,curID;
_RecordsetPtr m_pTRecordset;
if( m_EndIndex < 0 ) return;
AreaComb.GetLBText(m_EndIndex,Name);
sql="select mod_id,mod_name from RegionTree where mod_name='"+Name+"'";
try
{
m_pTRecordset.CreateInstance("ADODB.Recordset");
m_pTRecordset->Open((_variant_t)sql,_variant_t((IDispatch*)theApp.m_pDBCon->GetActiveConnection(),true),adOpenDynamic,adLockOptimistic,adCmdText);
m_pTRecordset->MoveFirst();
if(!m_pTRecordset->adoEOF)
{
while(!m_pTRecordset->adoEOF)
{
curID= VariantToCString(m_pTRecordset->GetCollect("mod_id"));
mComb.SetWindowTextA(curID);
//SelectRegion(curID,AreaComb);
if (!m_pTRecordset->adoEOF)
m_pTRecordset->MoveNext();
}
}
m_pTRecordset->Close();
}
catch(_com_error e)
{
CString errormessage;
MessageBox("读取类别子树出错!");
}
UpdateData();
}
void CBaseInfo::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
CWnd * pWnd=GetDlgItem(IDD_BASICINFOFRM);
if(pWnd!=NULL&&IsWindow(pWnd->m_hWnd))
pWnd->MoveWindow(0,0,cx,cy);
// TODO: 在此处添加消息处理程序代码
}
int CBaseInfo::GenNewID()
{
int NewID;
this->m_Storage.OpenSql("ProjectTab","Max(ProjectID)");
try
{
CString value;
this->m_Storage.GetFieldValue(0,value);
_variant_t vIndex = (long)0;
_variant_t vtemp = value;
if(vtemp.lVal>0)
NewID =(long)(_variant_t(value))+1;
else
NewID=1;
}
catch(_com_error e)
{
CString stemp;
stemp.Format("获取类别ID最大值出错:%s",e.ErrorMessage());
AfxMessageBox(stemp);
}
return NewID;
}
void CBaseInfo::OnBntModity()
{
// TODO: 在此添加控件通知处理程序代码
CString ProjectName,ProjID,ProjDesc,UserType,RegionName,SalesDate,cDataTime,SalesPerson,ServiceReson,ServiceConcent,ServiceResult;
CString value;
CProjectManageApp* app=(CProjectManageApp*)AfxGetApp();
CProjectManageView* pView=app->GetMyView();
CComboBox* modBox=(CComboBox*)this->GetDlgItem(IDC_COMBO3);
modBox->GetWindowTextA(value);
CComboBox* RegionBox=(CComboBox*)this->GetDlgItem(IDC_COMBO4);
RegionBox->GetWindowTextA(RegionName);
CEdit * mProjName=(CEdit*)this->GetDlgItem(IDC_EDIT1);
mProjName->GetWindowTextA(ProjectName);
CComboBox* mProjID=(CComboBox*)this->GetDlgItem(IDC_COMBO1);
mProjID->GetWindowTextA(UserType);
CEdit* txtSalesDate=(CEdit*)this->GetDlgItem(IDC_DATETIMEPICKER1);
txtSalesDate->GetWindowTextA(SalesDate);
CEdit* txtDataTime=(CEdit*) this->GetDlgItem(IDC_DATETIMEPICKER2);
txtDataTime->GetWindowTextA(cDataTime);
CEdit* txtSalesPerson=(CEdit*) this->GetDlgItem(IDC_EDIT3);
txtSalesPerson->GetWindowTextA(SalesPerson);
CEdit* txtServiceReson=(CEdit*) this->GetDlgItem(IDC_EDIT4);
txtServiceReson->GetWindowTextA(ServiceReson);
CEdit* txtServiceConcent=(CEdit*) this->GetDlgItem(IDC_EDIT5);
txtServiceConcent->GetWindowTextA(ServiceConcent);
CEdit* txtServiceResult=(CEdit*) this->GetDlgItem(IDC_EDIT6);
txtServiceResult->GetWindowTextA(ServiceResult);
CEdit* txtServiceDesc=(CEdit*) this->GetDlgItem(IDC_EDIT7);
txtServiceDesc->GetWindowTextA(ProjDesc);
CEdit* txtPIDbox=(CEdit*) this->GetDlgItem(IDC_EDIT2);
txtPIDbox->GetWindowTextA(ProjID);
CString sql;
sql="update ProjectTab set mod_id="+value+",UserName='"+UserType+"',ProjectName='"+ProjectName+"',[DateTime]='"+SalesDate+"',CDataTime='"+cDataTime+"',EmpTabID='"+SalesPerson+"',ServiceReason='"+ServiceReson+"',ServiceContent='"+ServiceConcent+"',ServiceResult='"+ServiceResult+"',[desc]='"+ProjDesc+"' where ProjectID="+ProjID;
try
{
if(this->m_Storage.ExecSql(sql))
{
MessageBox("修改成功!");
pView->LoadListViewData();
}
}
catch(_com_error e)
{
MessageBox("更新数据发生错误!");
}
}
void CBaseInfo::OnBntDelete()
{
// TODO: 在此添加控件通知处理程序代码
CString sql,sql2,sql3,sql4;
if(theApp.ProjID!="")
{
sql="delete from ProjectTab where ProjectID="+theApp.ProjID+" ";
sql2=" delete from carcost where ProjID="+theApp.ProjID+" ";
sql3=" delete from ManPowerCost where ProjID="+theApp.ProjID+" ";
sql4=" delete from StuffBill where ProjID="+theApp.ProjID+"";
CProjectManageApp* app=(CProjectManageApp*)AfxGetApp();
CProjectManageView* pView=app->GetMyView();
if(MessageBox(_T("真的要退出系统吗?你删除基本信息其他相关信息也删除!"),_T("确定删除"),MB_OKCANCEL|MB_ICONQUESTION)==IDOK)
{
if(this->m_Storage.ExecSql(sql4))
{
pView->m_oSutffList.LoadDataView();
}
if(this->m_Storage.ExecSql(sql3))
{
pView->m_oStuffList.LoadDataView();
}
if(this->m_Storage.ExecSql(sql2))
{
pView->m_oCarList.LoadDataView();
}
if(this->m_Storage.ExecSql(sql))
{
pView->LoadListViewData();
}
}
}
}
void CBaseInfo::ClearText(void)
{
}
void CBaseInfo::Serializeinit()
{
CWnd* pFrame = AfxGetMainWnd();
if (theApp.m_bProgressBarCreated==FALSE) {
for (int pct=10; pct<=100; pct+=10) {
Sleep(150);
if (pFrame)
{
pFrame->SendMessage(MYWM_PROGRESS, pct);
}
}
}
if (pFrame)
pFrame->SendMessage(MYWM_PROGRESS, 0);
}
void CBaseInfo::OnBntExport()
{
// TODO: 在此添加控件通知处理程序代码
CProjectManageApp* app=(CProjectManageApp*)AfxGetApp();
CProjectManageView* pView=app->GetMyView();
CString str,m_Path;
BROWSEINFO bi;
char name[MAX_PATH];
ZeroMemory(&bi,sizeof(BROWSEINFO));
bi.hwndOwner=GetSafeHwnd();
bi.pszDisplayName=name;
bi.lpszTitle="选择存放目录";
bi.ulFlags=BIF_USENEWUI;
LPITEMIDLIST idl=SHBrowseForFolder(&bi);
if(idl==NULL)
return;
SHGetPathFromIDList(idl,str.GetBuffer(MAX_PATH));
str.ReleaseBuffer();
m_Path=str;
if(str.GetAt(str.GetLength()-1)!='\\')
m_Path+="\\";
//Serializeinit();
pView->OnWriteexcel(m_Path);
UpdateData(FALSE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -