thing.aspx.vb
来自「c++builder开发的一个仓库信息管理系统」· VB 代码 · 共 204 行
VB
204 行
Option Explicit On
Option Strict On
Imports System.Data
Imports System.Data.SqlClient
Partial Class Mode1huopin
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 thing", 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 sqlbuff As New StringBuilder
sqlbuff.Append(" insert into thing values( ")
sqlbuff.Append(" " + Me.tappendno.Text)
sqlbuff.Append(" ,'" + Me.tappendname.Text)
sqlbuff.Append(" ','" + Me.tappenduint.Text)
sqlbuff.Append(" ','" + Me.tappendproprice.Text)
sqlbuff.Append(" ','" + Me.teditshopprice.Text)
sqlbuff.Append(" ','" + Me.teditmin.Text)
sqlbuff.Append(" ','" + Me.teditmax.Text)
sqlbuff.Append(" ','" + Me.tappendclassno.Text)
sqlbuff.Append(" ','" + Me.tappendprono.Text)
sqlbuff.Append(" ',' " + Me.tappendstock.Text)
sqlbuff.Append(" ','" + Me.tappendremark.Text)
sqlbuff.Append(" ') ")
Dim str As String = sqlbuff.ToString
Me.Label1.Text = str
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(str, conn)
comm.ExecuteNonQuery()
conn.Close()
Me.Response.Redirect("~/Mode1_Thing.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
conn.Open()
Dim comm As New SqlCommand("select thingno from thing where thingno='" + Me.teditno.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 thing ")
sqlbuff.Append(" set thingno=" + Me.teditno.Text.ToString)
sqlbuff.Append(" ,thingname='" + Me.teditname.Text + "'")
sqlbuff.Append(" ,thingunit='" + Me.tedituint.Text + "'")
sqlbuff.Append(" ,Providerprice='" + Me.teditproprice.Text + "'")
sqlbuff.Append(" ,shopprice='" + Me.teditshopprice.Text + "'")
sqlbuff.Append(" ,minnumber='" + Me.teditmin.Text + "'")
sqlbuff.Append(" ,MaxNumber='" + Me.teditmax.Text + "'")
sqlbuff.Append(" ,ClassNo='" + Me.teditclassno.Text + "'")
sqlbuff.Append(" ,ProviderNo='" + Me.teditprono.Text + "'")
sqlbuff.Append(" ,StockNumber='" + Me.teditstock.Text + "'")
sqlbuff.Append(" ,remark='" + Me.teditremark.Text + "'")
sqlbuff.Append(" where thingno=" + Me.teditno.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 thingname from thing where thingname='" + 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 thing where thingname='" + 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 thing where thingname='" + 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 + -
显示快捷键?