📄 frmmodifycontract.frm
字号:
VERSION 5.00
Begin VB.Form frmModifyContract
Caption = "修改合同"
ClientHeight = 5400
ClientLeft = 60
ClientTop = 345
ClientWidth = 6870
LinkTopic = "Form1"
ScaleHeight = 5400
ScaleWidth = 6870
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton cmdCancel
Caption = "返回(&C)"
Height = 375
Left = 4680
TabIndex = 29
Top = 4800
Width = 1335
End
Begin VB.CommandButton cmdDelete
Caption = "删除(&D)"
Height = 375
Left = 3120
TabIndex = 28
Top = 4800
Width = 1335
End
Begin VB.CommandButton cmdModify
Caption = "修改(&M)"
Height = 375
Left = 1560
TabIndex = 27
Top = 4800
Width = 1335
End
Begin VB.Frame Frame1
Caption = "合同信息"
Height = 3375
Index = 1
Left = 120
TabIndex = 4
Top = 1200
Width = 6615
Begin VB.TextBox txtContract
Enabled = 0 'False
Height = 285
Index = 9
Left = 1080
TabIndex = 26
Top = 1080
Width = 2295
End
Begin VB.TextBox txtContract
Enabled = 0 'False
Height = 285
Index = 8
Left = 1080
TabIndex = 25
Top = 720
Width = 2295
End
Begin VB.TextBox txtContract
Height = 285
Index = 0
Left = 1080
TabIndex = 12
Text = " "
Top = 360
Width = 2535
End
Begin VB.TextBox txtContract
Enabled = 0 'False
Height = 285
Index = 1
Left = 4800
TabIndex = 11
Text = " "
Top = 360
Width = 1575
End
Begin VB.TextBox txtContract
Height = 285
Index = 2
Left = 4800
TabIndex = 10
Text = " "
Top = 720
Width = 1575
End
Begin VB.TextBox txtContract
Height = 285
Index = 3
Left = 4800
TabIndex = 9
Text = " "
Top = 1080
Width = 1575
End
Begin VB.TextBox txtContract
Height = 285
Index = 4
Left = 1080
TabIndex = 8
Text = " "
Top = 1440
Width = 1575
End
Begin VB.TextBox txtContract
Height = 735
Index = 6
Left = 1080
MultiLine = -1 'True
TabIndex = 7
Top = 1800
Width = 5295
End
Begin VB.TextBox txtContract
Enabled = 0 'False
Height = 285
Index = 5
Left = 4680
TabIndex = 6
Text = " "
Top = 1440
Width = 1215
End
Begin VB.TextBox txtContract
Height = 615
Index = 7
Left = 1080
TabIndex = 5
Text = " "
Top = 2640
Width = 5295
End
Begin VB.Label Label1
Caption = "合同名称:"
Height = 255
Index = 1
Left = 120
TabIndex = 24
Top = 360
Width = 975
End
Begin VB.Label Label2
Caption = "合同编号:"
Height = 255
Left = 3840
TabIndex = 23
Top = 360
Width = 975
End
Begin VB.Label Label3
Caption = "合同描述:"
Height = 255
Left = 120
TabIndex = 22
Top = 1800
Width = 1335
End
Begin VB.Label Label4
Caption = "客户名称:"
Height = 255
Left = 120
TabIndex = 21
Top = 720
Width = 975
End
Begin VB.Label Label5
Caption = "合同金额:"
Height = 255
Left = 120
TabIndex = 20
Top = 1440
Width = 975
End
Begin VB.Label Label6
Caption = "签 约 人:"
Height = 255
Left = 120
TabIndex = 19
Top = 1080
Width = 975
End
Begin VB.Label Label7
Caption = "合同生效日期:"
Height = 255
Left = 3480
TabIndex = 18
Top = 720
Width = 1335
End
Begin VB.Label Label8
Caption = "合同截止日期:"
Height = 255
Left = 3480
TabIndex = 17
Top = 1080
Width = 1335
End
Begin VB.Label Label9
Caption = "已付合同款:"
Height = 255
Left = 3600
TabIndex = 16
Top = 1440
Width = 1215
End
Begin VB.Label Label10
Caption = "备注信息:"
Height = 255
Left = 120
TabIndex = 15
Top = 2640
Width = 1215
End
Begin VB.Label Label11
Caption = "(元)"
Height = 375
Left = 2640
TabIndex = 14
Top = 1440
Width = 615
End
Begin VB.Label Label12
Caption = "(元)"
Height = 255
Left = 5880
TabIndex = 13
Top = 1440
Width = 615
End
End
Begin VB.Frame Frame1
Caption = "查询"
Height = 975
Index = 0
Left = 120
TabIndex = 0
Top = 120
Width = 6615
Begin VB.CommandButton cmdQuery
Caption = "查询(&Q)"
Height = 375
Left = 4320
TabIndex = 3
Top = 360
Width = 1215
End
Begin VB.TextBox txtContractNo
Height = 375
Left = 1560
TabIndex = 2
Top = 360
Width = 2175
End
Begin VB.Label Label1
Caption = "合同编号:"
Height = 255
Index = 0
Left = 600
TabIndex = 1
Top = 360
Width = 1215
End
End
End
Attribute VB_Name = "frmModifyContract"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public sqlStr As String
Public msgText As String
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdDelete_Click()
Dim conn As ADODB.Connection
'组合得到完成数据删除的SQL语句
sqlStr = "delete from contract where " _
& "[contractNo]='" & Trim(txtContract(1).Text) & "'"
On Error GoTo exitSub
Set conn = New ADODB.Connection
conn.Open connStr
'执行SQL语句
conn.Execute sqlStr
MsgBox "成功删除数据!!"
exitSub:
conn.Close
End Sub
Private Sub cmdModify_Click()
Dim conn As ADODB.Connection
'组合得到完成数据修改的SQL语句
sqlStr = "update contract set [contractName]='" & txtContract(0).Text _
& "',[startDate]=#" & txtContract(2).Text _
& "#,[dueDate]=#" & txtContract(3).Text _
& "#,[amount]=" & txtContract(4).Text _
& ",[description]='" & txtContract(6).Text _
& "',[memo]='" & txtContract(7).Text _
& "' where [contractNo]='" & Trim(txtContract(1).Text) & "'"
On Error GoTo exitSub
Set conn = New ADODB.Connection
conn.Open connStr
'执行SQL语句
conn.Execute sqlStr
MsgBox "成功修改数据!!"
exitSub:
conn.Close
End Sub
Private Sub cmdQuery_Click()
getContractInfo txtContractNo.Text
End Sub
Sub getContractInfo(no As String)
Dim rstContract As ADODB.Recordset
'从合同信息表中读取合同信息并在窗体上显示
sqlStr = "select * from contract where" _
& " contractNo='" & no & "'"
Set rstContract = ExecuteSQL(sqlStr, msgText)
If Not rstContract.EOF Then
txtContract(0).Text = rstContract.Fields("contractName")
txtContract(1).Text = rstContract.Fields("contractNo")
txtContract(2).Text = rstContract.Fields("startDate")
txtContract(3).Text = rstContract.Fields("dueDate")
txtContract(4).Text = rstContract.Fields("amount")
txtContract(5).Text = rstContract.Fields("payment")
txtContract(6).Text = rstContract.Fields("description")
txtContract(7).Text = rstContract.Fields("memo")
txtContract(8).Text = rstContract.Fields("clientName")
txtContract(9).Text = rstContract.Fields("signer")
Else
MsgBox "没有找到相关信息,请添加!", vbOKOnly + vbExclamation, "警告"
Exit Sub
End If
rstContract.Close
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -