VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form add_editjudge 
   Caption         =   "添加法官信息"
   ClientHeight    =   3225
   ClientLeft      =   60
   ClientTop       =   240
   ClientWidth     =   4470
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   3225
   ScaleWidth      =   4470
   StartUpPosition =   2  '屏幕中心
   Begin VB.OptionButton xingbie2 
      Caption         =   "女"
      Height          =   255
      Left            =   3240
      TabIndex        =   11
      Top             =   1320
      Width           =   615
   End
   Begin VB.OptionButton xingbie1 
      Caption         =   "男"
      Height          =   255
      Left            =   2160
      TabIndex        =   10
      Top             =   1320
      Value           =   -1  'True
      Width           =   615
   End
   Begin VB.ComboBox fayuan 
      Height          =   300
      ItemData        =   "add_editjudge.frx":0000
      Left            =   2160
      List            =   "add_editjudge.frx":0010
      TabIndex        =   9
      Top             =   1800
      Width           =   1695
   End
   Begin MSAdodcLib.Adodc Adodc1 
      Height          =   375
      Left            =   240
      Top             =   2280
      Visible         =   0   'False
      Width           =   2535
      _ExtentX        =   4471
      _ExtentY        =   661
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   1
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=CourtM"
      OLEDBString     =   "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=CourtM"
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   "select * from judgeInformation"
      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
   Begin VB.TextBox bianhao 
      BeginProperty DataFormat 
         Type            =   1
         Format          =   ""
         HaveTrueFalseNull=   0
         FirstDayOfWeek  =   0
         FirstWeekOfYear =   0
         LCID            =   2052
         SubFormatType   =   0
      EndProperty
      Enabled         =   0   'False
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   9.75
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   330
      Left            =   2160
      TabIndex        =   4
      Top             =   300
      Width           =   1755
   End
   Begin VB.TextBox xingming 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   9.75
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   330
      Left            =   2160
      TabIndex        =   3
      Top             =   825
      Width           =   1755
   End
   Begin VB.CommandButton Command2 
      Caption         =   "删除"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   1800
      TabIndex        =   2
      Top             =   2640
      Width           =   855
   End
   Begin VB.CommandButton Command3 
      Caption         =   "返回"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   3120
      TabIndex        =   1
      Top             =   2640
      Width           =   855
   End
   Begin VB.CommandButton Command1 
      Caption         =   "确定"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   480
      TabIndex        =   0
      Top             =   2640
      Width           =   855
   End
   Begin VB.Label Label4 
      Alignment       =   2  'Center
      AutoSize        =   -1  'True
      Caption         =   "所属法院级别"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   210
      Left            =   330
      TabIndex        =   8
      Top             =   1890
      Width           =   1260
   End
   Begin VB.Label Label12 
      Alignment       =   2  'Center
      AutoSize        =   -1  'True
      Caption         =   "性        别"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   210
      Left            =   330
      TabIndex        =   7
      Top             =   1395
      Width           =   1275
   End
   Begin VB.Label Label1 
      Alignment       =   2  'Center
      AutoSize        =   -1  'True
      Caption         =   "编        号"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   210
      Left            =   330
      TabIndex        =   6
      Top             =   360
      Width           =   1275
   End
   Begin VB.Label Label10 
      Alignment       =   2  'Center
      AutoSize        =   -1  'True
      Caption         =   "姓        名"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   210
      Left            =   330
      TabIndex        =   5
      Top             =   885
      Width           =   1275
   End
End
Attribute VB_Name = "add_editjudge"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim MaxNum As String


Private Sub Form_Load()
    If flag = 1 Then
        Call MaxNo
        Caption = "添加法官信息"
        Command2.Enabled = False
    Else
        Caption = "修改法官信息"
        Command1.Enabled = True
        Command2.Enabled = True
            Call display
     End If
End Sub

'在添加窗体中单击“确定”按钮时执行
Private Sub Command1_Click()

Dim sql As String
   If flag = 1 Then
        Call addNewRecord
        MsgBox "添加成功！", vbOKOnly + vbExclamation, "添加结果！"
        Call init
    Else
        Call uprecord
        MsgBox "修改成功！", vbOKOnly + vbExclamation, "修改结果！"
        Unload Me
    End If
End Sub
'在添加窗体中单击“删除”按钮时执行
Private Sub Command2_Click()
    If MsgBox("真的要删除这条记录么？", vbOKCancel + vbExclamation, "提示！") = vbOK _
        Then
        ingid.Delete
        MsgBox "法官信息已经删除！", vbOKOnly + vbExclamation, "警告!"
        Unload Me
    End If
End Sub
'在添加窗体中单击“确定”按钮时执行
Private Sub Command3_Click()
    Unload Me
    Exit Sub
End Sub

'设置添加法官记录过程
Private Sub addNewRecord()
    Dim sql As String
    sql = "select * from judgeInformation"
    Adodc1.RecordSource = sql
    Adodc1.Refresh
    
    With Adodc1.Recordset
        .AddNew                                 '添加新记录
        .Fields(0) = Trim(bianhao)
        .Fields(1) = Trim(xingming)
        If xingbie1.Value Then .Fields(2) = Trim(xingbie1.Caption) Else .Fields(2) = Trim(xingbie2.Caption)
        .Fields(3) = Trim(fayuan.Text)
        .Update
    End With
End Sub

Private Sub init()        '初始化
    Call MaxNo
    xingming.Text = ""
    xingbie1.Value = True
    fayuan.Text = ""
End Sub

'设置修改过程
Public Sub display()
    bianhao.Enabled = False
    bianhao = ingid.Fields(0)
    xingming = ingid.Fields(1)
    If Trim(ingid.Fields(2)) = "男" Then
       xingbie1.Value = True
    Else
        xingbie2.Value = True
    End If
    fayuan.Text = ingid.Fields(3)
End Sub

'设置更新过程
Public Sub uprecord()
   ' ingid.Fields(0) = Trim(Me.bianhao)
    ingid.Fields(1) = Trim(Me.xingming)
    If xingbie1.Value Then ingid.Fields(2) = xingbie1.Caption Else ingid.Fields(2) = xingbie2.Caption
    ingid.Fields(3) = Trim(Me.fayuan)
    ingid.Update
End Sub


'求最大编号
Sub MaxNo()
    Dim sql As String
    Dim num As Integer
    Dim temp As String
        sql = "select max(编号) from judgeInformation"                  '自动编号
        Adodc1.RecordSource = sql
        Adodc1.Refresh
        
        MaxNum = Trim(Adodc1.Recordset(0))
        num = Right(MaxNum, 3) + 1
        temp = Right(Format(1000 + num), 3)
        bianhao = "J" & temp

End Sub
