Commit inicial Ventas Productivo

This commit is contained in:
JORGE LUIS CAUDILLO ESPARZA
2019-08-14 16:40:54 -07:00
commit c35cf91883
13328 changed files with 3711549 additions and 0 deletions

View File

@@ -0,0 +1,386 @@

Option Explicit On
Option Strict On
Imports Extensiones
Imports System.Data
Partial Class RH_PopUpBuscarPersonal
Inherits ClsPaginas
#Region "Propiedades"
Private ReadOnly Property OpcionBusqueda As String
Get
Return ViewState("Opt").ToString
End Get
End Property
Private Property DTCaracteristicasOpciones As DataTable
Get
If ViewState("DTCaracteristicasOpciones") Is Nothing Then
Return New DataTable
Else
Return DirectCast(ViewState("DTCaracteristicasOpciones"), DataTable)
End If
End Get
Set(value As DataTable)
ViewState("DTCaracteristicasOpciones") = value
End Set
End Property
#End Region
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
CType(Me.Master, Site).EsPopup = True
CType(Me.Master, Site).PopupWidth = 970
RegistraScript("$get('tdContenido').style.height='520px'")
ViewState("Opt") = ""
If Request("Opt") = "OI/OE" Then
ViewState("Opt") = "OI/OE"
End If
If Not Request("EsThickbox") Is Nothing Then
hdnEsThickbox.Value = Request("EsThickbox")
Else
hdnEsThickbox.Value = "N"
End If
'Carga Combos
CargaTurno()
CargaProyecto()
CargaTipoPeriodo()
CargaDepartamento()
CargaPuesto()
CargaTiposContrato()
CargaGenero()
CargaEstadoCivil()
CargaEscolaridad()
CargaRuta()
CargaEstatusPersonal()
DdlClienteAsignado.Attributes.Add("onclick", "CargaClientes();")
CargaCaracteristicas()
End If
End Sub
Private Sub CargaTurno()
DdlTurnos.DataSource = GlobalDTTurno.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
DdlTurnos.DataBind()
End Sub
Private Sub CargaProyecto()
DdlProyecto.DataSource = GlobalDTProyectos(UsuarioActual.CveEmpresa)
DdlProyecto.DataBind()
End Sub
Private Sub CargaSubProyecto()
DdlSubProyecto.Items.Clear()
DdlSubProyecto.DataSource = GlobalDTSubProyectos(DdlProyecto.SelectedValue.ToEntero)
DdlSubProyecto.DataBind()
DdlSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1"))
End Sub
Private Sub CargaClientes()
Dim ObjClientes As New ClsClientes
If ObjClientes.GetClientes(-1, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa) Then
DdlClienteAsignado.DataSource = ObjClientes.DtResultados
Else
DdlClienteAsignado.DataSource = Nothing
End If
ObjClientes.Dispose()
DdlClienteAsignado.DataBind()
End Sub
Private Sub CargaTipoPeriodo()
DdlTipoPeriodo.DataSource = GlobalDTTipoPeriodo
DdlTipoPeriodo.DataBind()
End Sub
Private Sub CargaDepartamento()
DdlDepartamentos.DataSource = GlobalDTDepartamentos.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
DdlDepartamentos.DataBind()
End Sub
Private Sub CargaPuesto()
DdlPuestos.DataSource = GlobalDTRHPuestos(UsuarioActual.CveEmpresa)
DdlPuestos.DataBind()
End Sub
Private Sub CargaTiposContrato()
DdlTipoContrato.DataSource = GlobalDTTiposContrato
DdlTipoContrato.DataBind()
End Sub
Private Sub CargaGenero()
DdlGenero.DataSource = GlobalDTGenero
DdlGenero.DataBind()
End Sub
Private Sub CargaEstadoCivil()
DdlEstadoCivil.DataSource = GlobalDTEstadoCivil
DdlEstadoCivil.DataBind()
End Sub
Private Sub CargaEscolaridad()
DdlEscolaridad.DataSource = GlobalDTEscolaridad
DdlEscolaridad.DataBind()
End Sub
Private Sub CargaRuta()
DdlRuta.DataSource = GlobalDTRutas.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
DdlRuta.DataBind()
End Sub
Private Sub CargaEstatusPersonal()
DdlEstatus.DataSource = GlobalDTEstatusPersonal
DdlEstatus.DataBind()
End Sub
Protected Sub DdlProyecto_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlProyecto.SelectedIndexChanged
CargaSubProyecto()
End Sub
Protected Sub BtnBuscar_Click(sender As Object, e As System.EventArgs) Handles BtnBuscar.Click
Dim ObjPersonal As New ClsRH()
Dim Codigo As String = "-1"
Dim Nombre As String = "-1"
Dim NSS As String = "-1"
Dim RFC As String = "-1"
Dim Horario As String = "-1"
'Definir estructura de supervisores.
Dim CveSupervisor As Integer = -1
If TxtCodigo.Text.Trim <> String.Empty Then Codigo = TxtCodigo.Text.Trim
If TxtNombre.Text.Trim <> String.Empty Then Nombre = TxtNombre.Text.Trim
If TxtNSS.Text.Trim <> String.Empty Then NSS = TxtNSS.Text.Trim
If TxtRFC.Text.Trim <> String.Empty Then RFC = TxtRFC.Text.Trim
If TxtHorarioDe.Text.Trim <> String.Empty Then Horario = TxtHorarioDe.Text.Trim
Dim StrFiltroCaracteristica As String = GeneraFiltroCaracteristicas()
If ObjPersonal.GetPersonal2(-1, Codigo, Nombre, NSS, RFC, DdlTurnos.SelectedValue.ToEntero, DdlPuestos.SelectedValue.ToEntero, DdlDepartamentos.SelectedValue.ToEntero,
DdlRuta.SelectedValue.ToEntero, DdlEscolaridad.SelectedValue.ToEntero, DdlEstadoCivil.SelectedValue.ToEntero, DdlGenero.SelectedValue.ToEntero,
DdlEstatus.SelectedValue.ToEntero, DdlSubProyecto.SelectedValue.ToEntero, DdlClienteAsignado.SelectedValue.ToEntero, Horario, CveSupervisor,
-1, -1, -1, -1, -1, "-1", "-1", "-1", "-1", StrFiltroCaracteristica, 1, UsuarioActual.CveEmpresa) Then
If ObjPersonal.DtResultados.Rows.Count > 0 Then
LtlTotalRegistros.Text = ObjPersonal.DtResultados.Rows.Count.ToString.FormatoNumero(0)
GV.DataSource = ObjPersonal.DtResultados
Else
LtlTotalRegistros.Text = "0"
GV.DataSource = Nothing
Alert("No se encontraron registros con los parámetros solicitados.", Extensiones.TipoMensaje.MsgAdvertencia)
End If
End If
ObjPersonal.Dispose()
GV.DataBind()
UPDatos.Update()
TblBusqueda.Visible = True
End Sub
Private Function GeneraFiltroCaracteristicas() As String
Dim sqlStr As New StringBuilder
Dim NCaracteristicas As Integer = 0
Dim CampoUno As Boolean = True
Dim Retorno As New StringBuilder
For Each dRow As GridViewRow In GvCrt1.Rows
Dim DdlValor As DropDownList = dRow.FCDropDownList("DdlValor")
Dim TxtValor As TextBox = dRow.FCTextBox("TxtValor")
Dim Caracteristica As String = dRow.DataKey("Caracteristica")
Dim CveCaracteristica As Integer = dRow.DataKey("CveCaracteristica").ToString.ToEntero
If DdlValor.SelectedIndex > 0 Then
NCaracteristicas = NCaracteristicas + 1
If sqlStr.ToString <> "" Then sqlStr.Append(" OR ")
sqlStr.AppendFormat(" CveCaracteristica ={0} AND CveCaracteristicaOpcion ={1} AND CvePersonal <> NULL", CveCaracteristica, DdlValor.SelectedValue)
CampoUno = False
ElseIf (TxtValor.Text.Trim.Length > 0) Then
NCaracteristicas = NCaracteristicas + 1
If sqlStr.ToString <> "" Then sqlStr.Append(" OR ")
sqlStr.AppendFormat(" CveCaracteristica = {0} AND CveCaracteristicaOpcion LIKE '%{1}%' AND CvePersonal <> NULL", CveCaracteristica, TxtValor.Text.Trim)
CampoUno = False
End If
Next
For Each dRow As GridViewRow In GvCrt2.Rows
Dim DdlValor As DropDownList = dRow.FCDropDownList("DdlValor")
Dim TxtValor As TextBox = dRow.FCTextBox("TxtValor")
Dim Caracteristica As String = dRow.DataKey("Caracteristica")
Dim CveCaracteristica As Integer = dRow.DataKey("CveCaracteristica").ToString.ToEntero
If DdlValor.SelectedIndex > 0 Then
NCaracteristicas = NCaracteristicas + 1
If sqlStr.ToString <> "" Then sqlStr.Append(" OR ")
sqlStr.AppendFormat(" CveCaracteristica ={0} AND CveCaracteristicaOpcion ={1} AND CvePersonal <> NULL", CveCaracteristica, DdlValor.SelectedValue)
CampoUno = False
ElseIf (TxtValor.Text.Trim.Length > 0) Then
NCaracteristicas = NCaracteristicas + 1
If sqlStr.ToString <> "" Then sqlStr.Append(" OR ")
sqlStr.AppendFormat(" CveCaracteristica = {0} AND CveCaracteristicaOpcion LIKE '%{1}%' AND CvePersonal <> NULL", CveCaracteristica, TxtValor.Text.Trim)
CampoUno = False
End If
Next
For Each dRow As GridViewRow In GvCrt3.Rows
Dim DdlValor As DropDownList = dRow.FCDropDownList("DdlValor")
Dim TxtValor As TextBox = dRow.FCTextBox("TxtValor")
Dim Caracteristica As String = dRow.DataKey("Caracteristica")
Dim CveCaracteristica As Integer = dRow.DataKey("CveCaracteristica").ToString.ToEntero
If DdlValor.SelectedIndex > 0 Then
NCaracteristicas = NCaracteristicas + 1
If sqlStr.ToString <> "" Then sqlStr.Append(" OR ")
sqlStr.AppendFormat(" CveCaracteristica ={0} AND CveCaracteristicaOpcion ={1} AND CvePersonal <> NULL ", CveCaracteristica, DdlValor.SelectedValue)
CampoUno = False
ElseIf (TxtValor.Text.Trim.Length > 0) Then
NCaracteristicas = NCaracteristicas + 1
If sqlStr.ToString <> "" Then sqlStr.Append(" OR ")
sqlStr.AppendFormat(" CveCaracteristica = {0} AND CveCaracteristicaOpcion LIKE '%{1}%' AND CvePersonal <> NULL ", CveCaracteristica, TxtValor.Text.Trim)
CampoUno = False
End If
Next
If NCaracteristicas > 0 Then
Retorno.Append(" SELECT CvePersonal as CvePersonal, SUM(1) AS Contador FROM Gral_CaracteristicasValores WHERE ")
Retorno.Append(sqlStr.ToString)
Retorno.Append(" GROUP BY CvePersonal ")
End If
Return Retorno.ToString
End Function
Protected Sub GV_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GV.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.RowIndex = 0 Then
'e.Row.Cells(0).Width = Unit.Pixel(70)
'e.Row.Cells(1).Width = Unit.Pixel(300)
'e.Row.Cells(2).Width = Unit.Pixel(80)
'e.Row.Cells(3).Width = Unit.Pixel(90)
'e.Row.Cells(4).Width = Unit.Pixel(90)
'e.Row.Cells(5).Width = Unit.Pixel(120)
'e.Row.Cells(6).Width = Unit.Pixel(120)
'e.Row.Cells(7).Width = Unit.Pixel(80)
End If
e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Left
e.Row.Cells(1).HorizontalAlign = HorizontalAlign.Left
e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Left
e.Row.Cells(4).HorizontalAlign = HorizontalAlign.Left
e.Row.Cells(5).HorizontalAlign = HorizontalAlign.Left
e.Row.Cells(6).HorizontalAlign = HorizontalAlign.Left
Dim Liga As String = String.Empty
Select Case OpcionBusqueda
Case "OI/OE"
Liga = String.Format("<a class='Texto' href='javascript:IrOI({0});'>", e.Row.DBCampo("CvePersonal"))
Case Else
If hdnEsThickbox.Value = "S" Then
Liga = String.Format("<a class='Texto' href='javascript:Ir2(""{0}"");'>", e.Row.DBCampo("CvePersonal"))
Else
If e.Row.DBCampo("CveEstatusPersonal") = "3" Then
Liga = String.Format("<a class='Texto' href='javascript:Ir3(""{0}"");'>", e.Row.DBCampo("CvePersonal"))
Else
Liga = String.Format("<a class='Texto' href='javascript:Ir(""{0}"");'>", e.Row.DBCampo("CvePersonal"))
End If
End If
End Select
e.Row.FCLiteral("LtlCodigo").Text = String.Format("<div class='truncate' style='width:54px;'>{0}{1}</a></div>", Liga, e.Row.DBCampo("Codigo"))
e.Row.FCLiteral("LtlNombre").Text = String.Format("<div class='truncate' style='width:155px;'>{0}{1}</a></div>", Liga, e.Row.DBCampo("Nombre"))
e.Row.FCLiteral("LtlFechaIng").Text = String.Format("<div class='truncate' style='width:64px;'>{0}{1}</a></div>", Liga, e.Row.DBCampo("FechaIng").ToDate.ToShortDateString)
e.Row.FCLiteral("LtlTipoPeriodo").Text = String.Format("<div class='truncate' style='width:60px;'>{0}{1}</a></div>", Liga, e.Row.DBCampo("TipoPeriodo"))
e.Row.FCLiteral("LtlTurno").Text = String.Format("<div class='truncate' style='width:60px;'>{0}{1}</a></div>", Liga, e.Row.DBCampo("Turno"))
e.Row.FCLiteral("LtlDepartamento").Text = String.Format("<div class='truncate' style='width:84px;'>{0}{1}</a></div>", Liga, e.Row.DBCampo("Departamento"))
e.Row.FCLiteral("LtlPuesto").Text = String.Format("<div class='truncate' style='width:62px;'>{0}{1}</a></div>", Liga, e.Row.DBCampo("Puesto"))
e.Row.FCLiteral("LtlEstatus").Text = String.Format("<div class='truncate' style='width:44px;'>{0}{1}</a></div>", Liga, e.Row.DBCampo("EstatusPersonal"))
End If
End Sub
Protected Sub BtnCargarClientes_Click(sender As Object, e As System.EventArgs) Handles BtnCargarClientes.Click
CargaClientes()
DdlClienteAsignado.Attributes.Remove("onclick")
End Sub
#Region "C A R A C T E R I S T I C A S "
Private Sub CargaCaracteristicas()
Dim objCaract As New ClsGenerales
If objCaract.GetCaracteristicas(-1, -1, UsuarioActual.Empresa.CveEmpresa) Then
Dim dtt As DataTable = objCaract.DtResultados
Dim column As DataColumn = New DataColumn
column.DataType = System.Type.GetType("System.Int32") : column.ColumnName = "Cve" : dtt.Columns.Add(column)
Dim i As Integer = 1
For Each dr As DataRow In dtt.Rows
dr("Cve") = i
i += 1
If i > 3 Then i = 1
Next
'With column
' .AutoIncrement = True : .AutoIncrementSeed = 1 : .AutoIncrementStep = 1
'End With
GvCrt1.DataSource = dtt.FiltraParametros("Cve = 1")
GvCrt2.DataSource = dtt.FiltraParametros("Cve = 2")
GvCrt3.DataSource = dtt.FiltraParametros("Cve = 3")
End If
If objCaract.GetCaracteriscasOpciones(-1, UsuarioActual.Empresa.CveEmpresa) Then
DTCaracteristicasOpciones = objCaract.DtResultados
End If
objCaract.Dispose()
GvCrt1.DataBind() : GvCrt2.DataBind() : GvCrt3.DataBind()
End Sub
#End Region
Protected Sub GvCaracteristicas_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvCrt1.RowDataBound, GvCrt2.RowDataBound, GvCrt3.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim DdlValor As DropDownList = e.Row.FCDropDownList("DdlValor")
Dim TxtValor As TextBox = e.Row.FCTextBox("TxtValor")
Dim CveCaracteristica As Integer = e.Row.DBCampo("CveCaracteristica").ToString.ToEntero
Dim DtTempResultado As DataTable = DTCaracteristicasOpciones.FiltraParametros(String.Format("CveCaracteristica ={0} ", CveCaracteristica))
If DtTempResultado.Rows.Count <> 0 Then
DdlValor.DataSource = DtTempResultado
DdlValor.DataBind()
DdlValor.Items.Insert(0, New ListItem("-", "-1"))
DdlValor.Visible = True
DdlValor.Visible = True
TxtValor.Visible = False
Else
DdlValor.Visible = False
TxtValor.Visible = True
End If
End If
End Sub
End Class