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

📄 frmmg.frm

📁 VB写的通过串口与考勤机连接通讯的程序
💻 FRM
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "msadodc.ocx"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDatGrd.ocx"
Begin VB.Form frmMG 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "系统管理"
   ClientHeight    =   4380
   ClientLeft      =   2580
   ClientTop       =   3300
   ClientWidth     =   6600
   BeginProperty Font 
      Name            =   "宋体"
      Size            =   12
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   4380
   ScaleWidth      =   6600
   ShowInTaskbar   =   0   'False
   Begin VB.CommandButton cmdRef 
      Caption         =   "刷新"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   9
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   1920
      TabIndex        =   17
      Top             =   2400
      Width           =   735
   End
   Begin VB.ComboBox cobQuan 
      Height          =   360
      Left            =   4560
      Style           =   2  'Dropdown List
      TabIndex        =   15
      ToolTipText     =   "用户权限"
      Top             =   1920
      Width           =   1575
   End
   Begin VB.CommandButton cmdQuit 
      Caption         =   "退出"
      Height          =   375
      Left            =   5160
      TabIndex        =   12
      Top             =   3720
      Width           =   1335
   End
   Begin VB.Frame Frame3 
      Height          =   1335
      Left            =   1440
      TabIndex        =   10
      Top             =   2760
      Width           =   1695
      Begin VB.CommandButton cmdThree 
         Caption         =   "删除"
         Height          =   375
         Left            =   360
         TabIndex        =   11
         Top             =   840
         Width           =   1095
      End
      Begin VB.Label Label4 
         BackStyle       =   0  'Transparent
         Caption         =   "删除三个月以前的数据"
         Height          =   495
         Left            =   240
         TabIndex        =   16
         Top             =   240
         Width           =   1215
      End
   End
   Begin VB.Frame Frame2 
      Caption         =   "考勤管理 "
      Height          =   1695
      Left            =   3360
      TabIndex        =   8
      Top             =   2400
      Width           =   1455
      Begin VB.CommandButton cmdROpen 
         Caption         =   "从新录入"
         Height          =   375
         Left            =   120
         TabIndex        =   9
         Top             =   1200
         Width           =   1215
      End
      Begin VB.Label Label5 
         Caption         =   "删除所有临时考勤记录,从新录入"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   735
         Left            =   120
         TabIndex        =   18
         Top             =   360
         Width           =   1215
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "用户管理"
      Height          =   1695
      Left            =   0
      TabIndex        =   4
      Top             =   2400
      Width           =   1335
      Begin VB.CommandButton cmdDel 
         Caption         =   "删除"
         Height          =   375
         Left            =   120
         TabIndex        =   7
         Top             =   1200
         Width           =   975
      End
      Begin VB.CommandButton cmdAdd 
         Caption         =   "添加"
         Height          =   375
         Left            =   120
         TabIndex        =   6
         Top             =   360
         Width           =   975
      End
      Begin VB.CommandButton cmdModify 
         Caption         =   "修改"
         Height          =   375
         Left            =   120
         TabIndex        =   5
         Top             =   780
         Width           =   975
      End
   End
   Begin VB.TextBox txtPass 
      Height          =   375
      Left            =   2520
      MaxLength       =   8
      TabIndex        =   2
      Text            =   "12345678"
      Top             =   1920
      Width           =   1095
   End
   Begin VB.TextBox txtName 
      Height          =   375
      Left            =   840
      MaxLength       =   8
      TabIndex        =   1
      Top             =   1920
      Width           =   1215
   End
   Begin MSAdodcLib.Adodc AdoFind 
      Height          =   375
      Left            =   3120
      Top             =   1320
      Visible         =   0   'False
      Width           =   1680
      _ExtentX        =   2963
      _ExtentY        =   661
      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            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin MSDataGridLib.DataGrid DataGrl 
      Bindings        =   "frmMG.frx":0000
      Height          =   1695
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   6375
      _ExtentX        =   11245
      _ExtentY        =   2990
      _Version        =   393216
      AllowUpdate     =   0   'False
      HeadLines       =   1
      RowHeight       =   18
      BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ColumnCount     =   2
      BeginProperty Column00 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column01 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   0
         EndProperty
      EndProperty
      SplitCount      =   1
      BeginProperty Split0 
         BeginProperty Column00 
         EndProperty
         BeginProperty Column01 
         EndProperty
      EndProperty
   End
   Begin VB.Label Label3 
      AutoSize        =   -1  'True
      Caption         =   "权限"
      Height          =   240
      Left            =   3720
      TabIndex        =   14
      Top             =   2040
      Width           =   480
   End
   Begin VB.Label Label2 
      AutoSize        =   -1  'True
      Caption         =   "用户名:"
      Height          =   240
      Left            =   120
      TabIndex        =   13
      Top             =   2040
      Width           =   960
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "密码"
      Height          =   240
      Left            =   2040
      TabIndex        =   3
      Top             =   2040
      Width           =   480
   End
End
Attribute VB_Name = "frmMG"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim ISID As String
Private Sub cmdAdd_Click()

If txtName.Text = "" Then
   MsgBox "用户名没有填写!", vbOKOnly + vbExclamation, "系统提示"
   Exit Sub
End If
Set adoRs = adoCon.Execute("select count(*) from Login where Name='" & Trim(txtName.Text) & "'")
If adoRs(0) > 0 Then
   MsgBox "用户名已经存在!", vbOKOnly + vbExclamation, "系统提示"
   Exit Sub
End If
If txtPass.Text = "" Then
   MsgBox "密码没有填写!", vbOKOnly + vbExclamation, "系统提示"
   Exit Sub
End If
   adoCon.Execute ("insert into Login values ('" & Trim(txtName.Text) & "','" & Trim(txtPass.Text) & "','" & Trim(cobQuan.Text) & "')")
 
   SetNew
End Sub

Private Sub cmdDel_Click()
If ISID = "0" Then
   MsgBox "您没有选中记录!", vbOKOnly + vbExclamation, "系统提示"
   Exit Sub
Else
  If MsgBox("是否要删除这条记录?", vbYesNo, "删除提示") = vbYes Then
     adoCon.Execute ("delete from Login where ID='" & Trim(ISID) & "'")
     Call SetNew
 
  End If

End If
End Sub

Private Sub cmdMOdify_Click()
If txtName.Text = "" Then
 MsgBox "用户名不能为空!", vbOKOnly + vbExclamation, "系统提示"
 Exit Sub
End If
If txtPass.Text = "" Then
   MsgBox "密码不能为空!", vbOKOnly + vbExclamation, "系统提示"
 Exit Sub
End If
If ISID = "0" Then
   MsgBox "您没有选中记录!", vbOKOnly + vbExclamation, "系统提示"
   Exit Sub
Else
  If MsgBox("是否要修改这条记录?", vbYesNo, "修改提示") = vbYes Then
     adoCon.Execute ("update Login set Name ='" & Trim(txtName.Text) & "',Password='" & Trim(txtPass.Text) & "',Quanxian='" & Trim(cobQuan.Text) & "'  where ID='" & Trim(ISID) & "'")
     Call SetNew
   End If

End If
End Sub

Private Sub cmdQuit_Click()
Unload Me
End Sub
Private Sub SetNew()
   txtName.Text = ""
   txtPass.Text = ""
   With cobQuan
      .Clear
      .AddItem "查询"
      .AddItem "修改"
      .AddItem "管理员"
     .ListIndex = 0
   End With
   ISID = "0"
   With AdoFind
      .ConnectionString = RtnStr
      .RecordSource = "select ID as 编号, Name as 用户名,Password as 密码,Quanxian as 权限  from Login"
      .Refresh
   End With
End Sub

Private Sub cmdRef_Click()
Call SetNew
End Sub

Private Sub cmdROpen_Click()
MsgBox "删除所有临时考勤记录" + Chr(13) + "从新录入考勤记录", vbOKOnly + vbExclamation, "系统提示"
If MsgBox("确实要更新?", vbYesNo + vbExclamation, "系统提示") = vbYes Then

adoCon.Execute ("delete from KaoQin")
adoCon.Execute ("delete from Lastday")
Call InPutKaoQin
Call setChushi

MsgBox "刷新成功!", vbOKOnly, "系统提示"
End If
End Sub

Private Sub cmdThree_Click()
Dim sDate As Date
Dim M, Y As Integer
M = Month(Now)
Y = Year(Now)
M = M - 3
If M < 0 Then
  M = M + 12
  Y = Y - 1
End If
sDate = CDate(CStr(Y) + "-" + CStr(M) + "-1")
Set adoRs = adoCon.Execute("select * from lastday")
If (adoRs!LastDay - sDate) < 90 Then
   MsgBox "删除时间有误,请校正日期!", vbOKOnly + vbExclamation, "系统提示"
   Exit Sub
End If

If MsgBox("是否要删除三个月以前的数据?", vbYesNo, "系统提示") = vbYes Then
   adoCon.Execute ("delete KaoQin where Date <'" & Trim(sDate) & "'")
   adoCon.Execute ("delete KaoQinSource where Date <'" & Trim(sDate) & "'")
   adoCon.Execute ("delete QingJia where StartDay <'" & Trim(sDate) & "'")
   MsgBox "删除成功!", vbOKOnly, "系统提示"
End If
End Sub

Private Sub DataGrl_Click()
On Error GoTo ErrMsg
DataGrl.Col = 0
ISID = DataGrl.Text
Set adoRs = adoCon.Execute("select * from Login where ID='" & Trim(ISID) & "'")
txtName.Text = adoRs!Name
txtPass.Text = adoRs!Password
cobQuan.Text = adoRs!Quanxian
ErrMsg:
If Err.Number > 0 Then
   MsgBox "您没有选中记录!", vbOKOnly + vbExclamation, "系统提示"
   Exit Sub
End If
End Sub

Private Sub Form_Load()

 Call SetNew
Me.Move (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 2 - 200


End Sub

⌨️ 快捷键说明

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