/
ivan
/
ModMas
Обзор
Документация
Войти
/
ivan
/
ModMas
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
ModuleMaster/mach/machdetails.aspx.vb
271 строка
12 KB
i.krivokon
Initial commit
13 мар 2026, 13:49
13 мар 2026, 13:49
00d9fb6
Код
Авторство
О чём код?
Imports sharedClasses.Auth Imports sharedClasses.dbFunctions Imports System.Data Imports System.Data.SqlClient Partial Class mach_machDetails Inherits System.Web.UI.Page Private sqlf As New SqlFunctions Private a As sharedClasses.Auth.auth Private projectid As String Private processType As String Private Function getApprovalLine(_projectId As String, _processtype As String) As DataTable Return sqlf.GetData("SELECT process_type as [Process], step_seq as [No.], step_type as [Type], single_id as [Single ID], confirmation as [Decision]" & _ ", confirmation_datetime as [Approved Date/Time], comments as [Comments], active_step, Approval_ID " & _ "FROM UserModules.[user].mach_approval where table_name = 'MACH_APPROVAL' and row_id='" & _projectId & _ "' ORDER BY id") End Function Private Function getProjectDetails(projectID As String) As DataTable Return sqlf.GetData("SELECT * FROM UserModules.[user].mach WHERE id = " & projectID) End Function Private Sub buildDetails(data As DataTable) If Not IsNothing(data) Then If data.Rows.Count > 0 Then Dim dr As DataRow = data.Rows(0) Try lblProjectName.Text = dr("name") Catch ex As Exception End Try Try lblSerkGroup.Text = dr("serk_group") Catch ex As Exception End Try Try lblDepartment.Text = dr("department") Catch ex As Exception End Try Try lblProjectLeader.Text = dr("leader") Catch ex As Exception End Try Try lblProjectTeam.Text = dr("pic") Catch ex As Exception End Try Try lblMachCategory.Text = dr("mach_category") Catch ex As Exception End Try Try lblFinance.Text = dr("finance_y_n") Catch ex As Exception End Try Try lblCostType.Text = dr("cost_type") Catch ex As Exception End Try Try lblAmount.Text = dr("amount") Catch ex As Exception End Try Try lblFormula.Text = dr("calculation_formula") Catch ex As Exception End Try Try lblStart.Text = dr("start") Catch ex As Exception End Try Try lblEnd.Text = dr("end") Catch ex As Exception End Try Try lblasis.Text = dr("asnois") Catch ex As Exception End Try Try lbltobe.Text = dr("tonobe") Catch ex As Exception End Try Else projectDetails.visible = False lblDeleted.visible = True End If End If End Sub Private Sub linkFiles(projectid As String) Dim pictureid As String = sqlf.GetScalar("SELECT top 1 id FROM UserModulesAttachments.[user].mach WHERE parentid = " & projectid & " and type='PICTURES' AND DELETED='N'") If pictureid <> "" Then imgPicture.ImageUrl = "http://" & HttpContext.Current.Request.Url.Authority & HttpContext.Current.Request.ApplicationPath & "/handlers/getfile.ashx?id=" & pictureid & "&storage=[UserModulesAttachments].[user].[MACH]" End If Dim dr As DataRow = sqlf.GetRow("SELECT top 1 id, name FROM UserModulesAttachments.[user].mach WHERE parentid = " & projectid & " and type='PRESENTATION' AND DELETED='N'") If Not IsNothing(dr) Then hlFiles.Text = dr("name") hlFiles.NavigateUrl = "http://" & HttpContext.Current.Request.Url.Authority & HttpContext.Current.Request.ApplicationPath & "/handlers/getfile.ashx?id=" & dr("id") & "&storage=[UserModulesAttachments].[user].[MACH]" End If End Sub Private Sub SaveDecision(sender As Object, e As EventArgs) Handles btnSave.Click Dim com As New SqlCommand With com.Parameters .AddWithValue("approval_id", approval_id.Value) .AddWithValue("project_id", projectid) End With com.CommandText = "SELECT * FROM UserModules.[user].mach_approval WHERE table_name = 'MACH_APPROVAL' " & _ "and row_id=@project_id and active_step='Y' and approval_id=@approval_id" Dim currentApprover As DataRow = sqlf.GetRow(com) 'and single_id='" & a.userId & "'") Dim lastStepNumber As Integer = sqlf.GetScalar("SELECT max(step_seq) FROM UserModules.[user].mach_approval WHERE approval_id='" & currentApprover("approval_id") & "'") ' and single_id='" & a.userId & "'") Dim currentStepSeq As Integer = 0 Try currentStepSeq = currentApprover("step_seq") Dim decision As String = rbDecicion.SelectedItem.Value.ToUpper Dim sql As New StringBuilder sql.AppendLine("UPDATE UserModules.[user].mach_approval SET confirmation=@decision ") sql.AppendLine(", CONFIRMATION_DATETIME=convert(varchar, getdate(),120) ") sql.AppendLine(", comments=@approvalComments") 'If decision = "APPROVE" Then sql.AppendLine(", ACTIVE_STEP = 'N' ") 'End If 'sql.AppendLine("WHERE table_name = 'MACH_APPROVAL' and process_type = @processType and row_id=@projectId and single_id=@userId and active_step='Y'") sql.AppendLine("WHERE approval_id='" & currentApprover("approval_id") & "' and active_step='Y' and (single_id = '" & a.userId & "' or (single_id='I.KRIVOKON' and ('" & a.userId & "'= 'EKATERINA.KH' or '" & a.userId & "'= 'M.GOLTSMAN')))") com.Parameters.Clear() com.CommandText = sql.ToString With com.Parameters .AddWithValue("decision", decision) .AddWithValue("approvalComments", txtApprovalComments.Text) .AddWithValue("projectId", projectid) .AddWithValue("userid", a.userId) End With sqlf.NonQuery(com) If currentStepSeq = 1 Then If currentApprover("PROCESS_TYPE") = "REGISTER_SUBMIT" Then com.CommandText = "UPDATE UserModules.[user].mach SET VALIDATION_RESULT = @decision, validation_comments = @approvalComments " If (decision <> "REJECT") Then com.CommandText &= ", MANAGER_REGISTER_APPROVE='PENDING' " End If com.CommandText &= " WHERE id=" & projectid sqlf.NonQuery(com) ElseIf currentApprover("PROCESS_TYPE") = "FINISH_SUBMIT" Then com.CommandText = "UPDATE UserModules.[user].mach SET VERIFICATION_RESULT = @decision, VERIFICATION_COMMENTS = @approvalComments" If (decision <> "REJECT") Then com.CommandText &= ", MANAGER_COMPLETE_APPROVE='PENDING' " End If com.CommandText &= " WHERE id=" & projectid sqlf.NonQuery(com) End If ElseIf (currentStepSeq = lastStepNumber) Then If currentApprover("PROCESS_TYPE") = "REGISTER_SUBMIT" Then com.CommandText = "UPDATE UserModules.[user].mach SET MANAGER_REGISTER_APPROVE = @decision, " & _ "REGISTER_COMMENTS = @approvalComments WHERE id=" & projectid sqlf.NonQuery(com) ElseIf currentApprover("PROCESS_TYPE") = "FINISH_SUBMIT" Then com.CommandText = "UPDATE UserModules.[user].mach SET MANAGER_COMPLETE_APPROVE = @decision, " & _ "COMPLETE_COMMENTS = @approvalComments WHERE id=" & projectid sqlf.NonQuery(com) End If End If If (currentStepSeq = lastStepNumber) Or (decision = "REJECT") Then sqlf.NonQuery("UPDATE UserModules.[user].mach_approval SET APPROVAL_FINISHED='Y' WHERE approval_id='" & currentApprover("approval_id") & "'") End If If (currentStepSeq <> lastStepNumber) And (decision = "APPROVE") Then sql.Clear() sql.AppendLine("UPDATE UserModules.[user].mach_approval SET ACTIVE_STEP = 'Y' ") sql.AppendLine("WHERE approval_id='" & currentApprover("approval_id") & "' and step_seq = " & (currentStepSeq + 1)) com.CommandText = sql.ToString sqlf.NonQuery(com) End If approvalLine.DataSource = getApprovalLine(projectid, processType) approvalLine.DataBind() Catch ex As Exception End Try End Sub Private mode As String = "" Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load mode = Request.QueryString("mode") If IsNothing(mode) Then mode = "" Else mode = mode.ToUpper End If phConfirmation.Visible = False a = New sharedClasses.Auth.auth("SSO", IIf(Request.UserHostAddress = "::1", "106.109.72.69", Request.UserHostAddress)) projectid = Request.QueryString("projectid") processType = Request.QueryString("processtype") If Not IsNothing(projectid) Then approvalLine.DataSource = getApprovalLine(projectid, processType) approvalLine.DataBind() buildDetails(getProjectDetails(projectid)) linkFiles(projectid) End If imgHeader.ImageUrl = "http://" & HttpContext.Current.Request.Url.Authority & HttpContext.Current.Request.ApplicationPath & "/Images/MACH.JPG" End Sub Protected Sub Page_PreRender(sender As Object, e As EventArgs) Handles Me.PreRender If mode.ToUpper = "view" Then phConfirmation.Visible = False End If End Sub Protected Sub approvalLine_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles approvalLine.RowDataBound With e.Row If .RowType = DataControlRowType.Header Then .Cells(7).Text = "" ElseIf .RowType = DataControlRowType.DataRow Then If mode = "VIEW" Then If (.Cells(7).Text = "Y") Then .Cells(4).Text = "PENDING" Dim hl As New HyperLink hl.NavigateUrl = "http://" & HttpContext.Current.Request.Url.Authority & HttpContext.Current.Request.ApplicationPath & "/mach/machdetails.aspx?projectid=" & projectid hl.Text = "GO TO APPROVAL" hl.Target = "_blank" .Cells(7).Controls.Add(hl) Else .Cells(7).Text = "" End If Else If (.Cells(7).Text = "Y") And (.Cells(3).Text.ToUpper = a.userId.ToUpper _ Or a.userId.ToUpper = "EKATERINA.KH" _ Or a.userId.ToUpper = "M.GOLTSMAN") Then phConfirmation.Visible = True Dim img1 As New Image With {.ImageUrl = "http://" & HttpContext.Current.Request.Url.Authority & HttpContext.Current.Request.ApplicationPath & "/Images/ok.png", .CssClass = "click", .ToolTip = "Make decision", .ID = "decide"} img1.Attributes.Add("approval_id", .Cells(8).Text) img1.ClientIDMode = UI.ClientIDMode.Static .Cells(7).Controls.Add(img1) Else .Cells(7).Text = "" End If End If If .Cells(4).Text = "APPROVE" Then .Cells(4).Style.Add("color", "green") ElseIf .Cells(4).Text = "REJECT" Then .Cells(4).Style.Add("color", "red") End If End If .Cells(8).Visible = False End With End Sub End Class