provider.aspx.vb
来自「c++builder开发的一个仓库信息管理系统」· VB 代码 · 共 200 行
VB
200 行
Option Explicit On
Option Strict On
Imports System.Data
Imports System.Data.SqlClient
Partial Class _Default
Inherits System.Web.UI.Page
#Region "变量"
Dim conn As New SqlConnection("Data Source=.;Initial Catalog=WMS;User ID=sa;pwd=074345")
#End Region
#Region "初期化"
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Dim conn As New SqlConnection("Data Source=.;Initial Catalog=WMS;Persist Security Info=True;User ID=sa;pwd=074345")
conn.Open()
Dim adap As New SqlDataAdapter("select * from provider", conn)
Dim dataset As New DataSet
adap.Fill(dataset, "provider")
Dim table As New DataTable
table = dataset.Tables("provider")
Me.DataGridfile.DataSource = table
Me.DataGridfile.DataBind()
Me.Panelappend.Visible = False
Me.Paneldelete.Visible = False
Me.Paneledit.Visible = False
Me.Panelseek.Visible = False
End If
End Sub
#End Region
#Region "添加"
Protected Sub append_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles append.Click
Me.Panelappend.Visible = True
Me.Panelfile.Visible = False
Me.Paneldelete.Visible = False
Me.Paneledit.Visible = False
Me.Panelseek.Visible = False
End Sub
Protected Sub append2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles append2.Click
Dim ProviderNo As Integer = CInt(Me.TextBox1.Text)
Dim ProviderName As String = Me.TextBox2.Text
Dim ProviderPeople As String = Me.TextBox5.Text
Dim ProviderPhone As String = Me.TextBox4.Text
Dim ProviderFax As String = Me.TextBox7.Text
Dim ProviderAddress As String = Me.TextBox3.Text
Dim Remark As String = Me.TextBox6.Text
Dim str As String = "(" + ProviderNo.ToString + ",'" + ProviderName + "','" + ProviderPeople + "','" + ProviderPhone + "','" + ProviderFax + "','" + ProviderAddress + "','" + Remark + "')"
Dim conn As New SqlConnection("Data Source=.;Initial Catalog=WMS;Persist Security Info=True;User ID=sa;pwd=074345")
conn.Open()
Dim comm As New SqlCommand("Insert Into Provider Values" + str, conn)
comm.ExecuteNonQuery()
conn.Close()
Me.Response.Redirect("~/Mode1_Provider.aspx")
End Sub
#End Region
#Region "修改"
Protected Sub edit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles edit.Click
Me.Panelappend.Visible = False
Me.Panelfile.Visible = False
Me.Paneldelete.Visible = False
Me.Paneledit.Visible = True
Me.Panelseek.Visible = False
End Sub
Protected Sub edit2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles edit2.Click
Dim ProviderNo As Integer = CInt(Me.TextBox8.Text)
Dim ProviderName As String = Me.TextBox9.Text
Dim ProviderPeople As String = Me.TextBox10.Text
Dim ProviderPhone As String = Me.TextBox11.Text
Dim ProviderFax As String = Me.TextBox12.Text
Dim ProviderAddress As String = Me.TextBox13.Text
Dim Remark As String = Me.TextBox14.Text
conn.Open()
Dim comm As New SqlCommand("select providerno from provider where providerno='" + Me.TextBox8.Text + "'", conn)
Dim reader As SqlDataReader
reader = comm.ExecuteReader
If reader.Read Then
Dim conn1 As New SqlConnection("Data Source=.;Initial Catalog=WMS;Persist Security Info=True;User ID=sa;pwd=074345")
conn1.Open()
Dim sqlbuff As New StringBuilder
sqlbuff.Append(" update provider ")
sqlbuff.Append(" set providerno=" + ProviderNo.ToString)
sqlbuff.Append(" ,providername='" + ProviderName + "'")
sqlbuff.Append(" ,ProviderPeople='" + ProviderPeople + "'")
sqlbuff.Append(" ,ProviderPhone='" + ProviderPhone + "'")
sqlbuff.Append(" ,ProviderFax='" + ProviderFax + "'")
sqlbuff.Append(" ,ProviderAddress='" + ProviderAddress + "'")
sqlbuff.Append(" ,Remark='" + Remark + "'")
sqlbuff.Append(" where providerno=" + Me.TextBox8.Text)
Dim comm1 As New SqlCommand(sqlbuff.ToString, conn1)
comm1.ExecuteNonQuery()
conn1.Close()
Me.Labeledit.Text = "修改成功"
Else
Me.Labeledit.Text = "没有您要修改的对象。"
End If
End Sub
#End Region
#Region "删除"
Protected Sub delete_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles delete.Click
Me.Panelappend.Visible = False
Me.Panelfile.Visible = False
Me.Paneldelete.Visible = True
Me.Paneledit.Visible = False
Me.Panelseek.Visible = False
End Sub
Protected Sub delete2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles delete2.Click
Dim conn As New SqlConnection("Data Source=.;Initial Catalog=WMS;User ID=sa;pwd=074345")
conn.Open()
Dim comm As New SqlCommand("select providername from provider where providername='" + Me.Text_delete.Text + "'", conn)
Dim reader As SqlDataReader
reader = comm.ExecuteReader
If reader.Read Then
Dim conn1 As New SqlConnection("Data Source=.;Initial Catalog=WMS;User ID=sa;pwd=074345")
conn1.Open()
Try
Dim comm1 As New SqlCommand("delete from provider where providername='" + Me.Text_delete.Text + "'", conn1)
comm1.ExecuteNonQuery()
Me.Labeldelete.Text = "删除成功。"
Catch ex As Exception
Me.Labeldelete.Text = "对不起,执行错误。"
End Try
conn1.Close()
Else
Me.Labeldelete.Text = "对不起,没有您要删除的供货商。"
End If
conn.Close()
End Sub
#End Region
#Region "查找"
Protected Sub seek_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles seek.Click
Me.Panelappend.Visible = False
Me.Panelfile.Visible = False
Me.Paneldelete.Visible = False
Me.Paneledit.Visible = False
Me.Panelseek.Visible = True
End Sub
Protected Sub seek2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles seek2.Click
conn.Open()
Dim adap As New SqlDataAdapter("select * from provider where providername='" + Me.TextBoxseek.Text + "'", conn)
Dim data As New DataSet
adap.Fill(data)
Dim tb As New DataTable
tb = data.Tables(0)
If tb.Rows.Count <> 0 Then
Me.DataGridseek.DataSource = tb
Me.DataGridseek.DataBind()
Me.Labelseek.Text = "这是您要查找的供货商。"
Else
Me.Labelseek.Text = "没有您要查找的供货商。"
End If
End Sub
#End Region
End Class
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?