1005 lines
39 KiB
C#
1005 lines
39 KiB
C#
using SIG.Web.AppCode.Configuration;
|
|
using SIG.Web.AppCode.Infrastructure.WebForms;
|
|
using SIG.Web.AppCode.Models.Bloqueos;
|
|
using SIG.Web.AppCode.Models.Clientes;
|
|
using SIG.Web.AppCode.Models.Common;
|
|
using SIG.Web.AppCode.Models.Convenios;
|
|
using SIG.Web.AppCode.Models.Fraccionamientos;
|
|
using SIG.Web.AppCode.Security;
|
|
using SIG.Web.AppCode.Session;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace SIG.Web.Pages.Desarrolladores
|
|
{
|
|
public partial class DesarrolladorDetalle : ClsPaginaBase
|
|
{
|
|
private bool ValidarFiltroLotes()
|
|
{
|
|
if (CveFraccionamientoLotes > 0)
|
|
{
|
|
return true;
|
|
}
|
|
Alert("Seleccione un fraccionamiento en la pestaña Lotes.", TipoMensaje.MsgAdvertencia);
|
|
return false;
|
|
}
|
|
|
|
protected void BuscarFraccionamientosFiltro(
|
|
object origen, SIG.Web.AppCode.SigControls.ConsultaCatalogoEventArgs argumentos)
|
|
{
|
|
var tabla = CrearTablaFiltro();
|
|
argumentos.Resultados = tabla;
|
|
var consulta = AppServices.ServicioFraccionamiento.Listar(
|
|
string.Empty, CveClienteActual, true, CurrentUser.CveUsuario, CurrentUser.NombreDominio);
|
|
if (!consulta.Success)
|
|
{
|
|
argumentos.Error = consulta.UserMessage;
|
|
return;
|
|
}
|
|
foreach (var fraccionamiento in consulta.Data)
|
|
{
|
|
tabla.Rows.Add(
|
|
fraccionamiento.CveFraccionamiento.ToString(CultureInfo.InvariantCulture),
|
|
fraccionamiento.Fraccionamiento, fraccionamiento.Fraccionamiento, string.Empty);
|
|
}
|
|
}
|
|
|
|
private static System.Data.DataTable CrearTablaFiltro()
|
|
{
|
|
var tabla = new System.Data.DataTable();
|
|
foreach (string columna in new[] { "Clave", "Descripcion", "Fraccionamiento", "Etapa" })
|
|
{
|
|
tabla.Columns.Add(columna);
|
|
}
|
|
return tabla;
|
|
}
|
|
|
|
private void BuscarEtapasFiltro(
|
|
int cveFraccionamiento, SIG.Web.AppCode.SigControls.ConsultaCatalogoEventArgs argumentos)
|
|
{
|
|
var tabla = CrearTablaFiltro();
|
|
argumentos.Resultados = tabla;
|
|
if (cveFraccionamiento <= 0)
|
|
{
|
|
argumentos.Error = "Seleccione primero un fraccionamiento.";
|
|
return;
|
|
}
|
|
var consulta = AppServices.ServicioFraccionamiento.ListarDesarrollos(
|
|
CveClienteActual, CurrentUser.CveUsuario, CurrentUser.NombreDominio);
|
|
if (!consulta.Success)
|
|
{
|
|
argumentos.Error = consulta.UserMessage;
|
|
return;
|
|
}
|
|
foreach (var etapa in consulta.Data.Where(elemento =>
|
|
!elemento.EsFraccionamiento &&
|
|
elemento.CveFraccionamiento == cveFraccionamiento &&
|
|
elemento.CveFraccionamientoEtapa.HasValue))
|
|
{
|
|
tabla.Rows.Add(
|
|
etapa.CveFraccionamientoEtapa.Value.ToString(CultureInfo.InvariantCulture),
|
|
etapa.Fraccionamiento + " · " + etapa.Etapa,
|
|
etapa.Fraccionamiento, etapa.Etapa);
|
|
}
|
|
}
|
|
|
|
private int ValidarFraccionamientoFiltro(string valor)
|
|
{
|
|
int cveFraccionamiento;
|
|
if (!int.TryParse(valor, out cveFraccionamiento) || cveFraccionamiento <= 0)
|
|
{
|
|
return 0;
|
|
}
|
|
var consulta = AppServices.ServicioFraccionamiento.Obtener(
|
|
cveFraccionamiento, CurrentUser.CveUsuario, CurrentUser.NombreDominio);
|
|
if (!consulta.Success || consulta.Data == null || consulta.Data.CveCliente != CveClienteActual)
|
|
{
|
|
Alert(consulta.Success ? "Seleccione un fraccionamiento del desarrollador." :
|
|
consulta.UserMessage, TipoMensaje.MsgAdvertencia);
|
|
return 0;
|
|
}
|
|
return cveFraccionamiento;
|
|
}
|
|
|
|
private int ValidarEtapaFiltro(string valor, int cveFraccionamiento)
|
|
{
|
|
int cveEtapa;
|
|
if (!int.TryParse(valor, out cveEtapa) || cveEtapa <= 0)
|
|
{
|
|
return 0;
|
|
}
|
|
var consulta = AppServices.ServicioFraccionamiento.ObtenerEtapa(
|
|
cveEtapa, CurrentUser.CveUsuario, CurrentUser.NombreDominio);
|
|
if (!consulta.Success || consulta.Data == null ||
|
|
consulta.Data.CveCliente != CveClienteActual ||
|
|
consulta.Data.CveFraccionamiento != cveFraccionamiento)
|
|
{
|
|
Alert(consulta.Success ? "Seleccione una etapa del fraccionamiento." :
|
|
consulta.UserMessage, TipoMensaje.MsgAdvertencia);
|
|
return 0;
|
|
}
|
|
return cveEtapa;
|
|
}
|
|
|
|
private int CveFraccionamientoLotes
|
|
{
|
|
get { return (int?)ViewState["CveFraccionamientoLotes"] ?? 0; }
|
|
set { ViewState["CveFraccionamientoLotes"] = value; }
|
|
}
|
|
|
|
private int CveEtapaLotes
|
|
{
|
|
get { return (int?)ViewState["CveEtapaLotes"] ?? 0; }
|
|
set { ViewState["CveEtapaLotes"] = value; }
|
|
}
|
|
|
|
protected void BuscarEtapasLotes(
|
|
object origen, SIG.Web.AppCode.SigControls.ConsultaCatalogoEventArgs argumentos)
|
|
{
|
|
BuscarEtapasFiltro(CveFraccionamientoLotes, argumentos);
|
|
}
|
|
|
|
protected void FraccionamientoLotesCambiado(object origen, EventArgs argumentos)
|
|
{
|
|
CveFraccionamientoLotes = ValidarFraccionamientoFiltro(
|
|
BuscadorFraccionamientoLotes.SelectedValue);
|
|
CveEtapaLotes = 0;
|
|
BuscadorEtapaLotes.SelectedValue = string.Empty;
|
|
BuscadorEtapaLotes.Text = string.Empty;
|
|
BuscadorEtapaLotes.LimpiarFuenteDatos();
|
|
BuscadorEtapaLotes.LimpiarFiltrosUsuario();
|
|
CargarLotesFiltrados();
|
|
}
|
|
|
|
protected void EtapaLotesCambiada(object origen, EventArgs argumentos)
|
|
{
|
|
CveEtapaLotes = ValidarEtapaFiltro(
|
|
BuscadorEtapaLotes.SelectedValue, CveFraccionamientoLotes);
|
|
if (CveEtapaLotes == 0)
|
|
{
|
|
BuscadorEtapaLotes.SelectedValue = string.Empty;
|
|
BuscadorEtapaLotes.Text = string.Empty;
|
|
}
|
|
CargarLotesFiltrados();
|
|
}
|
|
|
|
private void CargarLotesFiltrados()
|
|
{
|
|
bool tieneFraccionamiento = CveFraccionamientoLotes > 0;
|
|
ContenidoLotesFiltrado.Visible = tieneFraccionamiento;
|
|
if (tieneFraccionamiento)
|
|
{
|
|
if (CveEtapaLotes > 0)
|
|
{
|
|
UcLotesConjunto.Cargar(CveFraccionamientoLotes, CveEtapaLotes);
|
|
}
|
|
else
|
|
{
|
|
UcLotesConjunto.CargarConjunto(CveClienteActual, CveFraccionamientoLotes);
|
|
}
|
|
}
|
|
PestanasDesarrollador.ActiveTab = PestanaLotes;
|
|
UpFiltroLotes.Update();
|
|
}
|
|
|
|
private int CveFraccionamientoSupervisiones
|
|
{
|
|
get { return (int?)ViewState["CveFraccionamientoSupervisiones"] ?? 0; }
|
|
set { ViewState["CveFraccionamientoSupervisiones"] = value; }
|
|
}
|
|
|
|
private int CveEtapaSupervisiones
|
|
{
|
|
get { return (int?)ViewState["CveEtapaSupervisiones"] ?? 0; }
|
|
set { ViewState["CveEtapaSupervisiones"] = value; }
|
|
}
|
|
|
|
protected void BuscarEtapasSupervisiones(
|
|
object origen, SIG.Web.AppCode.SigControls.ConsultaCatalogoEventArgs argumentos)
|
|
{
|
|
BuscarEtapasFiltro(CveFraccionamientoSupervisiones, argumentos);
|
|
}
|
|
|
|
protected void FraccionamientoSupervisionesCambiado(object origen, EventArgs argumentos)
|
|
{
|
|
CveFraccionamientoSupervisiones = ValidarFraccionamientoFiltro(
|
|
BuscadorFraccionamientoSupervisiones.SelectedValue);
|
|
CveEtapaSupervisiones = 0;
|
|
BuscadorEtapaSupervisiones.SelectedValue = string.Empty;
|
|
BuscadorEtapaSupervisiones.Text = string.Empty;
|
|
BuscadorEtapaSupervisiones.LimpiarFuenteDatos();
|
|
BuscadorEtapaSupervisiones.LimpiarFiltrosUsuario();
|
|
CargarSupervisionesFiltrados();
|
|
}
|
|
|
|
protected void EtapaSupervisionesCambiada(object origen, EventArgs argumentos)
|
|
{
|
|
CveEtapaSupervisiones = ValidarEtapaFiltro(
|
|
BuscadorEtapaSupervisiones.SelectedValue, CveFraccionamientoSupervisiones);
|
|
if (CveEtapaSupervisiones == 0)
|
|
{
|
|
BuscadorEtapaSupervisiones.SelectedValue = string.Empty;
|
|
BuscadorEtapaSupervisiones.Text = string.Empty;
|
|
}
|
|
CargarSupervisionesFiltrados();
|
|
}
|
|
|
|
private void CargarSupervisionesFiltrados()
|
|
{
|
|
bool tieneFraccionamiento = CveFraccionamientoSupervisiones > 0;
|
|
ContenidoSupervisionesFiltrado.Visible = tieneFraccionamiento;
|
|
if (tieneFraccionamiento)
|
|
{
|
|
UcSupervisionesConjunto.CargarContexto(
|
|
CveClienteActual, CveFraccionamientoSupervisiones, CveEtapaSupervisiones);
|
|
}
|
|
PestanasDesarrollador.ActiveTab = PestanaSupervisiones;
|
|
UpFiltroSupervisiones.Update();
|
|
}
|
|
|
|
protected void SolicitarDocumentoConjunto(object origen, EventArgs argumentos)
|
|
{
|
|
PestanasDesarrollador.ActiveTab = PestanaDocumentacion;
|
|
UcDocumentosEtapa.IniciarSolicitudDocumento();
|
|
}
|
|
|
|
protected void CargarDocumentosConjunto(object origen, EventArgs argumentos)
|
|
{
|
|
PestanasDesarrollador.ActiveTab = PestanaDocumentacion;
|
|
UcDocumentosEtapa.IniciarCargaMasiva();
|
|
}
|
|
|
|
protected void DescargarDocumentosConjunto(object origen, EventArgs argumentos)
|
|
{
|
|
PestanasDesarrollador.ActiveTab = PestanaDocumentacion;
|
|
UcDocumentosEtapa.DescargarTodosArchivos();
|
|
}
|
|
|
|
protected void AgregarTipoViviendaConjunto(object origen, EventArgs argumentos)
|
|
{
|
|
PestanasDesarrollador.ActiveTab = PestanaLotes;
|
|
if (!ValidarFiltroLotes())
|
|
{
|
|
return;
|
|
}
|
|
UcLotesConjunto.IniciarAgregarTipoVivienda();
|
|
}
|
|
|
|
protected void AgregarLotesConjunto(object origen, EventArgs argumentos)
|
|
{
|
|
PestanasDesarrollador.ActiveTab = PestanaLotes;
|
|
if (!ValidarFiltroLotes())
|
|
{
|
|
return;
|
|
}
|
|
UcLotesConjunto.IniciarAgregarLotes();
|
|
}
|
|
|
|
protected void CargarGisConjunto(object origen, EventArgs argumentos)
|
|
{
|
|
PestanasDesarrollador.ActiveTab = PestanaLotes;
|
|
if (!ValidarFiltroLotes())
|
|
{
|
|
return;
|
|
}
|
|
UcLotesConjunto.IniciarArchivoGis();
|
|
}
|
|
|
|
protected void ExportarLotesAccion(object origen, EventArgs argumentos)
|
|
{
|
|
PestanasDesarrollador.ActiveTab = PestanaLotes;
|
|
UcLotesConjunto.MostrarExportacionExcel();
|
|
}
|
|
|
|
protected void ExportarConveniosAccion(object origen, EventArgs argumentos)
|
|
{
|
|
PestanasDesarrollador.ActiveTab = PestanaConvenios;
|
|
UcConveniosDesarrollador.MostrarExportacionExcel();
|
|
}
|
|
|
|
protected void LimpiarLotesConjunto(object origen, EventArgs argumentos)
|
|
{
|
|
PestanasDesarrollador.ActiveTab = PestanaLotes;
|
|
if (!ValidarFiltroLotes())
|
|
{
|
|
return;
|
|
}
|
|
UcLotesConjunto.LimpiarLotes();
|
|
}
|
|
|
|
protected void TramitesConjuntoCambiados(object origen, EventArgs argumentos)
|
|
{
|
|
UcDocumentosEtapa.CargarDesarrollador(CveClienteActual);
|
|
}
|
|
|
|
protected void DocumentosConjuntoCambiados(object origen, EventArgs argumentos)
|
|
{
|
|
UcTramitesConjunto.Cargar(CveClienteActual);
|
|
UcDocumentosEtapa.CargarDesarrollador(CveClienteActual);
|
|
}
|
|
|
|
private void ConvenioGuardadoDesdeTramites(object origen, EventArgs argumentos)
|
|
{
|
|
UcConveniosDesarrollador.Recargar();
|
|
}
|
|
|
|
protected override void OnInit(EventArgs argumentos)
|
|
{
|
|
base.OnInit(argumentos);
|
|
UcLotesConjunto.GisActualizado += DocumentosConjuntoCambiados;
|
|
UcTramitesConjunto.ConvenioGuardado += ConvenioGuardadoDesdeTramites;
|
|
UcConveniosDesarrollador.Cambiado += ConvenioCreado;
|
|
var administradorAcciones = ScriptManager.GetCurrent(Page);
|
|
if (administradorAcciones != null)
|
|
{
|
|
administradorAcciones.RegisterAsyncPostBackControl(BtnAgregarConvenioAccion);
|
|
administradorAcciones.RegisterAsyncPostBackControl(BtnSolicitarDocumentoConjunto);
|
|
administradorAcciones.RegisterAsyncPostBackControl(BtnCargarDocumentosConjunto);
|
|
administradorAcciones.RegisterAsyncPostBackControl(BtnDescargarDocumentosConjunto);
|
|
administradorAcciones.RegisterAsyncPostBackControl(BtnAgregarTipoViviendaConjunto);
|
|
administradorAcciones.RegisterAsyncPostBackControl(BtnAgregarLotesConjunto);
|
|
administradorAcciones.RegisterAsyncPostBackControl(BtnCargarGisConjunto);
|
|
administradorAcciones.RegisterAsyncPostBackControl(BtnLimpiarLotesConjunto);
|
|
}
|
|
|
|
PresentadorBloqueos.Registrar(this, () =>
|
|
{
|
|
_estadoBloqueo = PresentadorBloqueos.ObtenerEstado(CveClienteActual);
|
|
bool bloqueado = _estadoBloqueo != null && _estadoBloqueo.EstaBloqueado;
|
|
PnlAvisoBloqueoDesarrollador.Visible = bloqueado || CveClienteActual > 0 && _estadoBloqueo == null;
|
|
LitAvisoBloqueoDesarrollador.Text = _estadoBloqueo == null
|
|
? " No fue posible verificar el bloqueo. Las modificaciones no están disponibles."
|
|
: " Sólo se permiten consultas, pagos, convenios y actualización de documentos.";
|
|
PresentadorBloqueos.Aplicar(this, _estadoBloqueo);
|
|
});
|
|
}
|
|
|
|
private EstadoBloqueo _estadoBloqueo;
|
|
protected void Fraccionamientos_FilaEnlazada(object origen, GridViewRowEventArgs argumentos)
|
|
{
|
|
if (argumentos.Row.RowType != DataControlRowType.DataRow)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var desarrollo = argumentos.Row.DataItem as ModeloFilaDesarrollos;
|
|
if (desarrollo == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
string grupo = "desarrollo-" +
|
|
desarrollo.CveFraccionamiento.ToString(CultureInfo.InvariantCulture);
|
|
|
|
if (desarrollo.EsFraccionamiento)
|
|
{
|
|
argumentos.Row.CssClass =
|
|
(argumentos.Row.CssClass +
|
|
" sig-grid-grupo desarrollador-fila-fraccionamiento").Trim();
|
|
argumentos.Row.Attributes["data-sig-group-row"] = "1";
|
|
argumentos.Row.Attributes["data-sig-group-id"] = grupo;
|
|
argumentos.Row.Attributes["data-sig-level"] = "2";
|
|
argumentos.Row.Attributes["data-sig-expanded-default"] = "true";
|
|
return;
|
|
}
|
|
|
|
argumentos.Row.CssClass =
|
|
(argumentos.Row.CssClass +
|
|
" sig-grid-fila-dato desarrollador-fila-etapa").Trim();
|
|
if (_estadoBloqueo != null && desarrollo.CveFraccionamientoEtapa.HasValue &&
|
|
(_estadoBloqueo.BloqueoTotal || _estadoBloqueo.Motivos.Exists(m =>
|
|
m.Tipo == "Documento" && m.CveFraccionamientoEtapa == desarrollo.CveFraccionamientoEtapa)))
|
|
{
|
|
argumentos.Row.CssClass += " danger";
|
|
argumentos.Row.ToolTip = _estadoBloqueo.BloqueoTotal ? "Desarrollador bloqueado" :
|
|
"Supervisión pausada por documentos vencidos de esta etapa";
|
|
}
|
|
argumentos.Row.Attributes["data-sig-item-row"] = "1";
|
|
argumentos.Row.Attributes["data-sig-parent-group"] = grupo;
|
|
argumentos.Row.Attributes["data-sig-level"] = "1";
|
|
}
|
|
|
|
protected string DescribirFraccionamiento(object objeto)
|
|
{
|
|
var fila = (ModeloFilaDesarrollos)objeto;
|
|
return string.Format(
|
|
CultureInfo.CurrentCulture,
|
|
"{0} · {1} etapa(s)",
|
|
fila.Estatus,
|
|
fila.NumeroEtapas);
|
|
}
|
|
|
|
protected string FormatearHectareas(object objeto)
|
|
{
|
|
var fila = objeto as ModeloFilaDesarrollos;
|
|
if (fila == null)
|
|
{
|
|
return string.Empty;
|
|
}
|
|
|
|
decimal? hectareas = fila.EsFraccionamiento
|
|
? fila.HectareasFraccionamiento
|
|
: fila.Hectareas;
|
|
|
|
return hectareas.HasValue
|
|
? hectareas.Value.ToString("N2", CultureInfo.CurrentCulture)
|
|
: string.Empty;
|
|
}
|
|
|
|
protected string FormatearAvance(object objeto)
|
|
{
|
|
var fila = objeto as ModeloFilaDesarrollos;
|
|
|
|
return fila == null
|
|
? string.Empty
|
|
: fila.Avance.ToString("N2", CultureInfo.CurrentCulture) + " %";
|
|
}
|
|
|
|
protected void Etapa_Cambiada(object origen, EventArgs argumentos)
|
|
{
|
|
CargarFraccionamientos();
|
|
UpFraccionamientos.Update();
|
|
}
|
|
|
|
protected void BuscarDesarrolladores(object origen,
|
|
SIG.Web.AppCode.SigControls.ConsultaCatalogoEventArgs argumentos)
|
|
{
|
|
var tabla = new System.Data.DataTable();
|
|
foreach (string columna in new[] { "Clave", "Descripcion", "RFC", "Nombre", "Estatus", "AsociadoCanadevi" })
|
|
{
|
|
tabla.Columns.Add(columna);
|
|
}
|
|
argumentos.Resultados = tabla;
|
|
var consulta = AppServices.ServicioDesarrolladores.Listar(string.Empty, true);
|
|
if (!consulta.Success)
|
|
{
|
|
argumentos.Error = consulta.UserMessage;
|
|
return;
|
|
}
|
|
foreach (var cliente in consulta.Data)
|
|
{
|
|
tabla.Rows.Add(cliente.CveCliente.ToString(CultureInfo.InvariantCulture),
|
|
cliente.RFC + " - " + cliente.Nombre, cliente.RFC, cliente.Nombre,
|
|
cliente.Estatus ? "Activo" : "Inactivo", cliente.AsociadoCanadevi ? "Sí" : "No");
|
|
}
|
|
}
|
|
|
|
protected void SeleccionarDesarrollador(object origen, EventArgs argumentos)
|
|
{
|
|
int clave;
|
|
if (int.TryParse(BuscadorDesarrolladores.SelectedValue, out clave))
|
|
{
|
|
Response.Redirect(ResolveUrl("~/Pages/Desarrolladores/DesarrolladorDetalle.aspx") +
|
|
"?cveCliente=" + clave.ToString(CultureInfo.InvariantCulture), false);
|
|
Context.ApplicationInstance.CompleteRequest();
|
|
}
|
|
}
|
|
|
|
private int CveClienteActual
|
|
{
|
|
get { return ViewState["CveClienteActual"] as int? ?? 0; }
|
|
set { ViewState["CveClienteActual"] = value; }
|
|
}
|
|
|
|
private int CveFraccionamientoEtapaActual
|
|
{
|
|
get { return ViewState["CveFraccionamientoEtapaActual"] as int? ?? 0; }
|
|
set { ViewState["CveFraccionamientoEtapaActual"] = value; }
|
|
}
|
|
|
|
private bool AsociadoCanadeviActual
|
|
{
|
|
get { return ViewState["AsociadoCanadeviActual"] as bool? ?? false; }
|
|
set { ViewState["AsociadoCanadeviActual"] = value; }
|
|
}
|
|
|
|
private bool ModoEdicion
|
|
{
|
|
get { return ViewState["ModoEdicion"] as bool? ?? false; }
|
|
set { ViewState["ModoEdicion"] = value; }
|
|
}
|
|
|
|
protected void Page_Load(object origen, EventArgs argumentos)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
int cveCliente;
|
|
if (!int.TryParse(Request.QueryString["cveCliente"], out cveCliente) || cveCliente <= 0)
|
|
{
|
|
Alert("Seleccione un desarrollador válido.", TipoMensaje.MsgAdvertencia);
|
|
return;
|
|
}
|
|
|
|
CveClienteActual = cveCliente;
|
|
DbResult<ModeloDesarrollador> consulta = AppServices.ServicioDesarrolladores.Obtener(cveCliente);
|
|
if (!consulta.Success)
|
|
{
|
|
Alert(consulta.UserMessage, TipoMensaje.MsgAdvertencia);
|
|
return;
|
|
}
|
|
|
|
PnlDetalle.Visible = true;
|
|
ModoEdicion = false;
|
|
MostrarDatos(consulta.Data);
|
|
CargarFraccionamientos();
|
|
UcDocumentosEtapa.CargarDesarrollador(CveClienteActual);
|
|
UcTramitesConjunto.Cargar(CveClienteActual);
|
|
|
|
UcConveniosDesarrollador.Cargar(new FiltroConvenios { CveCliente = CveClienteActual });
|
|
CargarEstatus();
|
|
BuscadorDesarrolladores.SelectedValue = cveCliente.ToString(CultureInfo.InvariantCulture);
|
|
BuscadorDesarrolladores.Text = consulta.Data.RFC + " - " + consulta.Data.Nombre;
|
|
switch ((Request.QueryString["tab"] ?? string.Empty).ToLowerInvariant())
|
|
{
|
|
case "datos":
|
|
PestanasDesarrollador.ActiveTab = PestanaDatos;
|
|
break;
|
|
case "desarrollos":
|
|
PestanasDesarrollador.ActiveTab = PestanaDesarrollos;
|
|
break;
|
|
case "convenios":
|
|
PestanasDesarrollador.ActiveTab = PestanaConvenios;
|
|
break;
|
|
case "documentos":
|
|
PestanasDesarrollador.ActiveTab = PestanaDocumentacion;
|
|
break;
|
|
case "tramites":
|
|
PestanasDesarrollador.ActiveTab = PestanaTramites;
|
|
break;
|
|
case "lotes":
|
|
PestanasDesarrollador.ActiveTab = PestanaLotes;
|
|
break;
|
|
case "supervisiones":
|
|
PestanasDesarrollador.ActiveTab = PestanaSupervisiones;
|
|
break;
|
|
case "representantes":
|
|
PestanasDesarrollador.ActiveTab = PestanaRepresentantes;
|
|
break;
|
|
}
|
|
}
|
|
|
|
ConfigurarCanadevi(AsociadoCanadeviActual);
|
|
ConfigurarModoEdicion(ModoEdicion);
|
|
}
|
|
|
|
protected override void OnPreRender(EventArgs argumentos)
|
|
{
|
|
bool esUsuarioAgua = CurrentUser != null && !CurrentUser.EsDesarrollador;
|
|
BtnSolicitarDocumentoConjunto.Visible = esUsuarioAgua;
|
|
BtnAgregarTipoViviendaConjunto.Visible = esUsuarioAgua;
|
|
BtnAgregarLotesConjunto.Visible = esUsuarioAgua;
|
|
BtnCargarGisConjunto.Visible = esUsuarioAgua;
|
|
BtnLimpiarLotesConjunto.Visible = esUsuarioAgua;
|
|
base.OnPreRender(argumentos);
|
|
var sitio = Master as SIG.Web.Site;
|
|
if (sitio != null)
|
|
{
|
|
sitio.SetPageNavigation("Detalle de desarrollador", new[]
|
|
{
|
|
new BreadcrumbItemModel { Texto = "Inicio", Url = "~/Inicio.aspx" },
|
|
new BreadcrumbItemModel
|
|
{
|
|
Texto = "Desarrolladores",
|
|
Url = "~/Pages/Desarrolladores/Desarrolladores.aspx"
|
|
},
|
|
new BreadcrumbItemModel { Texto = "Detalle de desarrollador" }
|
|
});
|
|
}
|
|
}
|
|
|
|
protected void EditarDesarrollador_Click(object origen, EventArgs argumentos)
|
|
{
|
|
if (!ValidarDesarrollador())
|
|
{
|
|
return;
|
|
}
|
|
|
|
ModoEdicion = true;
|
|
PestanasDesarrollador.ActiveTab = PestanaDatos;
|
|
ConfigurarModoEdicion(true);
|
|
UpDatos.Update();
|
|
}
|
|
|
|
protected void AgregarFraccionamientoAccion_Click(object origen, EventArgs argumentos)
|
|
{
|
|
if (!ValidarDesarrollador())
|
|
{
|
|
return;
|
|
}
|
|
|
|
PestanasDesarrollador.ActiveTab = PestanaDesarrollos;
|
|
UpModalFraccionamiento.Update();
|
|
RegistraScript("$('#ModalFraccionamiento').modal('show');");
|
|
}
|
|
|
|
private void ConvenioCreado(object origen, EventArgs argumentos)
|
|
{
|
|
UcTramitesConjunto.Cargar(CveClienteActual);
|
|
}
|
|
|
|
protected void AgregarConvenioAccion_Click(object origen, EventArgs argumentos)
|
|
{
|
|
if (!ValidarDesarrollador())
|
|
{
|
|
return;
|
|
}
|
|
|
|
PestanasDesarrollador.ActiveTab = PestanaConvenios;
|
|
UcConveniosDesarrollador.IniciarAgregarConvenio();
|
|
}
|
|
|
|
protected void GuardarDatos_Click(object origen, EventArgs argumentos)
|
|
{
|
|
if (!ModoEdicion)
|
|
{
|
|
return;
|
|
}
|
|
|
|
ModeloDesarrollador desarrollador = LeerDesarrollador();
|
|
desarrollador.CveCliente = CveClienteActual;
|
|
if (!AppServices.ServicioDesarrolladores.PuedeCambiarAsociadoCanadevi)
|
|
{
|
|
desarrollador.AsociadoCanadevi = AsociadoCanadeviActual;
|
|
}
|
|
|
|
DbResult<bool> resultado = AppServices.ServicioDesarrolladores.Actualizar(desarrollador);
|
|
if (!resultado.Success)
|
|
{
|
|
Alert(resultado.UserMessage, TipoMensaje.MsgAdvertencia);
|
|
return;
|
|
}
|
|
|
|
AsociadoCanadeviActual = desarrollador.AsociadoCanadevi;
|
|
ModoEdicion = false;
|
|
ConfigurarCanadevi(AsociadoCanadeviActual);
|
|
ConfigurarModoEdicion(false);
|
|
UpDatos.Update();
|
|
Alert("Datos del desarrollador guardados.", TipoMensaje.ToastExito);
|
|
}
|
|
|
|
protected void GuardarFraccionamiento_Click(object origen, EventArgs argumentos)
|
|
{
|
|
if (!ValidarDesarrollador())
|
|
{
|
|
return;
|
|
}
|
|
|
|
decimal? hectareas;
|
|
int cveEstatus;
|
|
if (!LeerHectareas(TxtHectareasFraccionamiento.Text, out hectareas) ||
|
|
!int.TryParse(DdlEstatus.SelectedValue, out cveEstatus))
|
|
{
|
|
Alert("Capture hectáreas válidas y seleccione un estatus.", TipoMensaje.MsgAdvertencia);
|
|
return;
|
|
}
|
|
|
|
List<ModeloEtapaFraccionamiento> etapas;
|
|
string mensajeEtapas;
|
|
if (!UcCapturaEtapas.Capturar(out etapas, out mensajeEtapas))
|
|
{
|
|
Alert(mensajeEtapas, TipoMensaje.MsgAdvertencia);
|
|
return;
|
|
}
|
|
|
|
DbResult<ResultadoGuardarFraccionamientoConEtapas> resultado = AppServices.ServicioFraccionamiento.GuardarConEtapas(
|
|
new ModeloFraccionamiento
|
|
{
|
|
CveCliente = CveClienteActual,
|
|
Fraccionamiento = TxtFraccionamiento.Text,
|
|
UbicacionGeoJson = UcUbicacionGeo.GeoJson,
|
|
Hectareas = hectareas,
|
|
CveEstatus = cveEstatus,
|
|
EsActivo = true
|
|
},
|
|
etapas,
|
|
CurrentUser.CveUsuario, CurrentUser.NombreDominio);
|
|
if (!resultado.Success)
|
|
{
|
|
Alert(resultado.UserMessage, TipoMensaje.MsgAdvertencia);
|
|
return;
|
|
}
|
|
|
|
TxtFraccionamiento.Text = string.Empty;
|
|
UcUbicacionGeo.GeoJson = string.Empty;
|
|
TxtHectareasFraccionamiento.Text = string.Empty;
|
|
UcCapturaEtapas.Reiniciar();
|
|
CargarFraccionamientos();
|
|
UpFraccionamientos.Update();
|
|
RegistraScript("$('#ModalFraccionamiento').modal('hide');");
|
|
|
|
string mensajeInformacion = "Fraccionamiento registrado.";
|
|
|
|
if (resultado.Data != null &&
|
|
resultado.Data.Etapas != null &&
|
|
resultado.Data.Etapas.Count > 0)
|
|
{
|
|
mensajeInformacion +=
|
|
"<br/><br/><strong>Etapas generadas:</strong><ul>";
|
|
|
|
foreach (ModeloEtapaFraccionamiento etapaGenerada in resultado.Data.Etapas)
|
|
{
|
|
string urlEtapa = ResolveUrl(
|
|
"~/Pages/Fraccionamientos/EtapaDetalle.aspx?etapa=" +
|
|
etapaGenerada.CveFraccionamientoEtapa.ToString(
|
|
CultureInfo.InvariantCulture));
|
|
|
|
mensajeInformacion +=
|
|
"<li><a href=\"" +
|
|
HttpUtility.HtmlAttributeEncode(urlEtapa) +
|
|
"\">" +
|
|
HttpUtility.HtmlEncode(etapaGenerada.Etapa) +
|
|
"</a></li>";
|
|
}
|
|
|
|
mensajeInformacion += "</ul>";
|
|
}
|
|
Alert("Fraccionamiento registrado.", TipoMensaje.ToastExito);
|
|
}
|
|
|
|
protected void Fraccionamientos_Comando(object origen, GridViewCommandEventArgs argumentos)
|
|
{
|
|
if (argumentos.CommandName != "AgregarEtapa" || !ValidarDesarrollador())
|
|
{
|
|
return;
|
|
}
|
|
|
|
var control = argumentos.CommandSource as Control;
|
|
var fila = control == null ? null : control.NamingContainer as GridViewRow;
|
|
if (fila == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
int cveFraccionamiento = Convert.ToInt32(GvFraccionamientos.DataKeys[fila.RowIndex].Value);
|
|
ModeloFraccionamiento fraccionamiento = ObtenerFraccionamientoDelCliente(cveFraccionamiento);
|
|
if (fraccionamiento == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
CveFraccionamientoEtapaActual = cveFraccionamiento;
|
|
LitFraccionamientoEtapa.Text = fraccionamiento.Fraccionamiento;
|
|
TxtEtapa.Text = string.Empty;
|
|
TxtHectareasEtapa.Text = string.Empty;
|
|
UpModalEtapa.Update();
|
|
RegistraScript("$('#ModalEtapa').modal('show');");
|
|
}
|
|
|
|
protected void GuardarEtapa_Click(object origen, EventArgs argumentos)
|
|
{
|
|
if (!ValidarDesarrollador() ||
|
|
ObtenerFraccionamientoDelCliente(CveFraccionamientoEtapaActual) == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
decimal? hectareas;
|
|
if (!LeerHectareas(TxtHectareasEtapa.Text, out hectareas))
|
|
{
|
|
Alert("Capture hectáreas válidas.", TipoMensaje.MsgAdvertencia);
|
|
return;
|
|
}
|
|
|
|
DbResult<int> resultado = AppServices.ServicioFraccionamiento.GuardarEtapa(
|
|
new ModeloEtapaFraccionamiento
|
|
{
|
|
CveCliente = CveClienteActual,
|
|
CveFraccionamiento = CveFraccionamientoEtapaActual,
|
|
Etapa = TxtEtapa.Text,
|
|
Hectareas = hectareas,
|
|
EsActivo = true
|
|
},
|
|
CurrentUser.CveUsuario, CurrentUser.NombreDominio);
|
|
if (!resultado.Success)
|
|
{
|
|
Alert(resultado.UserMessage, TipoMensaje.MsgAdvertencia);
|
|
return;
|
|
}
|
|
|
|
CveFraccionamientoEtapaActual = 0;
|
|
CargarFraccionamientos();
|
|
UpFraccionamientos.Update();
|
|
RegistraScript("$('#ModalEtapa').modal('hide');");
|
|
Alert("Etapa registrada.", TipoMensaje.ToastExito);
|
|
}
|
|
|
|
private bool ValidarDesarrollador()
|
|
{
|
|
DbResult<ModeloDesarrollador> consulta = AppServices.ServicioDesarrolladores.Obtener(CveClienteActual);
|
|
if (!consulta.Success)
|
|
{
|
|
Alert(consulta.UserMessage, TipoMensaje.MsgAdvertencia);
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
private ModeloFraccionamiento ObtenerFraccionamientoDelCliente(int cveFraccionamiento)
|
|
{
|
|
DbResult<ModeloFraccionamiento> consulta = AppServices.ServicioFraccionamiento.Obtener(
|
|
cveFraccionamiento, CurrentUser.CveUsuario, CurrentUser.NombreDominio);
|
|
if (!consulta.Success || consulta.Data == null ||
|
|
consulta.Data.CveCliente != CveClienteActual || !consulta.Data.EsActivo)
|
|
{
|
|
Alert(consulta.Success ? "El fraccionamiento no está activo o no pertenece a este desarrollador." :
|
|
consulta.UserMessage, TipoMensaje.MsgAdvertencia);
|
|
return null;
|
|
}
|
|
|
|
return consulta.Data;
|
|
}
|
|
|
|
protected string ObtenerUrlFraccionamiento(object clave)
|
|
{
|
|
return ResolveUrl("~/Pages/Fraccionamientos/FraccionamientoDetalle.aspx?id=" +
|
|
Convert.ToInt32(clave).ToString(CultureInfo.InvariantCulture));
|
|
}
|
|
|
|
protected string ObtenerUrlEtapa(object clave)
|
|
{
|
|
int cveEtapa = Convert.ToInt32(clave);
|
|
return cveEtapa <= 0
|
|
? string.Empty
|
|
: ResolveUrl("~/Pages/Fraccionamientos/EtapaDetalle.aspx?etapa=" +
|
|
cveEtapa.ToString(CultureInfo.InvariantCulture));
|
|
}
|
|
|
|
private void CargarFraccionamientos()
|
|
{
|
|
var bloqueo = AppServices.ServicioBloqueos.ObtenerEstado(CveClienteActual, null,
|
|
CurrentUser.CveUsuario, CurrentUser.NombreDominio);
|
|
_estadoBloqueo = bloqueo.Success ? bloqueo.Data : null;
|
|
if (!bloqueo.Success) { Alert(bloqueo.UserMessage, TipoMensaje.MsgAdvertencia); return; }
|
|
var resultado = AppServices.ServicioFraccionamiento.ListarDesarrollos(
|
|
CveClienteActual, CurrentUser.CveUsuario, CurrentUser.NombreDominio);
|
|
GvFraccionamientos.DataSource = resultado.Success ? resultado.Data : null;
|
|
GvFraccionamientos.DataBind();
|
|
if (!resultado.Success)
|
|
{
|
|
Alert(resultado.UserMessage, TipoMensaje.MsgAdvertencia);
|
|
}
|
|
}
|
|
|
|
private void CargarEstatus()
|
|
{
|
|
var resultado = AppServices.ServicioFraccionamiento.ListarEstatus(
|
|
CurrentUser.CveUsuario, CurrentUser.NombreDominio);
|
|
DdlEstatus.DataSource = resultado.Success ? resultado.Data : null;
|
|
DdlEstatus.DataTextField = "Estatus";
|
|
DdlEstatus.DataValueField = "CveEstatus";
|
|
DdlEstatus.DataBind();
|
|
DdlEstatus.SelectedValue= "1";
|
|
if (!resultado.Success)
|
|
{
|
|
Alert(resultado.UserMessage, TipoMensaje.MsgAdvertencia);
|
|
}
|
|
}
|
|
|
|
private void MostrarDatos(ModeloDesarrollador desarrollador)
|
|
{
|
|
TxtRFC.Text = desarrollador.RFC;
|
|
TxtNombre.Text = desarrollador.Nombre;
|
|
TxtDireccion.Text = desarrollador.Direccion;
|
|
TxtNoExt.Text = desarrollador.NoExt;
|
|
TxtDuplicador.Text = desarrollador.Duplicador;
|
|
TxtReferencia.Text = desarrollador.Referencia;
|
|
TxtTelefono.Text = desarrollador.Telefono;
|
|
TxtMail.Text = desarrollador.Mail;
|
|
TxtAdherente.Text = desarrollador.Adherente;
|
|
TxtCP.Text = desarrollador.CP;
|
|
if (CargarColonias())
|
|
{
|
|
ListItem colonia = DdlColonia.Items.FindByValue(
|
|
desarrollador.CveColonia.ToString(CultureInfo.InvariantCulture));
|
|
if (colonia != null)
|
|
{
|
|
DdlColonia.SelectedValue = colonia.Value;
|
|
}
|
|
}
|
|
|
|
AsociadoCanadeviActual = desarrollador.AsociadoCanadevi;
|
|
ChkCanadevi.Checked = desarrollador.AsociadoCanadevi;
|
|
}
|
|
|
|
private static bool LeerHectareas(string texto, out decimal? hectareas)
|
|
{
|
|
hectareas = null;
|
|
if (string.IsNullOrWhiteSpace(texto))
|
|
{
|
|
return true;
|
|
}
|
|
|
|
decimal valor;
|
|
if (!decimal.TryParse(texto.Trim(), NumberStyles.AllowDecimalPoint,
|
|
CultureInfo.InvariantCulture, out valor) || valor < 0 || valor > 999999999.9999m)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
hectareas = valor;
|
|
return true;
|
|
}
|
|
|
|
private ModeloDesarrollador LeerDesarrollador()
|
|
{
|
|
int cveColonia;
|
|
int.TryParse(DdlColonia.SelectedValue, out cveColonia);
|
|
return new ModeloDesarrollador
|
|
{
|
|
RFC = TxtRFC.Text,
|
|
Nombre = TxtNombre.Text,
|
|
Direccion = TxtDireccion.Text,
|
|
NoExt = TxtNoExt.Text,
|
|
Duplicador = TxtDuplicador.Text,
|
|
Referencia = TxtReferencia.Text,
|
|
Telefono = TxtTelefono.Text,
|
|
Mail = TxtMail.Text,
|
|
Adherente = TxtAdherente.Text,
|
|
CP = TxtCP.Text,
|
|
CveColonia = cveColonia,
|
|
AsociadoCanadevi = ChkCanadevi.Checked
|
|
};
|
|
}
|
|
|
|
protected void ConsultarCP_Click(object origen, EventArgs argumentos)
|
|
{
|
|
CargarColonias();
|
|
}
|
|
|
|
private bool CargarColonias()
|
|
{
|
|
DdlColonia.Items.Clear();
|
|
LitUbicacionPostal.Text = string.Empty;
|
|
var resultado = AppServices.ServicioDesarrolladores.ConsultarCodigoPostal(TxtCP.Text);
|
|
if (!resultado.Success || resultado.Data == null)
|
|
{
|
|
Alert(resultado.Success ? "No se encontró el código postal." : resultado.UserMessage,
|
|
TipoMensaje.MsgAdvertencia);
|
|
return false;
|
|
}
|
|
|
|
DdlColonia.DataSource = resultado.Data.Colonias;
|
|
DdlColonia.DataTextField = "NombreAsentamiento";
|
|
DdlColonia.DataValueField = "CveColonia";
|
|
DdlColonia.DataBind();
|
|
DdlColonia.Items.Insert(0, new ListItem("Seleccione una colonia", ""));
|
|
LitUbicacionPostal.Text = resultado.Data.Ciudad + ", " + resultado.Data.Estado;
|
|
return true;
|
|
}
|
|
|
|
private void ConfigurarModoEdicion(bool editar)
|
|
{
|
|
TxtRFC.Enabled = editar;
|
|
TxtNombre.Enabled = editar;
|
|
TxtDireccion.Enabled = editar;
|
|
TxtNoExt.Enabled = editar;
|
|
TxtDuplicador.Enabled = editar;
|
|
TxtCP.Enabled = editar;
|
|
BtnConsultarCP.Enabled = editar;
|
|
DdlColonia.Enabled = editar;
|
|
TxtReferencia.Enabled = editar;
|
|
TxtTelefono.Enabled = editar;
|
|
TxtMail.Enabled = editar;
|
|
TxtAdherente.Enabled = editar;
|
|
ChkCanadevi.Enabled = editar && AppServices.ServicioDesarrolladores.PuedeCambiarAsociadoCanadevi;
|
|
BtnGuardarDatos.Visible = editar;
|
|
}
|
|
|
|
private void ConfigurarCanadevi(bool asociado)
|
|
{
|
|
bool puedeEditar = AppServices.ServicioDesarrolladores.PuedeCambiarAsociadoCanadevi;
|
|
PnlEditarCanadevi.Visible = puedeEditar;
|
|
PnlConsultarCanadevi.Visible = !puedeEditar;
|
|
LitCanadevi.Text = "Asociado CANADEVI: " + (asociado ? "Sí" : "No");
|
|
}
|
|
|
|
}
|
|
}
|
|
|