/
ivan
/
ModMas
Обзор
Документация
Войти
/
ivan
/
ModMas
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
ModuleMaster/innovation/soccer/projects.aspx.vb
335 строк
14 KB
i.krivokon
Initial commit
13 мар 2026, 13:49
13 мар 2026, 13:49
00d9fb6
Код
Авторство
О чём код?
Imports System.Data Imports System.Data.SqlClient Imports System.Net Imports System.IO Imports Newtonsoft.Json Partial Class Xml_viewTable Inherits System.Web.UI.Page Private sqlf As New sharedClasses.dbFunctions.SqlFunctions Private 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" Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load Dim _qString As NameValueCollection = Request.QueryString If Not IsNothing(_qString("method")) Then If _qString("method").ToLower = "search" Then Response.Clear() Response.Write(searchEmployee(_qString("idtosearch"))) Response.End() ElseIf _qString("method").ToLower = "list" Then End If End If Dim userid As String = "" 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 If userid = "" Then authorize("SSO") userid = a.userId edTableToView.Message = "By SSO: " & a.userId End If Dim tableId As String = "" If Not IsNothing(Request.QueryString("tableId")) Then tableId = Request.QueryString("tableId") End If If Not IsNothing(Request.QueryString("t")) Then tableId = Request.QueryString("t") End If edTableToView.IsReadOnly = True edTableToView.UserName = userid.ToUpper 'Получаем значений для поля SERK Group. В дальнейшем его будем использовать для построения списка multi-select Dim sql As New StringBuilder sql.Append("SELECT [FIELDTEXT] FROM [UserModules].[dbo].[FieldsValues] where tableid = 1484 and fieldid = 37940 and Enabled = 'Y'") Dim dt As DataTable = sqlf.GetData(sql.ToString) Dim group_list_string As String = "" ' Сюда кладём значения через из DT; If dt.Rows.Count <> 0 Then For Each row As DataRow In dt.Rows group_list_string = group_list_string & row.Item(0).ToString & "," Next Group_list.Value = group_list_string.Substring(0, group_list_string.Length - 2) End If 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 addApprover1.Text = "" addApprover2.Text = "" addApprover3.Text = "" End Sub Protected Sub Page_Unload(sender As Object, e As EventArgs) Handles Me.Unload End Sub #End Region #Region "Handlers" Private Function searchEmployee(idToSearch As String) As String Dim sql As New StringBuilder sql.Append("SELECT [Name] +'/' + Title + ' (' + band + ')' + '/' + replace(Department,'/','-') + '/' + [SingleId] as Title") sql.Append(" ,[GEN] + '|' + [SingleId] + '|APPROVE' as [EmpId] ") sql.Append(" FROM [hr].[dbo].[GHR_EMP_INFO] ") sql.Append(" where ") sql.Append(" (gen like '%" & idToSearch & "%' or ") sql.Append(" name like '%" & idToSearch & "%' or ") sql.Append(" singleid like '%" & idToSearch & "%' or department like '%" & idToSearch & "%')") Dim dt As DataTable = sqlf.GetData(sql.ToString) If Not IsNothing(dt) Then Dim lv As New ListBox lv.SelectionMode = ListSelectionMode.Multiple lv.ID = "foundEmployees" lv.Width = Unit.Pixel(525) lv.ClientIDMode = UI.ClientIDMode.Static lv.DataSource = dt lv.DataTextField = "Title" lv.DataValueField = "EmpId" lv.DataBind() For Each l As ListItem In lv.Items l.Attributes.Add("title", l.Text) Next Dim myCItrad As System.Globalization.CultureInfo = New System.Globalization.CultureInfo("EN-US", True) Dim sw As IO.StringWriter = New IO.StringWriter(myCItrad) Dim hw As HtmlTextWriter = New HtmlTextWriter(sw) lv.RenderControl(hw) Dim result As String = sw.ToString 'result &= "<table><tr><td>" 'If dt.Rows(0)("Status") = "INITIAL" Then ' result &= "<img id='submitApproval' title='Submit approval request' gen='" & dt.Rows(0)("GEN") & "' requestid='" & dt.Rows(0)("id") & "' class='submitapproval action icon' src='../images/fatcow/contact_email.png' onclick='doSubmitApproval()'>" 'Else ' 'result &= "<img title='View approval request' gen='" & dt.Rows(0)("GEN") & "' otdate='" & dt.Rows(0)("Date") & "' class='submitapproval action icon' src='../images/fatcow/zoom.png'>" 'End If 'result &= "</td><td>" 'result &= "<img title='Close' id='cancelView' class='action icon' src='../images/fatcow/cancel.png' onclick='doCancelView()'>" 'result &= "</td></tr></table>" Return result End If Return "DB ERROR." End Function <System.Web.Script.Services.ScriptMethod(), System.Web.Services.WebMethod()> Public Shared Function searchEmployee(ByVal prefixText As String, ByVal count As Integer) As List(Of String) Dim sql As New StringBuilder sql.Append("SELECT [Name] +'/' + Title + ' (' + band + ')' + '/' + replace(Department,'/','-') + '/' + [SingleId] as Title") sql.Append(" ,[GEN] + '|' + [SingleId] + '|APPROVE' as [EmpId] ") sql.Append(" FROM [hr].[dbo].[GHR_EMP_INFO] ") sql.Append(" where ") sql.Append(" (gen like '%" & prefixText & "%' or ") sql.Append(" name like '%" & prefixText & "%' or ") sql.Append(" singleid like '%" & prefixText & "%' or department like '%" & prefixText & "%')") Dim sqlf As New sharedClasses.dbFunctions.SqlFunctions Dim dt As Data.DataTable = sqlf.GetData(sql.ToString) If Not IsNothing(dt) Then Dim result As New List(Of String) For Each dr As Data.DataRow In dt.Rows result.Add(dr("title")) Next Return result End If Return Nothing End Function #End Region Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control) End Sub Private Sub addViewButton(ByRef r As GridViewRow) Handles edTableToView.RowDataBoundComplete If r.RowType = DataControlRowType.DataRow Then Dim l As New LiteralControl l.Text = "<a href='details.aspx?projectid=" & r.Attributes("rowid") & "' target='_blank'> <img src='../Images/sap/details.png' /></a>" r.Cells(r.Cells.Count - 2).Controls.Add(l) Dim dep As String = "" Dim group As String = "" For Each cell As TableCell In r.Cells If cell.Attributes.Item("field") = "CO_DEPARTMENTS" Then cell.Attributes.Add("dep", dep) cell.Attributes.Add("group", group) cell.CssClass = "multi-select" End If Next End If End Sub Protected Sub UpdateUserInfo(ByRef com As SqlCommand) Handles edTableToView.NewRecordSaving Try com.Parameters("@CHANGED_BY").Value = Request.QueryString("orchuserlogin") Catch ex As Exception End Try End Sub Protected Sub Page_SaveStateComplete(sender As Object, e As EventArgs) Handles Me.SaveStateComplete edTableToView.CreateGroupingText() 'edTableToView.InsertVisible = False End Sub #Region "Approval submit" Protected Sub submitDoc1_Click(sender As Object, e As ImageClickEventArgs) Handles submitDoc1.Click RequestApprove() End Sub Protected Sub submit_Click(sender As Object, e As ImageClickEventArgs) Handles submit.Click RequestApprove() End Sub Private Sub RequestApprove() Dim params() As String = projectId.Value.Split("|") If params.Count = 2 Then startApprovalProcess(params(0), params(1)) End If End Sub Private Sub startApprovalProcess(documentId As String, processType As String) Dim activeApproval As Boolean activeApproval = sqlf.GetScalar("SELECT COUNT(*) FROM UserModules.[user].mach_approval " & "WHERE table_name = 'ISCRAQ_APPROVAL' and process_type ='" & processType & "' " & "and row_id=" & documentId & " and approval_finished ='N' ") <> 0 If activeApproval Then ClientScript.RegisterStartupScript(Me.GetType, "activeApproval", "<script>alert('Approval process already started!');</script>") Exit Sub End If Dim approvalStatus As String = "" If processType = "REGISTER_SUBMIT" Then approvalStatus = sqlf.GetScalar("SELECT VALUATIOM_RESULT FROM UserModules.[user].NEW_PROJECT_2017 " & "WHERE id=" & documentId) ElseIf processType = "FINISH_SUBMIT" Then approvalStatus = sqlf.GetScalar("SELECT MANAGER__COMPLETE_APPROVE FROM UserModules.[user].NEW_PROJECT_2017 " & "WHERE id=" & documentId) End If If approvalStatus = "APPROVE" Then ClientScript.RegisterStartupScript(Me.GetType, "activeApproval", "<script>alert('Approval process finished!');</script>") Exit Sub End If Dim sql As New StringBuilder sql.AppendLine("INSERT INTO [UserModules].[user].[MACH_APPROVAL] ") sql.AppendLine(" ([CREATED_BY] ") sql.AppendLine(" ,[TABLE_NAME] ") sql.AppendLine(" ,[PROCESS_TYPE] ") sql.AppendLine(" ,[ROW_ID] ") sql.AppendLine(" ,[STEP_SEQ] ") sql.AppendLine(" ,[STEP_TYPE] ") sql.AppendLine(" ,[SINGLE_ID] ") sql.AppendLine(" ,[GEN] ") sql.AppendLine(" ,[CONFIRMATION] ") sql.AppendLine(" ,[CONFIRMATION_DATETIME] ") sql.AppendLine(" ,[COMMENTS] ") sql.AppendLine(" ,[ACTIVE_STEP] ") sql.AppendLine(" ,[NOTIFICATION_SENT], [APPROVAL_ID],[APPROVAL_FINISHED] ) ") sql.AppendLine(" VALUES ") sql.AppendLine(" (@CREATED_BY ") sql.AppendLine(" ,@TABLE_NAME ") sql.AppendLine(" ,@PROCESS_TYPE ") sql.AppendLine(" ,@ROW_ID ") sql.AppendLine(" ,@STEP_SEQ ") sql.AppendLine(" ,@STEP_TYPE ") sql.AppendLine(" ,@SINGLE_ID ") sql.AppendLine(" ,@GEN ") sql.AppendLine(" ,@CONFIRMATION ") sql.AppendLine(" ,@CONFIRMATION_DATETIME ") sql.AppendLine(" ,@COMMENTS ") sql.AppendLine(" ,@ACTIVE_STEP ") sql.AppendLine(" ,@NOTIFICATION_SENT, @APPROVAL_ID, @APPROVAL_FINISHED) ") Dim com As New SqlCommand com.CommandText = sql.ToString Dim approvalId As String = Guid.NewGuid.ToString With com.Parameters .Clear() .AddWithValue("CREATED_BY", edTableToView.UserName) .AddWithValue("TABLE_NAME", "ISCRAQ_APPROVAL") .AddWithValue("PROCESS_TYPE", processType) .AddWithValue("ROW_ID", documentId) .AddWithValue("STEP_SEQ", 0) .AddWithValue("STEP_TYPE", "DRAFTER") .AddWithValue("SINGLE_ID", edTableToView.UserName) .AddWithValue("GEN", "000000") .AddWithValue("COMMENTS", otDescription.Text) .AddWithValue("ACTIVE_STEP", "N") .AddWithValue("NOTIFICATION_SENT", "N") .AddWithValue("APPROVAL_ID", approvalId) .AddWithValue("APPROVAL_FINISHED", "N") .AddWithValue("CONFIRMATION", "SUBMIT") .AddWithValue("CONFIRMATION_DATETIME", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")) sqlf.NonQuery(com) .Item("STEP_TYPE").Value = "APPROVE" .Item("STEP_SEQ").Value = 1 .Item("ACTIVE_STEP").Value = "Y" .Item("SINGLE_ID").Value = picApprover.Text.Split("/")(3) .Item("COMMENTS").Value = "" .Item("CONFIRMATION").Value = "" .Item("CONFIRMATION_DATETIME").Value = "" sqlf.NonQuery(com) .Item("STEP_SEQ").Value = 2 .Item("ACTIVE_STEP").Value = "N" .Item("SINGLE_ID").Value = managerApprover.Text.Split("/")(3) sqlf.NonQuery(com) For i = 1 To 3 Dim txt As TextBox = CType(dialogblock.FindControl("addApprover" & i), TextBox) If Not IsNothing(txt) Then If txt.Text <> "" Then .Item("STEP_SEQ").Value = 2 + i .Item("ACTIVE_STEP").Value = "N" .Item("SINGLE_ID").Value = txt.Text.Split("/")(3) sqlf.NonQuery(com) End If End If Next End With If processType = "REGISTER_SUBMIT" Then sqlf.NonQuery("UPDATE UserModules.[user].NEW_PROJECT_2017 SET VALIDATION_RESULT = 'PENDING', VALIDATION_COMMENTS='' WHERE id=" & documentId) ElseIf processType = "FINISH_SUBMIT" Then sqlf.NonQuery("UPDATE UserModules.[user].NEW_PROJECT_2017 SET VERIFICATION_RESULT = 'PENDING', VERIFICATION_COMMENTS='', MANAGER__COMPLETE_APPROVE='', COMPLETE_COMMENTS='' WHERE id=" & documentId) End If edTableToView.RefreshData() End Sub #End Region End Class