/
ivan
/
ModMas
Обзор
Документация
Войти
/
ivan
/
ModMas
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
ModuleMaster/fi/fifo_mx18.aspx.vb
176 строк
8 KB
i.krivokon
Initial commit
13 мар 2026, 13:49
13 мар 2026, 13:49
00d9fb6
Код
Авторство
О чём код?
Imports System.Data Imports sharedClasses.dbFunctions Partial Class FIFO_MX18 Inherits System.Web.UI.Page Private sqlf As New SqlFunctions Private _firstPageRowCount As Integer = 7 Private _secondPageRowCount As Integer = 25 Private _lastPageRowCount As Integer = 4 Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load docNumber.Text = IIf(IsNothing(Request.QueryString("dn")), "", Request.QueryString("dn")) Dim dt As DataTable = buildList(docNumber.Text) Dim curTbl As HtmlTable = report If Not IsNothing(dt) Then sqlf.NonQuery("UPDATE UserModules.[user].GERP_MB_51_FOR_GTD SET PRINTED_FG='" & DateTime.Now.ToString("yyyyMMddHHmmss") & "' WHERE ID = " & Request.QueryString("dn")) Dim cnt As Integer = 0 'docDate.Text = prodDate.Substring(0, 4) & "-" & prodDate.Substring(4, 2) & "-" & prodDate.Substring(6, 2) ' docNumber.Text = getDocNumber(prodDate) Dim ttl As Integer = 0 Dim subTtl As Integer = 0 Dim gross As Decimal = 0 Dim sgross As Decimal = 0 Dim net As Decimal = 0 Dim snet As Decimal = 0 Dim firstPage As Boolean = True For Each dr As DataRow In dt.Rows docNumber.Text = dr("po") docDate.Text = dr("po_date") If dr("po_date") >= "20140301" Then duty.Text = "начальник цеха" Else duty.Text = "зам начальника цеха" End If Try docDate.Text = docDate.Text.Substring(0, 4) & "-" & docDate.Text.Substring(4, 2) & "-" & docDate.Text.Substring(6, 2) Catch ex As Exception 'Response.Write(ex.Message & "?" & tmp) End Try Dim tr As New HtmlTableRow For Each c As HtmlTableCell In templateRow.Cells Dim tc As New HtmlTableCell tc.InnerHtml = c.InnerHtml.Replace("MODEL", dr("model")) _ .Replace("INCH", dr("inch")) _ .Replace("QTY", dr("qty").ToString.Trim("0").Trim(".")) _ .Replace("GROSS", (dr("GROSS_WEIGHT") * dr("qty")).ToString.Trim("0").Trim(".")) _ .Replace("NET", (dr("NET_WEIGHT") * dr("qty")).ToString.Trim("0").Trim(".")) tc.Attributes("style") = c.Attributes("style") tc.Attributes("colspan") = c.Attributes("colspan") tr.Cells.Add(tc) Next curTbl.Rows.Add(tr) subTtl += dr("qty") ttl += dr("qty") gross += dr("GROSS_WEIGHT") * dr("qty") sgross += dr("GROSS_WEIGHT") * dr("qty") net += dr("NET_WEIGHT") * dr("qty") snet += dr("NET_WEIGHT") * dr("qty") cnt += 1 If (firstPage And ((cnt Mod _firstPageRowCount) = 0)) _ Or ((cnt Mod _secondPageRowCount) = 0) Then firstPage = False Dim ttr As New HtmlTableRow For Each c As HtmlTableCell In templateRowTotalByPage.Cells Dim tc As New HtmlTableCell tc.InnerHtml = c.InnerHtml.Replace("SUBTTL", subTtl) _ .Replace("SGROSS", sgross.ToString.Trim("0").Trim(".")) _ .Replace("SNET", snet.ToString.Trim("0").Trim(".")) tc.Attributes("style") = c.Attributes("style") tc.Attributes("colspan") = c.Attributes("colspan") ttr.Cells.Add(tc) Next curTbl.Rows.Add(ttr) 'Start new page with new table curTbl = New HtmlTable curTbl.Attributes("style") = report.Attributes("Style") curTbl.Style.Add("page-break-before", "always") For r = 0 To 4 Dim th As New HtmlTableRow For Each c As HtmlTableCell In report.Rows(r).Cells Dim hc As New HtmlTableCell With {.InnerHtml = c.InnerHtml} hc.Attributes("style") = c.Attributes("style") hc.Attributes("colspan") = c.Attributes("colspan") hc.Attributes("rowspan") = c.Attributes("rowspan") th.Cells.Add(hc) Next curTbl.Rows.Add(th) Next reportPlace.Controls.Add(curTbl) subTtl = 0 sgross = 0 snet = 0 End If Next 'Adding final total and subtotal rows Dim sttr As New HtmlTableRow For Each c As HtmlTableCell In templateRowTotalByPage.Cells Dim tc As New HtmlTableCell tc.InnerHtml = c.InnerHtml.Replace("SUBTTL", subTtl) _ .Replace("SGROSS", sgross.ToString.Trim("0").Trim(".")) _ .Replace("SNET", snet.ToString.Trim("0").Trim(".")) tc.Attributes("style") = c.Attributes("style") tc.Attributes("colspan") = c.Attributes("colspan") sttr.Cells.Add(tc) Next curTbl.Rows.Add(sttr) Dim fttr As New HtmlTableRow For Each c As HtmlTableCell In templateRowTotal.Cells Dim tc As New HtmlTableCell tc.InnerHtml = c.InnerHtml.Replace("TTL", ttl) _ .Replace("TGROSS", gross.ToString.Trim("0").Trim(".")) _ .Replace("TNET", net.ToString.Trim("0").Trim(".")) tc.Attributes("style") = c.Attributes("style") tc.Attributes("colspan") = c.Attributes("colspan") fttr.Cells.Add(tc) Next curTbl.Rows.Add(fttr) End If End Sub Private Function buildList(documentNumber As String) As DataTable Dim sql As New StringBuilder sql.AppendLine("select ") sql.AppendLine("isnull(FG_MODEL,'NA') as model, isnull(PRODUCTION_ORDER, 'NA') as po, isnull(PRODUCTION_ORDER_DATE,'NA') as po_date, ") sql.AppendLine("MAT__DOC_ + '-' + ITEM as docnumber, ") sql.AppendLine("isnull(substring(FG_MODEL, 3,2),'NA') as inch, ") sql.AppendLine("isnull(PRODUCTION_ORDER_QUANTITY,'NA') as qty, ") sql.AppendLine("isnull((select GROSS_WEIGHT from GMESData.dbo.TB_VWM_BSC_MODEL where MODEL_NUMBER collate Cyrillic_General_CI_AI = t.fg_model collate Cyrillic_General_CI_AI),'NA') as GROSS_WEIGHT, ") sql.AppendLine("isnull((select NET_WEIGHT from GMESData.dbo.TB_VWM_BSC_MODEL where MODEL_NUMBER collate Cyrillic_General_CI_AI = t.fg_model collate Cyrillic_General_CI_AI),'NA') as NET_WEIGHT ") sql.AppendLine("from UserModules.[user].GERP_MB_51_FOR_GTD t ") 'sql.AppendLine("-- MAT__DOC_ = '6053096431' ") sql.AppendLine("where id = " & documentNumber) Return sqlf.GetData(sql.ToString) End Function 'Private Function getDocNumber(prodDate As String) As String ' If prodDate <> "" Then ' Dim sql As New StringBuilder ' sql.AppendLine("SELECT po_number FROM OPENQUERY(GMES20, '") ' sql.AppendLine("SELECT max(po_number) as po_number ") ' sql.AppendLine("FROM VWS_QMS_MDL_PROD p ") ' sql.AppendLine("where p.work_date = ''" & prodDate & "'' ") ' sql.AppendLine("and p.sect = ''P001'' ") ' sql.AppendLine("and p.route_code = ''7160'' ')") ' Return sqlf.GetScalar(sql.ToString) ' Else ' Return "" ' End If 'End Function End Class