FrmSell销售管理

Imports System.Data
Imports System.Data.SqlClient
Public Class FrmSell

    Dim str1 As String
    Private Sub FrmSell_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim conn As New SqlConnection
        Dim sql As String
        Dim mytable As New DataTable
        Dim ds As New DataSet
        conn.ConnectionString = "data source=127.0.0.1;initial catalog=Supermarket;user=text;password=text"
        Try
            sql = "select sellid as 销售编号,barcode as 条形码 ,selldate as 销售日期,unitprice as 单价,quantity as 数量,unitprice*quantity as 总额,employeesid as 销售员工编号" _
        & " from sells  "
            Dim adp As New SqlDataAdapter(sql, conn)
            adp.Fill(ds, "a")
            Me.DataGrid1.DataSource = ds.Tables("a")
        Catch ex As Exception
            ' MsgBox(ex.ToString)
        Finally
        End Try
    End Sub
    Private Sub ButQuery_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButQuery.Click
        Select Case Me.ComboBox1.Text
            Case "员工ID"
                str1 = "employeesid"
                chaxun()
            Case "条形码"
                str1 = "barcode"
                chaxun()
        End Select
    End Sub

    Private Sub ButCollect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButCollect.Click
        Select Case Me.ComboBox1.Text
            Case "员工ID"
                str1 = "employeesid"
                huizhong()
            Case "条形码"
                str1 = "barcode"
                huizhong()
        End Select

    End Sub

    Private Sub huizhong()
        Try
            If Me.ComboBox1.Text = "" Or Me.TxtCondition.Text = "" Then
                MsgBox("方法,条件不能为空!")
            Else
                Dim conn As New SqlConnection
                Dim sql As String
                Dim ds As New DataSet
                conn.ConnectionString = "data source=127.0.0.1;initial catalog=Supermarket;user=text;password=text"
                sql = " select  sum(unitprice * quantity) as 总额 from sells where " & str1 & "='" & Me.TxtCondition.Text & "' and selldate between '" & Me.DTime1.Text & "' and '" & Me.DTime2.Text & "'"
                Dim adp As New SqlDataAdapter(sql, conn)
                adp.Fill(ds, "a")
                Me.DataGrid1.DataSource = ds.Tables("a")
            End If
        Catch ex As Exception
            ' MsgBox(ex.ToString)
        End Try
    End Sub
    Private Sub chaxun()
        Try
            Dim conn As New SqlConnection
            Dim sql As String
            Dim ds As New DataSet
            conn.ConnectionString = "data source=127.0.0.1;initial catalog=Supermarket;user=text;password=text"
            If Me.ComboBox1.Text = "" Or Me.TxtCondition.Text = "" Then
                MsgBox("方法,条件不能为空!")
            Else
                sql = "select sellid as 销售编号,barcode as 条形码 ,selldate as 销售日期,unitprice as 单价,quantity as 数量,unitprice*quantity as 总额,employeesid as 销售员工编号" _
                          & " from sells where " & str1 & "='" & Me.TxtCondition.Text & "' and selldate between '" & Me.DTime1.Text & "' and '" & Me.DTime2.Text & "'"
                Dim adp As New SqlDataAdapter(sql, conn)
                adp.Fill(ds, "a")
                Me.DataGrid1.DataSource = ds.Tables("a").DefaultView
            End If
        Catch ex As Exception
            ' MsgBox(ex.ToString)
        End Try
    End Sub
End Class 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值