VB电表管理信息系统 第8页

VB电表管理信息系统 第8页
单户抄表代码设计:
Private Sub Command2_Click()
    Dim cnn As New ADODB.Connection
    Dim rstE As New ADODB.Recordset
    Dim cmdExe As New ADODB.Command
    Dim nowEv As Double
    Dim sqlAdd As String
    If Trim(txtUserName(0).Text) = "" Then
       MsgBox " 没有要抄表用户,请先添加用户!   ", vbInformation
       Exit Sub
    End If
    If Trim(txtUserName(9).Text) = "" Then
       MsgBox " 请先输入数据!   ", vbInformation
       Exit Sub
    End If
   
    If Trim(txtUserName(9).Text) < Trim(txtUserName(2).Text) Then
       MsgBox " 输入数据错误,当前止码太小!   ", vbInformation
       Exit Sub
    End If
    cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:database password= " & DbPassword & " ;Data Source= " & _
    App.Path & "\data\dbdb.mdb;Persist Security Info=False"
    cnn.CursorLocation = adUseClient
    cnn.Open
    cmdExe.ActiveConnection = cnn
    rstE.Open "select nowecount from panelinfo where  holderID= '" & Trim(txtUserName(0)) & "'", cnn, adOpenStatic, adLockBatchOptimistic
   
    nowEv = Val(rstE.Fields(0).Value) + (Val(txtUserName(9)) - Val(txtUserName(2)))
   
   
    sqlAdd = "update  panelinfo  set LEndPCode=" & Val(txtUserName(2).Text) & ",cEndCode=" & Val(txtUserName(9).Text) & ",nowEcount=" & nowEv & " ,writedate=#" & dtpwdate(1) & "#  where  holderID= '" & Trim(txtUserName(0)) & "'"
    cmdExe.CommandText = sqlAdd
    cmdExe.Execute sqlAdd
   ' cnn.Execute sqlAdd
    txtUserName(2).Text = txtUserName(9)
    txtUserName(9) = ""
  
    cnn.Close
   
    MsgBox " 数据保存完成! ", vbInformation
   Unload Me
   
End Sub

Private Sub Form_Load()
Dim rst As New ADODB.Recordset
Dim sqlEdit As String
dtpwdate(1).Value = Format(Now, "yyyy-mm-dd")
sqlEdit = "select * from panelinfo  "
sqlEdit = sqlEdit & " where holderid='" & Trim(MDIme.txtUserName(0)) & "'and delflag<>true"
rst.Open sqlEdit, gCnn, adOpenStatic, adLockBatchOptimistic
 

If Not rst.EOF Then

    txtUserName(0) = rst.Fields(1)
    txtUserName(1) = rst.Fields(2)
    txtUserName(2) = rst.Fields!cendcode
    dtpwdate(0).Value = rst.Fields(4)
   
     
End If
buttontime = False
End Sub

Private Sub Form_Unload(Cancel As Integer)
 
MDIme.loadData (txtUserName(0))
Cancel = 0
End Sub

Private Sub nextuser_Click()
 
Dim rst As New ADODB.Recordset
Dim sqlEdit As String
sqlEdit = "select * from panelinfo   "
    sqlEdit = sqlEdit & " where holderid<>'" & Trim(txtUserName(0)) & "'and delflag<>true "
 
    rst.Open sqlEdit, gCnn, adOpenStatic, adLockBatchOptimistic
 
If buttontime = False Then
   
    If Not rst.EOF Then
   
        txtUserName(0) = rst.Fields(1)
        txtUserName(1) = rst.Fields(2)
        txtUserName(2) = rst.Fields!cendcode
        dtpwdate(0).Value = rst.Fields(4)
        buttontime = True
   End If
Else
    rst.MoveNext
    If Not rst.EOF Then
        txtUserName(0) = rst.Fields(1)
        txtUserName(1) = rst.Fields(2)
        txtUserName(2) = rst.Fields!cendcode
        dtpwdate(0).Value = rst.Fields(4)
        buttontime = True
   End If
End If
End Sub
Private Sub txtUserName_KeyPress(Index As Integer, KeyAscii As Integer)
If Index = 9 Then
    If KeyAscii <> 8 And KeyAscii <> 46 And KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0
End If
End Sub6. 数据导入界面设计:
 数据导入代码设计:
Private Sub Command1_Click()
On Error GoTo errhandle:
Dim a As String
a = App.Path
a = a & "\"
b = Text1.Text
Dim filename As String
If Dir("" & a & "计费系统数据库.mdb") <> "" Then
Dim ll As String
ll = MsgBox("此目录下有此文件要覆盖吗", vbYesNo, "复制文件")
If ll = vbYes Then
Kill ("" & a & "计费系统数据库.mdb")
FileCopy "" & Text1.Text & "", "" & a & "计费系统数据库.mdb"
Dim l
l = MsgBox("数据导入成功", vbOKOnly, "提示")
Else
Exit Sub
End If
Else

上一页  [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]  ... 下一页  >> 

Copyright © 2007-2012 www.chuibin.com 六维论文网 版权所有