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

📄 form3.frm

📁 VB+SQL住院管理系统
💻 FRM
📖 第 1 页 / 共 2 页
字号:
            EndProperty
            BeginProperty Column01 
            EndProperty
         EndProperty
      End
      Begin VB.Label Label9 
         Caption         =   "职称:"
         Height          =   255
         Left            =   5520
         TabIndex        =   24
         Top             =   1800
         Width           =   615
      End
      Begin VB.Label Label8 
         Caption         =   "姓名:"
         Height          =   255
         Left            =   5520
         TabIndex        =   23
         Top             =   1200
         Width           =   615
      End
      Begin VB.Label Label7 
         Caption         =   "医生工号:"
         Height          =   255
         Left            =   5400
         TabIndex        =   21
         Top             =   600
         Width           =   975
      End
   End
   Begin MSAdodcLib.Adodc Adodc1 
      Height          =   330
      Left            =   240
      Top             =   2880
      Visible         =   0   'False
      Width           =   2775
      _ExtentX        =   4895
      _ExtentY        =   582
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "Adodc1"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
End
Attribute VB_Name = "Form3"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub Command1_Click()
Dim str As String

Dim txtsql     As String
Dim mrc     As ADODB.Recordset


    If Text1.Text = Empty Then
        MsgBox "医生工号不能为空"
        Text1.SetFocus
    ElseIf Text2.Text = Empty Then
        MsgBox "医生姓名不能为空"
        Text2.SetFocus
    ElseIf Text3.Text = Empty Then
        MsgBox "医生职称不能为空"
        Text3.SetFocus
    
    
    Else
      txtsql = "select   count(*)   from   医生   where   医生工号='" & Text1.Text & "'"
      Set mrc = con.Execute(txtsql)
      If mrc.Fields(0).Value > 0 Then
        MsgBox ("该医生工号已存在!")
        Text1.Text = ""
        Text1.SetFocus
        Exit Sub
      
      
      Else
        str = "select * from 医生"
        If querydata(str) = True Then
            rct.AddNew
            rct.Fields("医生工号").Value = Text1.Text
            rct.Fields("姓名").Value = Text2.Text
            rct.Fields("职称").Value = Text3.Text
            rct.Update
        Else
            MsgBox "错误"
        End If
    MsgBox "添加成功"
  Text1.Text = ""
  Text2.Text = ""
  Text3.Text = ""
  Text1.SetFocus
    End If
    
    End If
End Sub

Private Sub Command2_Click()
Dim sql1  As String
Dim sql2  As String
 
 
 
 
Dim txtsql     As String
Dim mrc     As ADODB.Recordset
Dim msgtext     As String
Dim str1  As String
 
           
If Text4.Text = "" Then
 MsgBox "请输入医生工号!", vbOKOnly + vbExclamation, "警告"
 Exit Sub
 Text4.SetFocus
Else
 txtsql = "select   count(*)   from   医生   where   医生工号='" & Text4.Text & "'"
 Set mrc = con.Execute(txtsql)
 If mrc.Fields(0).Value > 0 Then
  If MsgBox("医生存在,确认要修改吗?", vbYesNo) = vbYes Then
 
   If Text5.Text = Empty Then
       sql2 = "update   医生   set   职称='" & Text6.Text & "'   where   医生工号='" & Text4.Text & "'"
       If querydata(sql2) = True Then
       MsgBox ("已更新")
       Text4.Text = ""
       Text6.Text = ""
       End If
   ElseIf Text6.Text = Empty Then
       sql1 = "update   医生   set   姓名='" & Text5.Text & "'   where   医生工号='" & Text4.Text & "'"
       If querydata(sql1) = True Then
       MsgBox ("已更新")
       Text4.Text = ""
       Text5.Text = ""
       End If
   Else
    sql1 = "update   医生   set   姓名='" & Text5.Text & "'   where   医生工号='" & Text4.Text & "'"
    sql2 = "update   医生   set   职称='" & Text6.Text & "'   where   医生工号='" & Text4.Text & "'"
     If querydata(sql1) = True Then
     If querydata(sql2) = True Then
      MsgBox ("已更新")
     Text4.Text = ""
  Text5.Text = ""
  Text6.Text = ""
  Else
       MsgBox ("未更新")
  End If
  End If
  End If
  End If
  
  Else
      MsgBox "医生不存在!"
      Exit Sub
 
 End If
 End If
  
End Sub

Private Sub Command3_Click()
Dim strsql     As String
        Dim cnn     As String
        Dim rst     As New ADODB.Recordset

        cnn = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=true;Initial Catalog=住院管理信息系统;Data Source=(local)"
        strsql = "select   * from   医生   where   医生工号= '" & Text7.Text & "' or 姓名='" & Text8.Text & "' or 职称='" & Text9.Text & "'"
        
    
        Dim Conn     As New ADODB.Connection
        
        With Conn
                .CursorLocation = adUseClient
                .ConnectionString = cnn
                .ConnectionTimeout = 10
                .Open
        End With

        rst.Open strsql, Conn, 3, 3
        
        Set DataGrid1.DataSource = rst

End Sub

Private Sub Command4_Click()
    Unload Me
End Sub



Private Sub Command5_Click()
Dim txtsql     As String
          Dim mrc     As ADODB.Recordset
          Dim msgtext     As String
          Dim str1  As String
 
           
        If Text10.Text = "" Then
                  MsgBox "请输入医生工号!", vbOKOnly + vbExclamation, "警告"
                  Exit Sub
                  Text10.SetFocus
          Else
                  txtsql = "select   count(*)   from   医生   where   医生工号='" & Text10.Text & "'"
                  Set mrc = con.Execute(txtsql)
                  If mrc.Fields(0).Value > 0 Then
                          If MsgBox("医生存在,确认要删除该医生吗?", vbYesNo) = vbYes Then
                             
                                  txtsql = "delete   医生   where   医生工号='" & Text10.Text & "'"
                                  Set mrc = con.Execute(txtsql)
                                  MsgBox "删除医生成功!", vbOKOnly + vbExclamation, "删除医生"
                                 Text10.Text = ""
                             
                          End If
                  Else
                          MsgBox "医生不存在!"
                          Exit Sub
                  End If
          End If
End Sub

Private Sub Command6_Click()
Dim strsql     As String
        Dim cnn     As String
        Dim rst     As New ADODB.Recordset

        cnn = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=true;Initial Catalog=住院管理信息系统;Data Source=(local)"
        strsql = "select   *  from   医生 "
        
    
        Dim Conn     As New ADODB.Connection
        
        With Conn
                .CursorLocation = adUseClient
                .ConnectionString = cnn
                .ConnectionTimeout = 10
                .Open
        End With

        rst.Open strsql, Conn, 3, 3
        
        Set DataGrid1.DataSource = rst
End Sub

⌨️ 快捷键说明

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