Searching means searching and searching. It means finding the information you want in one or more places. If I want to search my own blog, the name is "Love in the snow, I entered Ding Guohua in the search box of Baidu. What kind of surprises will happen to me?
Ah, this information is not what I want, so I search again. The search result of "ding Guohua Langfang Normal University csdn" is as follows:
Obviously, this is not what I want. I went on to search for "ding Guohua Langfang Normal University csdn ";
In my understanding, composite queries are based on conditions and are precise step by step to get the answer we want. In the data room charging system, there are several queries involving composite queries. Next, take the maintenance of students' basic information as an example to explain the combined query. In the second data room charging system, I did not use the original Hu Yang version template. The original version passed the seven fields of the card number, student number, name, gender, department, grade, and class number, to query, the operators are equal to, greater than, less than, not equal to, but in real life, there is a condition where gender is greater than what, and name is less than what, so I re-designed the form, the four field names are selected as the condition for the combined query to simplify the difficulty of the Combined Query. the main interface is designed as follows:
Next, let's look at our specific implementation process. First, the entity layer --- the E layer;
<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 PropertyEnd Class</span>
Data access layer --- layer D
<Span style = "font-size: 18px;"> Imports System. data. sqlClientPublic Class extends 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 'instantiate 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 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 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 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 cmd = New SqlCommand (SQL, conn) dataAdpter. selectCommand = cmd dataAdpter. fill (dst, "Student_info") dt = dst. tables ("Student_info") End Using Return dt End FunctionEnd Class </span>
Business logic layer --- layer 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 FunctionEnd Class</span>
Display layer --- U layer;
<Span style = "font-size: 18px;"> Imports BLLPublic 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' create a column DataGridView1.DataSource = dt DataGridView1.Columns (0) automatically ). headerText = "student ID" Maid (1 ). headerText = "dview1.columns (2 ). headerText = "name" Maid (3 ). headerText = "gender" Maid (4 ). headerText = "don't" DataGridView1.Columns (5 ). headerText = "Grade" Maid (6 ). headerText = "class" DataGridView1.Columns (7 ). headerText = "Remarks" 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 SubEnd Class </span>
The running effect is as follows:
Since then, the maintenance of basic information for students has come to an end for the time being. When I started to record the maintenance of basic information for students, I didn't know where to start, and I had to worry about various ways of escaping, as I have grown up, I can no longer do things with my own temper. I want to take responsibility for what I have done and go over. Is it really so difficult? I think only people who have passed through can really understand the taste.
I once saw some comments from Mr Mi, such as a blog post. I cannot remember the main content of this blog. It seems that it is a blog post that solves a problem and then solves it successfully, teacher Mi said, is this process very helpful? Yes, this process not only raises people, but also trains people and tests our mentality of facing new knowledge. It is a drag-and-drop process, and our current goal is red and red, we can still face it calmly. In the past two days, we have to deal with the three combined queries. The data center charging system is not complete and will be continued ......