封装下拉框控件!将查询到信息塞到下拉框中,将所选的内容截取并显示到静态框(联动显示)
1 int CSetOrgan::GetAllArea(CString& operArea) 2 { 3 CString strTemp; 4 for(int i=0; i<m_cmbDept.GetCount(); i++) 5 { 6 m_cmbDept.DeleteString(i); 7 } 8 this->PrepareReqPack(TX_QUERYORGAN); 9 AddField((getUIData().getUserId()), sorder0, F_SORDER0); 10 AddFieldI(0, lvol0, F_LVOL0); 11 AddField("0", sholder_type, F_SHOLDER_TYPE); 12 AddField(getUIData().getUserBankArea(),scust_auth,F_SCUST_AUTH); 13 AddField("0", sstatus1, F_SSTATUS1); 14 if(Send2BCC(&m_data) != 0) 15 { 16 strTemp = this->GetErrorMsg(); 17 if(strTemp.Compare("无记录")) 18 { 19 AfxMessageBox(this->GetErrorMsg()); 20 return 0; 21 } 22 m_cmbArea.AddString("00000000-全部"); 23 return 0; 24 } 25 if(operArea.Compare("")) 26 { 27 for(i=0; i<m_data.size(); i++) 28 { 29 if(!operArea.Compare(m_data[i].sholder_ac_no)) 30 { 31 strTemp.Format("%s-%s", m_data[i].sholder_ac_no, m_data[i].sall_name); 32 m_cmbArea.AddString(strTemp); 33 } 34 } 35 return 1; 36 } 37 else 38 { 39 m_cmbArea.AddString("00000000-全部"); 40 for(i=0; i<m_data.size(); i++) 41 { 42 strTemp.Format("%s-%s", m_data[i].sholder_ac_no, m_data[i].sall_name); 43 m_cmbArea.AddString(strTemp); 44 } 45 return 0; 46 } 47 } 48 //这个里面呢~,也是很简单就是依靠上一级选择好了然后再去查下选好的条件下的东西 49 void CSetOrgan::GetAllDept() 50 { 51 CString strTemp; 52 CString strArea; 53 int i=0; 54 int pos=0; 55 CString operDept = getUIData().getUserDepuBank(); 56 m_cmbArea.GetWindowText(strTemp); 57 if(!strTemp.Compare("00000000-全部")) 58 { 59 m_cmbDept.ResetContent(); 60 m_cmbDept.AddString("00000000-全部"); 61 m_cmbDept.SetCurSel(0); 62 return; 63 } 64 m_cmbDept.ResetContent(); 65 this->PrepareReqPack(TX_QUERYORGAN); 66 if(operDept.GetLength() != 0) 67 { 68 AddField((LPCSTR)operDept, sholder_ac_no, F_SHOLDER_AC_NO); 69 AddFieldI(2, lvol0, F_LVOL0); 70 AddFieldI(1, lvol8, F_LVOL8); 71 AddField("1", sholder_type, F_SHOLDER_TYPE); 72 } 73 else 74 { 75 pos = strTemp.FindOneOf("-"); 76 strArea = strTemp.Left(pos); 77 m_cmbDept.ResetContent(); 78 AddField((getUIData().getUserId()), sorder0, F_SORDER0); 79 AddFieldI(2, lvol0, F_LVOL0); 80 AddField("1", sholder_type, F_SHOLDER_TYPE); 81 AddField((LPCSTR)strArea, scust_auth, F_SCUST_AUTH); 82 } 83 84 m_data.clear(); 85 if(Send2BCC(&m_data) != 0) 86 { 87 strTemp = this->GetErrorMsg(); 88 if(strTemp.Compare("无记录")) 89 { 90 m_cmbDept.AddString("00000000-全部"); 91 m_cmbDept.SetCurSel(0); 92 return; 93 } 94 else 95 { 96 AfxMessageBox(this->GetErrorMsg()); 97 return; 98 } 99 } 100 if(operDept.Compare("")) 101 { 102 for(i=0; i<m_data.size(); i++) 103 { 104 strTemp.Format("%s-%s", m_data[i].sholder_ac_no, m_data[i].sall_name); 105 m_cmbDept.AddString(strTemp); 106 } 107 m_cmbDept.SetCurSel(0); 108 } 109 else 110 { 111 m_cmbDept.AddString("00000000-全部"); 112 for(i=0; i<m_data.size(); i++) 113 { 114 strTemp.Format("%s-%s", m_data[i].sholder_ac_no, m_data[i].sall_name); 115 m_cmbDept.AddString(strTemp); 116 } 117 pos = m_cmbDept.FindString(0,"00000000-全部"); 118 m_cmbDept.SetCurSel(pos); 119 } 120 }
具体描述:针对下拉框呢~,就是把查到的信息全部塞进去。然后呢当选择了下拉框中某一条后将这一条的信息的某些信息塞到静态框、或者可以依据所选的筛选另一个下拉框的内容!
好了~,不多说了上效果图了这个是选择一个后的效果换了一个选项后
1 //这是实现能够将东西显示在框里的部分 2 int COtherCustmerInfoUpdate::GetMemberId(CString& operArea) // 查询所有的会员显示在下拉框里面, 3 { 4 CString strTemp,sGetMemberId,sMemberName,sBankAcc; 5 int i; 6 int pos=0; 7 this->PrepareReqPack(TX_QUERYMEMBERID); //TX_QUERYORGAN TX_QUERYMEMBERID 8 AddFieldI(0, lvol0, F_LVOL0);//机构查询标志 9 AddField("0", sholder_type, F_SHOLDER_TYPE);//机构级别 10 if(Send2BCC(&m_data) != 0) 11 { 12 AfxMessageBox(this->GetErrorMsg()); 13 return 0; 14 } 15 m_cmb_MemberId.AddString("00000000-全部"); 16 for(i=0; i<m_data.size(); i++) 17 { 18 sGetMemberId.Format("%s-%s", m_data[i].sholder_ac_no , m_data[i].sall_name); //将传递回来的值转换成字符串 19 m_cmb_MemberId.AddString(sGetMemberId); 20 } 21 return 0; 22 } 23 //这个函数是联动显示 24 void COtherCustmerInfoUpdate::GetMemberInformation() 25 { 26 CString sMemberId ,sGetNumber; 27 m_cmb_MemberId.GetWindowText(sMemberId); 28 int pos = sMemberId.FindOneOf("-"); 29 sGetNumber = sMemberId.Left(pos); 30 GetMemberInfo(sGetNumber); 31 32 } 33 //这个是将截取的值显示到静态框部分 34 int COtherCustmerInfoUpdate::GetMemberInfo(CString& sGetNumber) 35 { 36 CString strtmp,sGetMemberId,sMemberName,sBankAcc; 37 m_cmb_MemberId.GetWindowText(strtmp); 38 for(int i=0; i<m_data.size(); i++) 39 { 40 if (!sGetNumber.Compare(m_data[i].sholder_ac_no)) 41 { 42 sMemberName.Format("%s", m_data[i].sall_name); 43 sBankAcc.Format("%s", m_data[i].scust_limit2); 44 m_edt_MemberName.SetWindowText(sMemberName); 45 m_edt_MemberBankAcc.SetWindowText(sBankAcc); 46 } 47 } 48 return 0; 49 } 50 //这一部分呢~,是将确定的值截取好,然后呢准备收拾收拾通过架构发到后台哟~ 51 { 52 CString strTemp,roletype; 53 m_cmb_MemberId.GetWindowText(strTemp); 54 if(!strTemp.Compare("00000000-全部")) //恒等于全部 55 { 56 AfxMessageBox("会员号不能为空!"); 57 return; 58 } 59 else 60 { 61 int pos = strTemp.FindOneOf("-"); 62 sMemberId = strTemp.Left(pos); 63 } 64 } 65 //这一部分呢~是架构里的初始化 66 { 67 operArea = getUIData().getUserBankArea(); 68 if(GetMemberId(operArea)) 69 { 70 m_cmb_MemberId.SetCurSel(0); 71 } 72 else 73 { 74 int pos = m_cmb_MemberId.FindString(0,"00000000-全部"); 75 m_cmb_MemberId.SetCurSel(pos); 76 // GetMemberInformation(); 77 } 78 }
那么上面还有一种依据选好的结果筛选怎么操作呢? 一不小心好像放上去了
总之呢,记得要有个消息控件去联动控制
ON_CBN_SELCHANGE(IDC_CMB_AREA, OnSelchangeCmbArea) // 这个就是一种
唔,如果实在不知道可以自己在vc上面调试f7是build、f5启动debug版本也可以直接跳到下个断点哟~、f9打断点、f10单步调试、f11忘记了。。。。
好了,今天的记录就到这里了!