📄 frmtransinfo.vb
字号:
Me.Label9.Text = "客户名称:*"
'
'Label8
'
Me.Label8.AutoSize = True
Me.Label8.Location = New System.Drawing.Point(64, 256)
Me.Label8.Name = "Label8"
Me.Label8.Size = New System.Drawing.Size(54, 17)
Me.Label8.TabIndex = 14
Me.Label8.Text = "客户ID:*"
'
'txtAmount
'
Me.txtAmount.Location = New System.Drawing.Point(128, 224)
Me.txtAmount.Name = "txtAmount"
Me.txtAmount.ReadOnly = True
Me.txtAmount.Size = New System.Drawing.Size(112, 21)
Me.txtAmount.TabIndex = 13
Me.txtAmount.Text = ""
'
'Label7
'
Me.Label7.AutoSize = True
Me.Label7.Location = New System.Drawing.Point(64, 224)
Me.Label7.Name = "Label7"
Me.Label7.Size = New System.Drawing.Size(48, 17)
Me.Label7.TabIndex = 12
Me.Label7.Text = "总金额:"
'
'txtNum
'
Me.txtNum.Location = New System.Drawing.Point(128, 192)
Me.txtNum.MaxLength = 9
Me.txtNum.Name = "txtNum"
Me.txtNum.Size = New System.Drawing.Size(112, 21)
Me.txtNum.TabIndex = 11
Me.txtNum.Text = ""
'
'Label6
'
Me.Label6.AutoSize = True
Me.Label6.Location = New System.Drawing.Point(64, 192)
Me.Label6.Name = "Label6"
Me.Label6.Size = New System.Drawing.Size(66, 17)
Me.Label6.TabIndex = 10
Me.Label6.Text = "交易数量:*"
'
'txtPrice
'
Me.txtPrice.Location = New System.Drawing.Point(128, 160)
Me.txtPrice.Name = "txtPrice"
Me.txtPrice.Size = New System.Drawing.Size(112, 21)
Me.txtPrice.TabIndex = 9
Me.txtPrice.Text = ""
'
'Label5
'
Me.Label5.AutoSize = True
Me.Label5.Location = New System.Drawing.Point(64, 160)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(42, 17)
Me.Label5.TabIndex = 8
Me.Label5.Text = "单价:*"
'
'Label4
'
Me.Label4.AutoSize = True
Me.Label4.Location = New System.Drawing.Point(64, 96)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(54, 17)
Me.Label4.TabIndex = 6
Me.Label4.Text = "图书ID:*"
'
'Label3
'
Me.Label3.AutoSize = True
Me.Label3.Location = New System.Drawing.Point(64, 128)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(66, 17)
Me.Label3.TabIndex = 4
Me.Label3.Text = "图书名称:*"
'
'Label2
'
Me.Label2.AutoSize = True
Me.Label2.Location = New System.Drawing.Point(64, 64)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(66, 17)
Me.Label2.TabIndex = 2
Me.Label2.Text = "交易类型:*"
'
'txtTransID
'
Me.txtTransID.Location = New System.Drawing.Point(128, 32)
Me.txtTransID.Name = "txtTransID"
Me.txtTransID.ReadOnly = True
Me.txtTransID.Size = New System.Drawing.Size(112, 21)
Me.txtTransID.TabIndex = 1
Me.txtTransID.Text = ""
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Location = New System.Drawing.Point(64, 32)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(54, 17)
Me.Label1.TabIndex = 0
Me.Label1.Text = "交易ID:*"
'
'btnCancel
'
Me.btnCancel.Location = New System.Drawing.Point(848, 520)
Me.btnCancel.Name = "btnCancel"
Me.btnCancel.Size = New System.Drawing.Size(64, 24)
Me.btnCancel.TabIndex = 11
Me.btnCancel.Text = "取消"
'
'btnOK
'
Me.btnOK.Location = New System.Drawing.Point(768, 520)
Me.btnOK.Name = "btnOK"
Me.btnOK.Size = New System.Drawing.Size(64, 24)
Me.btnOK.TabIndex = 10
Me.btnOK.Text = "确定"
'
'btnDel
'
Me.btnDel.Location = New System.Drawing.Point(688, 520)
Me.btnDel.Name = "btnDel"
Me.btnDel.Size = New System.Drawing.Size(64, 24)
Me.btnDel.TabIndex = 9
Me.btnDel.Text = "删除"
'
'btnUpdate
'
Me.btnUpdate.Location = New System.Drawing.Point(608, 520)
Me.btnUpdate.Name = "btnUpdate"
Me.btnUpdate.Size = New System.Drawing.Size(64, 24)
Me.btnUpdate.TabIndex = 8
Me.btnUpdate.Text = "更新"
'
'btnAdd
'
Me.btnAdd.Location = New System.Drawing.Point(528, 520)
Me.btnAdd.Name = "btnAdd"
Me.btnAdd.Size = New System.Drawing.Size(64, 24)
Me.btnAdd.TabIndex = 7
Me.btnAdd.Text = "添加"
'
'btnQueren
'
Me.btnQueren.Enabled = False
Me.btnQueren.Location = New System.Drawing.Point(448, 520)
Me.btnQueren.Name = "btnQueren"
Me.btnQueren.Size = New System.Drawing.Size(64, 24)
Me.btnQueren.TabIndex = 30
Me.btnQueren.Text = "确认"
'
'cboTransType
'
Me.cboTransType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
Me.cboTransType.Items.AddRange(New Object() {"采购", "采购退货", "销售", "销售退货"})
Me.cboTransType.Location = New System.Drawing.Point(128, 64)
Me.cboTransType.Name = "cboTransType"
Me.cboTransType.Size = New System.Drawing.Size(112, 20)
Me.cboTransType.TabIndex = 28
'
'frmTransInfo
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(928, 557)
Me.Controls.Add(Me.btnQueren)
Me.Controls.Add(Me.btnCancel)
Me.Controls.Add(Me.btnOK)
Me.Controls.Add(Me.btnDel)
Me.Controls.Add(Me.btnUpdate)
Me.Controls.Add(Me.btnAdd)
Me.Controls.Add(Me.GroupBox2)
Me.Controls.Add(Me.GroupBox1)
Me.Name = "frmTransInfo"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "图书交易信息管理"
Me.WindowState = System.Windows.Forms.FormWindowState.Maximized
Me.GroupBox1.ResumeLayout(False)
CType(Me.dgTransInfo, System.ComponentModel.ISupportInitialize).EndInit()
Me.GroupBox2.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub frmTransInfo_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
With cboOrderByType.Items
.Add("所有")
.Add("采购")
.Add("采购退货")
.Add("销售")
.Add("销售退货")
End With
With cboOrderByStatus.Items
.Add("所有")
.Add("退单")
.Add("已提交")
.Add("仓库确认")
End With
With cboOrderType.Items
.Add("交易ID")
.Add("图书ID")
.Add("客户ID")
.Add("负责人")
End With
strSQL = "SELECT GoodsID, GoodsName FROM Goods"
myDataObj.ExecuteSQL(strSQL, drSqlServer)
While drSqlServer.Read()
cboGoodsID.Items.Add(drSqlServer("GoodsID"))
cboGoodsName.Items.Add(drSqlServer("GoodsName"))
End While
drSqlServer.Close()
strSQL = "SELECT CustomerID, CustomerName FROM Customer"
myDataObj.ExecuteSQL(strSQL, drSqlServer)
While drSqlServer.Read()
cboCustomerID.Items.Add(drSqlServer("CustomerID"))
cboCustomerName.Items.Add(drSqlServer("CustomerName"))
End While
drSqlServer.Close()
'交易管理员
If strUserType = "3" Then
btnQueren.Visible = False
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 "
'图书库存管理员
ElseIf strUserType = "2" Then
btnAdd.Visible = False
btnUpdate.Visible = False
btnDel.Visible = False
btnQueren.Visible = True
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 " & _
"WHERE Status='已提交'"
End If
freshData()
End Sub
Private Sub freshData()
Dim dsTransInfo As New DataSet()
Dim myDataAdapter As New SqlDataAdapter()
dsTransInfo.Clear()
myDataAdapter = New SqlDataAdapter(strSQL, cnSqlServer)
myDataAdapter.Fill(dsTransInfo)
With dgTransInfo
.TableStyles.Clear()
.DataSource = dsTransInfo
.DataMember = "table"
End With
Dim ts As New DataGridTableStyle()
Dim ac As New DataGridTextBoxColumn()
Dim HeaderValues(12) As String
Dim WidthValues(12) As Integer
Dim i As Integer
HeaderValues(0) = "交易ID"
HeaderValues(1) = "交易类型"
HeaderValues(2) = "商品ID"
HeaderValues(3) = "商品名称"
HeaderValues(4) = "单价"
HeaderValues(5) = "交易数量"
HeaderValues(6) = "总金额"
HeaderValues(7) = "客户ID"
HeaderValues(8) = "客户名称"
HeaderValues(9) = "更新时间"
HeaderValues(10) = "负责人"
HeaderValues(11) = "交易状态"
WidthValues(0) = 50
WidthValues(1) = 70
WidthValues(2) = 70
WidthValues(3) = 100
WidthValues(4) = 70
WidthValues(5) = 70
WidthValues(6) = 70
WidthValues(7) = 70
WidthValues(8) = 100
WidthValues(9) = 70
WidthValues(10) = 70
WidthValues(11) = 70
ts.MappingName = dsTransInfo.Tables(0).TableName
For i = 0 To 11
ac = New DataGridTextBoxColumn()
ac.HeaderText = HeaderValues(i) '列名
ac.MappingName = dsTransInfo.Tables("table").Columns(i).ColumnName
ac.TextBox.AutoSize = True 'datagrid内的文本框宽度自适应调整
ac.NullText = String.Empty
ts.AlternatingBackColor = Color.LightGray '设定交替行的背景色
ts.PreferredColumnWidth = WidthValues(i) '列宽
ts.GridColumnStyles.Add(ac)
Next i
dgTransInfo.TableStyles.Add(ts)
'showData()
btnQueren.Enabled = False
End Sub
Private Sub showData()
With dgTransInfo
txtTransID.Text = .Item(.CurrentRowIndex, 0)
cboTransType.Text = .Item(.CurrentRowIndex, 1)
cboGoodsID.Text = .Item(.CurrentRowIndex, 2)
cboGoodsName.Text = .Item(.CurrentRowIndex, 3)
txtPrice.Text = .Item(.CurrentRowIndex, 4)
txtNum.Text = .Item(.CurrentRowIndex, 5)
txtAmount.Text = .Item(.CurrentRowIndex, 6)
cboCustomerID.Text = .Item(.CurrentRowIndex, 7)
cboCustomerName.Text = .Item(.CurrentRowIndex, 8)
txtModifyDate.Text = .Item(.CurrentRowIndex, 9)
txtUserID.Text = .Item(.CurrentRowIndex, 10)
cboStatus.Text = .Item(.CurrentRowIndex, 11)
If strUserType = "2" Then
If cboStatus.Text = "已提交" Then
btnQueren.Enabled = True
Else
btnQueren.Enabled = False
End If
'ElseIf strUserType = "4" Then
' If cboStatus.Text = "已提交" Or cboStatus.Text = "仓库确认" Then
'btnQueren.Enabled = True
' Else
'btnQueren.Enabled = False
' End If
End If
End With
End Sub
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
GroupBox2.Enabled = True
txtTransID.Text = ""
cboTransType.Text = ""
cboGoodsID.Text = ""
txtPrice.Text = ""
txtNum.Text = ""
txtAmount.Text = ""
cboCustomerID.Text = ""
txtModifyDate.Text = ""
'txtUserID.Text = ""
cboStatus.SelectedIndex = 1
txtUserID.ReadOnly = False
txtUserID.Text = STRUSERID
txtUserID.ReadOnly = True
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -