⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.vb

📁 用vb.net写的基于c/s结构的进销存程序设计源代码
💻 VB
📖 第 1 页 / 共 3 页
字号:
Public Class fmOrders
    Inherits System.Windows.Forms.Form
    '建立dtOrderDetails对象, 我们要利用它的ColumnChanged事件
    '来计算金额
    Dim WithEvents dtOrderDetails As New DataTable()
    '管理Orders的记录
    Dim BmOrders As BindingManagerBase
    '管理OrderDetails的记录
    Dim BmOrderDetails As BindingManagerBase
    '是否要计算金额的旗标
    Dim OrderDetailsHasChange As Boolean
    '建立字段对象-小计, 用来指定新建时的默认值
    Dim SubTotal As DataColumn
    '建立字段对象-税额, 用来指定新建时的默认值
    Dim Tax As DataColumn
    '建立字段对象-总计, 用来指定新建时的默认值
    Dim Amount As DataColumn
    '建立字段对象-数量, 用来指定新建时的默认值
    Dim Quantity As DataColumn
    '建立字段对象-单价, 用来指定新建时的默认值
    Dim UnitPrice As DataColumn


#Region " Windows 窗体设计器生成的代码 "

    Public Sub New()
        MyBase.New()

        '该调用是 Windows 窗体设计器所必需的。
        InitializeComponent()

        '在 InitializeComponent() 调用之后添加任何初始化

    End Sub

    '窗体重写处置以清理组件列表。
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Windows 窗体设计器所必需的
    Private components As System.ComponentModel.IContainer

    '注意:以下过程是 Windows 窗体设计器所必需的
    '可以使用 Windows 窗体设计器修改此过程。
    '不要使用代码编辑器修改它。
    Friend WithEvents daOrders As System.Data.SqlClient.SqlDataAdapter
    Friend WithEvents cnTest As System.Data.SqlClient.SqlConnection
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
    Friend WithEvents bnFirst As System.Windows.Forms.Button
    Friend WithEvents bnPrior As System.Windows.Forms.Button
    Friend WithEvents bnNext As System.Windows.Forms.Button
    Friend WithEvents bnLast As System.Windows.Forms.Button
    Friend WithEvents bnAdd As System.Windows.Forms.Button
    Friend WithEvents bnCancel As System.Windows.Forms.Button
    Friend WithEvents bnDelete As System.Windows.Forms.Button
    Friend WithEvents bnUpdate As System.Windows.Forms.Button
    Friend WithEvents bnLoad As System.Windows.Forms.Button
    Friend WithEvents dsTest As _10_5.DataSet1
    Friend WithEvents daOrderDetails As System.Data.SqlClient.SqlDataAdapter
    Friend WithEvents OleDbConnection1 As System.Data.OleDb.OleDbConnection
    Friend WithEvents daCustomer As System.Data.SqlClient.SqlDataAdapter
    Friend WithEvents SqlSelectCommand3 As System.Data.SqlClient.SqlCommand
    Friend WithEvents SqlSelectCommand1 As System.Data.SqlClient.SqlCommand
    Friend WithEvents SqlInsertCommand1 As System.Data.SqlClient.SqlCommand
    Friend WithEvents SqlUpdateCommand1 As System.Data.SqlClient.SqlCommand
    Friend WithEvents SqlDeleteCommand1 As System.Data.SqlClient.SqlCommand
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents Label5 As System.Windows.Forms.Label
    Friend WithEvents Label6 As System.Windows.Forms.Label
    Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
    Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
    Friend WithEvents TextBox4 As System.Windows.Forms.TextBox
    Friend WithEvents SqlSelectCommand2 As System.Data.SqlClient.SqlCommand
    Friend WithEvents SqlInsertCommand2 As System.Data.SqlClient.SqlCommand
    Friend WithEvents SqlUpdateCommand2 As System.Data.SqlClient.SqlCommand
    Friend WithEvents SqlDeleteCommand2 As System.Data.SqlClient.SqlCommand
    Friend WithEvents OrderDetails As System.Windows.Forms.DataGridTableStyle
    Friend WithEvents txProductID As System.Windows.Forms.DataGridTextBoxColumn
    Friend WithEvents txQuantity As System.Windows.Forms.DataGridTextBoxColumn
    Friend WithEvents txDetailAmount As System.Windows.Forms.DataGridTextBoxColumn
    Friend WithEvents txUnitPrice As System.Windows.Forms.DataGridTextBoxColumn
    Friend WithEvents cbCustomerID As System.Windows.Forms.ComboBox
    Friend WithEvents dtpOrderData As System.Windows.Forms.DateTimePicker
    Friend WithEvents gdOrderDetails As System.Windows.Forms.DataGrid
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.daOrders = New System.Data.SqlClient.SqlDataAdapter()
        Me.SqlDeleteCommand1 = New System.Data.SqlClient.SqlCommand()
        Me.cnTest = New System.Data.SqlClient.SqlConnection()
        Me.SqlInsertCommand1 = New System.Data.SqlClient.SqlCommand()
        Me.SqlSelectCommand1 = New System.Data.SqlClient.SqlCommand()
        Me.SqlUpdateCommand1 = New System.Data.SqlClient.SqlCommand()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.Label2 = New System.Windows.Forms.Label()
        Me.Label3 = New System.Windows.Forms.Label()
        Me.dsTest = New _10_5.DataSet1()
        Me.TextBox1 = New System.Windows.Forms.TextBox()
        Me.bnFirst = New System.Windows.Forms.Button()
        Me.bnPrior = New System.Windows.Forms.Button()
        Me.bnNext = New System.Windows.Forms.Button()
        Me.bnLast = New System.Windows.Forms.Button()
        Me.bnAdd = New System.Windows.Forms.Button()
        Me.bnCancel = New System.Windows.Forms.Button()
        Me.bnDelete = New System.Windows.Forms.Button()
        Me.bnUpdate = New System.Windows.Forms.Button()
        Me.bnLoad = New System.Windows.Forms.Button()
        Me.daOrderDetails = New System.Data.SqlClient.SqlDataAdapter()
        Me.SqlDeleteCommand2 = New System.Data.SqlClient.SqlCommand()
        Me.SqlInsertCommand2 = New System.Data.SqlClient.SqlCommand()
        Me.SqlSelectCommand2 = New System.Data.SqlClient.SqlCommand()
        Me.SqlUpdateCommand2 = New System.Data.SqlClient.SqlCommand()
        Me.OleDbConnection1 = New System.Data.OleDb.OleDbConnection()
        Me.daCustomer = New System.Data.SqlClient.SqlDataAdapter()
        Me.SqlSelectCommand3 = New System.Data.SqlClient.SqlCommand()
        Me.cbCustomerID = New System.Windows.Forms.ComboBox()
        Me.dtpOrderData = New System.Windows.Forms.DateTimePicker()
        Me.gdOrderDetails = New System.Windows.Forms.DataGrid()
        Me.OrderDetails = New System.Windows.Forms.DataGridTableStyle()
        Me.txProductID = New System.Windows.Forms.DataGridTextBoxColumn()
        Me.txQuantity = New System.Windows.Forms.DataGridTextBoxColumn()
        Me.txUnitPrice = New System.Windows.Forms.DataGridTextBoxColumn()
        Me.txDetailAmount = New System.Windows.Forms.DataGridTextBoxColumn()
        Me.Label4 = New System.Windows.Forms.Label()
        Me.Label5 = New System.Windows.Forms.Label()
        Me.Label6 = New System.Windows.Forms.Label()
        Me.TextBox2 = New System.Windows.Forms.TextBox()
        Me.TextBox3 = New System.Windows.Forms.TextBox()
        Me.TextBox4 = New System.Windows.Forms.TextBox()
        CType(Me.dsTest, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.gdOrderDetails, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'daOrders
        '
        Me.daOrders.DeleteCommand = Me.SqlDeleteCommand1
        Me.daOrders.InsertCommand = Me.SqlInsertCommand1
        Me.daOrders.SelectCommand = Me.SqlSelectCommand1
        Me.daOrders.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "Orders", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("OrderID", "OrderID"), New System.Data.Common.DataColumnMapping("OrderDate", "OrderDate"), New System.Data.Common.DataColumnMapping("CustomerID", "CustomerID"), New System.Data.Common.DataColumnMapping("SubTotal", "SubTotal"), New System.Data.Common.DataColumnMapping("Tax", "Tax"), New System.Data.Common.DataColumnMapping("Amount", "Amount")})})
        Me.daOrders.UpdateCommand = Me.SqlUpdateCommand1
        '
        'SqlDeleteCommand1
        '
        Me.SqlDeleteCommand1.CommandText = "DELETE FROM Orders WHERE (OrderID = @Original_OrderID) AND (Amount = @Original_Am" & _
        "ount OR @Original_Amount IS NULL AND Amount IS NULL) AND (CustomerID = @Original" & _
        "_CustomerID OR @Original_CustomerID IS NULL AND CustomerID IS NULL) AND (OrderDa" & _
        "te = @Original_OrderDate) AND (SubTotal = @Original_SubTotal OR @Original_SubTot" & _
        "al IS NULL AND SubTotal IS NULL) AND (Tax = @Original_Tax OR @Original_Tax IS NU" & _
        "LL AND Tax IS NULL)"
        Me.SqlDeleteCommand1.Connection = Me.cnTest
        Me.SqlDeleteCommand1.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.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_Amount", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "Amount", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_CustomerID", System.Data.SqlDbType.VarChar, 8, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "CustomerID", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_OrderDate", System.Data.SqlDbType.DateTime, 8, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "OrderDate", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_SubTotal", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "SubTotal", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_Tax", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "Tax", System.Data.DataRowVersion.Original, Nothing))
        '
        'cnTest
        '
        Me.cnTest.ConnectionString = "data source=localhost;initial catalog=TEST;persist security info=False;user id=sa" & _
        ";packet size=4096"
        '
        'SqlInsertCommand1
        '
        Me.SqlInsertCommand1.CommandText = "INSERT INTO Orders(OrderID, OrderDate, CustomerID, SubTotal, Tax, Amount) VALUES " & _
        "(@OrderID, @OrderDate, @CustomerID, @SubTotal, @Tax, @Amount); SELECT OrderID, O" & _
        "rderDate, CustomerID, SubTotal, Tax, Amount FROM Orders WHERE (OrderID = @OrderI" & _
        "D)"
        Me.SqlInsertCommand1.Connection = Me.cnTest
        Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@OrderID", System.Data.SqlDbType.VarChar, 10, "OrderID"))
        Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@OrderDate", System.Data.SqlDbType.DateTime, 8, "OrderDate"))
        Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@CustomerID", System.Data.SqlDbType.VarChar, 8, "CustomerID"))
        Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@SubTotal", System.Data.SqlDbType.Int, 4, "SubTotal"))
        Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Tax", System.Data.SqlDbType.Int, 4, "Tax"))
        Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Amount", System.Data.SqlDbType.Int, 4, "Amount"))
        '
        'SqlSelectCommand1
        '
        Me.SqlSelectCommand1.CommandText = "SELECT OrderID, OrderDate, CustomerID, SubTotal, Tax, Amount FROM Orders"
        Me.SqlSelectCommand1.Connection = Me.cnTest
        '
        'SqlUpdateCommand1
        '
        Me.SqlUpdateCommand1.CommandText = "UPDATE Orders SET OrderID = @OrderID, OrderDate = @OrderDate, CustomerID = @Custo" & _
        "merID, SubTotal = @SubTotal, Tax = @Tax, Amount = @Amount WHERE (OrderID = @Orig" & _
        "inal_OrderID) AND (Amount = @Original_Amount OR @Original_Amount IS NULL AND Amo" & _
        "unt IS NULL) AND (CustomerID = @Original_CustomerID OR @Original_CustomerID IS N" & _
        "ULL AND CustomerID IS NULL) AND (OrderDate = @Original_OrderDate) AND (SubTotal " & _
        "= @Original_SubTotal OR @Original_SubTotal IS NULL AND SubTotal IS NULL) AND (Ta" & _
        "x = @Original_Tax OR @Original_Tax IS NULL AND Tax IS NULL); SELECT OrderID, Ord" & _
        "erDate, CustomerID, SubTotal, Tax, Amount FROM Orders WHERE (OrderID = @OrderID)" & _
        ""
        Me.SqlUpdateCommand1.Connection = Me.cnTest
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@OrderID", System.Data.SqlDbType.VarChar, 10, "OrderID"))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@OrderDate", System.Data.SqlDbType.DateTime, 8, "OrderDate"))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@CustomerID", System.Data.SqlDbType.VarChar, 8, "CustomerID"))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@SubTotal", System.Data.SqlDbType.Int, 4, "SubTotal"))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Tax", System.Data.SqlDbType.Int, 4, "Tax"))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Amount", System.Data.SqlDbType.Int, 4, "Amount"))
        Me.SqlUpdateCommand1.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.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_Amount", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "Amount", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_CustomerID", System.Data.SqlDbType.VarChar, 8, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "CustomerID", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_OrderDate", System.Data.SqlDbType.DateTime, 8, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "OrderDate", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_SubTotal", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "SubTotal", System.Data.DataRowVersion.Original, Nothing))
        Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_Tax", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "Tax", System.Data.DataRowVersion.Original, Nothing))
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(20, 72)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(77, 23)
        Me.Label1.TabIndex = 0
        Me.Label1.Text = "订购客户"
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(20, 44)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(82, 23)
        Me.Label2.TabIndex = 1
        Me.Label2.Text = "订购日期"
        '
        'Label3
        '
        Me.Label3.Location = New System.Drawing.Point(307, 44)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(72, 23)
        Me.Label3.TabIndex = 2
        Me.Label3.Text = "订购单号"
        '
        'dsTest
        '

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -