⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dangan.vb

📁 这是我自己用VB.NET编写的一款监护仪的电脑软件
💻 VB
字号:
Public Class DangAn

    Private Sub Button_Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_Cancel.Click
        Close()
    End Sub

    Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
        Me.xingming.BackColor = Color.White
        Me.bianhao.BackColor = Color.White
        Me.chuangweihao.BackColor = Color.White
        Me.yunzhou.BackColor = Color.White
        Me.nianling.BackColor = Color.White
        Me.gp.BackColor = Color.White
        Me.beizhu.BackColor = Color.White
        Me.xingming.Focus()
        Me.xingming.Enabled = True
        Me.bianhao.Enabled = True
        Me.chuangweihao.Enabled = True
        Me.yunzhou.Enabled = True
        Me.gp.Enabled = True
        Me.beizhu.Enabled = True
        Me.nianling.Enabled = True
        Me.Button_Apply.Enabled = True
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_Apply.Click
        '以下进行数据库操作
        If Me.xingming.Text = Nothing Or Me.xingming.Text = "Not set" Then
            MessageBox.Show("Necessary information is non-complete!")
            Exit Sub
        End If
        Button_Apply.Enabled = False
        Dim MySqlString As String = Login.MySqlDataBaseConnectionString
        Dim MySql As New Odbc.OdbcConnection(MySqlString)
        Try
            MySql.Open()
            Dim MySQLStr As String = "Select max(Preg_ID) From [Pregnant]"
            Dim MyCommand As New System.Data.Odbc.OdbcCommand(MySQLStr, MySql)

            Dim MyID As Integer = MyCommand.ExecuteScalar
            MyID += 1                 '计算病人ID

            If MainForm.Prag_Name.Text = "Not set" Then
                MySQLStr = "Insert into [Pregnant] values(" & MyID & ",'" & xingming.Text & "','" & chuangweihao.Text & "','" & bianhao.Text & "','" & yunzhou.Text & "','" & gp.Text & "','" & nianling.Text & "','" & beizhu.Text & "')"
            Else
                MyID -= 1
                MySQLStr = "Update [Pregnant] Set Preg_Name='" & xingming.Text & "',Preg_BedID='" & chuangweihao.Text
                MySQLStr += "',Preg_HosID='" & bianhao.Text & "',Preg_Week='" & yunzhou.Text & "',Preg_GP='" & gp.Text
                MySQLStr += "',Preg_Age='" & nianling.Text & "',Preg_Note='" & beizhu.Text & "'  Where Preg_ID=" & MyID
            End If

            MyCommand = New System.Data.Odbc.OdbcCommand(MySQLStr, MySql)
            Dim i As Integer = MyCommand.ExecuteNonQuery()
            If i = 1 Then
                MainForm.Prag_Name.Text = Me.xingming.Text
                MainForm.Prag_HosID.Text = Me.bianhao.Text
                MainForm.Prag_BedID.Text = Me.chuangweihao.Text
                MainForm.Prag_week.Text = Me.yunzhou.Text
            End If
            If MySql.State = ConnectionState.Open Then
                MySql.Close()
            End If
        Catch ex As Exception
            MessageBox.Show("Sorry,but an unexpected error occurred while updating the database ,please contact with the administrator!", "Database error", MessageBoxButtons.OK, MessageBoxIcon.Information)
            If MySql.State = ConnectionState.Open Then
                MySql.Close()
            End If
            Close()
        End Try




        Me.xingming.BackColor = Me.BackColor
        Me.bianhao.BackColor = Me.BackColor
        Me.chuangweihao.BackColor = Me.BackColor
        Me.yunzhou.BackColor = Me.BackColor
        Me.nianling.BackColor = Me.BackColor
        Me.gp.BackColor = Me.BackColor
        Me.beizhu.BackColor = Me.BackColor

        Me.xingming.Enabled = False
        Me.bianhao.Enabled = False
        Me.chuangweihao.Enabled = False
        Me.yunzhou.Enabled = False
        Me.gp.Enabled = False
        Me.beizhu.Enabled = False
        Me.nianling.Enabled = False

    End Sub

    Private Sub DangAn_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        If MainForm.Auto_Save = True Then
            Me.Auto_Save.Enabled = True
            Me.LinkLabel1_LinkClicked(Nothing, Nothing)
            MainForm.Auto_Save = False
            Exit Sub
        Else
            Me.Auto_Save.Enabled = False
        End If
        Me.xingming.BackColor = Me.BackColor
        Me.bianhao.BackColor = Me.BackColor
        Me.chuangweihao.BackColor = Me.BackColor
        Me.yunzhou.BackColor = Me.BackColor
        Me.nianling.BackColor = Me.BackColor
        Me.gp.BackColor = Me.BackColor
        Me.beizhu.BackColor = Me.BackColor

        Me.xingming.Enabled = False
        Me.bianhao.Enabled = False
        Me.chuangweihao.Enabled = False
        Me.yunzhou.Enabled = False
        Me.gp.Enabled = False
        Me.beizhu.Enabled = False
        Me.nianling.Enabled = False



        Me.xingming.Text = MainForm.Prag_Name.Text
        If MainForm.Prag_Name.Text = "Not set" Then
            Exit Sub
        End If

        Dim MySqlString As String = Login.MySqlDataBaseConnectionString
        Dim MySql As New Odbc.OdbcConnection(MySqlString)
        Try
            MySql.Open()
            Dim MySQLStr As String = "Select Preg_Age From [Pregnant] where Preg_Name='" & Me.xingming.Text & "'"
            Dim MyCommand As Odbc.OdbcCommand = MySql.CreateCommand

            MyCommand.CommandText = MySQLStr
            Me.nianling.Text = MyCommand.ExecuteScalar

            MySQLStr = "Select Preg_HosID From [Pregnant] where Preg_Name='" & Me.xingming.Text & "'"
            MyCommand.CommandText = MySQLStr
            Me.bianhao.Text = MyCommand.ExecuteScalar

            MySQLStr = "Select Preg_BedID From [Pregnant] where Preg_Name='" & Me.xingming.Text & "'"
            MyCommand.CommandText = MySQLStr
            Me.chuangweihao.Text = MyCommand.ExecuteScalar

            MySQLStr = "Select Preg_Week From [Pregnant] where Preg_Name='" & Me.xingming.Text & "'"
            MyCommand.CommandText = MySQLStr
            Me.yunzhou.Text = MyCommand.ExecuteScalar

            MySQLStr = "Select Preg_GP From [Pregnant] where Preg_Name='" & Me.xingming.Text & "'"
            MyCommand.CommandText = MySQLStr
            Me.gp.Text = MyCommand.ExecuteScalar

            MySQLStr = "Select Preg_Note From [Pregnant] where Preg_Name='" & Me.xingming.Text & "'"
            MyCommand.CommandText = MySQLStr
            Me.beizhu.Text = MyCommand.ExecuteScalar

            If MySql.State = ConnectionState.Open Then
                MySql.Close()
            End If
        Catch ex As Exception
            MessageBox.Show("Sorry,but an unexpected error occurred while updating the database ,please contact with the administrator!", "Database error", MessageBoxButtons.OK, MessageBoxIcon.Information)
            If MySql.State = ConnectionState.Open Then
                MySql.Close()
            End If
            Close()
        End Try

    End Sub

    Private Sub Auto_Save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Auto_Save.Click
        '****************以下进行图像保存操作
        If Me.xingming.Enabled = True Then
            MessageBox.Show("Please click the 'apply' button to save the information of patient first!", "Apply", MessageBoxButtons.OK, MessageBoxIcon.Information)
            Exit Sub
        End If
        MainForm.ImageSave_Click(Nothing, Nothing)
        Close()
    End Sub
End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -