/
ivan
/
ModMas
Обзор
Документация
Войти
/
ivan
/
ModMas
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
ModuleMaster/innovation/bp/bp.aspx.vb
184 строки
7 KB
i.krivokon
Initial commit
13 мар 2026, 13:49
13 мар 2026, 13:49
00d9fb6
Код
Авторство
О чём код?
Imports System.Data Imports System.Data.SqlClient Imports sharedClasses.dbFunctions Imports sharedClasses.Auth Partial Class swat Inherits System.Web.UI.Page Private sqlf As New SqlFunctions Private votingStatus As DataTable Private userid As String = "" Dim a As sharedClasses.Auth.auth Private Sub authorize(mode As String) a = New sharedClasses.Auth.auth(mode, IIf(Request.UserHostAddress = "::1", "106.109.72.69", Request.UserHostAddress)) End Sub #Region "Page Events" Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load 'If Not IsNothing(Request.QueryString("OrchUserLogin")) Then ' userid = Request.QueryString("OrchUserLogin") 'End If 'If Not IsNothing(Request.QueryString("u")) Then ' userid = Request.QueryString("u") 'End If authorize("SSO") userid = a.userId edTableToView.Message = userid edTableToView.IsReadOnly = True edTableToView.UserName = userid.ToUpper Dim sql As New StringBuilder sql.AppendLine("WITH VOTING as ( ") sql.AppendLine("SELECT ") sql.AppendLine("PROJECT_ID, ") sql.AppendLine("CAST(AVG(cast(EFF_AMT__PROJECT____CREATIVITY__IDEA___MAX_4_ as decimal(18,4))) as decimal (18,2)) as score1, ") sql.AppendLine("CAST(AVG(cast(INNOVATION__PROJECT____POTENTIAL__IDEA___MAX_4_ as decimal(18,4))) as decimal (18,2)) as score2, ") sql.AppendLine("CAST(AVG(cast(IMPLEMENT__PROJECT____REPLICATION__IDEA___MAX_2_ as decimal(18,4))) as decimal (18,2)) as score3, ") sql.AppendLine("CAST(AVG(cast(TTL as decimal(18,4))) as decimal (18,2)) as ttl ") sql.AppendLine("FROM UserModules.[user].[SWATNoPROJECTS_AND_IDEAS_VOTING] ") sql.AppendLine("where user_id in (SELECT user_id from UserModules.[user].SWAT_PIC_LIST WHERE group_name in ('MACH PIC','Local manager','Korean dispatcher')) ") sql.AppendLine("GROUP BY PROJECT_ID ") sql.AppendLine(") ") sql.AppendLine("MERGE ") sql.AppendLine("UserModules.[user].[SWATNoPROJECTS_AND_IDEAS] as target ") sql.AppendLine("USING VOTING as source ") sql.AppendLine("ON target.id = source.project_id ") sql.AppendLine("WHEN MATCHED THEN ") sql.AppendLine("UPDATE SET EFF_AMT__PROJECT____CREATIVITY__IDEA_ = source.score1, ") sql.AppendLine("INNOVATION__PROJECT____POTENTIAL__IDEA_ = source.score2, ") sql.AppendLine("IMPLEMENT__PROJECT____REPLICATION__IDEA_ = source.score3, ") sql.AppendLine("TTL = source.ttl; ") sqlf.NonQuery(sql.ToString) 'edTableToView.Message = sql.ToString votingStatus = GetVotingStatus() End Sub Protected Sub Page_PreRender(sender As Object, e As System.EventArgs) Handles Me.PreRender 'ClientScript.RegisterStartupScript(Me.GetType(), "CreateGridHeader", "<script>CreateGridHeader('DataDiv', 'editableGrid1_GridView1', 'HeaderDiv');</script>") If edTableToView.IsReadOnly Then edTableToView.CollectHeaderColumn(1) End If Title = edTableToView.TableDescription End Sub Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control) End Sub Protected Sub Page_SaveStateComplete(sender As Object, e As EventArgs) Handles Me.SaveStateComplete edTableToView.CreateGroupingText() End Sub Protected Sub Page_Unload(sender As Object, e As EventArgs) Handles Me.Unload End Sub #End Region Private Function GetVotingStatus() As DataTable Dim sql As New StringBuilder sql.AppendLine("select project_id, user_id, ") sql.AppendLine("count(*) as total, ") sql.AppendLine("sum(case when ttl is not null then 1 else 0 end) as voted, ") sql.AppendLine("sum(case when ttl is null then 1 else 0 end ) as not_voted ") sql.AppendLine("from ") sql.AppendLine("UserModules.[user].[SWATNoPROJECTS_AND_IDEAS_VOTING] ") sql.AppendLine("group by project_id , user_id ") sql.AppendLine("order by cast(project_id as int) ") Return sqlf.GetData(sql.ToString) End Function Private Function GetVotingStatus(project_id As Integer, vt As DataTable) As DataRow() If Not IsNothing(vt) Then Return vt.Select("project_id='" & project_id & "'") Else Return Nothing End If End Function #Region "Grid events" Protected Sub AddStatusButton(ByRef row As GridViewRow) Handles edTableToView.RowDataBoundComplete Try If row.RowType = DataControlRowType.DataRow Then Dim rows As DataRow() = GetVotingStatus(row.Cells(0).Text, votingStatus) Dim ttlCnt As Integer = 0 Dim votedCnt As Integer = 0 Dim toolTip As String = "" For Each dr As DataRow In rows ttlCnt += dr("total") votedCnt += dr("voted") If dr("voted") = 0 Then toolTip &= dr("user_id") & Chr(13) '& ":" & dr("voted") & Chr(13) End If Next Dim stn As New Image With {.ToolTip = toolTip} If votedCnt = 0 Then stn.ImageUrl = "~/images/bullet_red.png" ElseIf votedCnt <> ttlCnt Then stn.ImageUrl = "~/images/bullet_yellow.png" Else stn.ImageUrl = "~/images/bullet_green.png" End If stn.Attributes.Add("itemid", row.Cells(0).Text) row.Cells(row.Cells.Count - 2).Controls.Add(stn) 'Dim btn As New Image With {.ImageUrl = "~/images/Buttons/comments.png"} 'btn.Style.Add("cursor", "pointer") 'btn.Attributes.Add("itemid", row.Cells(0).Text) 'row.Cells(row.Cells.Count - 2).Controls.Add(btn) End If Catch ex As Exception End Try End Sub Protected Sub filterChanged() Handles edTableToView.GridFilterChanged End Sub Private Sub DataSelected(dt As DataTable) Handles edTableToView.DataSelected End Sub Protected Sub UpdateUserInfo(ByRef com As SqlCommand) Handles edTableToView.NewRecordSaving Try com.Parameters("@CHANGED_BY").Value = userid Catch ex As Exception End Try End Sub Protected Sub edTableToView_PreRender(sender As Object, e As System.EventArgs) Handles edTableToView.PreRender End Sub Private Sub action(sender As Object, e As CommandEventArgs) Handles edTableToView.ActionRequest Select Case e.CommandArgument Case "VOTE" Dim s As String = "window.location.href = 'bpvoting.aspx'; " ClientScript.RegisterStartupScript(Me.GetType(), "script", s, True) End Select End Sub #End Region End Class