frmMdQuery.vb
上传用户:wj57717022
上传日期:2014-12-16
资源大小:4093k
文件大小:5k
- Public Class frmMdQuery
- 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.DataMember = ""
- Me.dgQuery.Dock = System.Windows.Forms.DockStyle.Fill
- Me.dgQuery.HeaderForeColor = System.Drawing.SystemColors.ControlText
- Me.dgQuery.Location = New System.Drawing.Point(0, 0)
- Me.dgQuery.Name = "dgQuery"
- Me.dgQuery.Size = New System.Drawing.Size(528, 317)
- Me.dgQuery.TabIndex = 0
- '
- 'frmMdQuery
- '
- Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
- Me.ClientSize = New System.Drawing.Size(528, 317)
- Me.ControlBox = False
- Me.Controls.Add(Me.dgQuery)
- Me.Name = "frmMdQuery"
- Me.Text = "药品信息"
- 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_querymdId"), 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 frmMdQuery_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- End Sub
- End Class