📄 gongyingshang_xinxi.vb
字号:
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, 304)
Me.GroupBox2.TabIndex = 65
Me.GroupBox2.TabStop = False
Me.GroupBox2.Text = "操作区"
'
'LinkLabel1
'
Me.LinkLabel1.Image = CType(resources.GetObject("LinkLabel1.Image"), System.Drawing.Image)
Me.LinkLabel1.Location = New System.Drawing.Point(16, 32)
Me.LinkLabel1.Name = "LinkLabel1"
Me.LinkLabel1.Size = New System.Drawing.Size(80, 32)
Me.LinkLabel1.TabIndex = 24
Me.LinkLabel1.TabStop = True
Me.LinkLabel1.Text = "供应商信息查"
Me.LinkLabel1.TextAlign = System.Drawing.ContentAlignment.BottomCenter
'
'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, 224)
Me.Button4.Name = "Button4"
Me.Button4.Size = New System.Drawing.Size(80, 24)
Me.Button4.TabIndex = 22
Me.Button4.Text = "删除"
'
'gongyingshang_xinxi
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(696, 534)
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 = "gongyingshang_xinxi"
Me.Text = "添加供应商信息"
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
Me.GroupBox1.ResumeLayout(False)
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 gongyingshang_xinxi_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 gongyingshangxinxi"
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 gongyingshangxinxi"
a = GetDataFromDB(str)
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)("备注"))
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
Dim mystr As String
Dim mystr1 As String = Me.TextBox1.Text.Trim
mystr = "select * from gongyingshangxinxi 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 gongyingshangxinxi " & _
"(供应商编号,名称,地址,联系人,联系电话,备注,添加时间) " & _
"VALUES ('" & Me.TextBox1.Text & "','" & Me.TextBox2.Text & "','" & Me.TextBox3.Text & "','" & Me.TextBox4.Text & "','" & Me.TextBox5.Text & "','" & Me.TextBox6.Text & "','" & Now.Date & "')"
If UpdateData(sqlstr) = False Then
MsgBox("没有成功添加了该新供应商信息,请与管理员联系!", MsgBoxStyle.OKOnly + _
MsgBoxStyle.Exclamation, "添加成功")
Exit Sub
Else
MsgBox("成功添加了该新供应商信息!", MsgBoxStyle.OKOnly + _
MsgBoxStyle.Exclamation, "添加成功")
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
End If
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 gongyingshangxinxi 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) + "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, "更新成功")
Exit Sub
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 gongyingshangxinxi 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()
Else
MsgBox("没有能够删除该供应商信息", MsgBoxStyle.OKOnly + _
MsgBoxStyle.Exclamation, "删除成功")
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 LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -