Geen omschrijving
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Frm_PU_WORK.vb 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751
  1. Imports System.Data.SqlClient
  2. Public Class Frm_PU_WORK
  3. Dim cmd As New SqlCommand
  4. Dim da As New SqlDataAdapter
  5. Dim dt As New DataTable
  6. Dim sql As String
  7. Private Sub Frm_PU_WORK_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  8. Dim conn As New SqlConnection
  9. 'connstring = "Data Source=127.0.0.1;Persist Security Info=True;User ID=sa;Password=Lafayette11;Initial Catalog=maindb_hy2014"
  10. conn.ConnectionString = connstring
  11. conn.Open()
  12. cmd.Connection = conn
  13. End Sub
  14. Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
  15. sql = "SELECT date AS 日期, cust AS 客户, thick AS 厚度, pattern AS 纹路, qty AS 上机数量, spec AS 大小, qly AS 粗细, color AS 颜色,
  16. color1 AS 颜色1, code AS 代码, comment AS 中检卡号, spec4 AS 规格, price AS 单价, amount AS 金额
  17. FROM RT_PU_WORK WHERE date BETWEEN '" & String.Format("{0:d}", dtp_begin.Value) & "' and '" & String.Format("{0:d}", dtp_end.Value) & "' ORDER BY 日期"
  18. cmd.CommandText = sql
  19. da.SelectCommand = cmd
  20. da.Fill(dt)
  21. dgv1.DataSource = dt
  22. sql = "select sum(qty) from RT_PU_WORK WHERE date BETWEEN '" & String.Format("{0:d}", dtp_begin.Value) & "' and '" & String.Format("{0:d}", dtp_end.Value) & "'"
  23. cmd.CommandText = sql
  24. Label5.Text = cmd.ExecuteScalar
  25. End Sub
  26. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  27. Dim aa As String
  28. Dim bb As String
  29. Dim my_card As String = ""
  30. Dim my_date As Date
  31. aa = TextBox8.Text
  32. bb = aa
  33. If aa = "" Then
  34. MsgBox("请输入起始单号")
  35. Exit Sub
  36. End If
  37. Dim xlApp As Microsoft.Office.Interop.Excel.Application
  38. Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
  39. Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet
  40. Dim xlSheet2 As Microsoft.Office.Interop.Excel.Worksheet
  41. Dim file_name As String = ""
  42. Dim file_name1 As String = ""
  43. Dim my_weight As Double = 0
  44. Dim a As Integer = 0
  45. Dim my_count As Integer = 0
  46. Dim my_x As Integer = 0
  47. xlApp = CreateObject("Excel.Application")
  48. xlApp.Visible = True
  49. xlApp.DisplayAlerts = False
  50. xlBook = xlApp.Workbooks.Open("D:\K3\k3表格模板\PU主机入库.xls",, True)
  51. xlBook.Activate()
  52. Dim dt2 As New DataTable
  53. For i = 1 To xlApp.Worksheets.Count
  54. If xlApp.Workbooks(1).Worksheets(i).name = "Page1" Then
  55. xlSheet = xlApp.Workbooks(1).Worksheets(i)
  56. xlSheet.Activate()
  57. Exit For
  58. End If
  59. Next
  60. Dim my_no As String = "CPRK0"
  61. Dim yy As Integer = 1
  62. Dim x As Integer = 0
  63. 'sql = "" ''----下鼓
  64. 'Dim dt_out As DataTable
  65. 'cmd.CommandText = sql
  66. 'dt_out = New DataTable
  67. 'da.SelectCommand = cmd
  68. 'da.Fill(dt_out)
  69. Dim my_total_no As Integer = 0
  70. Dim dt_retan As New DataTable
  71. sql = "SELECT date FROM RT_pu_work
  72. WHERE date BETWEEN '" & String.Format("{0:d}", dtp_begin.Value) & "' and '" & String.Format("{0:d}", dtp_end.Value) & "' group by date"
  73. cmd.CommandText = sql
  74. da.SelectCommand = cmd
  75. da.Fill(dt_retan)
  76. For x = 0 To dt_retan.Rows.Count - 1 '-----------loop
  77. xlSheet.Cells(x + 2, 1) = String.Format("{0:d}", dt_retan.Rows(x).Item("date"))
  78. xlSheet.Cells(x + 2, 2) = String.Format("{0:d}", dt_retan.Rows(x).Item("date"))
  79. xlSheet.Cells(x + 2, 3) = "'戴燕卿"
  80. xlSheet.Cells(x + 2, 4) = "'" & my_no & bb
  81. xlSheet.Cells(x + 2, 5) = "'zhang"
  82. xlSheet.Cells(x + 2, 6) = "'1"
  83. xlSheet.Cells(x + 2, 7) = "'2"
  84. xlSheet.Cells(x + 2, 8) = "'165701"
  85. xlSheet.Cells(x + 2, 9) = "'651P-R"
  86. xlSheet.Cells(x + 2, 10) = "'中检、量尺-R"
  87. xlSheet.Cells(x + 2, 11) = "'124"
  88. xlSheet.Cells(x + 2, 12) = "'戴燕卿"
  89. xlSheet.Cells(x + 2, 13) = "'124"
  90. xlSheet.Cells(x + 2, 14) = "'戴燕卿"
  91. xlSheet.Cells(x + 2, 15) = "'85"
  92. For i = 1 To xlApp.Worksheets.Count
  93. If xlApp.Workbooks(1).Worksheets(i).name = "Page2" Then
  94. xlSheet2 = xlApp.Workbooks(1).Worksheets(i)
  95. xlSheet2.Activate()
  96. Exit For
  97. End If
  98. Next
  99. sql = "SELECT date AS 日期, cust AS 客户, thick AS 厚度, pattern AS 纹路, qty AS 上机数量, spec AS 大小, qly AS 粗细, color AS 颜色,
  100. color1 AS 颜色1, code AS 代码, comment AS 中检卡号, spec4 AS 规格, price AS 单价, amount AS 金额
  101. FROM RT_PU_WORK WHERE date = '" & dt_retan.Rows(x).Item("date") & "' ORDER BY 日期,客户,纹路,颜色,上机数量"
  102. sql = "SELECT RT_PU_WORK.date AS 日期, RT_PU_WORK.cust AS 客户, RT_PU_WORK.thick AS 厚度, RT_PU_WORK.pattern AS 纹路,
  103. RT_PU_WORK.qty AS 上机数量, RT_PU_WORK.spec AS 大小, RT_PU_WORK.qly AS 粗细, RT_PU_WORK.color AS 颜色,
  104. RT_PU_WORK.color1 AS 颜色1, RT_PU_WORK.code AS 代码, RT_PU_WORK.comment AS 中检卡号,
  105. RT_PU_WORK.spec4 AS 规格, RT_PU_WORK.price AS 单价, RT_PU_WORK.amount AS 金额, rt_pu_code.thick as thick
  106. FROM RT_PU_WORK LEFT OUTER JOIN
  107. rt_pu_code ON RT_PU_WORK.code = rt_pu_code.code WHERE date = '" & dt_retan.Rows(x).Item("date") & "' ORDER BY 日期,客户,纹路,颜色,上机数量 "
  108. dt2 = New DataTable
  109. cmd.CommandText = sql
  110. da.SelectCommand = cmd
  111. da.Fill(dt2)
  112. Dim serial As Integer = 1
  113. For y = 0 To dt2.Rows.Count - 1
  114. xlSheet2.Cells(yy + 1 + y, 2) = "'" & serial '行号
  115. xlSheet2.Cells(yy + 1 + y, 3) = "'" & my_no & bb
  116. xlSheet2.Cells(yy + 1 + y, 5) = dt2.Rows(y).Item("代码")
  117. xlSheet2.Cells(yy + 1 + y, 6) = dt2.Rows(y).Item("thick")
  118. xlSheet2.Cells(yy + 1 + y, 15) = dt2.Rows(y).Item("单价")
  119. xlSheet2.Cells(yy + 1 + y, 14) = dt2.Rows(y).Item("上机数量")
  120. xlSheet2.Cells(yy + 1 + y, 16) = dt2.Rows(y).Item("上机数量") * dt2.Rows(y).Item("单价")
  121. ' xlSheet2.Cells(yy + 1 + y, 17) = "112 " & dt2.Rows(y).Item("皮源1") '批号
  122. xlSheet2.Cells(yy + 1 + y, 18) = dt2.Rows(y).Item("规格") '备注
  123. xlSheet2.Cells(yy + 1 + y, 22) = dt2.Rows(y).Item("日期")
  124. xlSheet2.Cells(yy + 1 + y, 25) = "'215B-R"
  125. xlSheet2.Cells(yy + 1 + y, 26) = "'主机、燥干/赤湖"
  126. 'xlSheet.Cells(x + 2, 9) = "'607-R"
  127. ' xlSheet.Cells(x + 2, 10) = "'挑选等级-R"
  128. xlSheet2.Cells(yy + 1 + y, 38) = dt2.Rows(y).Item("客户")
  129. 'xlSheet2.Cells(yy + 1 + y, 39) = "'" & dt2.Rows(y).Item("客户")
  130. ' xlSheet2.Cells(yy + 1 + y, 40) = dt2.Rows(y).Item("技术员")
  131. ' xlSheet2.Cells(yy + 1 + y, 41) = dt2.Rows(y).Item("中检卡号")
  132. xlSheet2.Cells(yy + 1 + y, 42) = dt2.Rows(y).Item("颜色")
  133. xlSheet2.Cells(yy + 1 + y, 43) = dt2.Rows(y).Item("厚度")
  134. xlSheet2.Cells(yy + 1 + y, 44) = dt2.Rows(y).Item("中检卡号")
  135. xlSheet2.Cells(yy + 1 + y, 45) = dt2.Rows(y).Item("粗细")
  136. ' xlSheet2.Cells(yy + 1 + y, 46) = dt2.Rows(y).Item("化工成本")
  137. xlSheet2.Cells(yy + 1 + y, 47) = dt2.Rows(y).Item("颜色1")
  138. xlSheet2.Cells(yy + 1 + y, 49) = dt2.Rows(y).Item("纹路")
  139. xlSheet2.Cells(yy + 1 + y, 49) = dt2.Rows(y).Item("大小")
  140. my_total_no = yy + 1 + y
  141. serial = serial + 1
  142. Next
  143. yy = yy + dt2.Rows.Count
  144. aa = aa + 1
  145. my_x = my_x + 1
  146. bb = bb + 1
  147. Next
  148. xlSheet2.Range("A2:A" & xlSheet2.UsedRange.Rows.Count).FillDown()
  149. 'xlSheet2.Range("B2:B" & x + 1).FillDown()
  150. xlSheet2.Range("D2:D" & xlSheet2.UsedRange.Rows.Count).FillDown()
  151. xlSheet2.Range("I2:I" & xlSheet2.UsedRange.Rows.Count).FillDown()
  152. xlSheet2.Range("J2:J" & xlSheet2.UsedRange.Rows.Count).FillDown()
  153. xlSheet2.Range("L2:L" & xlSheet2.UsedRange.Rows.Count).FillDown()
  154. xlSheet2.Range("M2:M" & xlSheet2.UsedRange.Rows.Count).FillDown()
  155. 'xlSheet2.Range("O2:O" & x + 1).FillDown()
  156. 'xlSheet2.Range("P2:P" & x + 1).FillDown()
  157. MsgBox("")
  158. End Sub
  159. Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  160. Dim aa As String
  161. Dim bb As String
  162. Dim my_card As String = ""
  163. Dim my_date As Date
  164. aa = TextBox1.Text
  165. bb = aa
  166. If aa = "" Then
  167. MsgBox("请输入起始单号")
  168. Exit Sub
  169. End If
  170. Dim xlApp As Microsoft.Office.Interop.Excel.Application
  171. Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
  172. Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet
  173. Dim xlSheet2 As Microsoft.Office.Interop.Excel.Worksheet
  174. Dim file_name As String = ""
  175. Dim file_name1 As String = ""
  176. Dim my_weight As Double = 0
  177. Dim a As Integer = 0
  178. Dim my_count As Integer = 0
  179. Dim my_x As Integer = 0
  180. xlApp = CreateObject("Excel.Application")
  181. xlApp.Visible = True
  182. xlApp.DisplayAlerts = False
  183. xlBook = xlApp.Workbooks.Open("D:\K3\k3表格模板\PU主机出库.xls",, True)
  184. xlBook.Activate()
  185. Dim dt2 As New DataTable
  186. For i = 1 To xlApp.Worksheets.Count
  187. If xlApp.Workbooks(1).Worksheets(i).name = "Page1" Then
  188. xlSheet = xlApp.Workbooks(1).Worksheets(i)
  189. xlSheet.Activate()
  190. Exit For
  191. End If
  192. Next
  193. Dim my_no As String = "SCLL0"
  194. Dim yy As Integer = 1
  195. Dim x As Integer = 0
  196. 'sql = "" ''----下鼓
  197. 'Dim dt_out As DataTable
  198. 'cmd.CommandText = sql
  199. 'dt_out = New DataTable
  200. 'da.SelectCommand = cmd
  201. 'da.Fill(dt_out)
  202. Dim my_total_no As Integer = 0
  203. Dim dt_retan As New DataTable
  204. sql = "SELECT date FROM RT_pu_work
  205. WHERE date BETWEEN '" & String.Format("{0:d}", dtp_begin.Value) & "' and '" & String.Format("{0:d}", dtp_end.Value) & "' group by date"
  206. cmd.CommandText = sql
  207. da.SelectCommand = cmd
  208. da.Fill(dt_retan)
  209. For x = 0 To dt_retan.Rows.Count - 1 '-----------loop
  210. xlSheet.Cells(x + 2, 1) = String.Format("{0:d}", dt_retan.Rows(x).Item("date"))
  211. xlSheet.Cells(x + 2, 2) = String.Format("{0:d}", dt_retan.Rows(x).Item("date"))
  212. xlSheet.Cells(x + 2, 3) = "'戴燕卿"
  213. xlSheet.Cells(x + 2, 4) = "'" & my_no & bb
  214. xlSheet.Cells(x + 2, 5) = "'zhang"
  215. xlSheet.Cells(x + 2, 6) = "'1"
  216. xlSheet.Cells(x + 2, 7) = "'2"
  217. xlSheet.Cells(x + 2, 8) = "'165701"
  218. xlSheet.Cells(x + 2, 9) = "'655P-R"
  219. xlSheet.Cells(x + 2, 10) = "'修剪、成检、量尺、包装-R"
  220. xlSheet.Cells(x + 2, 12) = "'124"
  221. xlSheet.Cells(x + 2, 13) = "'戴燕卿"
  222. xlSheet.Cells(x + 2, 14) = "'124"
  223. xlSheet.Cells(x + 2, 15) = "'戴燕卿"
  224. ' xlSheet.Cells(x + 2, 16) = "'85"
  225. xlSheet.Cells(x + 2, 18) = "'YBLL"
  226. xlSheet.Cells(x + 2, 19) = "'一般领料"
  227. xlSheet.Cells(x + 2, 20) = "'471"
  228. xlSheet.Cells(x + 2, 21) = "'85"
  229. For i = 1 To xlApp.Worksheets.Count
  230. If xlApp.Workbooks(1).Worksheets(i).name = "Page2" Then
  231. xlSheet2 = xlApp.Workbooks(1).Worksheets(i)
  232. xlSheet2.Activate()
  233. Exit For
  234. End If
  235. Next
  236. sql = "SELECT RT_PU_WORK.date AS 日期, RT_PU_WORK.cust AS 客户, RT_PU_WORK.thick AS 厚度, RT_PU_WORK.pattern AS 纹路,
  237. RT_PU_WORK.qty AS 上机数量, RT_PU_WORK.spec AS 大小, RT_PU_WORK.qly AS 粗细, RT_PU_WORK.color AS 颜色,
  238. RT_PU_WORK.color1 AS 颜色1, RT_PU_WORK.code AS 代码, RT_PU_WORK.comment AS 中检卡号,
  239. RT_PU_WORK.spec4 AS 规格, RT_PU_WORK.price AS 单价, RT_PU_WORK.amount AS 金额, rt_pu_code.thick as thick
  240. FROM RT_PU_WORK LEFT OUTER JOIN
  241. rt_pu_code ON RT_PU_WORK.code = rt_pu_code.code WHERE date = '" & dt_retan.Rows(x).Item("date") & "' ORDER BY 日期,客户,纹路,颜色,上机数量 "
  242. dt2 = New DataTable
  243. cmd.CommandText = sql
  244. da.SelectCommand = cmd
  245. da.Fill(dt2)
  246. Dim serial As Integer = 1
  247. For y = 0 To dt2.Rows.Count - 1
  248. xlSheet2.Cells(yy + 1 + y, 2) = "'" & serial '行号
  249. xlSheet2.Cells(yy + 1 + y, 3) = "'" & my_no & bb
  250. xlSheet2.Cells(yy + 1 + y, 6) = dt2.Rows(y).Item("代码")
  251. xlSheet2.Cells(yy + 1 + y, 7) = dt2.Rows(y).Item("thick")
  252. ' xlSheet2.Cells(yy + 1 + y, 15) = dt2.Rows(y).Item("单价")
  253. xlSheet2.Cells(yy + 1 + y, 24) = dt2.Rows(y).Item("上机数量")
  254. ' xlSheet2.Cells(yy + 1 + y, 16) = dt2.Rows(y).Item("上机数量") * dt2.Rows(y).Item("单价")
  255. ' xlSheet2.Cells(yy + 1 + y, 17) = "112 " & dt2.Rows(y).Item("皮源1") '批号
  256. xlSheet2.Cells(yy + 1 + y, 54) = dt2.Rows(y).Item("规格") '备注
  257. xlSheet2.Cells(yy + 1 + y, 32) = dt2.Rows(y).Item("日期")
  258. xlSheet2.Cells(yy + 1 + y, 35) = "'215B-R"
  259. xlSheet2.Cells(yy + 1 + y, 36) = "'主机、燥干/赤湖"
  260. 'xlSheet.Cells(x + 2, 9) = "'607-R"
  261. ' xlSheet.Cells(x + 2, 10) = "'挑选等级-R"
  262. xlSheet2.Cells(yy + 1 + y, 52) = dt2.Rows(y).Item("客户")
  263. 'xlSheet2.Cells(yy + 1 + y, 39) = "'" & dt2.Rows(y).Item("客户")
  264. ' xlSheet2.Cells(yy + 1 + y, 40) = dt2.Rows(y).Item("技术员")
  265. ' xlSheet2.Cells(yy + 1 + y, 41) = dt2.Rows(y).Item("中检卡号")
  266. xlSheet2.Cells(yy + 1 + y, 56) = dt2.Rows(y).Item("颜色")
  267. xlSheet2.Cells(yy + 1 + y, 57) = dt2.Rows(y).Item("厚度")
  268. xlSheet2.Cells(yy + 1 + y, 54) = dt2.Rows(y).Item("中检卡号")
  269. xlSheet2.Cells(yy + 1 + y, 61) = dt2.Rows(y).Item("粗细")
  270. ' xlSheet2.Cells(yy + 1 + y, 46) = dt2.Rows(y).Item("化工成本")
  271. xlSheet2.Cells(yy + 1 + y, 53) = dt2.Rows(y).Item("颜色1")
  272. xlSheet2.Cells(yy + 1 + y, 63) = dt2.Rows(y).Item("纹路")
  273. xlSheet2.Cells(yy + 1 + y, 64) = dt2.Rows(y).Item("大小")
  274. my_total_no = yy + 1 + y
  275. serial = serial + 1
  276. Next
  277. yy = yy + dt2.Rows.Count
  278. aa = aa + 1
  279. my_x = my_x + 1
  280. bb = bb + 1
  281. Next
  282. xlSheet2.Range("A2:A" & yy).FillDown()
  283. xlSheet2.Range("D2:D" & yy).FillDown()
  284. xlSheet2.Range("k2:v" & yy).FillDown()
  285. MsgBox("")
  286. End Sub
  287. Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
  288. Dim aa As String
  289. Dim bb As String
  290. Dim my_card As String = ""
  291. Dim my_date As Date
  292. aa = TextBox2.Text
  293. bb = aa
  294. If aa = "" Then
  295. MsgBox("请输入起始单号")
  296. Exit Sub
  297. End If
  298. Dim xlApp As Microsoft.Office.Interop.Excel.Application
  299. Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
  300. Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet
  301. Dim xlSheet2 As Microsoft.Office.Interop.Excel.Worksheet
  302. Dim file_name As String = ""
  303. Dim file_name1 As String = ""
  304. Dim my_weight As Double = 0
  305. Dim a As Integer = 0
  306. Dim my_count As Integer = 0
  307. Dim my_x As Integer = 0
  308. xlApp = CreateObject("Excel.Application")
  309. xlApp.Visible = True
  310. xlApp.DisplayAlerts = False
  311. xlBook = xlApp.Workbooks.Open("D:\K3\k3表格模板\PU主机入库.xls",, True)
  312. xlBook.Activate()
  313. Dim dt2 As New DataTable
  314. For i = 1 To xlApp.Worksheets.Count
  315. If xlApp.Workbooks(1).Worksheets(i).name = "Page1" Then
  316. xlSheet = xlApp.Workbooks(1).Worksheets(i)
  317. xlSheet.Activate()
  318. Exit For
  319. End If
  320. Next
  321. Dim my_no As String = "CPRK0"
  322. Dim yy As Integer = 1
  323. Dim x As Integer = 0
  324. 'sql = "" ''----下鼓
  325. 'Dim dt_out As DataTable
  326. 'cmd.CommandText = sql
  327. 'dt_out = New DataTable
  328. 'da.SelectCommand = cmd
  329. 'da.Fill(dt_out)
  330. Dim my_total_no As Integer = 0
  331. Dim dt_retan As New DataTable
  332. sql = "SELECT date FROM RT_pu_work
  333. WHERE date BETWEEN '" & String.Format("{0:d}", dtp_begin.Value) & "' and '" & String.Format("{0:d}", dtp_end.Value) & "' group by date"
  334. cmd.CommandText = sql
  335. da.SelectCommand = cmd
  336. da.Fill(dt_retan)
  337. For x = 0 To dt_retan.Rows.Count - 1 '-----------loop
  338. xlSheet.Cells(x + 2, 1) = String.Format("{0:d}", dt_retan.Rows(x).Item("date"))
  339. xlSheet.Cells(x + 2, 2) = String.Format("{0:d}", dt_retan.Rows(x).Item("date"))
  340. xlSheet.Cells(x + 2, 3) = "'戴燕卿"
  341. xlSheet.Cells(x + 2, 4) = "'" & my_no & bb
  342. xlSheet.Cells(x + 2, 5) = "'zhang"
  343. xlSheet.Cells(x + 2, 6) = "'1"
  344. xlSheet.Cells(x + 2, 7) = "'2"
  345. xlSheet.Cells(x + 2, 8) = "'165701"
  346. xlSheet.Cells(x + 2, 9) = "'653P-R"
  347. xlSheet.Cells(x + 2, 10) = "'燥干-R"
  348. xlSheet.Cells(x + 2, 11) = "'124"
  349. xlSheet.Cells(x + 2, 12) = "'戴燕卿"
  350. xlSheet.Cells(x + 2, 13) = "'124"
  351. xlSheet.Cells(x + 2, 14) = "'戴燕卿"
  352. xlSheet.Cells(x + 2, 15) = "'85"
  353. For i = 1 To xlApp.Worksheets.Count
  354. If xlApp.Workbooks(1).Worksheets(i).name = "Page2" Then
  355. xlSheet2 = xlApp.Workbooks(1).Worksheets(i)
  356. xlSheet2.Activate()
  357. Exit For
  358. End If
  359. Next
  360. sql = "SELECT RT_PU_WORK.date AS 日期, RT_PU_WORK.cust AS 客户, RT_PU_WORK.thick AS 厚度, RT_PU_WORK.pattern AS 纹路,
  361. RT_PU_WORK.qty AS 上机数量, RT_PU_WORK.spec AS 大小, RT_PU_WORK.qly AS 粗细, RT_PU_WORK.color AS 颜色,
  362. RT_PU_WORK.color1 AS 颜色1, RT_PU_WORK.code AS 代码, RT_PU_WORK.comment AS 中检卡号,
  363. RT_PU_WORK.spec4 AS 规格, RT_PU_WORK.price AS 单价, RT_PU_WORK.amount AS 金额, rt_pu_code.thick as thick
  364. FROM RT_PU_WORK LEFT OUTER JOIN
  365. rt_pu_code ON RT_PU_WORK.code = rt_pu_code.code WHERE date = '" & dt_retan.Rows(x).Item("date") & "' ORDER BY 日期,客户,纹路,颜色,上机数量 "
  366. dt2 = New DataTable
  367. cmd.CommandText = sql
  368. da.SelectCommand = cmd
  369. da.Fill(dt2)
  370. Dim serial As Integer = 1
  371. For y = 0 To dt2.Rows.Count - 1
  372. xlSheet2.Cells(yy + 1 + y, 2) = "'" & serial '行号
  373. xlSheet2.Cells(yy + 1 + y, 3) = "'" & my_no & bb
  374. xlSheet2.Cells(yy + 1 + y, 5) = dt2.Rows(y).Item("代码")
  375. xlSheet2.Cells(yy + 1 + y, 6) = dt2.Rows(y).Item("thick")
  376. ' xlSheet2.Cells(yy + 1 + y, 15) = dt2.Rows(y).Item("单价")
  377. xlSheet2.Cells(yy + 1 + y, 14) = dt2.Rows(y).Item("上机数量")
  378. ' xlSheet2.Cells(yy + 1 + y, 16) = dt2.Rows(y).Item("上机数量") * dt2.Rows(y).Item("单价")
  379. ' xlSheet2.Cells(yy + 1 + y, 17) = "112 " & dt2.Rows(y).Item("皮源1") '批号
  380. xlSheet2.Cells(yy + 1 + y, 18) = dt2.Rows(y).Item("规格") '备注
  381. xlSheet2.Cells(yy + 1 + y, 22) = dt2.Rows(y).Item("日期")
  382. xlSheet2.Cells(yy + 1 + y, 25) = "'517B"
  383. xlSheet2.Cells(yy + 1 + y, 26) = "'PU成品仓"
  384. 'xlSheet.Cells(x + 2, 9) = "'607-R"
  385. ' xlSheet.Cells(x + 2, 10) = "'挑选等级-R"
  386. xlSheet2.Cells(yy + 1 + y, 38) = dt2.Rows(y).Item("客户")
  387. 'xlSheet2.Cells(yy + 1 + y, 39) = "'" & dt2.Rows(y).Item("客户")
  388. ' xlSheet2.Cells(yy + 1 + y, 40) = dt2.Rows(y).Item("技术员")
  389. ' xlSheet2.Cells(yy + 1 + y, 41) = dt2.Rows(y).Item("中检卡号")
  390. xlSheet2.Cells(yy + 1 + y, 42) = dt2.Rows(y).Item("颜色")
  391. xlSheet2.Cells(yy + 1 + y, 43) = dt2.Rows(y).Item("厚度")
  392. xlSheet2.Cells(yy + 1 + y, 44) = dt2.Rows(y).Item("中检卡号")
  393. xlSheet2.Cells(yy + 1 + y, 45) = dt2.Rows(y).Item("粗细")
  394. ' xlSheet2.Cells(yy + 1 + y, 46) = dt2.Rows(y).Item("化工成本")
  395. xlSheet2.Cells(yy + 1 + y, 47) = dt2.Rows(y).Item("颜色1")
  396. xlSheet2.Cells(yy + 1 + y, 49) = dt2.Rows(y).Item("纹路")
  397. xlSheet2.Cells(yy + 1 + y, 49) = dt2.Rows(y).Item("大小")
  398. my_total_no = yy + 1 + y
  399. serial = serial + 1
  400. Next
  401. yy = yy + dt2.Rows.Count
  402. aa = aa + 1
  403. my_x = my_x + 1
  404. bb = bb + 1
  405. Next
  406. xlSheet2.Range("A2:A" & xlSheet2.UsedRange.Rows.Count).FillDown()
  407. 'xlSheet2.Range("B2:B" & x + 1).FillDown()
  408. xlSheet2.Range("D2:D" & xlSheet2.UsedRange.Rows.Count).FillDown()
  409. xlSheet2.Range("I2:I" & xlSheet2.UsedRange.Rows.Count).FillDown()
  410. xlSheet2.Range("J2:J" & xlSheet2.UsedRange.Rows.Count).FillDown()
  411. xlSheet2.Range("L2:L" & xlSheet2.UsedRange.Rows.Count).FillDown()
  412. xlSheet2.Range("M2:M" & xlSheet2.UsedRange.Rows.Count).FillDown()
  413. 'xlSheet2.Range("O2:O" & x + 1).FillDown()
  414. 'xlSheet2.Range("P2:P" & x + 1).FillDown()
  415. MsgBox("")
  416. End Sub
  417. End Class