frmCommQuery.vb
上传用户:wj57717022
上传日期:2014-12-16
资源大小:4093k
文件大小:32k
- Imports System.Data.SqlClient
- Imports System.Windows.Forms
- Public Class frmCommQuery
- Inherits System.Windows.Forms.Form
- #Region " Windows 窗体设计器生成的代码 "
- Public Sub New()
- MyBase.New()
- '该调用是 Windows 窗体设计器所必需的。
- InitializeComponent()
- '在 InitializeComponent() 调用之后添加任何初始化
- End Sub
- '窗体重写 dispose 以清理组件列表。
- Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
- If disposing Then
- If Not (components Is Nothing) Then
- components.Dispose()
- End If
- End If
- MyBase.Dispose(disposing)
- End Sub
- 'Windows 窗体设计器所必需的
- Private components As System.ComponentModel.IContainer
- '注意: 以下过程是 Windows 窗体设计器所必需的
- '可以使用 Windows 窗体设计器修改此过程。
- '不要使用代码编辑器修改它。
- Friend WithEvents StatusBar1 As System.Windows.Forms.StatusBar
- Friend WithEvents ToolBar1 As System.Windows.Forms.ToolBar
- Friend WithEvents tbrquery As System.Windows.Forms.ToolBarButton
- Friend WithEvents tbrprint As System.Windows.Forms.ToolBarButton
- Friend WithEvents tbrexit As System.Windows.Forms.ToolBarButton
- Friend WithEvents Panel1 As System.Windows.Forms.Panel
- Friend WithEvents ListBox1 As System.Windows.Forms.ListBox
- Friend WithEvents Panel2 As System.Windows.Forms.Panel
- Friend WithEvents Panel3 As System.Windows.Forms.Panel
- Friend WithEvents Button5 As System.Windows.Forms.Button
- Friend WithEvents Button4 As System.Windows.Forms.Button
- Friend WithEvents Button3 As System.Windows.Forms.Button
- Friend WithEvents Button2 As System.Windows.Forms.Button
- Friend WithEvents Button1 As System.Windows.Forms.Button
- Friend WithEvents Panel4 As System.Windows.Forms.Panel
- Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
- Friend WithEvents Panel5 As System.Windows.Forms.Panel
- Friend WithEvents DataGrid2 As System.Windows.Forms.DataGrid
- Friend WithEvents DataGrid1 As System.Windows.Forms.DataGrid
- Friend WithEvents ImageList2 As System.Windows.Forms.ImageList
- <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
- Me.components = New System.ComponentModel.Container
- Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmCommQuery))
- Me.StatusBar1 = New System.Windows.Forms.StatusBar
- Me.ToolBar1 = New System.Windows.Forms.ToolBar
- Me.tbrquery = New System.Windows.Forms.ToolBarButton
- Me.tbrprint = New System.Windows.Forms.ToolBarButton
- Me.tbrexit = New System.Windows.Forms.ToolBarButton
- Me.ImageList2 = New System.Windows.Forms.ImageList(Me.components)
- Me.Panel1 = New System.Windows.Forms.Panel
- Me.ListBox1 = New System.Windows.Forms.ListBox
- Me.Panel2 = New System.Windows.Forms.Panel
- Me.DataGrid1 = New System.Windows.Forms.DataGrid
- Me.Panel3 = New System.Windows.Forms.Panel
- Me.Button5 = New System.Windows.Forms.Button
- Me.Button4 = New System.Windows.Forms.Button
- Me.Button3 = New System.Windows.Forms.Button
- Me.Button2 = New System.Windows.Forms.Button
- Me.Button1 = New System.Windows.Forms.Button
- Me.Panel4 = New System.Windows.Forms.Panel
- Me.TextBox1 = New System.Windows.Forms.TextBox
- Me.Panel5 = New System.Windows.Forms.Panel
- Me.DataGrid2 = New System.Windows.Forms.DataGrid
- Me.Panel1.SuspendLayout()
- Me.Panel2.SuspendLayout()
- CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).BeginInit()
- Me.Panel3.SuspendLayout()
- Me.Panel4.SuspendLayout()
- Me.Panel5.SuspendLayout()
- CType(Me.DataGrid2, System.ComponentModel.ISupportInitialize).BeginInit()
- Me.SuspendLayout()
- '
- 'StatusBar1
- '
- Me.StatusBar1.Location = New System.Drawing.Point(0, 498)
- Me.StatusBar1.Name = "StatusBar1"
- Me.StatusBar1.Size = New System.Drawing.Size(798, 17)
- Me.StatusBar1.TabIndex = 18
- '
- 'ToolBar1
- '
- Me.ToolBar1.Appearance = System.Windows.Forms.ToolBarAppearance.Flat
- Me.ToolBar1.Buttons.AddRange(New System.Windows.Forms.ToolBarButton() {Me.tbrquery, Me.tbrprint, Me.tbrexit})
- Me.ToolBar1.DropDownArrows = True
- Me.ToolBar1.ImageList = Me.ImageList2
- Me.ToolBar1.Location = New System.Drawing.Point(0, 0)
- Me.ToolBar1.Name = "ToolBar1"
- Me.ToolBar1.ShowToolTips = True
- Me.ToolBar1.Size = New System.Drawing.Size(798, 41)
- Me.ToolBar1.TabIndex = 19
- '
- 'tbrquery
- '
- Me.tbrquery.ImageIndex = 13
- Me.tbrquery.Text = "查询"
- '
- 'tbrprint
- '
- Me.tbrprint.ImageIndex = 12
- Me.tbrprint.Text = "打印"
- '
- 'tbrexit
- '
- Me.tbrexit.ImageIndex = 11
- Me.tbrexit.Text = "退出"
- '
- 'ImageList2
- '
- Me.ImageList2.ImageSize = New System.Drawing.Size(16, 16)
- Me.ImageList2.ImageStream = CType(resources.GetObject("ImageList2.ImageStream"), System.Windows.Forms.ImageListStreamer)
- Me.ImageList2.TransparentColor = System.Drawing.Color.Transparent
- '
- 'Panel1
- '
- Me.Panel1.Controls.Add(Me.ListBox1)
- Me.Panel1.Dock = System.Windows.Forms.DockStyle.Left
- Me.Panel1.Location = New System.Drawing.Point(0, 41)
- Me.Panel1.Name = "Panel1"
- Me.Panel1.Size = New System.Drawing.Size(80, 457)
- Me.Panel1.TabIndex = 20
- '
- 'ListBox1
- '
- Me.ListBox1.BackColor = System.Drawing.SystemColors.Info
- Me.ListBox1.Dock = System.Windows.Forms.DockStyle.Left
- Me.ListBox1.ItemHeight = 12
- Me.ListBox1.Items.AddRange(New Object() {"药品信息表", "客户信息表", "销售表", "入库表", "库存表", "盘点表"})
- Me.ListBox1.Location = New System.Drawing.Point(0, 0)
- Me.ListBox1.Name = "ListBox1"
- Me.ListBox1.RightToLeft = System.Windows.Forms.RightToLeft.Yes
- Me.ListBox1.Size = New System.Drawing.Size(80, 448)
- Me.ListBox1.TabIndex = 18
- '
- 'Panel2
- '
- Me.Panel2.Controls.Add(Me.DataGrid1)
- Me.Panel2.Dock = System.Windows.Forms.DockStyle.Top
- Me.Panel2.Location = New System.Drawing.Point(80, 41)
- Me.Panel2.Name = "Panel2"
- Me.Panel2.Size = New System.Drawing.Size(718, 100)
- Me.Panel2.TabIndex = 21
- '
- 'DataGrid1
- '
- Me.DataGrid1.AlternatingBackColor = System.Drawing.Color.Gainsboro
- Me.DataGrid1.BackColor = System.Drawing.Color.Silver
- Me.DataGrid1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
- Me.DataGrid1.CaptionBackColor = System.Drawing.Color.DarkSlateBlue
- Me.DataGrid1.CaptionFont = New System.Drawing.Font("Tahoma", 8.0!)
- Me.DataGrid1.CaptionForeColor = System.Drawing.Color.White
- Me.DataGrid1.CaptionText = "通用查询"
- Me.DataGrid1.DataMember = ""
- Me.DataGrid1.Dock = System.Windows.Forms.DockStyle.Fill
- Me.DataGrid1.FlatMode = True
- Me.DataGrid1.ForeColor = System.Drawing.Color.Black
- Me.DataGrid1.GridLineColor = System.Drawing.Color.White
- Me.DataGrid1.HeaderBackColor = System.Drawing.Color.DarkGray
- Me.DataGrid1.HeaderForeColor = System.Drawing.Color.Black
- Me.DataGrid1.LinkColor = System.Drawing.Color.DarkSlateBlue
- Me.DataGrid1.Location = New System.Drawing.Point(0, 0)
- Me.DataGrid1.Name = "DataGrid1"
- Me.DataGrid1.ParentRowsBackColor = System.Drawing.Color.Black
- Me.DataGrid1.ParentRowsForeColor = System.Drawing.Color.White
- Me.DataGrid1.ParentRowsVisible = False
- Me.DataGrid1.SelectionBackColor = System.Drawing.Color.DarkSlateBlue
- Me.DataGrid1.SelectionForeColor = System.Drawing.Color.White
- Me.DataGrid1.Size = New System.Drawing.Size(718, 100)
- Me.DataGrid1.TabIndex = 3
- '
- 'Panel3
- '
- Me.Panel3.Controls.Add(Me.Button5)
- Me.Panel3.Controls.Add(Me.Button4)
- Me.Panel3.Controls.Add(Me.Button3)
- Me.Panel3.Controls.Add(Me.Button2)
- Me.Panel3.Controls.Add(Me.Button1)
- Me.Panel3.Dock = System.Windows.Forms.DockStyle.Right
- Me.Panel3.Location = New System.Drawing.Point(702, 141)
- Me.Panel3.Name = "Panel3"
- Me.Panel3.Size = New System.Drawing.Size(96, 357)
- Me.Panel3.TabIndex = 22
- '
- 'Button5
- '
- Me.Button5.Dock = System.Windows.Forms.DockStyle.Top
- Me.Button5.FlatStyle = System.Windows.Forms.FlatStyle.Popup
- Me.Button5.Location = New System.Drawing.Point(0, 100)
- Me.Button5.Name = "Button5"
- Me.Button5.Size = New System.Drawing.Size(96, 25)
- Me.Button5.TabIndex = 18
- Me.Button5.Text = "取消"
- Me.Button5.TextAlign = System.Drawing.ContentAlignment.BottomCenter
- '
- 'Button4
- '
- Me.Button4.Dock = System.Windows.Forms.DockStyle.Top
- Me.Button4.FlatStyle = System.Windows.Forms.FlatStyle.Popup
- Me.Button4.Location = New System.Drawing.Point(0, 75)
- Me.Button4.Name = "Button4"
- Me.Button4.Size = New System.Drawing.Size(96, 25)
- Me.Button4.TabIndex = 17
- Me.Button4.Text = "确定"
- Me.Button4.TextAlign = System.Drawing.ContentAlignment.BottomCenter
- '
- 'Button3
- '
- Me.Button3.Dock = System.Windows.Forms.DockStyle.Top
- Me.Button3.FlatStyle = System.Windows.Forms.FlatStyle.Popup
- Me.Button3.Location = New System.Drawing.Point(0, 50)
- Me.Button3.Name = "Button3"
- Me.Button3.Size = New System.Drawing.Size(96, 25)
- Me.Button3.TabIndex = 16
- Me.Button3.Text = "插入"
- Me.Button3.TextAlign = System.Drawing.ContentAlignment.BottomCenter
- '
- 'Button2
- '
- Me.Button2.Dock = System.Windows.Forms.DockStyle.Top
- Me.Button2.FlatStyle = System.Windows.Forms.FlatStyle.Popup
- Me.Button2.Location = New System.Drawing.Point(0, 25)
- Me.Button2.Name = "Button2"
- Me.Button2.Size = New System.Drawing.Size(96, 25)
- Me.Button2.TabIndex = 15
- Me.Button2.Text = "删除"
- Me.Button2.TextAlign = System.Drawing.ContentAlignment.BottomCenter
- '
- 'Button1
- '
- Me.Button1.Dock = System.Windows.Forms.DockStyle.Top
- Me.Button1.FlatStyle = System.Windows.Forms.FlatStyle.Popup
- Me.Button1.Location = New System.Drawing.Point(0, 0)
- Me.Button1.Name = "Button1"
- Me.Button1.Size = New System.Drawing.Size(96, 25)
- Me.Button1.TabIndex = 14
- Me.Button1.Text = "添加"
- Me.Button1.TextAlign = System.Drawing.ContentAlignment.BottomCenter
- '
- 'Panel4
- '
- Me.Panel4.Controls.Add(Me.TextBox1)
- Me.Panel4.Dock = System.Windows.Forms.DockStyle.Top
- Me.Panel4.Location = New System.Drawing.Point(80, 141)
- Me.Panel4.Name = "Panel4"
- Me.Panel4.Size = New System.Drawing.Size(622, 51)
- Me.Panel4.TabIndex = 23
- '
- 'TextBox1
- '
- Me.TextBox1.BackColor = System.Drawing.SystemColors.Info
- Me.TextBox1.Dock = System.Windows.Forms.DockStyle.Fill
- Me.TextBox1.Location = New System.Drawing.Point(0, 0)
- Me.TextBox1.Multiline = True
- Me.TextBox1.Name = "TextBox1"
- Me.TextBox1.Size = New System.Drawing.Size(622, 51)
- Me.TextBox1.TabIndex = 7
- Me.TextBox1.Text = ""
- '
- 'Panel5
- '
- Me.Panel5.Controls.Add(Me.DataGrid2)
- Me.Panel5.Dock = System.Windows.Forms.DockStyle.Fill
- Me.Panel5.Location = New System.Drawing.Point(80, 192)
- Me.Panel5.Name = "Panel5"
- Me.Panel5.Size = New System.Drawing.Size(622, 306)
- Me.Panel5.TabIndex = 24
- '
- 'DataGrid2
- '
- Me.DataGrid2.AlternatingBackColor = System.Drawing.Color.Gainsboro
- Me.DataGrid2.BackColor = System.Drawing.Color.Silver
- Me.DataGrid2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
- Me.DataGrid2.CaptionBackColor = System.Drawing.Color.DarkSlateBlue
- Me.DataGrid2.CaptionFont = New System.Drawing.Font("Tahoma", 8.0!)
- Me.DataGrid2.CaptionForeColor = System.Drawing.Color.White
- Me.DataGrid2.DataMember = ""
- Me.DataGrid2.Dock = System.Windows.Forms.DockStyle.Fill
- Me.DataGrid2.FlatMode = True
- Me.DataGrid2.ForeColor = System.Drawing.Color.Black
- Me.DataGrid2.GridLineColor = System.Drawing.Color.White
- Me.DataGrid2.HeaderBackColor = System.Drawing.Color.DarkGray
- Me.DataGrid2.HeaderForeColor = System.Drawing.Color.Black
- Me.DataGrid2.LinkColor = System.Drawing.Color.DarkSlateBlue
- Me.DataGrid2.Location = New System.Drawing.Point(0, 0)
- Me.DataGrid2.Name = "DataGrid2"
- Me.DataGrid2.ParentRowsBackColor = System.Drawing.Color.Black
- Me.DataGrid2.ParentRowsForeColor = System.Drawing.Color.White
- Me.DataGrid2.SelectionBackColor = System.Drawing.Color.DarkSlateBlue
- Me.DataGrid2.SelectionForeColor = System.Drawing.Color.White
- Me.DataGrid2.Size = New System.Drawing.Size(622, 306)
- Me.DataGrid2.TabIndex = 16
- '
- 'frmCommQuery
- '
- Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
- Me.ClientSize = New System.Drawing.Size(798, 515)
- Me.ControlBox = False
- Me.Controls.Add(Me.Panel5)
- Me.Controls.Add(Me.Panel4)
- Me.Controls.Add(Me.Panel3)
- Me.Controls.Add(Me.Panel2)
- Me.Controls.Add(Me.Panel1)
- Me.Controls.Add(Me.ToolBar1)
- Me.Controls.Add(Me.StatusBar1)
- Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D
- Me.MinimizeBox = False
- Me.Name = "frmCommQuery"
- Me.Text = "frmCommQuery"
- Me.WindowState = System.Windows.Forms.FormWindowState.Maximized
- Me.Panel1.ResumeLayout(False)
- Me.Panel2.ResumeLayout(False)
- CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
- Me.Panel3.ResumeLayout(False)
- Me.Panel4.ResumeLayout(False)
- Me.Panel5.ResumeLayout(False)
- CType(Me.DataGrid2, System.ComponentModel.ISupportInitialize).EndInit()
- Me.ResumeLayout(False)
- End Sub
- #End Region
- Public lsweb As New jxcmanage
- Public MyCombo As New ComboBox
- Public MyCombo1 As New ComboBox
- Public MyCombo3 As New ComboBox
- Dim drv As New DataView
- Dim ds As New DataSet
- Dim drrow As DataRow
- Dim dtquery As DataTable
- Private Sub frmCommQuery_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- tbrquery.Enabled = False
- dtquery = New DataTable("commquery")
- ds.Tables.Add(dtquery)
- Dim dccontion As New DataColumn("条件")
- dtquery.Columns.Add("条件", GetType(System.String))
- Dim dcfields As New DataColumn("字段名称")
- dtquery.Columns.Add("字段名称", GetType(System.String))
- Dim dcoption As New DataColumn("比较符")
- dtquery.Columns.Add("比较符", GetType(System.String))
- Dim dcvalue As New DataColumn("查询目标")
- dtquery.Columns.Add("查询目标", GetType(System.String))
- AddHandler MyCombo3.TextChanged, AddressOf Ctrls_TextChanged
- AddHandler MyCombo.TextChanged, AddressOf Ctrls_TextChanged
- AddHandler MyCombo1.TextChanged, AddressOf Ctrls_TextChanged
- MyCombo3.Name = "MyCombo3"
- MyCombo3.Visible = False
- MyCombo3.Items.Clear()
- MyCombo3.Items.Add("")
- MyCombo3.Items.Add("or")
- MyCombo3.Items.Add("and")
- MyCombo.Name = "MyCombo"
- MyCombo.Visible = False
- MyCombo.Items.Clear()
- MyCombo1.Name = "MyCombo1"
- MyCombo1.Visible = False
- MyCombo1.Items.Clear()
- MyCombo1.Items.Add("=")
- MyCombo1.Items.Add("<")
- MyCombo1.Items.Add("<=")
- MyCombo1.Items.Add(">")
- MyCombo1.Items.Add(">=")
- MyCombo1.Items.Add("like")
- MyCombo1.Items.Add("<>")
- DataGrid1.PreferredRowHeight = MyCombo.Height
- DataGrid1.DataSource = ds.Tables(0).DefaultView
- DataGrid1.Controls.Add(MyCombo3)
- DataGrid1.Controls.Add(MyCombo)
- DataGrid1.Controls.Add(MyCombo1)
- End Sub
- Private Sub DataGrid1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs)
-
- End Sub
- Private Sub Ctrls_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs)
- If DataGrid1.CurrentCell.ColumnNumber = 0 Then
- MyCombo3.Visible = False
- If DataGrid1.Item(DataGrid1.CurrentCell) & "" = "" Then
- SendKeys.Send("*")
- End If
- DataGrid1.Item(DataGrid1.CurrentCell) = MyCombo3.Text
- End If
- If DataGrid1.CurrentCell.ColumnNumber = 1 Then
- MyCombo.Visible = False
- If DataGrid1.Item(DataGrid1.CurrentCell) & "" = "" Then
- SendKeys.Send("*")
- End If
- DataGrid1.Item(DataGrid1.CurrentCell) = MyCombo.Text
- End If
- If DataGrid1.CurrentCell.ColumnNumber = 2 Then
- MyCombo1.Visible = False
- If DataGrid1.Item(DataGrid1.CurrentCell) & "" = "" Then
- SendKeys.Send("*")
- End If
- DataGrid1.Item(DataGrid1.CurrentCell) = MyCombo1.Text
- End If
- End Sub
- Private Sub DataGrid1_CurrentCellChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
-
- End Sub
- Private Sub DataGrid1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs)
-
- End Sub
- Private Sub DataGrid1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
-
- End Sub
- Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs)
-
- End Sub
- Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs)
-
- End Sub
- Private Sub Button3_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs)
- End Sub
- Private Sub Button4_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs)
-
- End Sub
- Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
-
- End Sub
- Private Sub ToolBar1_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar1.ButtonClick
- Dim strtablename As String
- If ListBox1.Text = "药品信息表" Then
- strtablename = "wz_cp"
- ElseIf ListBox1.Text = "客户信息表" Then
- strtablename = "wz_kh"
- ElseIf ListBox1.Text = "销售表" Then
- strtablename = "wz_ck"
- ElseIf ListBox1.Text = "入库表" Then
- strtablename = "wz_rk"
- ElseIf ListBox1.Text = "库存表" Then
- strtablename = "wz_kc"
- ElseIf ListBox1.Text = "盘点表" Then
- strtablename = "wz_pd"
- End If
- Select Case e.Button.Text
- Case "查询"
- Dim dslocal As DataSet
- dslocal = lsweb.returndataset(TextBox1.Text.Trim, strtablename)
- DataGrid2.DataSource = dslocal.Tables(strtablename).DefaultView
- Case "退出"
- Me.Close()
- Case "打印"
- Dim sqlString As String
- Select Case ListBox1.Text
- Case "药品信息表"
- Try
- If TextBox1.Text = String.Empty Then
- MessageBox.Show("没有要打印的记录!", "提示", MessageBoxButtons.OK)
- Else
- Dim frmviewcper As New frmviewcp
- frmviewcper.sqlString = TextBox1.Text.Trim
- frmviewcper.Show()
- End If
- Catch ex As Exception
- MessageBox.Show(Me, "报表错误: " + ex.Message + "; " + ex.InnerException.Message, "Report Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
- End Try
- Case "客户信息表"
- Try
- If TextBox1.Text = String.Empty Then
- MessageBox.Show("没有要打印的记录!", "提示", MessageBoxButtons.OK)
- Else
- Dim frmviewkher As New frmviewkh
- frmviewkher.sqlString = TextBox1.Text.Trim
- frmviewkher.Show()
- End If
- Catch ex As Exception
- MessageBox.Show(Me, "报表错误: " + ex.Message + "; " + ex.InnerException.Message, "Report Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
- End Try
- Case "入库表"
- Try
- If TextBox1.Text = String.Empty Then
- MessageBox.Show("没有要打印的记录!", "提示", MessageBoxButtons.OK)
- Else
- Dim frmviewrkmanager As New frmviewrkmanage
- frmviewrkmanager.sqlString = TextBox1.Text.Trim
- frmviewrkmanager.Show()
- End If
- Catch ex As Exception
- MessageBox.Show(Me, "报表错误: " + ex.Message + "; " + ex.InnerException.Message, "Report Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
- End Try
- Case "销售表"
- Try
- If TextBox1.Text = String.Empty Then
- MessageBox.Show("没有要打印的记录!", "提示", MessageBoxButtons.OK)
- Else
- Dim frmviewckmanager As New frmviewckmanage
- frmviewckmanager.sqlString = TextBox1.Text.Trim
- frmviewckmanager.Show()
- End If
- Catch ex As Exception
- MessageBox.Show(Me, "报表错误: " + ex.Message + "; " + ex.InnerException.Message, "Report Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
- End Try
- Case "库存表"
- Try
- If TextBox1.Text = String.Empty Then
- MessageBox.Show("没有要打印的记录!", "提示", MessageBoxButtons.OK)
- Else
- Dim frmviewkcmanager As New frmviewkcmanage
- frmviewkcmanager.sqlString = TextBox1.Text.Trim
- frmviewkcmanager.Show()
- End If
- Catch ex As Exception
- MessageBox.Show(Me, "报表错误: " + ex.Message + "; " + ex.InnerException.Message, "Report Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
- End Try
- Case "盘点表"
- Try
- If TextBox1.Text = String.Empty Then
- MessageBox.Show("没有要打印的记录!", "提示", MessageBoxButtons.OK)
- Else
- Dim frmviewpder As New frmviewpd
- frmviewpder.sqlString = TextBox1.Text.Trim
- frmviewpder.Show()
- End If
- Catch ex As Exception
- MessageBox.Show(Me, "报表错误: " + ex.Message + "; " + ex.InnerException.Message, "Report Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
- End Try
- End Select
- End Select
- End Sub
- Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
- End Sub
- Private Sub DataGrid1_Navigate(ByVal sender As System.Object, ByVal ne As System.Windows.Forms.NavigateEventArgs) Handles DataGrid1.Navigate
- End Sub
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- drrow = dtquery.NewRow()
- drrow("条件") = ""
- drrow("字段名称") = "请选择字段"
- drrow("比较符") = "请选择比较符"
- drrow("查询目标") = ""
- dtquery.Rows.Add(drrow)
- Button1.Enabled = False
- tbrquery.Enabled = False
- End Sub
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
- Dim drv As DataRowView = BindingContext(Me.DataGrid1.DataSource).Current
- If drv("字段名称") Is System.DBNull.Value Then
- MessageBox.Show("没有要删除的记录!", "提示", MessageBoxButtons.OK)
- Else
- drv.Delete()
- End If
- Button1.Enabled = True
- End Sub
- Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
- dtquery.Rows.InsertAt(drrow, 6)
- End Sub
- Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
- Dim drver As DataRowView = BindingContext(Me.DataGrid1.DataSource).Current
- Dim strtable As String
- Dim strtablename As String
- If ListBox1.Text = "药品信息表" Then
- strtablename = "wz_cp"
- ElseIf ListBox1.Text = "客户信息表" Then
- strtablename = "wz_kh"
- ElseIf ListBox1.Text = "销售表" Then
- strtablename = "wz_ck"
- ElseIf ListBox1.Text = "入库表" Then
- strtablename = "wz_rk"
- ElseIf ListBox1.Text = "库存表" Then
- strtablename = "wz_kc"
- ElseIf ListBox1.Text = "盘点表" Then
- strtablename = "wz_pd"
- End If
- strtable = "select * from " & strtablename & " where "
- If drver("字段名称") Is System.DBNull.Value Or drver("比较符") Is System.DBNull.Value Or drver("查询目标") Is System.DBNull.Value Then
- MessageBox.Show("请设值查询条件!", "提示", MessageBoxButtons.OK)
- Else
- If drver("条件") = String.Empty Then
- Dim strfields As String
- strfields = drver("字段名称")
- If strfields.Substring(0, 1) = "_" Then
- Dim strcolumn As String
- strcolumn = drver("字段名称").Substring(1, drver("字段名称").Length - 1) & " " & drver("比较符") & " '" & drver("查询目标") & "' "
- TextBox1.Text = strtable + strcolumn & " "
- Else
- Dim strcolumn As String
- strcolumn = drver("字段名称") & " " & drver("比较符") & " " & drver("查询目标")
- TextBox1.Text = strtable + strcolumn & " "
- End If
- End If
- If drver("条件") <> String.Empty Then
- Dim strfields As String
- strfields = drver("字段名称")
- If strfields.Substring(0, 1) = "_" Then
- TextBox1.Text = TextBox1.Text & "" & drver("条件") & " " & drver("字段名称").Substring(1, drver("字段名称").Length - 1) & " " & drver("比较符") & " '" & drver("查询目标") & "' "
- Else
- TextBox1.Text = TextBox1.Text & "" & drver("条件") & " " & drver("字段名称") & " " & drver("比较符") & " " & drver("查询目标") & ""
- End If
- End If
- End If
- Button1.Enabled = True
- tbrquery.Enabled = True
- End Sub
- Private Sub ListBox1_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
- Dim strtablename As String
- If ListBox1.Text = "药品信息表" Then
- strtablename = "wz_cp"
- ElseIf ListBox1.Text = "客户信息表" Then
- strtablename = "wz_kh"
- ElseIf ListBox1.Text = "销售表" Then
- strtablename = "wz_ck"
- ElseIf ListBox1.Text = "入库表" Then
- strtablename = "wz_rk"
- ElseIf ListBox1.Text = "库存表" Then
- strtablename = "wz_kc"
- ElseIf ListBox1.Text = "盘点表" Then
- strtablename = "wz_pd"
- End If
- Dim dslocals As DataSet
- dslocals = lsweb.returndataset("select * from " & strtablename, strtablename)
- dslocals.Clear()
- drv = dslocals.Tables(0).DefaultView
- MyCombo.Name = "MyCombo"
- MyCombo.Visible = False
- MyCombo.Items.Clear()
- Dim i As Int16
- For i = 0 To drv.Table.Columns.Count - 1
- If drv.Table.Columns.Item(i).DataType Is GetType(System.String) Then
- MyCombo.Items.Add("_" & drv.Table.Columns.Item(i).Caption)
- Else
- MyCombo.Items.Add(drv.Table.Columns.Item(i).Caption)
- End If
- Next
- End Sub
- Private Sub DataGrid1_CurrentCellChanged1(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.CurrentCellChanged
- If DataGrid1.CurrentCell.ColumnNumber = 0 Then
- MyCombo3.Visible = False
- MyCombo3.Width = 0
- MyCombo3.Left = DataGrid1.GetCurrentCellBounds.Left
- MyCombo3.Top = DataGrid1.GetCurrentCellBounds.Top
- MyCombo3.Text = DataGrid1.Item(DataGrid1.CurrentCell) & ""
- MyCombo3.Visible = True
- Else
- MyCombo3.Visible = False
- MyCombo3.Width = 0
- End If
- If DataGrid1.CurrentCell.ColumnNumber = 1 Then
- MyCombo.Visible = False
- MyCombo.Width = 0
- MyCombo.Left = DataGrid1.GetCurrentCellBounds.Left
- MyCombo.Top = DataGrid1.GetCurrentCellBounds.Top
- MyCombo.Text = DataGrid1.Item(DataGrid1.CurrentCell) & ""
- MyCombo.Visible = True
- Else
- MyCombo.Visible = False
- MyCombo.Width = 0
- End If
- If DataGrid1.CurrentCell.ColumnNumber = 2 Then
- MyCombo1.Visible = False
- MyCombo1.Width = 0
- MyCombo1.Left = DataGrid1.GetCurrentCellBounds.Left
- MyCombo1.Top = DataGrid1.GetCurrentCellBounds.Top
- MyCombo1.Text = DataGrid1.Item(DataGrid1.CurrentCell) & ""
- MyCombo1.Visible = True
- Else
- MyCombo1.Visible = False
- MyCombo1.Width = 0
- End If
- End Sub
- Private Sub DataGrid1_Scroll1(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.Scroll
- MyCombo.Visible = False
- MyCombo.Width = 0
- MyCombo1.Visible = False
- MyCombo1.Width = 0
- MyCombo3.Visible = False
- MyCombo3.Width = 0
- End Sub
- Private Sub DataGrid1_Click1(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.Click
- MyCombo.Visible = False
- MyCombo.Width = 0
- MyCombo1.Visible = False
- MyCombo1.Width = 0
- MyCombo3.Visible = False
- MyCombo3.Width = 0
- End Sub
- Private Sub DataGrid1_Paint1(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles DataGrid1.Paint
- If DataGrid1.CurrentCell.ColumnNumber = 0 Then
- MyCombo3.Width = DataGrid1.GetCurrentCellBounds.Width
- End If
- If DataGrid1.CurrentCell.ColumnNumber = 1 Then
- MyCombo.Width = DataGrid1.GetCurrentCellBounds.Width
- End If
- If DataGrid1.CurrentCell.ColumnNumber = 2 Then
- MyCombo1.Width = DataGrid1.GetCurrentCellBounds.Width
- End If
- End Sub
- End Class