/
ivan
/
ModMas
Обзор
Документация
Войти
/
ivan
/
ModMas
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
ModuleMaster/innovation/bp/bpvoting.aspx.vb
134 строки
6 KB
i.krivokon
Initial commit
13 мар 2026, 13:49
13 мар 2026, 13:49
00d9fb6
Код
Авторство
О чём код?
Imports sharedClasses.Auth Imports sharedClasses.dbFunctions Partial Class swatVoting Inherits System.Web.UI.Page Private a As sharedClasses.Auth.auth Private sqlf As New SqlFunctions Private Sub authorize(mode As String) a = New sharedClasses.Auth.auth(mode, IIf(Request.UserHostAddress = "::1", "106.109.72.76", Request.UserHostAddress)) End Sub Protected Sub Page_PreInit(sender As Object, e As EventArgs) Handles Me.PreInit authorize("SSO") End Sub Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load ''Voting finished 'voting.Visible = False 'votingFinished.Visible = True 'noaccess.Visible = False 'Exit Sub 'voting voting.Visible = True votingFinished.Visible = False userId.Text = a.userId If Not IsPostBack Then Dim sql As New StringBuilder sql.AppendLine("WITH PROJECT_LIST as ( ") sql.AppendLine("select t1.id, t1.projects_group, ") sql.AppendLine("t1.TYPE, ") sql.AppendLine("t1.SERK_GROUP, ") sql.AppendLine("t1.date, ") sql.AppendLine("t1.name, ") sql.AppendLine("t1.DESCRIPTION, ") sql.AppendLine("t2.USER_ID ") sql.AppendLine("from ") sql.AppendLine("UserModules.[user].[SWATNoPROJECTS_AND_IDEAS] t1 ") sql.AppendLine("FULL JOIN UserMOdules.[user].SWAT_PIC_LIST t2 ") sql.AppendLine("on 1=1 ") sql.AppendLine("WHERE t2.ENABLED = 'Y' ") sql.AppendLine(") ") sql.AppendLine("MERGE ") sql.AppendLine("UserModules.[user].[SWATNoPROJECTS_AND_IDEAS_VOTING] as target ") sql.AppendLine("USING PROJECT_LIST as source ") sql.AppendLine("on target.project_id = source.id ") sql.AppendLine("and target.user_id = source.user_id ") sql.AppendLine("WHEN MATCHED THEN ") sql.AppendLine("UPDATE SET type=source.type, serk_group=source.serk_group, ") sql.AppendLine("date=source.date, name=source.name, description=source.description, deleted='N', projects_group = source.projects_group") sql.AppendLine("WHEN NOT MATCHED THEN ") sql.AppendLine("INSERT (project_id, type, serk_group, date, name, description, user_id, deleted, projects_group) ") sql.AppendLine("VALUES(id, type, serk_group, date, name, description, user_id, 'N', projects_group); ") sqlf.NonQuery(sql.ToString) sql.Clear() sql.AppendLine("WITH deleted_id as ( ") sql.AppendLine("select distinct project_id from ") sql.AppendLine("UserModules.[user].[SWATNoPROJECTS_AND_IDEAS_VOTING] ") sql.AppendLine("where project_id not in( ") sql.AppendLine("select id from UserModules.[user].[SWATNoPROJECTS_AND_IDEAS])) ") sql.AppendLine("MERGE ") sql.AppendLine("UserModules.[user].[SWATNoPROJECTS_AND_IDEAS_VOTING] as target ") sql.AppendLine("USING deleted_id as source ") sql.AppendLine("ON SOURCE.project_id = target.project_id ") sql.AppendLine("WHEN MATCHED THEN ") sql.AppendLine("UPDATE SET deleted='Y'; ") ' sql.AppendLine("DELETE; ") sqlf.NonQuery(sql.ToString) 'projectType.DataSource = sqlf.GetData("SELECT DISTINCT [PROJECTS_GROUP] FROM UserModules.[User].[SWATNoPROJECTS_AND_IDEAS_VOTING] where user_id = '" & a.userId & "' AND DELETED='N' and PROJECTS_GROUP <> '' order by PROJECTS_GROUP desc") 'projectType.DataValueField = "PROJECTS_GROUP" 'projectType.DataTextField = "PROJECTS_GROUP" 'projectType.DataBind() If projectType.Items.Count > 0 Then projectType.Items(0).Selected = True noaccess.Visible = False tblMainForm.Visible = True Else noaccess.Visible = True tblMainForm.Visible = False End If BuildProjectList() End If End Sub Protected Sub projectType_SelectedIndexChanged(sender As Object, e As EventArgs) Handles projectType.SelectedIndexChanged BuildProjectList() End Sub Private Sub BuildProjectList() Try projectList.DataSource = sqlf.GetData("SELECT PROJECT_ID as id, type as [Type], " & _ "serk_group as [Group], name as [Title], isnull(cast(TTL as varchar),'-') as [Score] " & _ "FROM UserModules.[User].[SWATNoPROJECTS_AND_IDEAS_VOTING] where user_id = '" & a.userId & "' " & _ "AND [PROJECTS_GROUP]='" & projectType.SelectedItem.Text & "' ORDER BY name") projectList.DataBind() Catch ex As Exception End Try End Sub Protected Sub GridView1_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles projectList.RowDataBound With e.Row If .RowType = DataControlRowType.DataRow Then .CssClass = "click" .Cells(0).Attributes.Add("projectID", .Cells(0).Text) .Cells(.Cells.Count - 1).CssClass = "ttl" & .Cells(0).Text If .Cells(.Cells.Count - 1).Text = "-" Then .Cells(.Cells.Count - 1).CssClass &= " notVoted" Else .Cells(.Cells.Count - 1).CssClass &= " voted" End If End If .Cells(0).Style.Add("display", "none") .Cells(1).Style.Add("display", "none") End With End Sub End Class