Nav apraksta
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

Frm_ChemBuy.vb 6.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. Imports System.Data.SqlClient
  2. Imports System.Reflection
  3. Public Class Frm_ChemBuy
  4. Dim cmd As New SqlCommand
  5. Dim da As New SqlDataAdapter
  6. Dim dt As New DataTable
  7. Dim conn As New SqlConnection
  8. Dim DT1 As New DataTable
  9. Dim DT2 As New DataTable
  10. Dim DT3 As New DataTable
  11. Dim sql As String
  12. Private Sub FrmChemBuy_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  13. 'Me.MdiParent = FrmMDI
  14. conn.ConnectionString = connstring
  15. conn.Open()
  16. cmd.Connection = conn
  17. End Sub
  18. Private Sub dgv1_CellMouseUp(sender As Object, e As DataGridViewCellMouseEventArgs) Handles dgv1.CellMouseUp
  19. Dim dt As New DataTable
  20. 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" '----外购入库
  21. cmd.CommandText = sql
  22. da.SelectCommand = cmd
  23. da.Fill(dt)
  24. dgv2.DataSource = dt
  25. dgv2.Columns(0).Width = 100
  26. dgv2.Columns(1).Width = 170
  27. dgv2.Columns(2).Width = 70
  28. dgv2.Columns(3).Width = 70
  29. Dim dt1 As New DataTable
  30. 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" '----外购入库
  31. cmd.CommandText = sql
  32. da.SelectCommand = cmd
  33. da.Fill(dt1)
  34. dgv2_1.DataSource = dt1
  35. dgv2_1.Columns(0).Width = 100
  36. dgv2_1.Columns(1).Width = 170
  37. dgv2_1.Columns(2).Width = 70
  38. dgv2_1.Columns(3).Width = 70
  39. Dim dt2 As New DataTable
  40. Dim dt3 As New DataTable
  41. Dim dt4 As New DataTable
  42. Dim dt5 As New DataTable
  43. 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" '----外购入库
  44. cmd.CommandText = sql
  45. da.SelectCommand = cmd
  46. da.Fill(dt2)
  47. dgv3.DataSource = dt2
  48. 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" '----外购入库
  49. cmd.CommandText = sql
  50. da.SelectCommand = cmd
  51. da.Fill(dt3)
  52. dgv4.DataSource = dt3
  53. 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" '----外购入库
  54. cmd.CommandText = sql
  55. da.SelectCommand = cmd
  56. da.Fill(dt4)
  57. dgv5.DataSource = dt4
  58. 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"
  59. cmd.CommandText = sql
  60. da.SelectCommand = cmd
  61. da.Fill(dt5)
  62. DGV6.DataSource = dt5
  63. End Sub
  64. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  65. 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" '----外购入库
  66. cmd.CommandText = sql
  67. da.SelectCommand = cmd
  68. da.Fill(dt)
  69. dgv1.DataSource = dt
  70. dgv1.Columns(0).Width = 200
  71. dgv1.Columns(1).Width = 80
  72. dgv1.Columns(2).Width = 90
  73. 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 "
  74. cmd.CommandText = sql
  75. DateTimePicker6.Value = cmd.ExecuteScalar
  76. 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"
  77. cmd.CommandText = sql
  78. DateTimePicker5.Value = cmd.ExecuteScalar
  79. 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" '----外购入库
  80. cmd.CommandText = sql
  81. da.SelectCommand = cmd
  82. da.Fill(DT1)
  83. dgv3.DataSource = DT1
  84. 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" '----保税入库
  85. cmd.CommandText = sql
  86. da.SelectCommand = cmd
  87. da.Fill(DT2)
  88. dgv4.DataSource = DT2
  89. 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" '----外购入库
  90. cmd.CommandText = sql
  91. da.SelectCommand = cmd
  92. da.Fill(DT3)
  93. dgv5.DataSource = DT3
  94. End Sub
  95. Private Sub dgv1_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgv1.CellContentClick
  96. End Sub
  97. End Class