主题:[讨论]路过的兄弟姐妹帮我看看这个代码有什么问题(vb.net方面知识)
我用VB.NET编写一个进销存管理系统,有一个小问题一直没有办法解决。想请大家帮我看看,欢迎讨论。
怎么不能上传图片了????那我把问题复述出来吧。
当我只启动frmSellList.vb窗体时,我在窗体上面的mainmenu1上面的三个菜单可以正常显示。但是当我运行整个程序后,frmSellList上面添加的三个菜单选项会移到最顶上与其他五个窗体在同一栏上面,
我的五个窗体是资料管理,进货管理,销售管理,库存管理,系统管理。当我点击销售管理后,我添加的mainmenu1上面的三个菜单选项会跑到五个窗体上面变成了
资料管理,进货管理,销售管理,库存管理,系统管理 添加 修改 删除。
但是单独运行销售管理,正常显示 添加 修改 删除,但是运行整个程序就会变成和上面一讲的。资料管理,进货管理,销售管理,库存管理,系统管理 添加 修改 删除。
大家帮我想想是什么原因吗?我附代码如下:
Private Sub ToolBar1_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar1.ButtonClick
If e.Button Is Me.tbbSave Then
If Me.dtSellList.Rows.Count = 0 Then
Exit Sub
End If
Dim db As DataBase = New DataBase
' 获取单据ID
Dim dvTemp As DataView = db.RunSelectSQL("select max(编号) as 编号 from 销售单历史")
Dim sId As String = "0000000001"
If dvTemp.Table.Rows(0).IsNull(0) = False Then
sId = (CType(dvTemp.Table.Rows(0)("编号"), Integer) + 1).ToString
End If
Dim count As Integer
For count = sId.Trim.Length To 9
sId = "0" + sId
Next
' 删除已有数据
db.RunDelOrInsSQL("delete from 销售单明细 where 销售单号='" + sId + "'")
db.RunDelOrInsSQL("delete from 销售单 where 编号='" + sId + "'")
' 写入销售单
Dim strSQL As String = "insert into 销售单(编号,客户编号,销售日期, 制单人,业务员,"
strSQL += "税价合计,不含税价,税额,保管员) values('" + sId + "','"
strSQL += Me.txbClientId.Text.Trim + "','" + Me.txbOrderDate.Text + "','" + Me.txtListMaker.Text.Trim + "','"
strSQL += CType(Me.cbbWorker.SelectedItem("姓名"), String).Trim() + "'," + Me.txbTotal.Text.Trim() + "," + Me.txbWithoutTax.Text.Trim
strSQL += "," + Me.txbTax.Text + ",'sys')"
db.RunDelOrInsSQL(strSQL)
' 写入明细
Dim sId1 As String = "0000000000"
dvTemp = db.RunSelectSQL("select max(编号) as 编号 from 销售单明细历史")
If dvTemp.Table.Rows(0).IsNull(0) <> True Then
sId1 = dvTemp.Table.Rows(0)(0)
End If
Dim i As Integer
For i = 0 To dtSellList.Rows.Count - 1
sId1 = (CInt(sId1) + 1).ToString
For count = sId1.Trim.Length To 9
sId1 = "0" + sId1
Next
strSQL = "insert into 销售单明细(编号,销售单号,货号,销售数量,销售价,仓库,"
strSQL += "税价合计,税率,不含税价,税额) values('" + sId1 + "','"
strSQL += sId + "','" + dtSellList.Rows(i)("货号") + "','"
strSQL += dtSellList.Rows(i)("数量") + "','" + dtSellList.Rows(i)("单价") + "','"
strSQL += dtSellList.Rows(i)("仓库") + "','" + dtSellList.Rows(i)("税额") + "','"
strSQL += dtSellList.Rows(i)("税率") + "','" + dtSellList.Rows(i)("不含税价") + "','"
strSQL += dtSellList.Rows(i)("税额") + "')"
db.RunDelOrInsSQL(strSQL)
Next
db.Dispose()
End If
If e.Button Is Me.tbbConfirm Then
If MessageBox.Show("是否记帐确认销售单", "提示", MessageBoxButtons.YesNo) = DialogResult.Yes Then
Dim db As DataBase = New DataBase
Try
db.RunDelOrInsSQL("exec sf_销售单")
db.Dispose()
Me.txbClientId.Text = ""
Me.txbClientName.Text = ""
Me.txbGoodsCount.Text = ""
Me.txbGoodsName.Text = ""
Me.txbGoodsId.Text = ""
Me.txbGoodsUnit.Text = ""
Me.txbPrice.Text = ""
Me.txbTax.Text = "0"
Me.txbTotal.Text = "0"
Me.txbWithoutTax.Text = "0"
Me.dtSellList.Clear()
Catch ex As Exception
MessageBox.Show(ex.ToString()) '("提交销售单出错")
End Try
End If
End If
End Sub
Private Sub SetTaxForAdd(ByVal total As Integer)
Try
Dim iAll As Integer = total + CInt(Me.txbTotal.Text.Trim())
Me.txbTotal.Text = iAll.ToString
Me.txbTax.Text = (iAll - iAll / (1 + CInt(Me.lblRateValue.Text.Trim()) / 100)).ToString("f")
Me.txbWithoutTax.Text = (iAll / (1 + CInt(Me.lblRateValue.Text.Trim()) / 100)).ToString("f")
Catch ex As Exception
MessageBox.Show("数据格式不正确")
End Try
End Sub
Private Sub Clear()
'Me.txbGoodsName.Text = ""
'Me.txbGoodsUnit.Text = ""
'Me.txbGoodsId.Text = ""
Me.txbPrice.Text = ""
Me.txbGoodsCount.Text = ""
Me.txbDepot.Text = ""
End Sub
怎么不能上传图片了????那我把问题复述出来吧。
当我只启动frmSellList.vb窗体时,我在窗体上面的mainmenu1上面的三个菜单可以正常显示。但是当我运行整个程序后,frmSellList上面添加的三个菜单选项会移到最顶上与其他五个窗体在同一栏上面,
我的五个窗体是资料管理,进货管理,销售管理,库存管理,系统管理。当我点击销售管理后,我添加的mainmenu1上面的三个菜单选项会跑到五个窗体上面变成了
资料管理,进货管理,销售管理,库存管理,系统管理 添加 修改 删除。
但是单独运行销售管理,正常显示 添加 修改 删除,但是运行整个程序就会变成和上面一讲的。资料管理,进货管理,销售管理,库存管理,系统管理 添加 修改 删除。
大家帮我想想是什么原因吗?我附代码如下:
Private Sub ToolBar1_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar1.ButtonClick
If e.Button Is Me.tbbSave Then
If Me.dtSellList.Rows.Count = 0 Then
Exit Sub
End If
Dim db As DataBase = New DataBase
' 获取单据ID
Dim dvTemp As DataView = db.RunSelectSQL("select max(编号) as 编号 from 销售单历史")
Dim sId As String = "0000000001"
If dvTemp.Table.Rows(0).IsNull(0) = False Then
sId = (CType(dvTemp.Table.Rows(0)("编号"), Integer) + 1).ToString
End If
Dim count As Integer
For count = sId.Trim.Length To 9
sId = "0" + sId
Next
' 删除已有数据
db.RunDelOrInsSQL("delete from 销售单明细 where 销售单号='" + sId + "'")
db.RunDelOrInsSQL("delete from 销售单 where 编号='" + sId + "'")
' 写入销售单
Dim strSQL As String = "insert into 销售单(编号,客户编号,销售日期, 制单人,业务员,"
strSQL += "税价合计,不含税价,税额,保管员) values('" + sId + "','"
strSQL += Me.txbClientId.Text.Trim + "','" + Me.txbOrderDate.Text + "','" + Me.txtListMaker.Text.Trim + "','"
strSQL += CType(Me.cbbWorker.SelectedItem("姓名"), String).Trim() + "'," + Me.txbTotal.Text.Trim() + "," + Me.txbWithoutTax.Text.Trim
strSQL += "," + Me.txbTax.Text + ",'sys')"
db.RunDelOrInsSQL(strSQL)
' 写入明细
Dim sId1 As String = "0000000000"
dvTemp = db.RunSelectSQL("select max(编号) as 编号 from 销售单明细历史")
If dvTemp.Table.Rows(0).IsNull(0) <> True Then
sId1 = dvTemp.Table.Rows(0)(0)
End If
Dim i As Integer
For i = 0 To dtSellList.Rows.Count - 1
sId1 = (CInt(sId1) + 1).ToString
For count = sId1.Trim.Length To 9
sId1 = "0" + sId1
Next
strSQL = "insert into 销售单明细(编号,销售单号,货号,销售数量,销售价,仓库,"
strSQL += "税价合计,税率,不含税价,税额) values('" + sId1 + "','"
strSQL += sId + "','" + dtSellList.Rows(i)("货号") + "','"
strSQL += dtSellList.Rows(i)("数量") + "','" + dtSellList.Rows(i)("单价") + "','"
strSQL += dtSellList.Rows(i)("仓库") + "','" + dtSellList.Rows(i)("税额") + "','"
strSQL += dtSellList.Rows(i)("税率") + "','" + dtSellList.Rows(i)("不含税价") + "','"
strSQL += dtSellList.Rows(i)("税额") + "')"
db.RunDelOrInsSQL(strSQL)
Next
db.Dispose()
End If
If e.Button Is Me.tbbConfirm Then
If MessageBox.Show("是否记帐确认销售单", "提示", MessageBoxButtons.YesNo) = DialogResult.Yes Then
Dim db As DataBase = New DataBase
Try
db.RunDelOrInsSQL("exec sf_销售单")
db.Dispose()
Me.txbClientId.Text = ""
Me.txbClientName.Text = ""
Me.txbGoodsCount.Text = ""
Me.txbGoodsName.Text = ""
Me.txbGoodsId.Text = ""
Me.txbGoodsUnit.Text = ""
Me.txbPrice.Text = ""
Me.txbTax.Text = "0"
Me.txbTotal.Text = "0"
Me.txbWithoutTax.Text = "0"
Me.dtSellList.Clear()
Catch ex As Exception
MessageBox.Show(ex.ToString()) '("提交销售单出错")
End Try
End If
End If
End Sub
Private Sub SetTaxForAdd(ByVal total As Integer)
Try
Dim iAll As Integer = total + CInt(Me.txbTotal.Text.Trim())
Me.txbTotal.Text = iAll.ToString
Me.txbTax.Text = (iAll - iAll / (1 + CInt(Me.lblRateValue.Text.Trim()) / 100)).ToString("f")
Me.txbWithoutTax.Text = (iAll / (1 + CInt(Me.lblRateValue.Text.Trim()) / 100)).ToString("f")
Catch ex As Exception
MessageBox.Show("数据格式不正确")
End Try
End Sub
Private Sub Clear()
'Me.txbGoodsName.Text = ""
'Me.txbGoodsUnit.Text = ""
'Me.txbGoodsId.Text = ""
Me.txbPrice.Text = ""
Me.txbGoodsCount.Text = ""
Me.txbDepot.Text = ""
End Sub