/
ivan
/
ModMas
Обзор
Документация
Войти
/
ivan
/
ModMas
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
ModuleMaster/usercontrols/gridstatuscontrol.ascx.vb
122 строки
5 KB
i.krivokon
Initial commit
13 мар 2026, 13:49
13 мар 2026, 13:49
00d9fb6
Код
Авторство
О чём код?
Partial Class UserControls_gridStatusControl Inherits System.Web.UI.UserControl Public Property ToolTip As String Set(ByVal value As String) imgIco.ToolTip = value End Set Get Return imgIco.ToolTip End Get End Property Public Property ImageUrl As String Set(ByVal value As String) imgIco.ImageUrl = value End Set Get Return imgIco.ImageUrl End Get End Property Dim ControlExpression_ As String Public Property ControlExpression As String Set(value As String) ControlExpression_ = value.Trim End Set Get Return ControlExpression_ End Get End Property Public Sub DrawStatus() Try If ControlExpression <> "" Then Dim params() As String = ControlExpression.Split("|") If params.Count = 3 Then TwoWayIndicator(params) ElseIf params.Count = 4 Then Dim conditionParams() As String = params(0).Split(";") If conditionParams.Count = 2 Then Dim expr() As String = conditionParams(0).Split(" ") Dim result As Boolean = CalculateExpression(expr(0), expr(1), expr(2)) If result Then imgIco.ImageUrl = Request.Url.GetLeftPart(UriPartial.Authority) & _ Request.ApplicationPath & "/Images/SAP/" & params(1) & ".png" 'imgIco.ImageUrl = "http://serkweb.serk.lan:8080/ModuleMaster/Images/SAP/" & truePart & ".png" Else expr = conditionParams(1).Split(" ") result = CalculateExpression(expr(0), expr(1), expr(2)) If result Then imgIco.ImageUrl = Request.Url.GetLeftPart(UriPartial.Authority) & _ Request.ApplicationPath & "/Images/SAP/" & params(2) & ".png" 'imgIco.ImageUrl = "http://serkweb.serk.lan:8080/ModuleMaster/Images/SAP/" & truePart & ".png" Else imgIco.ImageUrl = Request.Url.GetLeftPart(UriPartial.Authority) & _ Request.ApplicationPath & "/Images/SAP/" & params(3) & ".png" 'imgIco.ImageUrl = "http://serkweb.serk.lan:8080/ModuleMaster/Images/SAP/" & falsepart & ".png" End If End If Else TwoWayIndicator(params) End If End If Else imgIco.ImageUrl = Request.Url.GetLeftPart(UriPartial.Authority) & _ Request.ApplicationPath & "/Images/redcross.png" End If Catch ex As Exception imgIco.ImageUrl = Request.Url.GetLeftPart(UriPartial.Authority) & _ Request.ApplicationPath & "/Images/redcross.png" End Try End Sub Private Sub TwoWayIndicator(params() As String) Dim expr() As String = params(0).Split(" ") Dim truePart As String = params(1).ToUpper Dim falsepart As String = params(2).ToUpper If expr.Count = 3 Then Dim result As Boolean = CalculateExpression(expr(0), expr(1), expr(2)) If result Then imgIco.ImageUrl = Request.Url.GetLeftPart(UriPartial.Authority) & _ Request.ApplicationPath & "/Images/SAP/" & truePart & ".png" 'imgIco.ImageUrl = "http://serkweb.serk.lan:8080/ModuleMaster/Images/SAP/" & truePart & ".png" Else imgIco.ImageUrl = Request.Url.GetLeftPart(UriPartial.Authority) & _ Request.ApplicationPath & "/Images/SAP/" & falsepart & ".png" 'imgIco.ImageUrl = "http://serkweb.serk.lan:8080/ModuleMaster/Images/SAP/" & falsepart & ".png" End If End If End Sub Private Function CalculateExpression(first As String, expressionOperator As String, second As String) As Boolean Dim result As Boolean Try Dim firstOperand As Decimal = Convert.ToDecimal(first) Dim secondOperand As Decimal = Convert.ToDecimal(second) Select Case expressionOperator Case ">" : result = firstOperand > secondOperand Case "<" : result = firstOperand < secondOperand Case "=" : result = firstOperand = secondOperand Case "<>", "><" : result = firstOperand <> secondOperand End Select Catch ex As Exception Dim firstOperand As String = first Dim secondOperand As String = second Select Case expressionOperator Case ">" : result = (firstOperand > secondOperand) Case "<" : result = (firstOperand < secondOperand) Case "=" : result = (firstOperand = secondOperand) Case "<>", "><" : result = (firstOperand <> secondOperand) End Select End Try Return result End Function Protected Sub Page_PreRender(sender As Object, e As System.EventArgs) Handles Me.PreRender End Sub End Class