| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 488 人关注过本帖
标题:高手高手在哪里!!小弟急!!
只看楼主 加入收藏
hongzhongmin
Rank: 1
等 级:新手上路
帖 子:36
专家分:0
注 册:2007-1-30
收藏
 问题点数:0 回复次数:0 
高手高手在哪里!!小弟急!!

小弟现在做一个销售系统,有很严重的问题,当我在把要销售的产品名称,尺寸,号码时点确定是会显示在datagrid中时,可以显示在datagrid中但是当我点销售时,就是在datagrid中的数据就没有了,而且我也没有添加到销售表里面.这该怎么解决呢``??
Imports System.Data.SqlClient
Public Class frmXiaoShou
Inherits System.Windows.Forms.Form
Dim ds As New DataSet
Dim sqlDa As New SqlDataAdapter
Dim sqlCmd As New SqlCommand
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Me.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ds.Clear()
' If Module1.sqlconn.State <> ConnectionState.Closed Then
' Module1.sqlconn.Open()
' End If
Dim str As String
str = "insert into 销售表(名称,尺寸,颜色,价格) values ('" & txtShoesID.Text & "','" & CombNoID.SelectedItem & "','" & combColorID.SelectedItem & "','" & txtUnitPrice.Text & "')"

sqlCmd.Connection = Module1.sqlconn
sqlCmd.CommandType = CommandType.Text
sqlCmd.CommandText = str
' sqlDa.SelectCommand = sqlCmd
' sqlDa.Fill(ds, "销售表")

If Me.ds.Tables.Count <> 0 Then
sqlCmd.Connection = Module1.sqlconn
sqlCmd.CommandType = CommandType.Text
sqlCmd.CommandText = "select * from 销售表 where 名称='" & txtShoesID.Text & "' and 尺寸='" & CombNoID.SelectedItem & "' and 颜色='" & combColorID.SelectedItem & "'"
sqlDa.SelectCommand = sqlCmd
sqlDa.Fill(ds, "销售表")
MessageBox.Show("销售成功", "提示信息")
txtShoesID.Text = ""
CombNoID.Text = ""
combColorID.Text = ""
txtShoesID.Focus()
Else

End If
'还要修改的内容
' sqlCmd.CommandText = "update 库存表 set 数量 = (数量 - NumericUpDown2) where 名称=@shoesID and 尺寸=@noID and 颜色=@colorID"
'sqlCmd.Connection = Module1.sqlconn
' sqlCmd.CommandType = CommandType.Text

' Dim printFrm As New Printfrmshoes
' Dim printDoc As New CrystalReport2
' printDoc.SetDataSource(ds.Tables("销售表"))
' printFrm.CrystalReportViewershoes.ReportSource = printDoc
' printFrm.Show()
End Sub

Private Sub txtShoesID_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtShoesID.TextChanged

End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim frm As New frmxiaoshouchaxun
frm.Show()
Me.Hide()
End Sub

Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox1.Enter

End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
If Me.txtShoesID.Text.Trim.Length = 0 Then
MsgBox("请输入鞋名!", MsgBoxStyle.Information, "提示")
Me.txtShoesID.Focus()
Exit Sub
End If
If Me.CombNoID.Text.Trim.Length = 0 Then
MsgBox("请输入号码!", MsgBoxStyle.Information, "提示")
Me.CombNoID.Focus()
Exit Sub
End If
If Me.combColorID.Text.Trim.Length = 0 Then
MsgBox("请输入颜色!", MsgBoxStyle.Information, "提示")
Me.combColorID.Focus()
Exit Sub
End If
Dim row As DataRow
row = Me.ds.Tables("销售表").NewRow
row("鞋名") = Me.txtShoesID.Text
row("尺寸") = Me.CombNoID.Text
row("单价") = Me.txtUnitPrice.Text
row("颜色") = Me.combColorID.Text
row("折扣") = Me.NumericUpDown1.Text
row("数量") = Me.NumericUpDown2.Text
Me.ds.Tables("销售表").Rows.Add(row)

If Me.ds.Tables("销售表").Rows.Count > 0 Then
Me.txtTotalMoney.Text = Me.ds.Tables("销售表").Compute("sum(金额)", "")
End If
End Sub

Private Sub txtColorID_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles combColorID.SelectedIndexChanged
If Me.txtShoesID.Text.Trim.Length = 0 And Me.txtShoesID.Text.Trim.Length Then
MsgBox("请输入正确的数据!", MsgBoxStyle.Information, "提示")
Me.txtShoesID.Focus()
Me.CombNoID.Focus()
Exit Sub
End If

sqlcmd.CommandText = "select 名称 ,尺寸 ,颜色,价格,数量 from 库存表 where 名称 = @shoesID and 尺寸 = @noID and 颜色 = @colorID"
sqlcmd.Parameters.Add("@shoesID", SqlDbType.VarChar)
sqlcmd.Parameters("@shoesID").Value = Me.txtShoesID.Text
sqlcmd.Parameters.Add("@noID", SqlDbType.Int)
sqlcmd.Parameters("@noID").Value = Me.CombNoID.Text
sqlcmd.Parameters.Add("@colorID", SqlDbType.VarChar)
sqlcmd.Parameters("@colorID").Value = Me.combColorID.SelectedItem
sqlCmd.Connection = Module1.sqlconn

Dim sqlDr As SqlDataReader
Try
Module1.sqlconn.Open()
sqlDr = sqlCmd.ExecuteReader(CommandBehavior.CloseConnection)
If sqlDr.Read Then
Me.txtUnitPrice.Text = sqlDr("价格")
Me.txtStockQuantity.Text = sqlDr("数量")
End If
Catch ex As Exception
MsgBox("发生错误:" & ex.Message)
Finally
If Module1.sqlconn.State <> ConnectionState.Open Then
Module1.sqlconn.Close()
End If
End Try
End Sub

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim dt As New DataTable("销售表")
dt.Columns.Add("鞋名", System.Type.GetType("System.String"))
dt.Columns.Add("尺寸", System.Type.GetType("System.Int16"))
dt.Columns.Add("颜色", System.Type.GetType("System.String"))
dt.Columns.Add("单价", System.Type.GetType("System.Decimal"))
dt.Columns.Add("折扣", System.Type.GetType("System.Single"))
dt.Columns.Add("数量", System.Type.GetType("System.Int16"))
dt.Columns.Add("金额", System.Type.GetType("System.Decimal"), "单价*折扣*数量")
Me.ds.Tables.Add(dt)
Me.DataGrid1.DataSource = dt

End Sub

也请高手们能顺便帮我改改代码```把正确的代码发表下```小弟将十分关注的!!!

搜索更多相关主题的帖子: 产品 而且 
2007-02-02 04:13
快速回复:高手高手在哪里!!小弟急!!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.046106 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved