📄 sjclview.cpp
字号:
m_ListCtrl.SetItemText(0,3,s);
s.Format("%f",dlg.m_fChuj);
m_ListCtrl.SetItemText(0,4,s);
s.Format("%f",dlg.m_fDuibj);
m_ListCtrl.SetItemText(0,5,s);
m_ListCtrl.SetItemText(0,6,dlg.m_sChangj);
m_ListCtrl.SetItemText(0,7,dlg.m_sCtel);
m_ListCtrl.SetItemText(0,8,dlg.m_sCfax);
m_ListCtrl.SetItemText(0,9,dlg.m_sClianxr);
m_ListCtrl.SetItemText(0,10,dlg.m_sGongys);
m_ListCtrl.SetItemText(0,11,dlg.m_sGtel);
m_ListCtrl.SetItemText(0,12,dlg.m_sGfax);
m_ListCtrl.SetItemText(0,13,dlg.m_sGlianxr);
//s=dlg.m_date.Format(_T("%Y%m%d"));
m_ListCtrl.SetItemText(0,14,dlg.m_date);
m_ListCtrl.SetItemText(0,15,dlg.m_sBeiz);
}
}
m_pSet->MoveFirst();
}
int CSjclView::Show()
{
int i=0;
m_pSet->MoveFirst();
do
{
CString s;
m_ListCtrl.InsertItem(i,m_pSet->m_column1,0);
m_ListCtrl.SetItemText(i,1,m_pSet->m_column2);
m_ListCtrl.SetItemText(i,2,m_pSet->m_column3);
s.Format("%f",m_pSet->m_column4);
m_ListCtrl.SetItemText(i,3,s);
s.Format("%f",m_pSet->m_column5);
m_ListCtrl.SetItemText(i,4,s);
s.Format("%f",m_pSet->m_column6);
m_ListCtrl.SetItemText(i,5,s);
m_ListCtrl.SetItemText(i,6,m_pSet->m_column7);
m_ListCtrl.SetItemText(i,7,m_pSet->m_column8);
m_ListCtrl.SetItemText(i,8,m_pSet->m_column9);
m_ListCtrl.SetItemText(i,9,m_pSet->m_column10);
m_ListCtrl.SetItemText(i,10,m_pSet->m_column11);
m_ListCtrl.SetItemText(i,11,m_pSet->m_column12);
m_ListCtrl.SetItemText(i,12,m_pSet->m_column13);
m_ListCtrl.SetItemText(i,13,m_pSet->m_column14);
//s=m_pSet->m_column15.Format(_T("%Y%m%d"));
m_ListCtrl.SetItemText(i,14,m_pSet->m_column15);
m_ListCtrl.SetItemText(i,15,m_pSet->m_column16);
i++;
m_pSet->MoveNext();
} while(!m_pSet->IsEOF());
m_pSet->MoveFirst();
return i;
}
HBRUSH CSjclView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
//HBRUSH hbr = CRecordView::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
// TODO: Return a different brush if the default is not desired
return m_Brush;
}
void CSjclView::OnButtonQuery()
{
// TODO: Add your control notification handler code here
CQUERY_DLG dlg;
// BOOL k=FALSE;
if(dlg.DoModal()==IDOK)
{
m_ListCtrl.DeleteAllItems();
int i=0;
CSjclSet mySet;
CString strSQL;
if(dlg.m_iCombo==0)
strSQL=_T("select * from jinhb where bianh='"+dlg.m_sNeir+"'");
else if (dlg.m_iCombo==1)
strSQL=_T("select * from jinhb where mingc='"+dlg.m_sNeir+"'");
else if (dlg.m_iCombo==2)
strSQL=_T("select * from jinhb where xingh='"+dlg.m_sNeir+"'");
else if (dlg.m_iCombo==3)
strSQL=_T("select * from jinhb where changj like '"+dlg.m_sNeir+"'");
else if (dlg.m_iCombo==4)
strSQL=_T("select * from jinhb where gongys like '"+dlg.m_sNeir+"'");
else if (dlg.m_iCombo==5)
strSQL=_T("select * from jinhb where riq>='"+dlg.m_date1+"' and riq<='"+dlg.m_date2+"'");
mySet.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL,CRecordset::none);
mySet.m_strSort="bianh";
if(mySet.GetRecordCount()==0)
AfxMessageBox("无符合条件的记录!");
else
{
mySet.MoveFirst();
do{
CString s;
m_ListCtrl.InsertItem(i,mySet.m_column1,0);
m_ListCtrl.SetItemText(i,1,mySet.m_column2);
m_ListCtrl.SetItemText(i,2,mySet.m_column3);
s.Format("%f",mySet.m_column4);
m_ListCtrl.SetItemText(i,3,s);
s.Format("%f",mySet.m_column5);
m_ListCtrl.SetItemText(i,4,s);
s.Format("%f",mySet.m_column6);
m_ListCtrl.SetItemText(i,5,s);
m_ListCtrl.SetItemText(i,6,mySet.m_column7);
m_ListCtrl.SetItemText(i,7,mySet.m_column8);
m_ListCtrl.SetItemText(i,8,mySet.m_column9);
m_ListCtrl.SetItemText(i,9,mySet.m_column10);
m_ListCtrl.SetItemText(i,10,mySet.m_column11);
m_ListCtrl.SetItemText(i,11,mySet.m_column12);
m_ListCtrl.SetItemText(i,12,mySet.m_column13);
m_ListCtrl.SetItemText(i,13,mySet.m_column14);
//s=m_pSet->m_column15.Format(_T("%Y%m%d"));
m_ListCtrl.SetItemText(i,14,mySet.m_column15);
m_ListCtrl.SetItemText(i,15,mySet.m_column16);
i++;
mySet.MoveNext();
} while(!mySet.IsEOF());
}
}
}
void CSjclView::OnButtonAll()
{
// TODO: Add your control notification handler code here
m_ListCtrl.DeleteAllItems();
this->Show();
}
void CSjclView::OnButtonDelete()
{
// TODO: Add your control notification handler code here
CDEL_DLG dlg;
if(dlg.DoModal()==IDOK)
{
if(dlg.m_sMim!="1234")
AfxMessageBox("你没有权限删除记录!请重输入密码:");
else
{
BOOL b=FALSE;
m_pSet->MoveFirst();
do
{
if(dlg.m_sBianh!=m_pSet->m_column1)
m_pSet->MoveNext();
else
{
m_ListCtrl.DeleteAllItems();
b=TRUE;
m_pSet->Delete();
m_pSet->Requery();
this->Show();
m_pSet->MoveFirst();
break;
}
}while(!m_pSet->IsEOF());
if(b==FALSE)
AfxMessageBox("没有此记录");
}
}
}
void CSjclView::OnButtonEdit()
{
// TODO: Add your control notification handler code here
CEDIT_DLG dlg;
POSITION pos=m_ListCtrl.GetFirstSelectedItemPosition();
int nItem;
// dlg.DoModal();
//if(dlg.DoModal()==IDOK)
dlg.flag=FALSE;
if(pos)
{
nItem=m_ListCtrl.GetNextSelectedItem(pos);
dlg.m_sBianh=m_ListCtrl.GetItemText(nItem,0);
dlg.m_sMingc=m_ListCtrl.GetItemText(nItem,1);
dlg.m_sXingh=m_ListCtrl.GetItemText(nItem,2);
// dlg.m_fJinj=m_ListCtrl.GetItemText(nItem,3);
// dlg.m_fChuj=m_ListCtrl.GetItemText(nItem,4);
// dlg.m_fDuibj=m_ListCtrl.GetItemText(nItem,5);
dlg.m_sChangj=m_ListCtrl.GetItemText(nItem,6);
dlg.m_sCtel=m_ListCtrl.GetItemText(nItem,7);
dlg.m_sCfax=m_ListCtrl.GetItemText(nItem,8);
dlg.m_sClianxr=m_ListCtrl.GetItemText(nItem,9);
dlg.m_sGongys=m_ListCtrl.GetItemText(nItem,10);
dlg.m_sGtel=m_ListCtrl.GetItemText(nItem,11);
dlg.m_sGfax=m_ListCtrl.GetItemText(nItem,12);
dlg.m_sGlianxr=m_ListCtrl.GetItemText(nItem,13);
dlg.m_date=m_ListCtrl.GetItemText(nItem,14);
dlg.m_sBeiz=m_ListCtrl.GetItemText(nItem,15);
// dlg.UpdateData(FALSE);
dlg.DoModal();
}
else
{
AfxMessageBox("你可以选择一行记录来加快更改!");
}
if(dlg.flag)
{
if(dlg.m_sMim!="1234")
AfxMessageBox("你没有权限更改记录!请重输入密码:");
else
{
BOOL b=FALSE;
m_pSet->MoveFirst();
do
{
if(dlg.m_sBianh!=m_pSet->m_column1)
m_pSet->MoveNext();
else
{
m_ListCtrl.DeleteAllItems();
m_pSet->Edit();
b=TRUE;
m_pSet->m_column1=dlg.m_sBianh;
m_pSet->m_column2=dlg.m_sMingc;
m_pSet->m_column3=dlg.m_sXingh;
m_pSet->m_column4=dlg.m_fJinj;
m_pSet->m_column5=dlg.m_fChuj;
m_pSet->m_column6=dlg.m_fDuibj;
m_pSet->m_column7=dlg.m_sChangj;
m_pSet->m_column8=dlg.m_sCtel;
m_pSet->m_column9=dlg.m_sCfax;
m_pSet->m_column10=dlg.m_sClianxr;
m_pSet->m_column11=dlg.m_sGongys;
m_pSet->m_column12=dlg.m_sGtel;
m_pSet->m_column13=dlg.m_sGfax;
m_pSet->m_column14=dlg.m_sGlianxr;
m_pSet->m_column15=dlg.m_date;
m_pSet->m_column16=dlg.m_sBeiz;
m_pSet->Update();
m_pSet->Requery();
this->Show();
m_pSet->MoveFirst();
break;
}
}while(!m_pSet->IsEOF());
if(b==FALSE)
AfxMessageBox("没有此记录");
}
}
}
void CSjclView::OnButtonSort()
{
// TODO: Add your control notification handler code here
m_ListCtrl.DeleteAllItems();
m_pSet->m_strSort="bianh";
m_pSet->Requery();
this->Show();
}
void CSjclView::OnDblclkList1(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
OnButtonEdit();
*pResult = 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -