暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Frm_Ship_daily_sum.vb 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. Imports System.Data.SqlClient
  2. Imports System
  3. Imports System.Collections.Generic
  4. Imports System.ComponentModel
  5. Imports System.Data
  6. Imports System.Drawing
  7. Imports System.Drawing.Design
  8. Imports System.Text
  9. Public Class Frm_Ship_Daily_sum
  10. Dim cmd As New SqlCommand
  11. Dim da As New SqlDataAdapter
  12. Dim dt As New DataTable
  13. Dim sql As String
  14. Dim conn As New SqlConnection
  15. Private dateTimePicker1 As DateTimePicker
  16. Dim p() As String
  17. Dim my_cust As String = ""
  18. Dim colorArray(10) As Color
  19. Private Sub Frm_Ship_Daily_sum_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  20. colorArray(0) = Color.FromName("Aquamarine")
  21. colorArray(1) = Color.FromName("azure")
  22. colorArray(2) = Color.FromName("beige")
  23. colorArray(3) = Color.FromName("gainsboro")
  24. colorArray(4) = Color.FromName("LightBlue")
  25. colorArray(5) = Color.FromName("LightSalmon")
  26. conn.ConnectionString = connstring
  27. conn.Open()
  28. cmd.Connection = conn
  29. sql = "SELECT p.出货日期, p.custname as 客户, p.颜色, p.尺数, p.卡号1, p.品名 AS 系统品名, p.库存尺数 AS 即时库存,
  30. - p.尺数 + p.库存尺数 AS 结存, p.编码 AS 系统编码, Rt_measure_daily.date AS 打尺日期,
  31. Rt_measure_daily.sf AS 打尺尺数
  32. FROM (SELECT TOP (100) PERCENT rt_ship_temp_1.custname, rt_ship_temp_1.card AS 卡号, CAST(SUM(rt_ship_temp_1.qty)
  33. AS numeric(10, 1)) AS 尺数, CASE WHEN RIGHT(rt_ship_temp_1.card, 1)
  34. = 'F' THEN 'BRF' + substring(rt_ship_temp_1.card, 0, len(rt_ship_temp_1.card)) ELSE '' END AS 卡号1,
  35. CASE WHEN rt_finish_stock.name IS NULL THEN N'杂皮 二层' ELSE rt_finish_stock.name END AS 品名,
  36. CASE WHEN rt_finish_stock.sf IS NULL THEN '' ELSE rt_finish_stock.sf END AS 库存尺数,
  37. CASE WHEN rt_finish_stock.code IS NULL THEN '' ELSE rt_finish_stock.code END AS 编码,
  38. rt_ship_temp_1.color1 AS 颜色, rt_ship_temp_1.date AS 出货日期
  39. FROM rt_ship_temp_1 LEFT OUTER JOIN
  40. rt_finish_stock ON rt_ship_temp_1.card = rt_finish_stock.lot
  41. WHERE (rt_ship_temp_1.date BETWEEN '2024/6/1' AND '2024/6/19')
  42. GROUP BY rt_ship_temp_1.custname, rt_ship_temp_1.card, rt_finish_stock.name, rt_finish_stock.sf, rt_finish_stock.code,
  43. rt_ship_temp_1.color1, rt_ship_temp_1.date
  44. ORDER BY rt_finish_stock.code) AS p LEFT OUTER JOIN
  45. Rt_measure_daily ON p.卡号1 = Rt_measure_daily.card
  46. ORDER BY p.出货日期, p.custname, p.颜色"
  47. cmd.CommandText = sql
  48. da.SelectCommand = cmd
  49. da.Fill(dt)
  50. dgv1.DataSource = dt
  51. dgv1.Columns(1).Width = 120
  52. dgv1.Columns(2).Width = 250
  53. dgv1.Columns(4).Width = 145
  54. Set_grid_color()
  55. End Sub
  56. Private Sub dgv1_CellPainting(sender As Object, e As DataGridViewCellPaintingEventArgs) Handles dgv1.CellPainting
  57. If e.ColumnIndex <> 0 And e.RowIndex <> -1 Then
  58. Dim Brush As SolidBrush
  59. Dim backcolorBrush As SolidBrush
  60. End If
  61. End Sub
  62. Private Sub Set_grid_color()
  63. Dim c As Integer = 1
  64. Dim p(1000) As Integer
  65. Dim x As Integer
  66. p(1) = 0
  67. For x = 1 To dgv1.Rows.Count - 2
  68. If dgv1.Rows(x).Cells(4).Value.ToString <> dgv1.Rows(x - 1).Cells(4).Value.ToString Then
  69. p(c + 1) = x
  70. c = c + 1
  71. End If
  72. Next
  73. p(c + 1) = x
  74. ReDim Preserve p(x)
  75. If c = 1 Then
  76. For z As Integer = 0 To x - 1
  77. dgv1.Rows(z).DefaultCellStyle.BackColor = colorArray(1)
  78. Next
  79. Else
  80. For cc As Integer = 1 To c
  81. For z As Integer = p(cc) To p(cc + 1) - 1
  82. dgv1.Rows(z).DefaultCellStyle.BackColor = colorArray(cc Mod 3)
  83. Next
  84. Next
  85. End If
  86. End Sub
  87. End Class