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

📄 salegatheringform.vb

📁 一个商品销售管理系统
💻 VB
字号:
'文件名:SaleGatheringForm.vb
Imports System.Data.SqlClient
Public Class SaleGatheringForm
    Public MyCompany As String
    Private Sub 采购商信息BindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 采购商信息BindingNavigatorSaveItem.Click
        Me.Validate()
        Me.采购商信息BindingSource.EndEdit()
        Me.采购商信息TableAdapter.Update(Me.MySaleDataSet.采购商信息)
    End Sub
    Private Sub SaleGatheringForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: 这行代码将数据加载到表“MySaleDataSet.采购商信息”中。您可以根据需要移动或移除它。
        Me.采购商信息TableAdapter.Fill(Me.MySaleDataSet.采购商信息)
    End Sub
    Private Sub 查询ToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 查询ToolStripButton.Click
        Try
            Me.采购商信息TableAdapter.FillBy(Me.MySaleDataSet.采购商信息, 客户名称ToolStripTextBox.Text)
        Catch ex As Exception
            System.Windows.Forms.MessageBox.Show(ex.Message)
        End Try
    End Sub
    Private Sub 客户名称TextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 客户名称TextBox.TextChanged
        '获取应收货款总额
        Dim MyConnection As New SqlConnection()
        MyConnection.ConnectionString = My.Settings.MySaleConnectionString
        MyConnection.Open()
        Dim MySQL As String = "Select SUM(应收帐款) From 销售信息 WHERE 客户名称='" + Me.客户名称TextBox.Text + "'"
        Dim MyCommand As New SqlCommand(MySQL, MyConnection)
        Me.应收货款总额TextBox.Text = MyCommand.ExecuteScalar().ToString()
        If (MyConnection.State = ConnectionState.Open) Then
            MyConnection.Close()
        End If
    End Sub
    Private Sub 打印Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 打印Button.Click
        Me.printPreviewDialog1.Document = Me.printDocument1
        Me.printPreviewDialog1.ShowDialog()
    End Sub
    Private Sub 保存Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 保存Button.Click
        If (Me.实收金额TextBox.Text.Length < 2) Then
            Return
        End If
        If (MessageBox.Show("请检查销售商品收款信息是否正确,一旦保存就无法修改,是否继续?", "信息提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.No) Then
            Return
        End If
        Dim MySQLConnectionString As String = My.Settings.MySaleConnectionString
        Dim MySQL As String = "INSERT INTO 销售信息(自编号,销售单号,客户名称,应收金额,实收金额,收款方式,经办人,出库日期,说明)VALUES('"
        MySQL += Me.GetNewID() + "','"
        MySQL += "Z这是在处理货款" + "','"
        MySQL += Me.客户名称TextBox.Text + "',"
        MySQL += "0" + ","
        MySQL += Me.实收金额TextBox.Text + ",'"
        MySQL += Me.收款方式ComboBox.Text + "','"
        MySQL += Me.经办人TextBox.Text + "','"
        MySQL += Me.收款日期DateTimePicker.Value.ToString() + "','"
        MySQL += Me.说明TextBox.Text + "');"
        Dim MyConnection As New SqlConnection(MySQLConnectionString)
        MyConnection.Open()
        Dim MyCommand As SqlCommand = MyConnection.CreateCommand()
        MyCommand.CommandText = MySQL
        MyCommand.ExecuteNonQuery()
        If (MyConnection.State = ConnectionState.Open) Then
            MyConnection.Close()
        End If
        Me.实收金额TextBox.Text = ""
    End Sub
    Private Sub 退出Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 退出Button.Click
        Me.Close()
    End Sub
    Private Sub printDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles printDocument1.PrintPage
        '打印退货收款单
        e.Graphics.DrawString(Me.MyCompany + "商品销售收款单", New Font("宋体", 20), Brushes.Black, 140, 80)
        e.Graphics.DrawString("应收货款总额:" + Me.应收货款总额TextBox.Text, New Font("宋体", 12), Brushes.Black, 100, 150)
        e.Graphics.DrawString("记帐本位币:人民币(元)", New Font("宋体", 12), Brushes.Black, 530, 150)
        e.Graphics.DrawLine(New Pen(Color.Black, 3.0), 100, 170, 720, 170)
        e.Graphics.DrawString("客户名称:" + Me.客户名称TextBox.Text, New Font("宋体", 12), Brushes.Black, 110, 175)
        e.Graphics.DrawString("本次实收金额:" + Me.实收金额TextBox.Text, New Font("宋体", 12), Brushes.Black, 400, 175)
        e.Graphics.DrawLine(New Pen(Color.Black), 100, 195, 720, 195)
        e.Graphics.DrawString("收款方式:" + Me.收款方式ComboBox.Text, New Font("宋体", 12), Brushes.Black, 110, 200)
        e.Graphics.DrawString("经办人:" + Me.经办人TextBox.Text, New Font("宋体", 12), Brushes.Black, 400, 200)
        e.Graphics.DrawString("收款日期:" + Me.收款日期DateTimePicker.Value.ToShortDateString(), New Font("宋体", 12), Brushes.Black, 530, 200)
        e.Graphics.DrawLine(New Pen(Color.Black), 100, 220, 720, 220)
        e.Graphics.DrawString("开户银行:" + Me.开户银行TextBox.Text, New Font("宋体", 12), Brushes.Black, 110, 225)
        e.Graphics.DrawString("银行帐号:" + Me.银行帐号TextBox.Text, New Font("宋体", 12), Brushes.Black, 400, 225)
        e.Graphics.DrawLine(New Pen(Color.Black), 100, 245, 720, 245)
        e.Graphics.DrawString("说明:" + Me.说明TextBox.Text, New Font("宋体", 12), Brushes.Black, 110, 250)
        e.Graphics.DrawLine(New Pen(Color.Black, 3.0), 100, 270, 720, 270)
        e.Graphics.DrawString("打印日期:" + DateTime.Now.ToShortDateString(), New Font("宋体", 12), Brushes.Black, 530, 275)
    End Sub
    Private Function GetNewID() As String
        '自动计算自编号
        Dim MySQLConnectionString As String = My.Settings.MySaleConnectionString
        Dim MyConnection As New SqlConnection(MySQLConnectionString)
        MyConnection.Open()
        Dim MyCommand As SqlCommand = MyConnection.CreateCommand()
        MyCommand.CommandText = "Select max(自编号) 最大编号 From 销售信息"
        Dim MyResult As Object = MyCommand.ExecuteScalar()
        Dim MyID As System.Int64 = 1
        If (Not (MyResult Is System.DBNull.Value)) Then
            Dim MyMaxID As String = MyResult.ToString().Trim()
            MyMaxID = MyMaxID.Substring(2, MyMaxID.Length - 2)
            MyID = Convert.ToInt64(MyMaxID) + 1
        End If
        Dim MyLength As Integer = MyID.ToString().Length
        Dim MyNewID As String = ""
        Select Case (MyLength)
            Case 1
                    MyNewID = "XS0000000" + MyID.ToString()
            Case 2
                    MyNewID = "XS000000" + MyID.ToString()
            Case 3
                    MyNewID = "XS00000" + MyID.ToString()
            Case 4
                    MyNewID = "XS0000" + MyID.ToString()
            Case 5
                    MyNewID = "XS000" + MyID.ToString()
            Case 6
                    MyNewID = "XS00" + MyID.ToString()
            Case 7
                    MyNewID = "XS0" + MyID.ToString()
        End Select
        If (MyConnection.State = ConnectionState.Open) Then
            MyConnection.Close()
        End If
        Return MyNewID
    End Function
End Class

⌨️ 快捷键说明

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