123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424 |
- Imports System.Data.SqlClient
- Imports System.Reflection
- Public Class Frm_BG_IO
- Dim cmd As New SqlCommand
- Dim da As New SqlDataAdapter
- Dim dt As New DataTable
- Dim sql As String
- Dim conn As New SqlConnection
- Dim DR As SqlDataReader
- Private Sub Frm_BG_IO_Load(sender As Object, e As EventArgs) Handles MyBase.Load
-
-
- Me.MdiParent = FrmMDI
-
- Dim type As Type = DGV1.GetType()
- Dim pi As PropertyInfo = type.GetProperty("DoubleBuffered", System.Reflection.BindingFlags.Instance Or System.Reflection.BindingFlags.NonPublic)
- pi.SetValue(DGV1, True, Nothing)
-
-
-
- conn.ConnectionString = connstring
- conn.Open()
-
-
- cmd.Connection = conn
-
-
- sql = "SELECT NO,case when checked='true' then N'已核销' else N'执行中' end as checked FROM RT_BG_MAIN ORDER BY SERIAL"
- cmd.CommandText = sql
-
- DR = cmd.ExecuteReader
-
- While DR.Read
-
-
- ListBox1.Items.Add(DR("NO") & vbTab & DR("checked"))
-
- End While
-
- DR.Close()
-
- 'DGV1.DataSource = dt
-
-
- DGV1.RowHeadersVisible = False
-
-
-
-
- End Sub
-
- Private Sub ListBox1_Click(sender As Object, e As EventArgs) Handles ListBox1.Click
-
- ListBox2.Items.Clear()
- ListBox2.Items.Clear()
- ListBox4.Items.Clear()
-
-
-
- Dim p() As String
-
- p = Split(ListBox1.Items(ListBox1.SelectedIndex), vbTab)
-
-
- sql = "SELECT item_new from rt_bg_io where xno like '%" & p(0) & "%' and item not like N'%牛二层%' group by item_new"
- cmd.CommandText = sql
-
- DR = cmd.ExecuteReader
-
- While DR.Read
-
-
- ListBox2.Items.Add(DR("item_new"))
- 'ListBox2.Items.Add(S1)
- 'ListBox2.Items.Add(S2)
-
-
- End While
-
- DR.Close()
-
-
- sql = "SELECT ITEM_new from rt_bg_io where xno like '%" & p(0) & "%' and item like N'%牛二层%' group by item_new "
- cmd.CommandText = sql
-
- DR = cmd.ExecuteReader
-
- While DR.Read
-
-
- ListBox4.Items.Add(DR("item_new"))
- 'ListBox2.Items.Add(S1)
- 'ListBox2.Items.Add(S2)
-
-
- End While
-
- DR.Close()
-
-
-
-
- ' ListBox2.SelectedIndex = 1
-
-
- End Sub
-
- Private Sub ListBox2_Click(sender As Object, e As EventArgs) Handles ListBox2.Click
-
- Dim dt As New DataTable
- Dim p() As String
-
- p = Split(ListBox1.Items(ListBox1.SelectedIndex), vbTab)
-
-
-
- sql = "SELECT date AS 日期, CASE WHEN m_in = '0' THEN NULL ELSE cast(m_in as numeric(10,1)) END AS 入库, CASE WHEN m_out = '0' THEN NULL ELSE cast(m_out as numeric(10,1)) END AS 出库, cast(bal as numeric(10,1)) AS 结存 FROM RT_BG_IO where xno like '%" & p(0) & "%' and item_new =N'" & ListBox2.Items(ListBox2.SelectedIndex) & "' order by date"
- cmd.CommandText = sql
-
- da.SelectCommand = cmd
-
- da.Fill(dt)
-
-
- Dim myDataRow As DataRow
- myDataRow = dt.NewRow
-
- 'myDataRow(0) = "合计"
- myDataRow(1) = dt.Compute("sum(入库)", "")
- myDataRow(2) = dt.Compute("sum(出库)", "")
-
-
- If IsDBNull(myDataRow(1)) Then myDataRow(1) = 0
- If IsDBNull(myDataRow(2)) Then myDataRow(2) = 0
-
-
- myDataRow(3) = myDataRow(1) - (myDataRow(2))
-
-
- l_in.Text = myDataRow(1)
- l_out.Text = myDataRow(2)
- l_bal.Text = myDataRow(3)
-
-
- dt.Rows.InsertAt(myDataRow, dt.Rows.Count)
-
-
- DGV1.DataSource = dt
-
-
- DGV1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing
-
- 'DGV3.AllowUserToAddRows = False
- DGV1.Rows(DGV1.Rows.Count - 2).Cells(0).Style.ForeColor = Color.Red
- DGV1.Rows(DGV1.Rows.Count - 2).Cells(1).Style.ForeColor = Color.Red
- DGV1.Rows(DGV1.Rows.Count - 2).Cells(2).Style.ForeColor = Color.Red
- DGV1.Rows(DGV1.Rows.Count - 2).Cells(3).Style.ForeColor = Color.Red
-
-
-
-
-
- dt = New DataTable
-
-
- sql = "SELECT year(date) AS 年,month(date) as 月, CASE WHEN sum(m_in) = 0 THEN NULL ELSE cast(sum(m_in) as numeric(10,1)) END AS 入库, CASE WHEN sum(m_out) = '0' THEN NULL ELSE cast(sum(m_out) as numeric(10,1)) END AS 出库 FROM RT_BG_IO where xno like '%" & p(0) & "%' and item_new =N'" & ListBox2.Items(ListBox2.SelectedIndex) & "' group by year(date),month(date) order by year(date),month(date)"
- cmd.CommandText = sql
-
- da.SelectCommand = cmd
-
- da.Fill(dt)
-
-
-
- myDataRow = dt.NewRow
-
- 'myDataRow(0) = "合计"
- myDataRow(1) = dt.Compute("sum(入库)", "")
- myDataRow(2) = dt.Compute("sum(出库)", "")
-
-
- If IsDBNull(myDataRow(1)) Then myDataRow(1) = 0
- If IsDBNull(myDataRow(2)) Then myDataRow(2) = 0
-
-
- myDataRow(3) = myDataRow(1) - (myDataRow(2))
-
-
- Label12.Text = myDataRow(1)
- Label11.Text = myDataRow(2)
- Label10.Text = myDataRow(3)
-
-
- dt.Rows.InsertAt(myDataRow, dt.Rows.Count)
-
-
- dgv2.DataSource = dt
-
-
- dgv2.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing
-
- 'DGV3.AllowUserToAddRows = False
- dgv2.Rows(dgv2.Rows.Count - 2).Cells(0).Style.ForeColor = Color.Red
- dgv2.Rows(dgv2.Rows.Count - 2).Cells(1).Style.ForeColor = Color.Red
- dgv2.Rows(dgv2.Rows.Count - 2).Cells(2).Style.ForeColor = Color.Red
- dgv2.Rows(dgv2.Rows.Count - 2).Cells(3).Style.ForeColor = Color.Red
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- End Sub
-
- Private Sub ListBox1_DoubleClick(sender As Object, e As EventArgs) Handles ListBox1.DoubleClick
-
- Dim p() As String
-
- p = Split(ListBox1.Items(ListBox1.SelectedIndex), vbTab)
-
- xno = p(0)
-
- Dim my_form As New Frm_BG_sum
- my_form.Show(Me)
-
-
-
-
-
- End Sub
-
- Private Sub ListBox2_LostFocus(sender As Object, e As EventArgs) Handles ListBox2.LostFocus
- l_in.Text = ""
- l_out.Text = ""
- l_bal.Text = ""
-
- End Sub
-
- Private Sub ListBox4_Click(sender As Object, e As EventArgs) Handles ListBox4.Click
-
-
- Dim dt As New DataTable
- Dim p() As String
-
- p = Split(ListBox1.Items(ListBox1.SelectedIndex), vbTab)
-
-
- sql = "SELECT cast(year + '/' + month + '/' + date1 as date) AS 日期, CASE WHEN m_in = '0' THEN NULL ELSE cast(m_in as numeric(10,1)) END AS 入库, CASE WHEN m_out = '0' THEN NULL ELSE cast(m_out as numeric(10,1)) END AS 出库, cast(bal as numeric(10,1)) AS 结存 FROM RT_BG_IO where xno like '%" & p(0) & "%' and item =N'" & ListBox4.Items(ListBox4.SelectedIndex) & "' order by 日期"
- sql = "SELECT (year + '/' + month + '/' + date1 ) AS 日期, CASE WHEN m_in = '0' THEN NULL ELSE cast(m_in as numeric(10,2)) END AS 入库, CASE WHEN m_out = '0' THEN NULL ELSE cast(m_out as numeric(10,2)) END AS 出库, cast(bal as numeric(10,2)) AS 结存 FROM RT_BG_IO where xno like '%" & p(0) & "%' and item_new =N'" & ListBox4.Items(ListBox4.SelectedIndex) & "'"
- cmd.CommandText = sql
-
- da.SelectCommand = cmd
-
- da.Fill(dt)
-
-
- Dim myDataRow As DataRow
- myDataRow = dt.NewRow
-
- 'myDataRow(0) = "合计"
- myDataRow(1) = dt.Compute("sum(入库)", "")
- myDataRow(2) = dt.Compute("sum(出库)", "")
-
-
- If IsDBNull(myDataRow(1)) Then myDataRow(1) = 0
- If IsDBNull(myDataRow(2)) Then myDataRow(2) = 0
-
-
- myDataRow(3) = myDataRow(1) - (myDataRow(2))
-
-
- l_in.Text = myDataRow(1)
- l_out.Text = myDataRow(2)
- l_bal.Text = myDataRow(3)
-
-
- dt.Rows.InsertAt(myDataRow, dt.Rows.Count)
-
-
- DGV1.DataSource = dt
-
-
- DGV1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing
-
- 'DGV3.AllowUserToAddRows = False
- DGV1.Rows(DGV1.Rows.Count - 2).Cells(0).Style.ForeColor = Color.Red
- DGV1.Rows(DGV1.Rows.Count - 2).Cells(1).Style.ForeColor = Color.Red
- DGV1.Rows(DGV1.Rows.Count - 2).Cells(2).Style.ForeColor = Color.Red
- DGV1.Rows(DGV1.Rows.Count - 2).Cells(3).Style.ForeColor = Color.Red
-
-
-
-
-
- dt = New DataTable
-
-
- sql = "SELECT year(date) AS 年,month(date) as 月, CASE WHEN sum(m_in) = 0 THEN NULL ELSE cast(sum(m_in) as numeric(10,1)) END AS 入库, CASE WHEN sum(m_out) = '0' THEN NULL ELSE cast(sum(m_out) as numeric(10,1)) END AS 出库 FROM RT_BG_IO where xno like '%" & p(0) & "%' and item_new =N'" & ListBox4.Items(ListBox4.SelectedIndex) & "' group by year(date),month(date) order by year(date),month(date)"
- cmd.CommandText = sql
-
- da.SelectCommand = cmd
-
- da.Fill(dt)
-
-
-
- myDataRow = dt.NewRow
-
- 'myDataRow(0) = "合计"
- myDataRow(1) = dt.Compute("sum(入库)", "")
- myDataRow(2) = dt.Compute("sum(出库)", "")
-
-
- If IsDBNull(myDataRow(1)) Then myDataRow(1) = 0
- If IsDBNull(myDataRow(2)) Then myDataRow(2) = 0
-
-
- myDataRow(3) = myDataRow(1) - (myDataRow(2))
-
-
- Label12.Text = myDataRow(1)
- Label11.Text = myDataRow(2)
- Label10.Text = myDataRow(3)
-
-
- dt.Rows.InsertAt(myDataRow, dt.Rows.Count)
-
-
- dgv2.DataSource = dt
-
-
- dgv2.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing
-
- 'DGV3.AllowUserToAddRows = False
- dgv2.Rows(dgv2.Rows.Count - 2).Cells(0).Style.ForeColor = Color.Red
- dgv2.Rows(dgv2.Rows.Count - 2).Cells(1).Style.ForeColor = Color.Red
- dgv2.Rows(dgv2.Rows.Count - 2).Cells(2).Style.ForeColor = Color.Red
- dgv2.Rows(dgv2.Rows.Count - 2).Cells(3).Style.ForeColor = Color.Red
-
-
-
-
- End Sub
-
-
- Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click '----查询
-
-
-
-
-
- Dim dt As New DataTable
- Dim p() As String
-
- p = Split(ListBox1.Items(ListBox1.SelectedIndex), vbTab)
-
-
-
- sql = "SELECT date AS 日期, CASE WHEN m_in = '0' THEN NULL ELSE cast(m_in as numeric(10,1)) END AS 入库, CASE WHEN m_out = '0' THEN NULL ELSE cast(m_out as numeric(10,1)) END AS 出库, cast(bal as numeric(10,1)) AS 结存 FROM RT_BG_IO where date between '" & dtp1.Value & "' and '" & dtp2.Value & "' and xno like '%" & p(0) & "%' and item_new =N'" & ListBox2.Items(ListBox2.SelectedIndex) & "' order by date"
- cmd.CommandText = sql
-
- da.SelectCommand = cmd
-
- da.Fill(dt)
-
-
- Dim myDataRow As DataRow
- myDataRow = dt.NewRow
-
- 'myDataRow(0) = "合计"
- myDataRow(1) = dt.Compute("sum(入库)", "")
- myDataRow(2) = dt.Compute("sum(出库)", "")
-
-
- If IsDBNull(myDataRow(1)) Then myDataRow(1) = 0
- If IsDBNull(myDataRow(2)) Then myDataRow(2) = 0
-
-
- myDataRow(3) = myDataRow(1) - (myDataRow(2))
-
-
- Label7.Text = myDataRow(1)
- Label6.Text = myDataRow(2)
- Label5.Text = myDataRow(3)
-
-
- dt.Rows.InsertAt(myDataRow, dt.Rows.Count)
-
-
- dgv_query.DataSource = dt
-
-
- dgv_query.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing
-
- 'DGV3.AllowUserToAddRows = False
- dgv_query.Rows(dgv_query.Rows.Count - 2).Cells(0).Style.ForeColor = Color.Red
- dgv_query.Rows(dgv_query.Rows.Count - 2).Cells(1).Style.ForeColor = Color.Red
- dgv_query.Rows(dgv_query.Rows.Count - 2).Cells(2).Style.ForeColor = Color.Red
- dgv_query.Rows(dgv_query.Rows.Count - 2).Cells(3).Style.ForeColor = Color.Red
-
-
-
-
-
-
-
-
-
-
-
-
- End Sub
- End Class
|