程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> Visual Basic語言 >> VB.NET >> VB.NET版機房免費零碎之組合查詢

VB.NET版機房免費零碎之組合查詢

編輯:VB.NET

VB.NET版機房免費零碎之組合查詢。本站提示廣大學習愛好者:(VB.NET版機房免費零碎之組合查詢)文章只能為提供參考,不一定能成為您想要的結果。以下是VB.NET版機房免費零碎之組合查詢正文


查詢的意思就是查找,尋覓,指在某一個或幾個中央找出自己所要的信息,假設我想搜索一下我自己寫的博客,名字叫做初雪之戀,我在百度的搜索框中輸出丁國華三個字,會有怎樣的驚喜等著我?

啊哦,這個信息並不是我想要的,於是我再搜,“丁國華 廊坊師范學院  csdn”搜索後果如下:

很顯然,這個還不是我想要的後果,我接著搜,“丁國華 廊坊師范學院 csdn 初雪之戀”;

在我的了解中,組合查詢就是經過條件層層限制,一步一步准確,失掉我們想要的答案,在機房免費零碎中,有好幾處觸及組合查詢,接上去,以學生根本信息維護為例,解說組合查詢。在第二次機房免費零碎中,我沒有按原來胡陽版的模板來,原版的經過卡號,學號,姓名,性別,系別,年級,班號七個字段,來停止查詢,操作符辨別為等於,大於,小於,不等於,可是,理想生活中哪有性別大於什麼,姓名小於什麼的條件,所以我重新設計了一下窗體,從中挑選了四個字段名作為組合查詢的條件簡化了組合查詢的難度,主界面設計如下:

接上去,看看我們的詳細完成進程,首先實體層---E層;

<span style="font-size:18px;">Public Class Studentinfo  
    Public studentNo As String
    Public Property _studentNo As String
        Get
            Return studentNo  
        End Get
        Set(value As String)  
            studentNo = value  
        End Set
    End Property
    Public cardNo As String
    Public Property _cardNo As String
        Get
            Return cardNo  
        End Get
        Set(value As String)  
            cardNo = value  
        End Set
    End Property
    Public studentName As String
    Public Property _studentName As String
        Get
            Return studentName  
        End Get
        Set(value As String)  
            studentName = value  
        End Set
    End Property
    Public sex As String
    Public Property _sex As String
        Get
            Return sex  
        End Get
        Set(value As String)  
            sex = value  
        End Set
    End Property
    Public department As String
    Public Property _department  
        Get
            Return department  
        End Get
        Set(value)  
            department = value  
        End Set
    End Property
    Public grade As String
    Public Property _grade  
        Get
            Return grade  
        End Get
        Set(value)  
            grade = value  
        End Set
    End Property
    Public stuclass As String
    Public Property _stuclass  
        Get
            Return stuclass  
        End Get
        Set(value)  
            stuclass = value  
        End Set
    End Property
    Public remark As String
    Public Property _remark  
        Get
            Return remark  
        End Get
        Set(value)  
            remark = value  
        End Set
    End Property
    Public Handler As String
    Public Property _Handler  
        Get
            Return Handler  
        End Get
        Set(value)  
            Handler = value  
        End Set
    End Property
End Class
</span>

前往欄目頁:

數據訪問層---D層

<span style="font-size:18px;">Imports System.Data.SqlClient  
Public Class StuBaInforPreserveDAO  
    Public Function query(ByVal cmbOperator1 As String, ByVal cardNo As String, ByVal cmbOperator2 As String, ByVal studentNo As String, ByVal cmbOperator3 As String, ByVal department As String, ByVal cmbOperator4 As String, ByVal grade As String) As DataTable  
        Dim db As New Entity.Dbutil '實例化  
        Dim dt As New DataTable  
      
        Using conn As New SqlConnection(db.connstring)  
            conn.Open()  
      
            Dim sql As String
            Dim cmd As SqlCommand  
            Dim dataAdpter As New SqlDataAdapter  
            Dim dst As New DataSet  
            Dim flag(3) As Boolean
      
            sql = "select studentNo,cardNo,studentName,sex,department,grade,class,remark,handler  from Student_info where "
            If Not (cardNo = "") Then
                sql = sql & "studentNo" & cmbOperator1 & "'" & cardNo & "'"
                flag(0) = True
            End If
      
            If Not (studentNo = "") Then
                flag(1) = True
                If flag(0) = True Then
                    sql = sql & "and studentNo " & cmbOperator2 & "'" & studentNo & "'"
                Else
                    sql = sql & "studentNo" & cmbOperator2 & "'" & studentNo & "'"
                End If
            End If
      
            If Not (department = "") Then
                flag(2) = True
                If flag(0) = True Or flag(1) = True Then
                    sql = sql & "and department " & cmbOperator3 & "'" & department & "'"
                Else
                    sql = sql & "department" & cmbOperator3 & "'" & department & "'"
                End If
            End If
      
            If Not (grade = "") Then
                flag(3) = True
                If flag(0) = True Or flag(1) = True Or flag(2) = True Then
                    sql = sql & "and grade" & cmbOperator4 & "'" & grade & "'"
                Else
                    sql = sql & "grade" & cmbOperator4 & "'" & grade & "'"
                End If
            End If
            cmd = New SqlCommand(sql, conn)  
            dataAdpter.SelectCommand = cmd  
            dataAdpter.Fill(dst, "Student_info")  
            dt = dst.Tables("Student_info")  
        End Using  
        Return dt  
    End Function
End Class
</span>

業務邏輯層---B層;

<span style="font-size:18px;">Public Class StuBaInforPreserveManager  
    Public Function query(ByVal cmbOperator1 As String, ByVal cardNo As String, ByVal cmbOperator2 As String, ByVal studentNo As String, ByVal cmbOperator3 As String, ByVal department As String, ByVal cmbOperator4 As String, ByVal grade As String) As DataTable  
        Dim StuBaInforPreserveDAO As New DAL.StuBaInforPreserveDAO  
        Return StuBaInforPreserveDAO.query(cmbOperator1, cardNo, cmbOperator2, studentNo, cmbOperator3, department, cmbOperator4, grade)  
    End Function
End Class</span>

顯示層---U層;

<span style="font-size:18px;">Imports BLL  
      
Public Class frmStuBaInforPreserve  
    Private Sub btnInquery_Click(sender As Object, e As EventArgs) Handles btnInquery.Click  
        Dim StuBaInforPreserveManager As New BLL.StuBaInforPreserveManager  
        Dim dt As New DataTable  
      
        dt = StuBaInforPreserveManager.query(cmbOperator1.Text, txtCardNo.Text, cmbOperator2.Text, txtStuNo.Text, cmbOperator3.Text, txtDepartment.Text, cmbOperator4.Text, txtGrade.Text)  
        DataGridView1.AutoGenerateColumns = True  '自動創立列  
        DataGridView1.DataSource = dt  
      
        DataGridView1.Columns(0).HeaderText = "學號"
        DataGridView1.Columns(1).HeaderText = "卡號"
        DataGridView1.Columns(2).HeaderText = "姓名"
        DataGridView1.Columns(3).HeaderText = "性別"
        DataGridView1.Columns(4).HeaderText = "系別"
        DataGridView1.Columns(5).HeaderText = "年級"
        DataGridView1.Columns(6).HeaderText = "班級"
        DataGridView1.Columns(7).HeaderText = "備注"
      
      
    End Sub
      
    Private Sub frmStuBaInforPreserve_Load(sender As Object, e As EventArgs) Handles MyBase.Load  
        cmbOperator1.Enabled = False
        txtCardNo.Text = ""
        txtCardNo.Enabled = False
      
        cmbOperator1.Items.Add("=")  
        cmbOperator1.Items.Add(">")  
        cmbOperator1.Items.Add("<")  
        cmbOperator1.Items.Add("<>")  
        cmbOperator1.SelectedIndex = 0  
      
        cmbOperator2.Enabled = False
        txtStuNo.Text = ""
        txtStuNo.Enabled = False
        cmbOperator2.Items.Add("=")  
        cmbOperator2.Items.Add(">")  
        cmbOperator2.Items.Add("<")  
        cmbOperator2.Items.Add("<>")  
        cmbOperator2.SelectedIndex = 0  
      
        cmbOperator3.Enabled = False
        txtDepartment.Text = ""
        txtDepartment.Enabled = False
        cmbOperator3.Items.Add("=")  
        cmbOperator3.Items.Add("<>")  
        cmbOperator3.SelectedIndex = 0  
      
        cmbOperator4.Enabled = False
        txtGrade.Text = ""
        txtGrade.Enabled = False
        cmbOperator4.Items.Add("=")  
        cmbOperator4.Items.Add("<>")  
        cmbOperator4.SelectedIndex = 0  
      
    End Sub
      
    Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click  
        Me.Close()  
    End Sub
    Private Sub chkCardNo_Click(sender As Object, e As EventArgs) Handles chkCardNo.Click  
        If chkCardNo.Checked Then
            txtCardNo.Enabled = True
            cmbOperator1.Enabled = True
        Else
            txtCardNo.Enabled = False
            cmbOperator1.Enabled = False
            txtCardNo.Text = ""
            cmbOperator1.SelectedIndex = 0  
      
        End If
    End Sub
    Private Sub chkStuNo_Click(sender As Object, e As EventArgs) Handles chkStuNo.Click  
        If chkStuNo.Checked Then
            txtStuNo.Enabled = True
            cmbOperator2.Enabled = True
        Else
            txtStuNo.Enabled = False
            cmbOperator2.Enabled = False
            txtStuNo.Text = ""
            cmbOperator2.SelectedIndex = 0  
        End If
    End Sub
      
         
    Private Sub chkDepartment_Click(sender As Object, e As EventArgs) Handles chkDepartment.Click  
        If chkDepartment.Checked Then
            txtDepartment.Enabled = True
            cmbOperator3.Enabled = True
        Else
            txtDepartment.Enabled = False
            cmbOperator3.Enabled = False
            txtDepartment.Text = ""
            cmbOperator3.SelectedIndex = 0  
        End If
    End Sub
    Private Sub chkGrade_Click(sender As Object, e As EventArgs) Handles chkGrade.Click  
        If chkGrade.Checked Then
            txtGrade.Enabled = True
            cmbOperator4.Enabled = True
        Else
            txtGrade.Enabled = False
            cmbOperator4.Enabled = False
            txtGrade.Text = ""
            cmbOperator4.SelectedIndex = 0  
        End If
    End Sub
End Class</span>

運轉效果如下:

自此學生根本信息維護就暫時告一段落,開端敲學生根本信息維護的時分,不知道從哪兒下手,各種糾結,各種逃避,各種不想敲,可是,我曾經長大了,我不能再由著我自己的性子來做事,我要為我自己做的事情擔任任,走過來了,真的有那麼困難麼?我想其中的味道只要走過的人才干夠真正明白。

已經看到米教師給一篇博文這樣的評語,這篇博客的次要內容,我記不清楚了,仿佛是處理一個問題,然後成功處理的一篇博文,米教師說,這個進程是不是很養人,對,這個進程不光養人,而且錘煉人,考驗我們面對新知識的心態,是一拖再拖,今目的紅了又紅,還是安然面對,兩天把三個組合查詢逐個搞定,機房免費零碎未完,待續......

作者:csdn博客 丁國華

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved