📄 frmtransinfo.vb
字号:
txtPrice.ReadOnly = True
strCommand = "add"
btnUpdate.Enabled = False
btnDel.Enabled = False
End Sub
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
Dim strOrderType As String
Select Case cboOrderType.SelectedIndex
Case 0 '交易ID
strOrderType = "WHERE t.TransactionID=" & Val(txtOrderValue.Text)
Case 1 '商品ID
strOrderType = "WHERE t.GoodsID = " & Val(txtOrderValue.Text)
Case 2 '客户ID
strOrderType = "WHERE t.CustomerID= " & Val(txtOrderValue.Text)
Case 3 '负责人
strOrderType = "WHERE t.UserID = '" & txtOrderValue.Text.Trim & "'"
End Select
strSQL = "SELECT t.TransactionID, t.TransactionType, t.GoodsID, g.GoodsName, t.GoodsPrice, t.GoodsNum, t.GoodsAmount, t.CustomerID, c.CustomerName, t.ModifyDate, t.UserID, t.Status " & _
"FROM TransInfo t " & _
"INNER JOIN Goods g ON t.GoodsID=g.GoodsID " & _
"INNER JOIN Customer c ON t.CustomerID=c.CustomerID " & strOrderType
freshData()
End Sub
Private Sub cboOrderByType_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboOrderByType.SelectedIndexChanged
Dim strType As String
Select Case cboOrderByType.SelectedIndex
Case 0
strType = ""
Case 1
strType = "WHERE t.TransactionType='采购'"
Case 2
strType = "WHERE t.TransactionType='采购退货'"
Case 3
strType = "WHERE t.TransactionType='销售'"
Case 4
strType = "WHERE t.TransactionType='销售退货'"
End Select
strSQL = "SELECT t.TransactionID, t.TransactionType, t.GoodsID, g.GoodsName, t.GoodsPrice, t.GoodsNum, t.GoodsAmount, t.CustomerID, c.CustomerName, t.ModifyDate, t.UserID, t.Status " & _
"FROM TransInfo t " & _
"INNER JOIN Goods g ON t.GoodsID=g.GoodsID " & _
"INNER JOIN Customer c ON t.CustomerID=c.CustomerID " & strType
freshData()
End Sub
Private Sub cboOrderByStatus_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboOrderByStatus.SelectedIndexChanged
Dim strStatus As String
Select Case cboOrderByStatus.SelectedIndex
Case 0
strStatus = ""
Case 1
strStatus = "WHERE t.Status='退单'"
Case 2
strStatus = "WHERE t.Status='已提交'"
Case 3
strStatus = "WHERE t.Status='仓库确认'"
End Select
strSQL = "SELECT t.TransactionID, t.TransactionType, t.GoodsID, g.GoodsName, t.GoodsPrice, t.GoodsNum, t.GoodsAmount, t.CustomerID, c.CustomerName, t.ModifyDate, t.UserID, t.Status " & _
"FROM TransInfo t " & _
"INNER JOIN Goods g ON t.GoodsID=g.GoodsID " & _
"INNER JOIN Customer c ON t.CustomerID=c.CustomerID " & strStatus
freshData()
End Sub
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
GroupBox2.Enabled = True
btnAdd.Enabled = False
btnDel.Enabled = False
strCommand = "update"
End Sub
Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
If strCommand = "add" Then
If cboGoodsID.Text = "" Or txtNum.Text.Trim = "" Or cboCustomerID.Text.Trim = "" Then
MsgBox("请填写完整的信息", MsgBoxStyle.Exclamation)
Exit Sub
End If
Dim Params() As SqlParameter = {New SqlParameter("@TransactionType", SqlDbType.VarChar), _
New SqlParameter("@GoodsID", SqlDbType.Int), _
New SqlParameter("@GoodsPrice", SqlDbType.Money), _
New SqlParameter("@GoodsNum", SqlDbType.Int), _
New SqlParameter("@CustomerID", SqlDbType.Int), _
New SqlParameter("@UserID", SqlDbType.VarChar)}
Params(0).Value = cboTransType.Text
Params(1).Value = Val(cboGoodsID.Text)
Params(2).Value = Val(txtPrice.Text)
Params(3).Value = Val(txtNum.Text)
Params(4).Value = Val(cboCustomerID.Text)
Params(5).Value = txtUserID.Text
myDataObj.ExecuteSP("sp_InsertTransInfo", Params)
MsgBox("添加完毕", MsgBoxStyle.Information)
ElseIf strCommand = "update" Then
If cboStatus.Text = "仓库确认" Then
MsgBox("此交易单已仓库确认过,不可修改!", MsgBoxStyle.Exclamation)
Exit Sub
End If
Dim Params() As SqlParameter = {New SqlParameter("@TransactionID", SqlDbType.Int), _
New SqlParameter("@TransactionType", SqlDbType.VarChar), _
New SqlParameter("@GoodsID", SqlDbType.Int), _
New SqlParameter("@GoodsPrice", SqlDbType.Money), _
New SqlParameter("@GoodsNum", SqlDbType.Int), _
New SqlParameter("@CustomerID", SqlDbType.Int), _
New SqlParameter("@UserID", SqlDbType.VarChar), _
New SqlParameter("@Status", SqlDbType.Char)}
params(0).Value = txtTransID.Text
Params(1).Value = cboTransType.Text
Params(2).Value = Val(cboGoodsID.Text)
Params(3).Value = Val(txtPrice.Text)
Params(4).Value = Val(txtNum.Text)
Params(5).Value = Val(cboCustomerID.Text)
Params(6).Value = txtUserID.Text
params(7).Value = cboStatus.Text
myDataObj.ExecuteSP("sp_UpdateTransInfo", Params)
MsgBox("修改完毕", MsgBoxStyle.Information)
Else
Me.Close()
End If
strSQL = "SELECT t.TransactionID, t.TransactionType, t.GoodsID, g.GoodsName, t.GoodsPrice, t.GoodsNum, t.GoodsAmount, t.CustomerID, c.CustomerName, t.ModifyDate, t.UserID, t.Status " & _
"FROM TransInfo t " & _
"INNER JOIN Goods g ON t.GoodsID=g.GoodsID " & _
"INNER JOIN Customer c ON t.CustomerID=c.CustomerID "
freshData()
strCommand = ""
GroupBox2.Enabled = False
btnAdd.Enabled = True
btnUpdate.Enabled = True
btnDel.Enabled = True
End Sub
Private Sub btnDel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDel.Click
If cboStatus.Text = "仓库确认" Then
MsgBox("此交易单已仓库确认过,不可删除!", MsgBoxStyle.Exclamation)
Exit Sub
End If
If MsgBox("确定要删除记录:" & txtTransID.Text & " ?", MsgBoxStyle.Exclamation + MsgBoxStyle.OKCancel) = MsgBoxResult.OK Then
Dim Params() As SqlParameter = {New SqlParameter("@TransactionID", SqlDbType.Int)}
Params(0).Value = txtTransID.Text
myDataObj.ExecuteSP("sp_DelTransInfo", Params)
MsgBox("删除完毕", MsgBoxStyle.Information)
strSQL = "SELECT t.TransactionID, t.TransactionType, t.GoodsID, g.GoodsName, t.GoodsPrice, t.GoodsNum, t.GoodsAmount, t.CustomerID, c.CustomerName, t.ModifyDate, t.UserID, t.Status " & _
"FROM TransInfo t " & _
"INNER JOIN Goods g ON t.GoodsID=g.GoodsID " & _
"INNER JOIN Customer c ON t.CustomerID=c.CustomerID "
freshData()
End If
End Sub
Private Sub dgTransInfo_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgTransInfo.Click
On Error Resume Next
showData()
End Sub
Private Sub cboCustomerID_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboCustomerID.SelectedIndexChanged
cboCustomerName.SelectedIndex = cboCustomerID.SelectedIndex
End Sub
Private Sub cboGoodsID_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboGoodsID.SelectedIndexChanged
'Dim ii As Int16
cboGoodsName.SelectedIndex = cboGoodsID.SelectedIndex
txtPrice.ReadOnly = False
'ii = CInt(cboGoodsID.Text)
strSQL = "select * from goods WHERE GOODSID='" & cboGoodsID.Text.Trim & "'"
myDataObj.ExecuteSQL(strSQL, drSqlServer)
' Do While drSqlServer.Read()
'If drSqlServer("goodsid").ToString() = cboGoodsID.Text.Trim Then
'MsgBox("dasfasfsa", MsgBoxStyle.Information)
drSqlServer.Read()
txtPrice.Text = drSqlServer("price").ToString()
' Exit Do
' End If
'Loop
'txtPrice.Text = Temporary
drSqlServer.Close()
'txtPrice.ReadOnly = True
End Sub
Private Sub cboOrder_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboOrder.SelectedIndexChanged
Dim strOrder As String
Select Case cboOrder.SelectedIndex
Case 0
strOrder = " ORDER BY t.TransactionID"
Case 1
strOrder = " ORDER BY t.TransactionType"
Case 2
strOrder = " ORDER BY t.GoodsID"
Case 3
strOrder = " ORDER BY t.GoodsPrice"
Case 4
strOrder = " ORDER BY t.GoodsNum"
Case 5
strOrder = " ORDER BY t.GoodsAmount"
Case 6
strOrder = " ORDER BY t.CustomerID"
Case 7
strOrder = " ORDER BY t.ModifyDate"
Case 8
strOrder = " ORDER BY t.UserID"
Case 9
strOrder = " ORDER BY t.Status"
End Select
strSQL = "SELECT t.TransactionID, t.TransactionType, t.GoodsID, g.GoodsName, t.GoodsPrice, t.GoodsNum, t.GoodsAmount, t.CustomerID, c.CustomerName, t.ModifyDate, t.UserID, t.Status " & _
"FROM TransInfo t " & _
"INNER JOIN Goods g ON t.GoodsID=g.GoodsID " & _
"INNER JOIN Customer c ON t.CustomerID=c.CustomerID "
strSQL = strSQL & strOrder
freshData()
End Sub
Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
If strCommand = "add" Then
txtTransID.Text = ""
cboTransType.Text = ""
cboGoodsID.Text = ""
txtPrice.Text = ""
txtNum.Text = ""
txtAmount.Text = ""
cboCustomerID.Text = ""
txtModifyDate.Text = ""
'txtUserID.Text = ""
cboStatus.Text = ""
GroupBox2.Enabled = False
btnAdd.Enabled = True
btnUpdate.Enabled = True
btnDel.Enabled = True
strCommand = ""
ElseIf strCommand = "update" Then
GroupBox2.Enabled = False
btnAdd.Enabled = True
btnUpdate.Enabled = True
btnDel.Enabled = True
strCommand = ""
Else
Me.Close()
End If
End Sub
Private Sub btnQueren_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnQueren.Click
Select Case strUserType
Case "2" '图书库存管理员
MDIGoodsTrans.btnAdd.PerformClick() '响应frmGoodsTrans窗体中"添加"按钮的click事件
MDIGoodsTrans.cboTransactionID.Text = txtTransID.Text
MDIGoodsTrans.cboGoodsTransType.SelectedIndex = cboTransType.SelectedIndex
strSQL = "select * from goods WHERE GOODSID='" & cboGoodsID.Text.Trim & "'"
myDataObj.ExecuteSQL(strSQL, drSqlServer)
drSqlServer.Read()
'If drSqlServer("goodsid").ToString() = cboGoodsID.Text.Trim Then
'MsgBox("dasfasfsa", MsgBoxStyle.Information)
MDIGoodsTrans.cboWarehouseID.Text = drSqlServer("warehouseid").ToString()
' Exit Do
'End If
'Loop
' strSQL = "select warehouseid from goods where goodsid=val(cboGoodsID.SelectedIndex)"
'myDataObj.ExecuteSQL(strSQL, drSqlServer)
' drSqlServer.Read()
' Temporary = drSqlServer("warehouseid").ToString()
drSqlServer.Close()
'MDIGoodsTrans.cboWarehouseID.Text = Temporary
MDIGoodsTrans.cboWarehouseName.SelectedIndex = MDIGoodsTrans.cboWarehouseID.SelectedIndex
' MDIGoodsTrans.cboWarehouseID.Enabled = False
'strCommand = "add"
'MDIGoodsTrans.cboGoodsTransType.Enabled = False
'MDIGoodsTrans.cboTransactionID.Enabled = False
'MDIGoodsTrans.btnUpdate.Enabled = False
' MDIGoodsTrans.btnDel.Enabled = False
'MDIGoodsTrans.btnAdd.Enabled = True
MDIGoodsTrans.Show()
End Select
Me.Close()
End Sub
Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox1.Enter
btnQueren.Enabled = False
End Sub
Private Sub txtPrice_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtPrice.TextChanged
End Sub
Private Sub txtNum_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtNum.TextChanged
End Sub
Private Sub txtNum_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtNum.LostFocus
Dim i As Integer
txtNum.Text = Trim(txtNum.Text)
If txtNum.Text = "" Then
Exit Sub
End If
Try
i = CInt(txtNum.Text)
Catch
MsgBox("只能是0-9之间的数字组成", MsgBoxStyle.Information)
txtNum.Text = ""
txtNum.Focus()
Exit Sub
End Try
If Val(txtNum.Text) <= 0 Or Val(txtNum.Text) <> i Then
MsgBox("输入错误,请输入大于0的整数", MsgBoxStyle.Information)
txtNum.Text = ""
txtNum.Focus()
End If
End Sub
Private Sub dgTransInfo_Navigate(ByVal sender As System.Object, ByVal ne As System.Windows.Forms.NavigateEventArgs) Handles dgTransInfo.Navigate
End Sub
Private Sub txtPrice_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtPrice.LostFocus
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -