123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- Imports System.Data.SqlClient
- Imports System.Reflection
- Public Class Frm_ChemBuy
- Dim cmd As New SqlCommand
- Dim da As New SqlDataAdapter
- Dim dt As New DataTable
- Dim conn As New SqlConnection
- Dim DT1 As New DataTable
- Dim DT2 As New DataTable
- Dim DT3 As New DataTable
-
- Dim sql As String
- Private Sub FrmChemBuy_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- 'Me.MdiParent = FrmMDI
-
-
-
-
- conn.ConnectionString = connstring
- conn.Open()
-
- cmd.Connection = conn
-
-
-
-
- End Sub
-
- Private Sub dgv1_CellMouseUp(sender As Object, e As DataGridViewCellMouseEventArgs) Handles dgv1.CellMouseUp
-
-
- Dim dt As New DataTable
-
-
- sql = "SELECT date as 日期,name as 品名,QTY AS 数量, cast(price as numeric(10,1)) as 单价,cast(AMOUNT AS numeric(10, 0)) AS 小计 FROM RT_CHEM_IN_PRICE where supplier=N'" & dgv1.Rows(dgv1.CurrentRow.Index).Cells("供应商").Value & "' ORDER BY date DESC" '----外购入库
-
-
- cmd.CommandText = sql
-
- da.SelectCommand = cmd
- da.Fill(dt)
-
- dgv2.DataSource = dt
- dgv2.Columns(0).Width = 100
-
- dgv2.Columns(1).Width = 170
- dgv2.Columns(2).Width = 70
- dgv2.Columns(3).Width = 70
-
-
-
- Dim dt1 As New DataTable
-
-
- sql = "SELECT date as 日期,name as 品名,QTY AS 数量, cast(price as numeric(10,1)) as 单价,cast(AMOUNT AS numeric(10, 0)) AS 小计 FROM RT_CHEM_IN_PRICE where supplier=N'" & dgv1.Rows(dgv1.CurrentRow.Index).Cells("供应商").Value & "' and (dep<>N'保税仓-R' or dep is null) ORDER BY date DESC" '----外购入库
-
-
- cmd.CommandText = sql
-
- da.SelectCommand = cmd
- da.Fill(dt1)
-
- dgv2_1.DataSource = dt1
- dgv2_1.Columns(0).Width = 100
- dgv2_1.Columns(1).Width = 170
- dgv2_1.Columns(2).Width = 70
- dgv2_1.Columns(3).Width = 70
-
-
-
-
-
- Dim dt2 As New DataTable
- Dim dt3 As New DataTable
-
- Dim dt4 As New DataTable
- Dim dt5 As New DataTable
-
-
- sql = "SELECT year(date) as 年, month(date) as 月,SUM(QTY) AS 数量, CAST(SUM(AMOUNT) AS numeric(10, 0)) AS 金额 FROM RT_CHEM_IN_PRICE where supplier = N'" & dgv1.Rows(dgv1.CurrentRow.Index).Cells("供应商").Value & "' AND (dep<>N'保税仓-R' or dep is null) GROUP BY year(date), month(date) ORDER BY year(date) DESC,month(date) desc" '----外购入库
-
- cmd.CommandText = sql
-
- da.SelectCommand = cmd
- da.Fill(dt2)
- dgv3.DataSource = dt2
-
-
- sql = "SELECT year(date) as 年, month(date) as 月,SUM(QTY) AS 数量, CAST(SUM(AMOUNT) AS numeric(10, 0)) AS 金额 FROM RT_CHEM_IN_PRICE where SUPPLIER = N'" & dgv1.Rows(dgv1.CurrentRow.Index).Cells("供应商").Value & "' AND dep=N'保税仓-R' GROUP BY year(date), month(date) ORDER BY year(date) DESC,month(date) desc" '----外购入库
-
- cmd.CommandText = sql
-
- da.SelectCommand = cmd
- da.Fill(dt3)
- dgv4.DataSource = dt3
-
- sql = "SELECT year(date) as 年, month(date) as 月,SUM(QTY) AS 数量, CAST(SUM(AMOUNT) AS numeric(10, 0)) AS 金额 FROM RT_CHEM_IN_PRICE WHERE SUPPLIER = N'" & dgv1.Rows(dgv1.CurrentRow.Index).Cells("供应商").Value & "' GROUP BY year(date), month(date) ORDER BY year(date) DESC,month(date) desc" '----外购入库
-
- cmd.CommandText = sql
-
- da.SelectCommand = cmd
- da.Fill(dt4)
- dgv5.DataSource = dt4
-
-
-
-
-
- sql = "SELECT YEAR(RT_CHEM_IN_PRICE.DATE) AS 年, MONTH(RT_CHEM_IN_PRICE.DATE) AS 月, SUM(RT_CHEM_IN_PRICE.QTY) AS 数量, CAST(SUM(RT_CHEM_IN_PRICE.AMOUNT) AS numeric(10, 0)) AS 金额 FROM RT_CHEM_IN_PRICE LEFT OUTER JOIN RT_SYS_CHEM_MAIN ON RT_CHEM_IN_PRICE.NAME = RT_SYS_CHEM_MAIN.name WHERE (RT_CHEM_IN_PRICE.SUPPLIER = N'" & dgv1.Rows(dgv1.CurrentRow.Index).Cells("供应商").Value & "') AND (RT_SYS_CHEM_MAIN.BRAND LIKE '%STAHL%') GROUP BY YEAR(RT_CHEM_IN_PRICE.DATE), MONTH(RT_CHEM_IN_PRICE.DATE) ORDER BY 年 DESC, 月 DESC"
-
-
-
- cmd.CommandText = sql
-
- da.SelectCommand = cmd
- da.Fill(dt5)
- DGV6.DataSource = dt5
-
-
- End Sub
-
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
- sql = "SELECT SUPPLIER as 供应商, SUM(QTY) AS 数量, CAST(SUM(AMOUNT) AS numeric(10, 0)) AS 金额 FROM RT_CHEM_IN_PRICE where date between '" & String.Format("{0:d}", dtp1.Value) & "' and '" & String.Format("{0:d}", dtp2.Value) & "' GROUP BY SUPPLIER ORDER BY 金额 DESC" '----外购入库
-
- cmd.CommandText = sql
-
- da.SelectCommand = cmd
- da.Fill(dt)
-
- dgv1.DataSource = dt
- dgv1.Columns(0).Width = 200
- dgv1.Columns(1).Width = 80
- dgv1.Columns(2).Width = 90
-
-
- sql = "select top 1 date from rt_chem_in_price where date between '" & String.Format("{0:d}", dtp1.Value) & "' and '" & String.Format("{0:d}", dtp2.Value) & "' order by date "
- cmd.CommandText = sql
-
- DateTimePicker6.Value = cmd.ExecuteScalar
-
- sql = "select top 1 date from rt_chem_in_price where date between '" & String.Format("{0:d}", dtp1.Value) & "' and '" & String.Format("{0:d}", dtp2.Value) & "' order by date desc"
- cmd.CommandText = sql
-
- DateTimePicker5.Value = cmd.ExecuteScalar
-
-
-
- sql = "SELECT year(date) as 年, month(date) as 月,SUM(QTY) AS 数量, CAST(SUM(AMOUNT) AS numeric(10, 0)) AS 金额 FROM RT_CHEM_IN_PRICE where date between '" & String.Format("{0:d}", dtp1.Value) & "' and '" & String.Format("{0:d}", dtp2.Value) & "' and (dep<>N'保税仓-R' or dep is null) GROUP BY year(date), month(date) ORDER BY year(date) DESC,month(date) desc" '----外购入库
-
- cmd.CommandText = sql
-
- da.SelectCommand = cmd
- da.Fill(DT1)
- dgv3.DataSource = DT1
-
-
- sql = "SELECT year(date) as 年, month(date) as 月,SUM(QTY) AS 数量, CAST(SUM(AMOUNT) AS numeric(10, 0)) AS 金额 FROM RT_CHEM_s_IN_PRICE where date between '" & String.Format("{0:d}", dtp1.Value) & "' and '" & String.Format("{0:d}", dtp2.Value) & "' and dep=N'保税仓-R' GROUP BY year(date), month(date) ORDER BY year(date) DESC,month(date) desc" '----保税入库
-
- cmd.CommandText = sql
-
- da.SelectCommand = cmd
- da.Fill(DT2)
- dgv4.DataSource = DT2
-
- sql = "SELECT year(date) as 年, month(date) as 月,SUM(QTY) AS 数量, CAST(SUM(AMOUNT) AS numeric(10, 0)) AS 金额 FROM RT_CHEM_IN_PRICE where date between '" & String.Format("{0:d}", dtp1.Value) & "' and '" & String.Format("{0:d}", dtp2.Value) & "' GROUP BY year(date), month(date) ORDER BY year(date) DESC,month(date) desc" '----外购入库
-
- cmd.CommandText = sql
-
- da.SelectCommand = cmd
- da.Fill(DT3)
- dgv5.DataSource = DT3
- End Sub
-
- Private Sub dgv1_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgv1.CellContentClick
-
- End Sub
- End Class
|