Files
SIG/OI/GraficaGantt.aspx.vb
JORGE LUIS CAUDILLO ESPARZA c35cf91883 Commit inicial Ventas Productivo
2019-08-14 16:40:54 -07:00

132 lines
6.0 KiB
VB.net

Imports Extensiones
Imports System.Data
Partial Class OI_GraficaGantt
Inherits ClsPaginas
Private Property DTDatos As DataTable
Get
Return CType(ViewState("DTDatos"), DataTable)
End Get
Set(value As DataTable)
ViewState("DTDatos") = value
End Set
End Property
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not IsPostBack Then
DdlSegundoNivel.DataBind()
DdlSegundoNivel.Items.Insert(0, New ListItem("Todos", "-1"))
DdlPrimerNivel.DataBind()
DdlPrimerNivel.Items.Insert(0, New ListItem("Todos", "-1"))
CargaCombos()
CargaEventos()
CargaComboP1()
End If
End Sub
Private Sub CargaCombos()
'usuarios
DdlUsuario.DataSource = GlobalDTUsuarios(CveEmpresa:=UsuarioActual.CveEmpresa)
DdlUsuario.DataBind()
DdlUsuario.Items.Insert(0, New ListItem("Todos", "-1"))
DdlUsuario.SelectedValue = -1
'Revision
Dim ObjOI As New ClsOIEventos
If ObjOI.GetRevisionesEventos(UsuarioActual.CveEmpresa) Then
DdlRevision.DataSource = ObjOI.DtResultados
DdlRevision.DataBind()
End If
ObjOI.Dispose()
DdlRevision.Items.Insert(0, New ListItem("Todos", "-1"))
DdlRevision.SelectedValue = -1
End Sub
Protected Sub CargaEventos()
Dim de As Integer = DdlUsuario.SelectedValue
Dim cverevision As Integer = DdlRevision.SelectedValue
Dim objoi As New ClsOIEventos
If objoi.GetEventosProyecto(UsuarioActual.CveEmpresa, de, cverevision, DdlPrimerNivel.SelectedValue, DdlSegundoNivel.SelectedValue) Then
DTDatos = objoi.DtResultados
End If
objoi.Dispose()
End Sub
Private Sub CargaComboP1()
DdlPrimerNivel.Items.Clear()
DdlPrimerNivel.DataSource = DTDatos.FiltraParametros("CveEventoPadre = 0")
DdlPrimerNivel.DataBind()
DdlPrimerNivel.Items.Insert(0, New ListItem("Todos", "-1"))
DdlSegundoNivel.Items.Clear()
DdlSegundoNivel.DataBind()
DdlSegundoNivel.Items.Insert(0, New ListItem("Todos", "-1"))
End Sub
Private Sub CargaComboP2()
DdlSegundoNivel.Items.Clear()
DdlSegundoNivel.DataSource = DTDatos.FiltraParametros(String.Format("CveEventoPadre = {0} OR {0}=-1", DdlPrimerNivel.SelectedValue))
DdlSegundoNivel.DataBind()
DdlSegundoNivel.Items.Insert(0, New ListItem("Todos", "-1"))
End Sub
Protected Sub DdlPrimerNivel_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlPrimerNivel.SelectedIndexChanged
CargaComboP2()
End Sub
Public Function DTTogant() As String
Dim StrDatos As New StringBuilder
StrDatos.Append("{""data"": [ ")
Dim dttemp As DataTable = GetDatos()
If Not (dttemp Is Nothing) Then
For Each item As DataRow In dttemp.Rows '28-03-2013
Dim duracion = DateDiff(DateInterval.Day, item("FechaInicio").ToString().ToDate(), item("FechaFin").ToString().ToDate())
If item("ISFhater").ToString = "1" Then
StrDatos.AppendFormat("{{""id"": {0}, ""text"": ""{1}"", ""start_date"": ""{2}"",""type"":""Project"", ""progress"": {4},""parent"":{5}, ""open"": true,""end_date"": ""{6}"",""users"":""{7}""}},", item("CveEvento").ToString, item("Asunto").ToString, If(item("FechaInicio").ToString <> "", item("FechaInicio").ToString().Substring(0, 10), ""), duracion, item("Avance").ToString.ToEntero / 100, item("CveEventoPadre").ToString().ToEntero, If(item("FechaFin").ToString <> "", item("FechaFin").ToString().Substring(0, 10), ""), item("UsuarioDe").ToString)
Else
StrDatos.AppendFormat("{{""id"": {0}, ""text"": ""{1}"", ""start_date"": ""{2}"", ""duration"": ""{3}"", ""progress"": {4},""parent"":{5}, ""open"": true,""end_date"": ""{6}"",""users"":""{7}""}},", item("CveEvento").ToString, item("Asunto").ToString, If(item("FechaInicio").ToString <> "", item("FechaInicio").ToString().Substring(0, 10), ""), duracion, item("Avance").ToString.ToEntero / 100, item("CveEventoPadre").ToString().ToEntero, If(item("FechaFin").ToString <> "", item("FechaFin").ToString().Substring(0, 10), ""), item("UsuarioDe").ToString)
End If
Next
End If
Return StrDatos.ToString.Substring(0, StrDatos.ToString.Length - 1) & "]}"
End Function
Public Function GetDatos() As DataTable
Dim dt As DataTable = DTDatos.Copy
'If Not (DdlPrimerNivel.SelectedValue = -1 And DdlSegundoNivel.SelectedValue = -1) Then
' dt.Clear()
'End If
Return dt
End Function
Protected Sub NewUser_Click(sender As Object, e As EventArgs) Handles NewUser.Click
Dim FechaI As Date = FechaInicio.Value.ToDate()
Dim Fechaf As Date = FechaI.AddDays(Duracion.Value.ToEntero)
Dim objOI As New ClsOIEventos
If objOI.AddEventoProyecto(Asunto.Value, Asunto.Value, 1, UsuarioActual.CveUsuario, -1, FechaI, Fechaf,
EventoPadre.Value.ToEntero, -1, "", -1, -1, -1, -1, -1, -1, -1, -1, UsuarioActual.CveUsuario,-1,
UsuarioActual.CveEmpresa) Then
Dim newrow As DataRow = DTDatos.NewRow()
newrow("CveEvento") = objOI.CveEvento
newrow("Asunto") = Asunto.Value
newrow("FechaInicio") = FechaInicio.Value
newrow("FechaFin") = Fechaf.ToString("dd/MM/yyyy")
newrow("CveEventoPadre") = EventoPadre.Value
DTDatos.Rows.Add(newrow)
Else
Alert("No se logro agregar la tarea", TipoMensaje.MsgInformacion)
End If
objOI.Dispose()
End Sub
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles BtnConsultar.Click
CargaEventos()
' RegistraScript(String.Format("debugger;gantt.parse('{0}');datagant='{0}';", DTTogant()))
End Sub
End Class