www.pudn.com > netserver.zip > frmStart.frm


VERSION 5.00 
Begin VB.Form frmStart  
   BorderStyle     =   1  'Fixed Single 
   Caption         =   "开始记费" 
   ClientHeight    =   3045 
   ClientLeft      =   45 
   ClientTop       =   330 
   ClientWidth     =   7125 
   Icon            =   "frmStart.frx":0000 
   LinkTopic       =   "Form1" 
   MaxButton       =   0   'False 
   MinButton       =   0   'False 
   ScaleHeight     =   3045 
   ScaleWidth      =   7125 
   StartUpPosition =   1  '所有者中心 
   Begin VB.CommandButton Command8  
      Caption         =   "开始通宵" 
      Height          =   375 
      Left            =   5640 
      TabIndex        =   8 
      Top             =   1200 
      Width           =   1215 
   End 
   Begin VB.ComboBox comSjZhengJi  
      Height          =   300 
      ItemData        =   "frmStart.frx":030A 
      Left            =   2880 
      List            =   "frmStart.frx":031A 
      TabIndex        =   7 
      Top             =   1680 
      Width           =   2055 
   End 
   Begin VB.TextBox txtZhengJian  
      Height          =   270 
      Left            =   2880 
      TabIndex        =   6 
      Top             =   2520 
      Width           =   2055 
   End 
   Begin VB.TextBox 设定分  
      Alignment       =   1  'Right Justify 
      Height          =   270 
      Left            =   3360 
      TabIndex        =   5 
      Top             =   720 
      Width           =   855 
   End 
   Begin VB.TextBox 设定时  
      Alignment       =   1  'Right Justify 
      Height          =   270 
      Left            =   1800 
      TabIndex        =   4 
      Top             =   720 
      Width           =   975 
   End 
   Begin VB.TextBox 预交金额  
      Alignment       =   1  'Right Justify 
      Height          =   270 
      Left            =   1800 
      TabIndex        =   3 
      Top             =   240 
      Width           =   2415 
   End 
   Begin VB.CommandButton cmdOpen  
      Caption         =   "开始计时" 
      Height          =   375 
      Left            =   5640 
      TabIndex        =   2 
      Top             =   480 
      Width           =   1215 
   End 
   Begin VB.CommandButton Command12  
      Caption         =   "设定" 
      Height          =   375 
      Left            =   5640 
      TabIndex        =   1 
      Top             =   1920 
      Width           =   1215 
   End 
   Begin VB.ComboBox txtSJName  
      Height          =   1440 
      Left            =   360 
      Sorted          =   -1  'True 
      Style           =   1  'Simple Combo 
      TabIndex        =   0 
      Text            =   "txtSJName" 
      Top             =   1440 
      Width           =   2415 
   End 
   Begin VB.Label Label23  
      Caption         =   "证件号码:" 
      Height          =   255 
      Left            =   2880 
      TabIndex        =   16 
      Top             =   2160 
      Width           =   1335 
   End 
   Begin VB.Label Label22  
      Caption         =   "上机人证件:" 
      Height          =   255 
      Left            =   2880 
      TabIndex        =   15 
      Top             =   1200 
      Width           =   1575 
   End 
   Begin VB.Label Label21  
      Caption         =   "上机人姓名:" 
      Height          =   255 
      Left            =   240 
      TabIndex        =   14 
      Top             =   1200 
      Width           =   1455 
   End 
   Begin VB.Label Label5  
      Caption         =   "分钟" 
      Height          =   375 
      Left            =   4320 
      TabIndex        =   13 
      Top             =   840 
      Width           =   495 
   End 
   Begin VB.Label Label4  
      Caption         =   "小时" 
      Height          =   375 
      Left            =   2880 
      TabIndex        =   12 
      Top             =   840 
      Width           =   615 
   End 
   Begin VB.Label Label3  
      Caption         =   "设定时间:" 
      Height          =   255 
      Left            =   240 
      TabIndex        =   11 
      Top             =   840 
      Width           =   1215 
   End 
   Begin VB.Label Label2  
      Caption         =   "元" 
      Height          =   375 
      Left            =   4320 
      TabIndex        =   10 
      Top             =   360 
      Width           =   375 
   End 
   Begin VB.Label Label1  
      Caption         =   "预交金额:" 
      Height          =   375 
      Left            =   240 
      TabIndex        =   9 
      Top             =   360 
      Width           =   1455 
   End 
End 
Attribute VB_Name = "frmStart" 
Attribute VB_GlobalNameSpace = False 
Attribute VB_Creatable = False 
Attribute VB_PredeclaredId = True 
Attribute VB_Exposed = False 
Private Sub cmdOpen_Click() 
 '开机 
On Error Resume Next 
 If txtSJName.Text <> "" Then 
    With frmMain.Data9.Recordset 
     .MoveFirst 
     Dim findIt As Boolean 
     findIt = False 
     For i = 1 To .RecordCount 
      If .Fields("客户姓名") = txtSJName.Text Then 
       findIt = True 
       Exit For 
      End If 
     .MoveNext 
     Next i 
     If findIt = False Then 
      If MsgBox("这个一个新用户,是否添加到用户表中?", vbYesNo + vbQuestion) = vbYes Then 
        Dim anum As Long, olda As Long, tnum As String 
        olda = .AbsolutePosition 
 
        anum = 0 
        Do 
            findIt = False 
            anum = anum + 1 
            .MoveFirst 
            For i = 1 To .RecordCount 
            If Val(.Fields("编号")) = anum Then findIt = True 
  
             .MoveNext 
                Next i 
                If findIt = False Then Exit Do 
        Loop 
        tnum = CStr(anum) 
        For i = 1 To 8 - Len(CStr(anum)) 
            tnum = "0" + tnum 
        Next i 
         aa = txtSJName.Text 
         .AddNew 
         .Fields("编号") = tnum 
         .Fields("客户姓名") = txtSJName.Text 
         .Fields("证件") = comSjZhengJi.Text 
         .Fields("证件号码") = txtZhengJian.Text 
        .Update 
         AddKehuList 
         txtSJName.Text = aa 
      End If 
     End If 
 
    End With 
 End If 
 'MsgBox txtSJName.Text 
 With frmMain.Data1.Recordset 
  .Edit 
  .Fields("状态").Value = "Y" 
  .Fields("开始时间").Value = Now 
  .Fields("客户姓名") = txtSJName.Text 
  .Fields("客户证件") = comSjZhengJi 
  .Fields("证件号码") = txtZhengJian 
  .Fields("上机方式") = "N" 
  If Val(设定分.Text) <> 0 Or Val(设定时.Text) <> 0 Then 
   .Fields("到点时间").Value = DateAdd("n", Val(设定时.Text) * 60 + Val(设定分.Text), Now) 
   If 预交金额 <> "" Then .Fields("已收款").Value = Val(预交金额) 
       
  End If 
  .Update 
  For i = 0 To frmMain.Winsock1.Count - 1 
  If .Fields("IP") = frmMain.Winsock1(i).RemoteHostIP Then 
    frmMain.Winsock1(i).SendData "_comm" + Chr(0) + "start" + Chr(0) + "OK$" 
   Exit For 
  End If 
 Next i 
 End With 
 frmMain.ListView1.ListItems(SelectComputer).Icon = 3 
 frmMain.ListView1.ListItems(SelectComputer).SmallIcon = 3 
 Unload Me 
 frmMain.Timer2_Timer 
 
  
  
End Sub 
 
Private Sub Command12_Click() 
With frmMain.Data1.Recordset 
  aa = Val(设定时.Text) * 60 + Val(设定分.Text) 
 
 .Edit 
 If aa <> 0 Then 
  .Fields("到点时间") = DateAdd("n", aa, .Fields("开始时间")) 
 End If 
   .Fields("客户证件") = comSjZhengJi.Text 
   .Fields("客户姓名") = txtSJName.Text 
   .Fields("证件号码") = txtZhengJian.Text 
    .Fields("已收款") = 预交金额.Text 
  .Update 
 
 
End With 
Unload Me 
frmMain.Timer2_Timer 
End Sub 
 
Private Sub Form_Load() 
On Error Resume Next 
AddKehuList 
With frmMain.Data1.Recordset 
   comSjZhengJi.Text = .Fields("客户证件") 
   txtSJName.Text = .Fields("客户姓名") 
   txtZhengJian.Text = .Fields("证件号码") 
   预交金额.Text = .Fields("已收款") 
    
End With 
End Sub 
Public Sub AddKehuList() 
' 
 
txtSJName.Clear 
frmMain.Data9.Recordset.MoveFirst 
For i = 1 To frmMain.Data9.Recordset.RecordCount 
 txtSJName.AddItem frmMain.Data9.Recordset.Fields("客户姓名") 
 txtSJName.ItemData(txtSJName.NewIndex) = frmMain.Data9.Recordset.AbsolutePosition 
 frmMain.Data9.Recordset.MoveNext 
Next i 
 
End Sub 
 
Private Sub txtSJName_Click() 
On Error Resume Next 
With frmMain.Data9.Recordset 
.MoveFirst 
.Move txtSJName.ItemData(txtSJName.ListIndex) 
comSjZhengJi.Text = .Fields("证件") 
txtZhengJian.Text = .Fields("证件号码") 
 
End With 
End Sub 
 
Private Sub Command8_Click() 
'开始通宵 
On Error Resume Next 
If frmMain.Data7.Recordset.Fields("通宵开始时间") > frmMain.Data7.Recordset.Fields("通宵结束时间") Then 
   If Time > frmMain.Data7.Recordset.Fields("通宵结束时间") And Time < frmMain.Data7.Recordset.Fields("通宵开始时间") Then 
      MsgBox "还未到通宵时间!" & vbCrLf & "通宵时间:" & frmMain.Data7.Recordset.Fields("通宵开始时间") & " 至 " & frmMain.Data7.Recordset.Fields("通宵结束时间"), vbCritical 
      Exit Sub 
   End If 
Else 
   If Not (Time < frmMain.Data7.Recordset.Fields("通宵结束时间") And Time > frmMain.Data7.Recordset.Fields("通宵开始时间")) Then 
      MsgBox "还未到通宵时间!" & vbCrLf & "通宵时间:" & frmMain.Data7.Recordset.Fields("通宵开始时间") & " 至 " & frmMain.Data7.Recordset.Fields("通宵结束时间"), vbCritical 
      Exit Sub 
   End If 
 
End If 
 If txtSJName.Text <> "" Then 
    With frmMain.Data9.Recordset 
     .MoveFirst 
     Dim findIt As Boolean 
     findIt = False 
     For i = 1 To .RecordCount 
      If .Fields("客户姓名") = txtSJName.Text Then 
       findIt = True 
       Exit For 
      End If 
     .MoveNext 
     Next i 
     If findIt = False Then 
      If MsgBox("这个一个新用户,是否添加到用户表中?", vbYesNo + vbQuestion) = vbYes Then 
        Dim anum As Long, olda As Long, tnum As String 
        olda = .AbsolutePosition 
 
        anum = 0 
        Do 
            findIt = False 
            anum = anum + 1 
            .MoveFirst 
            For i = 1 To .RecordCount 
            If Val(.Fields("编号")) = anum Then findIt = True 
  
             .MoveNext 
                Next i 
                If findIt = False Then Exit Do 
        Loop 
        tnum = CStr(anum) 
        For i = 1 To 8 - Len(CStr(anum)) 
            tnum = "0" + tnum 
        Next i 
 
         .AddNew 
         .Fields("编号") = tnum 
         .Fields("客户姓名") = txtSJName.Text 
         .Fields("证件") = comSjZhengJi.Text 
         .Fields("证件号码") = txtZhengJian.Text 
        .Update 
        aa = txtSJName.Text 
        AddKehuList 
        txtSJName.Text = aa 
 
      End If 
     End If 
    End With 
 End If 
 With frmMain.Data1.Recordset 
  .Edit 
  .Fields("状态").Value = "Y" 
  .Fields("开始时间").Value = Now 
  .Fields("到点时间").Value = Format(DateAdd("d", 1, Date), "yyyy-mm-dd") & Format(Data7.Recordset.Fields("通宵结束时间"), " hh:nn:ss") 
  .Fields("客户姓名") = txtSJName 
  .Fields("客户证件") = comSjZhengJi 
  .Fields("证件号码") = txtZhengJian 
  .Fields("上机方式") = "P" 
  If 设定分.Text <> "" Or 设定时.Text <> "" Then 
   .Fields("到点时间").Value = DateAdd("n", Val(设定时.Text) * 60 + Val(设定分.Text), Now) 
   If 预交金额 <> "" Then .Fields("已收款").Value = Val(预交金额) 
       
  End If 
  .Update 
  On Error Resume Next 
 For i = 0 To frmMain.Winsock1.Count - 1 
  If .Fields("IP") = frmMain.Winsock1(i).RemoteHostIP Then 
    frmMain.Winsock1(i).SendData "_comm" + Chr(0) + "start" + Chr(0) + "OK$" 
   Exit For 
  End If 
 Next i 
 End With 
 Unload Me 
frmMain.ListView1.ListItems(SelectComputer).SmallIcon = 3 
frmMain.ListView1.ListItems(SelectComputer).Icon = 3 
 
 frmMain.Timer2_Timer 
End Sub 
 
Private Sub 设定分_Change() 
If Val(设定分) >= 60 Then 
  MsgBox "分的设置最大为59", vbExclamation, "问题" 
  设定分 = "" 
 
End If 
End Sub 
 
Private Sub 设定分_KeyPress(KeyAscii As Integer) 
If Chr(KeyAscii) Like "[!0-9]" And (Not KeyAscii = 8) Then KeyAscii = 0 
 
End Sub 
 
Private Sub 设定时_KeyPress(KeyAscii As Integer) 
If Chr(KeyAscii) Like "[!0-9]" And (Not KeyAscii = 8) Then KeyAscii = 0 
 
End Sub 
 
Private Sub 预交金额_Change() 
On Error Resume Next 
mm = Data1.Recordset.Fields("单位费用").Value 
 
tt = Val(预交金额) 
hh = Int(tt / mm * 60) 
设定时 = hh \ 60 
设定分 = hh Mod 60 
预交金额.SetFocus 
End Sub 
 
Private Sub 预交金额_KeyPress(KeyAscii As Integer) 
If Chr(KeyAscii) Like "[!0-9.]" And (Not KeyAscii = 8) Then KeyAscii = 0 
If Len(预交金额.Text) > 3 And (Not KeyAscii = 8) Then KeyAscii = 0 
 
End Sub