📄 fu_hetongluru.vb
字号:
'
'PictureBox1
'
Me.PictureBox1.Image = CType(resources.GetObject("PictureBox1.Image"), System.Drawing.Image)
Me.PictureBox1.Location = New System.Drawing.Point(8, 16)
Me.PictureBox1.Name = "PictureBox1"
Me.PictureBox1.Size = New System.Drawing.Size(32, 24)
Me.PictureBox1.TabIndex = 23
Me.PictureBox1.TabStop = False
'
'Button3
'
Me.Button3.Location = New System.Drawing.Point(16, 176)
Me.Button3.Name = "Button3"
Me.Button3.Size = New System.Drawing.Size(80, 24)
Me.Button3.TabIndex = 21
Me.Button3.Text = "更新"
'
'Button4
'
Me.Button4.Location = New System.Drawing.Point(16, 232)
Me.Button4.Name = "Button4"
Me.Button4.Size = New System.Drawing.Size(80, 24)
Me.Button4.TabIndex = 22
Me.Button4.Text = "删除"
'
'GroupBox2
'
Me.GroupBox2.Controls.Add(Me.LinkLabel1)
Me.GroupBox2.Controls.Add(Me.PictureBox1)
Me.GroupBox2.Controls.Add(Me.Button3)
Me.GroupBox2.Controls.Add(Me.Button4)
Me.GroupBox2.Location = New System.Drawing.Point(568, 8)
Me.GroupBox2.Name = "GroupBox2"
Me.GroupBox2.Size = New System.Drawing.Size(112, 344)
Me.GroupBox2.TabIndex = 65
Me.GroupBox2.TabStop = False
Me.GroupBox2.Text = "操作区"
'
'fu_hetongluru
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(696, 574)
Me.Controls.Add(Me.TextBox6)
Me.Controls.Add(Me.Label5)
Me.Controls.Add(Me.DateTimePicker1)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.DataGrid1)
Me.Controls.Add(Me.Button6)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.TextBox5)
Me.Controls.Add(Me.TextBox4)
Me.Controls.Add(Me.TextBox3)
Me.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Label7)
Me.Controls.Add(Me.Label6)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.GroupBox1)
Me.Controls.Add(Me.GroupBox2)
Me.MaximizeBox = False
Me.Name = "fu_hetongluru"
Me.Text = "付款——合同录入"
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
Me.GroupBox2.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
'新建按钮,但不是新建保存到数据库
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.TextBox1.ReadOnly = False
Me.TextBox1.Text = ""
Me.TextBox2.Text = ""
Me.TextBox3.Text = ""
Me.TextBox4.Text = ""
Me.TextBox5.Text = ""
Me.TextBox6.Text = ""
Me.Button3.Enabled = False
Me.Button4.Enabled = False
Me.Button2.Enabled = True
Me.Button6.Enabled = True
End Sub
'本窗体的load事件
Private Sub fu_hetongluru_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Button2.Enabled = False
technologyinf()
loadchuangti()
End Sub
'得到所有工程的信息,并且加载到datagrid中
Private Sub technologyinf()
Dim mydataset As New DataSet
Dim str As String = "select * from fk_hetong"
mydataset = GetDataFromDB(str)
Me.DataGrid1.DataSource = mydataset
mydataset.Dispose()
End Sub
'把表中第一个数据加载到窗体中
Private Sub loadchuangti()
Dim a As New DataSet
Dim str As String = "select * from fk_hetong"
a = GetDataFromDB(str)
Dim y As Integer
y = a.Tables(0).Rows.Count
If y = 0 Then
Exit Sub
End If
TextBox1.Text = Trim(a.Tables(0).Rows(0)("合同编号"))
'Textbox2显示的是项目名称
TextBox2.Text = Trim(a.Tables(0).Rows(0)("合同名称"))
TextBox3.Text = Trim(a.Tables(0).Rows(0)("合同描述"))
TextBox4.Text = Trim(a.Tables(0).Rows(0)("合同金额"))
TextBox5.Text = Trim(a.Tables(0).Rows(0)("签订单位"))
TextBox6.Text = Trim(a.Tables(0).Rows(0)("备注"))
DateTimePicker1.Value = Trim(a.Tables(0).Rows(0)("签订时间"))
a.Dispose()
End Sub
'添加工程基本休息
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If Me.TextBox1.Text.Trim = "" Then
MsgBox("请输入合同编号!", MsgBoxStyle.Information, "提示!")
Me.TextBox1.Text = Nothing
Exit Sub
End If
If TextBox4.Text.Trim = "" Then
MsgBox("请输入--合同金额--值!", MsgBoxStyle.Information, "提示")
Exit Sub
End If
Dim mystr As String
Dim mystr1 As String = Me.TextBox1.Text.Trim
mystr = "select * from fk_hetong where 合同编号 =" + Chr(39) + mystr1 + Chr(39)
If panduan(mystr) = True Then
MsgBox("合同编号已经存在!", MsgBoxStyle.Information, "提示!")
Me.TextBox1.Text = Nothing
Exit Sub
End If
Dim sqlstr As String
sqlstr = "INSERT INTO fk_hetong " & _
"(合同编号,合同名称,合同描述,合同金额,签订单位,备注,签订时间,添加时间) " & _
"VALUES ('" & Me.TextBox1.Text & "','" & Me.TextBox2.Text & "','" & Me.TextBox3.Text & "','" & Me.TextBox4.Text & "','" & Me.TextBox5.Text & "','" & Me.TextBox6.Text & "','" & Me.DateTimePicker1.Value.Date & "','" & Now.Date & "')"
If UpdateData(sqlstr) = False Then
MsgBox("没有成功添加了该新合同信息!", MsgBoxStyle.OKOnly + _
MsgBoxStyle.Exclamation, "添加成功")
Exit Sub
End If
technologyinf()
Me.TextBox1.ReadOnly = False
Me.Button3.Enabled = True
Me.Button4.Enabled = True
Me.Button1.Enabled = True
Me.Button6.Enabled = True
Me.Button2.Enabled = False
MsgBox("已经成功添加了该新合同信息!", MsgBoxStyle.OKOnly + _
MsgBoxStyle.Exclamation, "添加成功")
End Sub
'当DataGrid当前单元格变化的时候响应事件
Private Sub DataGrid1_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.CurrentCellChanged
'textbox1中的文本不可更改
TextBox1.ReadOnly = True
'Textbox1显示的是匹配码
TextBox1.Text = DataGrid1.Item(DataGrid1.CurrentCell.RowNumber, 0)
'Textbox2显示的是项目名称
TextBox2.Text = DataGrid1.Item(DataGrid1.CurrentCell.RowNumber, 1)
TextBox3.Text = DataGrid1.Item(DataGrid1.CurrentCell.RowNumber, 2)
TextBox4.Text = DataGrid1.Item(DataGrid1.CurrentCell.RowNumber, 3)
TextBox5.Text = DataGrid1.Item(DataGrid1.CurrentCell.RowNumber, 4)
TextBox6.Text = DataGrid1.Item(DataGrid1.CurrentCell.RowNumber, 6)
End Sub
'更新用户信息
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim sqlstr As String
sqlstr = "UPDATE fk_hetong SET 合同名称 = " + Chr(39) + Trim(TextBox2.Text) + Chr(39) + ",合同描述=" + Chr(39) + Trim(TextBox3.Text) + Chr(39) + ",合同金额=" + Chr(39) + Trim(TextBox4.Text) + Chr(39) + ",签订单位=" + Chr(39) + Trim(TextBox5.Text) + Chr(39) + ",备注=" + Chr(39) + Trim(TextBox6.Text) + Chr(39) + ",签订时间=" + Chr(39) + Trim(DateTimePicker1.Value.Date) + Chr(39) + "where 合同编号=" + Chr(39) + Trim(TextBox1.Text) + Chr(39)
If UpdateData(sqlstr) = True Then
MsgBox("已经成功更新了该合同资料", MsgBoxStyle.OKOnly + _
MsgBoxStyle.Exclamation, "更新成功")
technologyinf()
Else
MsgBox("不能成功更新了该合同资料!", MsgBoxStyle.OKOnly + _
MsgBoxStyle.Exclamation, "更新成功")
End If
End Sub
'删除工程信息
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim sqlstr As String
sqlstr = "DELETE FROM fk_hetong WHERE 合同编号='" & Trim(TextBox1.Text) & "'"
If MsgBox("该合同信息是否已经使用?", MsgBoxStyle.YesNo, "提示!") = MsgBoxResult.Yes Then
MsgBox("不能进行删除,请与开发者联系?", MsgBoxStyle.Information, "提示")
Exit Sub
End If
If UpdateData(sqlstr) = True Then
MsgBox("已经成功删除了该合同信息", MsgBoxStyle.OKOnly + _
MsgBoxStyle.Exclamation, "删除成功")
technologyinf()
End If
End Sub
'取消新建操作
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Me.Button1.Enabled = False
Me.Button2.Enabled = True
Me.Button3.Enabled = True
Me.Button4.Enabled = True
End Sub
Private Sub TextBox4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox4.TextChanged
Dim str1 As String = TextBox4.Text.Trim
Dim y As Integer = str1.Length
Dim sstr As String
Dim i As Integer
Dim yy As Integer = 0
For i = 1 To y
sstr = Microsoft.VisualBasic.Mid(str1, i, 1)
If sstr = "0" Or sstr = "1" Or sstr = "2" Or sstr = "3" Or sstr = "4" Or sstr = "5" Or sstr = "6" Or sstr = "7" Or sstr = "8" Or sstr = "9" Or sstr = "." Then
If sstr = "." Then
yy = yy + 1
If yy = 2 Then
MsgBox("已经有了--.--,不能再输入了!", MsgBoxStyle.Information, "提示")
TextBox4.Focus()
Exit Sub
End If
End If
Else
MsgBox("请输入正确的数字,特别要分清----。----和---.----", MsgBoxStyle.Information, "提示")
TextBox4.Focus()
Exit Sub
End If
Next
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -