📄 form1.vb
字号:
Me.dsTest.DataSetName = "DataSet1"
Me.dsTest.Locale = New System.Globalization.CultureInfo("zh-TW")
Me.dsTest.Namespace = "http://www.tempuri.org/DataSet1.xsd"
'
'TextBox1
'
Me.TextBox1.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.dsTest, "Orders.OrderID"))
Me.TextBox1.Location = New System.Drawing.Point(389, 40)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(113, 21)
Me.TextBox1.TabIndex = 5
Me.TextBox1.Text = ""
'
'bnFirst
'
Me.bnFirst.Location = New System.Drawing.Point(26, 4)
Me.bnFirst.Name = "bnFirst"
Me.bnFirst.Size = New System.Drawing.Size(56, 24)
Me.bnFirst.TabIndex = 7
Me.bnFirst.Text = "首笔"
'
'bnPrior
'
Me.bnPrior.Location = New System.Drawing.Point(92, 4)
Me.bnPrior.Name = "bnPrior"
Me.bnPrior.Size = New System.Drawing.Size(56, 24)
Me.bnPrior.TabIndex = 8
Me.bnPrior.Text = "前笔"
'
'bnNext
'
Me.bnNext.Location = New System.Drawing.Point(159, 4)
Me.bnNext.Name = "bnNext"
Me.bnNext.Size = New System.Drawing.Size(56, 24)
Me.bnNext.TabIndex = 9
Me.bnNext.Text = "次笔"
'
'bnLast
'
Me.bnLast.Location = New System.Drawing.Point(225, 4)
Me.bnLast.Name = "bnLast"
Me.bnLast.Size = New System.Drawing.Size(57, 24)
Me.bnLast.TabIndex = 10
Me.bnLast.Text = "末笔"
'
'bnAdd
'
Me.bnAdd.Location = New System.Drawing.Point(292, 4)
Me.bnAdd.Name = "bnAdd"
Me.bnAdd.Size = New System.Drawing.Size(56, 24)
Me.bnAdd.TabIndex = 11
Me.bnAdd.Text = "新增"
'
'bnCancel
'
Me.bnCancel.Location = New System.Drawing.Point(425, 4)
Me.bnCancel.Name = "bnCancel"
Me.bnCancel.Size = New System.Drawing.Size(56, 24)
Me.bnCancel.TabIndex = 12
Me.bnCancel.Text = "取消"
'
'bnDelete
'
Me.bnDelete.Location = New System.Drawing.Point(358, 4)
Me.bnDelete.Name = "bnDelete"
Me.bnDelete.Size = New System.Drawing.Size(57, 24)
Me.bnDelete.TabIndex = 13
Me.bnDelete.Text = "删除"
'
'bnUpdate
'
Me.bnUpdate.Location = New System.Drawing.Point(558, 4)
Me.bnUpdate.Name = "bnUpdate"
Me.bnUpdate.Size = New System.Drawing.Size(56, 24)
Me.bnUpdate.TabIndex = 14
Me.bnUpdate.Text = "更新"
'
'bnLoad
'
Me.bnLoad.Location = New System.Drawing.Point(492, 4)
Me.bnLoad.Name = "bnLoad"
Me.bnLoad.Size = New System.Drawing.Size(56, 24)
Me.bnLoad.TabIndex = 15
Me.bnLoad.Text = "载入"
'
'daOrderDetails
'
Me.daOrderDetails.DeleteCommand = Me.SqlDeleteCommand2
Me.daOrderDetails.InsertCommand = Me.SqlInsertCommand2
Me.daOrderDetails.SelectCommand = Me.SqlSelectCommand2
Me.daOrderDetails.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "OrderDetails", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("OrderID", "OrderID"), New System.Data.Common.DataColumnMapping("ProductID", "ProductID"), New System.Data.Common.DataColumnMapping("Quantity", "Quantity"), New System.Data.Common.DataColumnMapping("UnitPrice", "UnitPrice"), New System.Data.Common.DataColumnMapping("DetailAmount", "DetailAmount")})})
Me.daOrderDetails.UpdateCommand = Me.SqlUpdateCommand2
'
'SqlDeleteCommand2
'
Me.SqlDeleteCommand2.CommandText = "DELETE FROM OrderDetails WHERE (OrderID = @Original_OrderID) AND (ProductID = @Or" & _
"iginal_ProductID) AND (DetailAmount = @Original_DetailAmount OR @Original_Detail" & _
"Amount IS NULL AND DetailAmount IS NULL) AND (Quantity = @Original_Quantity) AND" & _
" (UnitPrice = @Original_UnitPrice)"
Me.SqlDeleteCommand2.Connection = Me.cnTest
Me.SqlDeleteCommand2.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_OrderID", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "OrderID", System.Data.DataRowVersion.Original, Nothing))
Me.SqlDeleteCommand2.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_ProductID", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "ProductID", System.Data.DataRowVersion.Original, Nothing))
Me.SqlDeleteCommand2.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_DetailAmount", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "DetailAmount", System.Data.DataRowVersion.Original, Nothing))
Me.SqlDeleteCommand2.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_Quantity", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "Quantity", System.Data.DataRowVersion.Original, Nothing))
Me.SqlDeleteCommand2.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_UnitPrice", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "UnitPrice", System.Data.DataRowVersion.Original, Nothing))
'
'SqlInsertCommand2
'
Me.SqlInsertCommand2.CommandText = "INSERT INTO OrderDetails(OrderID, ProductID, Quantity, UnitPrice, DetailAmount) V" & _
"ALUES (@OrderID, @ProductID, @Quantity, @UnitPrice, @DetailAmount); SELECT Order" & _
"ID, ProductID, Quantity, UnitPrice, DetailAmount FROM OrderDetails WHERE (OrderI" & _
"D = @OrderID) AND (ProductID = @ProductID)"
Me.SqlInsertCommand2.Connection = Me.cnTest
Me.SqlInsertCommand2.Parameters.Add(New System.Data.SqlClient.SqlParameter("@OrderID", System.Data.SqlDbType.VarChar, 10, "OrderID"))
Me.SqlInsertCommand2.Parameters.Add(New System.Data.SqlClient.SqlParameter("@ProductID", System.Data.SqlDbType.VarChar, 10, "ProductID"))
Me.SqlInsertCommand2.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Quantity", System.Data.SqlDbType.Int, 4, "Quantity"))
Me.SqlInsertCommand2.Parameters.Add(New System.Data.SqlClient.SqlParameter("@UnitPrice", System.Data.SqlDbType.Int, 4, "UnitPrice"))
Me.SqlInsertCommand2.Parameters.Add(New System.Data.SqlClient.SqlParameter("@DetailAmount", System.Data.SqlDbType.Int, 4, "DetailAmount"))
'
'SqlSelectCommand2
'
Me.SqlSelectCommand2.CommandText = "SELECT OrderID, ProductID, Quantity, UnitPrice, DetailAmount FROM OrderDetails"
Me.SqlSelectCommand2.Connection = Me.cnTest
'
'SqlUpdateCommand2
'
Me.SqlUpdateCommand2.CommandText = "UPDATE OrderDetails SET OrderID = @OrderID, ProductID = @ProductID, Quantity = @Q" & _
"uantity, UnitPrice = @UnitPrice, DetailAmount = @DetailAmount WHERE (OrderID = @" & _
"Original_OrderID) AND (ProductID = @Original_ProductID) AND (DetailAmount = @Ori" & _
"ginal_DetailAmount OR @Original_DetailAmount IS NULL AND DetailAmount IS NULL) A" & _
"ND (Quantity = @Original_Quantity) AND (UnitPrice = @Original_UnitPrice); SELECT" & _
" OrderID, ProductID, Quantity, UnitPrice, DetailAmount FROM OrderDetails WHERE (" & _
"OrderID = @OrderID) AND (ProductID = @ProductID)"
Me.SqlUpdateCommand2.Connection = Me.cnTest
Me.SqlUpdateCommand2.Parameters.Add(New System.Data.SqlClient.SqlParameter("@OrderID", System.Data.SqlDbType.VarChar, 10, "OrderID"))
Me.SqlUpdateCommand2.Parameters.Add(New System.Data.SqlClient.SqlParameter("@ProductID", System.Data.SqlDbType.VarChar, 10, "ProductID"))
Me.SqlUpdateCommand2.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Quantity", System.Data.SqlDbType.Int, 4, "Quantity"))
Me.SqlUpdateCommand2.Parameters.Add(New System.Data.SqlClient.SqlParameter("@UnitPrice", System.Data.SqlDbType.Int, 4, "UnitPrice"))
Me.SqlUpdateCommand2.Parameters.Add(New System.Data.SqlClient.SqlParameter("@DetailAmount", System.Data.SqlDbType.Int, 4, "DetailAmount"))
Me.SqlUpdateCommand2.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_OrderID", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "OrderID", System.Data.DataRowVersion.Original, Nothing))
Me.SqlUpdateCommand2.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_ProductID", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "ProductID", System.Data.DataRowVersion.Original, Nothing))
Me.SqlUpdateCommand2.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_DetailAmount", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "DetailAmount", System.Data.DataRowVersion.Original, Nothing))
Me.SqlUpdateCommand2.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_Quantity", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "Quantity", System.Data.DataRowVersion.Original, Nothing))
Me.SqlUpdateCommand2.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_UnitPrice", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "UnitPrice", System.Data.DataRowVersion.Original, Nothing))
'
'OleDbConnection1
'
Me.OleDbConnection1.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=test;D" & _
"ata Source=BENNY_NB;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=" & _
"4096;Workstation ID=BENNY_NB"
'
'daCustomer
'
Me.daCustomer.SelectCommand = Me.SqlSelectCommand3
Me.daCustomer.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "Customer", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("CustomerID", "CustomerID"), New System.Data.Common.DataColumnMapping("AttribName", "AttribName")})})
'
'SqlSelectCommand3
'
Me.SqlSelectCommand3.CommandText = "SELECT CustomerID, AttribName FROM Customer"
Me.SqlSelectCommand3.Connection = Me.cnTest
'
'cbCustomerID
'
Me.cbCustomerID.DataBindings.Add(New System.Windows.Forms.Binding("SelectedValue", Me.dsTest, "Orders.CustomerID"))
Me.cbCustomerID.DataSource = Me.dsTest
Me.cbCustomerID.DisplayMember = "Customer.AttribName"
Me.cbCustomerID.Location = New System.Drawing.Point(113, 68)
Me.cbCustomerID.Name = "cbCustomerID"
Me.cbCustomerID.Size = New System.Drawing.Size(163, 20)
Me.cbCustomerID.TabIndex = 21
Me.cbCustomerID.Text = "System.Data.DataViewManagerListItemTypeDescriptor"
Me.cbCustomerID.ValueMember = "Customer.CustomerID"
'
'dtpOrderData
'
Me.dtpOrderData.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.dsTest, "Orders.OrderDate"))
Me.dtpOrderData.Location = New System.Drawing.Point(113, 40)
Me.dtpOrderData.Name = "dtpOrderData"
Me.dtpOrderData.Size = New System.Drawing.Size(163, 21)
Me.dtpOrderData.TabIndex = 22
'
'gdOrderDetails
'
Me.gdOrderDetails.DataMember = "Orders.OrdersOrderDetails"
Me.gdOrderDetails.DataSource = Me.dsTest
Me.gdOrderDetails.HeaderForeColor = System.Drawing.SystemColors.ControlText
Me.gdOrderDetails.Location = New System.Drawing.Point(20, 96)
Me.gdOrderDetails.Name = "gdOrderDetails"
Me.gdOrderDetails.Size = New System.Drawing.Size(600, 164)
Me.gdOrderDetails.TabIndex = 23
Me.gdOrderDetails.TableStyles.AddRange(New System.Windows.Forms.DataGridTableStyle() {Me.OrderDetails})
'
'OrderDetails
'
Me.OrderDetails.DataGrid = Me.gdOrderDetails
Me.OrderDetails.GridColumnStyles.AddRange(New System.Windows.Forms.DataGridColumnStyle() {Me.txProductID, Me.txQuantity, Me.txUnitPrice, Me.txDetailAmount})
Me.OrderDetails.HeaderForeColor = System.Drawing.SystemColors.ControlText
Me.OrderDetails.MappingName = "OrderDetails"
'
'txProductID
'
Me.txProductID.Format = ""
Me.txProductID.FormatInfo = Nothing
Me.txProductID.HeaderText = "产品编号"
Me.txProductID.MappingName = "ProductID"
Me.txProductID.Width = 75
'
'txQuantity
'
Me.txQuantity.Alignment = System.Windows.Forms.HorizontalAlignment.Right
Me.txQuantity.Format = ""
Me.txQuantity.FormatInfo = Nothing
Me.txQuantity.HeaderText = "数量"
Me.txQuantity.MappingName = "Quantity"
Me.txQuantity.Width = 75
'
'txUnitPrice
'
Me.txUnitPrice.Alignment = System.Windows.Forms.HorizontalAlignment.Right
Me.txUnitPrice.Format = ""
Me.txUnitPrice.FormatInfo = Nothing
Me.txUnitPrice.HeaderText = "单价"
Me.txUnitPrice.MappingName = "UnitPrice"
Me.txUnitPrice.Width = 75
'
'txDetailAmount
'
Me.txDetailAmount.Alignment = System.Windows.Forms.HorizontalAlignment.Right
Me.txDetailAmount.Format = ""
Me.txDetailAmount.FormatInfo = Nothing
Me.txDetailAmount.HeaderText = "金额"
Me.txDetailAmount.MappingName = "DetailAmount"
Me.txDetailAmount.ReadOnly = True
Me.txDetailAmount.Width = 75
'
'Label4
'
Me.Label4.Location = New System.Drawing.Point(425, 268)
Me.Label4.Name = "Label4"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -