飘过~~
直接把当前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 Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Module1.sqlconn.Open()
Try
Dim str As String
sqlCmd.Connection = Module1.sqlconn
str = "insert into 销售表(名称,尺寸,颜色,金额,数量) values ('" & txtShoesID.Text & "','" & CombNoID.SelectedItem & "','" & combColorID.SelectedItem & "','" & txtTotalMoney.Text & "','" & NumericUpDown2.Text & "')"
sqlCmd.CommandType = CommandType.Text
sqlCmd.CommandText = str
sqlDa.InsertCommand = sqlCmd
sqlCmd.ExecuteNonQuery()
MessageBox.Show("销售成功!", "提醒", MessageBoxButtons.OK, MessageBoxIcon.Information)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
' 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
' DataGrid1.DataSource = Me.ds.Tables("销售表")
'DataGrid1.DataBindings()
Module1.sqlconn.Close()
下面是更新库存表,这段代码还没有完成,这个步骤也要是把在datagrid中的数量通过点击销售来更新库存表
Module1.sqlconn.Open()
sqlCmd.CommandText = "update 库存表 set 数量 =数量-'" & NumericUpDown2.Text.Trim & "' where 名称='" & txtShoesID.Text & "' and 尺寸='" & CombNoID.SelectedItem & " and 颜色='" & combColorID.SelectedItem & "'"
sqlCmd.Connection = Module1.sqlconn
sqlCmd.CommandType = CommandType.Text
sqlDa.SelectCommand = sqlCmd
If sqlconn.State = ConnectionState.Open Then
Module1.sqlconn.Close()
End If
下面是把销售的情况打印出来
Dim printFrm As New Printfrmshoes
Dim printDoc As New CrystalReport2
printDoc.SetDataSource(ds.Tables("销售表"))
printFrm.CrystalReportViewershoes.ReportSource = printDoc
printFrm.Show()
End Sub
而下面这段代码是当我把鞋名和尺寸都输入后在输入颜色时会自动查询库存表里面的东西显示在
End Sub
下面的代码是确定按钮下的代码,通过点击可以把数据从在图片5上输入数据
点击确定显示在datagrid中的.
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
这段代码是我要运行这个界面时会自动把下面的字段显示在datagrid中的
其实我的毕业设计就差这一步了,做的不好,请不要见怪哦``
数据库