机房收费系统之学生基本信息维护

    这个窗体以及它后面三个窗体都用到了组合查询,因此,搞懂一个,其他两个就很轻松的拿下了。

    缕清关系是很重要的,我在这上面也花费了一定功夫,下面是代码,请看。

    If Trim(comboField1.Text) = "" Or Trim(comboOpSign1.Text) = "" Or Trim(txtInquiryContent1.Text) = "" Then
        MsgBox "请将信息填写完整!", vbOKOnly + vbExclamation, "警告"
        Exit Sub
   Else
  txtSQL = "select * from student_Info where " & field(comboField1.Text) & Trim(comboOpSign1.Text) & "'" &            Trim(txtInquiryContent1.Text) & "'"
  Set mrc = ExecuteSQL(txtSQL, MsgText)
  End If
If Trim(comboCombineRelation1.Text) <> "" Then      '检验第二个组合字段的正确性
   If Trim(comboField2.Text) = "" Or Trim(comboOpSign2.Text) = "" Or Trim(txtInquiryContent2.Text) = "" Then
      MsgBox "请将第二行信息填写完整!", vbOKOnly + vbExclamation, "警告"
   Exit Sub
   Else
   '第二个组合字段正确,开始添加信息
  txtSQL = "select * from student_Info where " & field(comboCombineRelation1.Text) & field(comboField2.Text) &    comboOpSign2.Text & "'" & Trim(txtInquiryContent2.Text) & "'"
  Set mrc = ExecuteSQL(txtSQL, MsgText)
  End If
 End If
  If comboCombineRelation2.Text <> "" Then     '检验第三组 组合字段的正确性
     If Trim(comboField3.Text) = "" Or Trim(comboOpSign3.Text) = "" Or Trim(txtInquiryContent3.Text) = "" Then
   MsgBox "请将第三行信息填写完整!", vbOKOnly + vbExclamation, "警告"
 Else
'第三个组合字段正确,开始添加信息
   txtSQL = "select * from student_Info where " & field(comboCombineRelation2.Text) & field(comboField3.Text) &    Trim(comboOpSign3.Text) & "'" & Trim(txtInquiryContent3.Text) & "'"
   Set mrc = ExecuteSQL(txtSQL, MsgText)
   End If
   End If
   If mrc.EOF = True Then
       MsgBox "无此记录!", vbOKOnly + vbExclamation, "警告"
       comboField1.SetFocus
    Else
   'txtSQL = "select * from student_Info where" & " " & field(comboCombineRelation2.Text) & " " &    field(comboField3.Text) & "" & Trim(comboOpSign3.Text) & "" & Trim(txtInquiryContent3.Text) & "'"
  Set mrc = ExecuteSQL(txtSQL, MsgText)
   With MSHFlexGrid1         '把标题写上
        .Rows = 1
        .CellAlignment = 4
        .TextMatrix(0, 0) = "学号"
        .TextMatrix(0, 1) = "姓名"
        .TextMatrix(0, 2) = "卡号"
        .TextMatrix(0, 3) = "余额"
        .TextMatrix(0, 4) = "学院"
        .TextMatrix(0, 5) = "年级"
        .TextMatrix(0, 6) = "班级"
        .TextMatrix(0, 7) = "性别"
        .TextMatrix(0, 8) = "状态"
        .TextMatrix(0, 9) = "备注"
    
        Do While mrc.EOF = False
            .Rows = .Rows + 1
            .CellAlignment = 4
            .TextMatrix(.Rows - 1, 0) = mrc.Fields(1)
            .TextMatrix(.Rows - 1, 1) = mrc.Fields(2)
            .TextMatrix(.Rows - 1, 2) = mrc.Fields(0)
            .TextMatrix(.Rows - 1, 3) = mrc.Fields(7)
            .TextMatrix(.Rows - 1, 4) = mrc.Fields(4)
            .TextMatrix(.Rows - 1, 5) = mrc.Fields(5)
            .TextMatrix(.Rows - 1, 6) = mrc.Fields(6)
            .TextMatrix(.Rows - 1, 7) = mrc.Fields(3)
            .TextMatrix(.Rows - 1, 8) = mrc.Fields(11)
            .TextMatrix(.Rows - 1, 9) = mrc.Fields(8)
       mrc.MoveNext
     Loop
       mrc.Close
End With
End If

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值