frmMedKcQuery.vb
上传用户:wj57717022
上传日期:2014-12-16
资源大小:4093k
文件大小:6k
- Public Class frmMedKcQuery
- 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 dgQuery As System.Windows.Forms.DataGrid
- <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
- Me.dgQuery = New System.Windows.Forms.DataGrid
- CType(Me.dgQuery, System.ComponentModel.ISupportInitialize).BeginInit()
- Me.SuspendLayout()
- '
- 'dgQuery
- '
- Me.dgQuery.AlternatingBackColor = System.Drawing.Color.Gainsboro
- Me.dgQuery.BackColor = System.Drawing.Color.Silver
- Me.dgQuery.BackgroundColor = System.Drawing.Color.Silver
- Me.dgQuery.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
- Me.dgQuery.CaptionBackColor = System.Drawing.Color.DarkSlateBlue
- Me.dgQuery.CaptionFont = New System.Drawing.Font("Tahoma", 8.0!)
- Me.dgQuery.CaptionForeColor = System.Drawing.Color.White
- Me.dgQuery.DataMember = ""
- Me.dgQuery.Dock = System.Windows.Forms.DockStyle.Fill
- Me.dgQuery.FlatMode = True
- Me.dgQuery.ForeColor = System.Drawing.Color.Black
- Me.dgQuery.GridLineColor = System.Drawing.Color.White
- Me.dgQuery.HeaderBackColor = System.Drawing.Color.DarkGray
- Me.dgQuery.HeaderForeColor = System.Drawing.Color.Black
- Me.dgQuery.LinkColor = System.Drawing.Color.DarkSlateBlue
- Me.dgQuery.Location = New System.Drawing.Point(0, 0)
- Me.dgQuery.Name = "dgQuery"
- Me.dgQuery.ParentRowsBackColor = System.Drawing.Color.Black
- Me.dgQuery.ParentRowsForeColor = System.Drawing.Color.White
- Me.dgQuery.RowHeadersVisible = False
- Me.dgQuery.SelectionBackColor = System.Drawing.Color.DarkSlateBlue
- Me.dgQuery.SelectionForeColor = System.Drawing.Color.White
- Me.dgQuery.Size = New System.Drawing.Size(837, 325)
- Me.dgQuery.TabIndex = 0
- '
- 'frmMedKcQuery
- '
- Me.AutoScaleBaseSize = New System.Drawing.Size(8, 18)
- Me.ClientSize = New System.Drawing.Size(837, 325)
- Me.ControlBox = False
- Me.Controls.Add(Me.dgQuery)
- Me.Name = "frmMedKcQuery"
- CType(Me.dgQuery, System.ComponentModel.ISupportInitialize).EndInit()
- Me.ResumeLayout(False)
- End Sub
- #End Region
- Public PYMs As String
- Public weblocals As New jxcmanage
- Public dtlists As DataTable
- Private Sub frmMedKcQuery_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- SetDataGrid(weblocals.QueryID(PYMs, "sp_querykcId"), dgQuery)
- End Sub
- Public Sub SetDataGrid(ByVal mSpDataset As Data.DataSet, ByVal dgDatagrid As DataGrid)
- Dim dtCustomerId As Data.DataSet
- dtCustomerId = mSpDataset
- Dim dts As DataTable = mSpDataset.Tables(0)
- 'bb为一随意表名
- dts.TableName = "bb"
- dtlists = dts
- Dim tss As New DataGridTableStyle 'datagrid样式
- Dim aColumnTextColumns As DataGridTextBoxColumn
- dgDatagrid.DataSource = dts
- tss.MappingName = dts.TableName
- Dim numColss As Integer
- numColss = dts.Columns.Count
- Dim i As Integer = 0
- Do While (i < numColss) '重绘所有的列
- aColumnTextColumns = New DataGridTextBoxColumn
- '夺过对textbox内落下光标的控制权
- AddHandler aColumnTextColumns.TextBox.Enter, New EventHandler(AddressOf TextBoxEnterHandler)
- '要更改列头名,请改下句的HeaderText值
- aColumnTextColumns.HeaderText = dts.Columns(i).ColumnName
- aColumnTextColumns.MappingName = dts.Columns(i).ColumnName
- tss.GridColumnStyles.Add(aColumnTextColumns) '增加一种自定义的column风格
- i = (i + 1)
- Loop
- dgDatagrid.TableStyles.Clear()
- dgDatagrid.TableStyles.Add(tss) '增加一种自定义的表风格
- End Sub
- Private Sub TextBoxEnterHandler(ByVal sender As Object, ByVal e As System.EventArgs)
- Dim inner As Control = sender
- inner.Visible = False
- dgQuery.Select(dgQuery.CurrentRowIndex)
- End Sub
- Public Function GetInfo(ByVal strnumber As String) As String
- '获得DataGrid当前被选中的行号
- Dim iRow As Integer = dgQuery.CurrentRowIndex
- Dim sId As String
- '获取DataGrid当前被选中的行的内容
- Try
- sId = dtlists.Rows(iRow)(strnumber).ToString().Trim
- Return sId
- Catch ex As Exception
- 'MessageBox.Show("没有查到您所要的记录,请重新查找!")
- End Try
- End Function
- Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As Boolean
- If msg.WParam.ToInt32() = CInt(Keys.Enter) Then
- dgQuery.UnSelect(dgQuery.CurrentRowIndex)
- Me.Close()
- Return True
- End If
- Return MyBase.ProcessCmdKey(msg, keyData)
- End Function
- Private Sub dgQuery_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgQuery.CurrentCellChanged
- Dim drv As DataRowView = BindingContext(Me.dgQuery.DataSource).Current
- Dim strquery As String
- strquery = "select sum(数量) as 数量 from wz_kc where 药品编号='" & drv("药品编号") & "'"
- dgQuery.CaptionText = drv("药品名称") & "的总库存数量是" & weblocals.sumcount(strquery)
- End Sub
-
- Private Sub dgQuery_Navigate(ByVal sender As System.Object, ByVal ne As System.Windows.Forms.NavigateEventArgs) Handles dgQuery.Navigate
- End Sub
- End Class