16,717
社区成员
发帖
与我相关
我的任务
分享Public Class Supply
Private s_goodsNO As String = ""
Private s_goodsName As String = ""
Private s_goodsAddress As String = ""
Private s_FirstPrice As Double = 0
Private s_endPrice As Double = 0
Public Property goodsNO() As String
Get
Return s_goodsNO
End Get
Set(ByVal value As String)
s_goodsNO = value
End Set
End Property
Public Property goodsName() As String
Get
Return s_goodsName
End Get
Set(ByVal value As String)
s_goodsName = value
End Set
End Property
Public Property goodsAddress() As String
Get
Return s_goodsAddress
End Get
Set(ByVal value As String)
s_goodsAddress = value
End Set
End Property
Public Property FirstPrice() As Double
Get
Return s_FirstPrice
End Get
Set(ByVal value As Double)
s_FirstPrice = value
End Set
End Property
Public Property endPrice() As Double
Get
Return s_endPrice
End Get
Set(ByVal value As Double)
s_endPrice = value
End Set
End Property
Private Function GetSqlString(ByVal iType As Integer) As String
Dim Result As String = ""
Select Case iType
Case 0 : Result = "Insert into Supply (goodsNO,goodsName,goodsAddress,FirstPrice,endPrice) values ('" & s_goodsNO & "','" & s_goodsName & "','" & s_goodsAddress & "'," & s_FirstPrice & "," & s_endPrice & ")"
Case 1 : Result = "Update Supply Set goodsName = '" & s_goodsName & "',goodsAddress='" & s_goodsAddress & "',FirstPrice = " & s_FirstPrice & ",endPrice = " & s_endPrice & ",goodsNO = '" & s_goodsNO & "'"
Case 2 : Result = "Delete From Supply where goodsName = '" & s_goodsName & "'"
Case Else : Result = ""
End Select
Return Result
End Function
我猜是不是应该这样呢?
Public Sub FD()
Dim F_Supply As Supply = New Supply
F_Supply.getdate()
F_Supply.goodsName = Me.F_NameTxt.Text
Me.F_NoTxt.Text = F_Supply.goodsNO
Me.F_AddressTxt.Text = F_Supply.goodsAddress
Me.F_firstTxt.Text = F_Supply.FirstPrice
Me.F_endTxt.Text = F_Supply.endPrice
End Sub Dim F_Supply As Supply = New Supply
F_Supply.goodsName = Me.F_NameTxt.Text
F_Supply.getdate()
Me.F_NoTxt.Text = F_Supply.goodsNO
Me.F_AddressTxt.Text = F_Supply.goodsAddress
Me.F_firstTxt.Text = F_Supply.FirstPrice
Me.F_endTxt.Text = F_Supply.endPrice
Public Sub getdate()
dim ds as new dataset
Dim txtSql As String = "select * from supply where goodsName = '" & s_goodsName & "'"
Dim Conn As New SqlConnection("SERVER=(local);database=StockGoods;user id=sa;pwd=123456")
Dim cmd As New SqlDataAdapter(txtsql, Conn)
cmd.fill(ds,"表名")
if ds.tables("表名").rows.count>0 then
with ds.tables("表名").rows(0)
s_goodsNO = .Item("值的字段名").ToString()
s_goodsAddress = .Item("值的字段名").ToString ()
s_FirstPrice = CType(.Item("值的字段名"), Double)
s_endPrice = CType(.Item("值的字段名"), Double)
end with
else
ds.dispose()
msgbox("没有数据!" + s_goodsname)
End If
cmd.Dispose()
ds.dispose()
End Sub