using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;
using AyABL;
using AyABL.AUT.Autenticacion;
//using AyABL.APL;
using AyADAL;
using System.Configuration;
using AyABL.RCS;
using AyABL;
using AyABL.Usuario;
using AyABL.APL;
using AyABL.Tran;
using AyABL.TRA;
using System.Collections;
using System.Data;
using AyABL.AUT.Encripta;
public partial class Forms_TRA_Validarplanosyfolios : General
{
#region Inicializar Formulario (R0)
override protected void OnInit(EventArgs e) //M0
{
try
{
base.OnInit(e);
InicializarFormulario();
}
catch (Exception ex)
{
MensajeError("Error en R0M0", ex);
}
}
private void InicializarFormulario() //M1
{
try
{
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Javascript.CheckAllGridViewItems(Page);
}
catch (Exception ex)
{
MensajeError("Error en R0M1", ex);
}
}
#endregion
#region Variables (R1)
terrenoBL objterrenoBL;
folioBL objfolioBL;
concesionarrendamientoBL objconcesionarrendamientoBL;
tipoterrenoBL objtipoterrenoBL;
solicitudfolioBL objsolicitudfolioBL;
solicitudBL objsolicitudBL;
provinciaBL objprovinciaBL;
consecutivoagBL objconsecutivoagBL;
consecutivoBL objconsecutivoBL;
public string strPKSolicitudTMP = "0";
public string strNumSolicitudTMP = "0";
ArrayList arlCondicionesFiltroBusqueda = new ArrayList();
#region variables del estandar
string strPagina = string.Empty;
string strScript = string.Empty;
#endregion
#endregion
#region Eventos Formulario (R2)
protected void Page_Load(object sender, EventArgs e) //M0
{
try
{
if (Session["SOLICITUD"] != null)
{
strPKSolicitudTMP = Session["PKSOLICITUD"].ToString();
strNumSolicitudTMP = Session["SOLICITUD"].ToString();
ViewState["PKSOLICITUD"] = Session["PKSOLICITUD"].ToString();
}
if (Session["SOLICITUD"] == null)
{
Session["SOLICITUD"] = null;
Session["PKSOLICITUD"] = null;
Session["FKREUTILIZA"] = null;
Session["PKPROGRAMACION"] = null;
}
if ((!IsPostBack) && (Session.Count > 0) && validarSesion())
{
string strMensajeRangeValidator = "El valor debe estar entre 1900 y " + DateTime.Now.Year.ToString();
//llenarGridView(true);
rvAno.MaximumValue = DateTime.Now.Year.ToString();
rvAno.ErrorMessage = strMensajeRangeValidator;
//rvAnnos.MaximumValue = DateTime.Now.Year.ToString();
//rvAnnos.ErrorMessage = strMensajeRangeValidator;
rvAnno.MaximumValue = DateTime.Now.Year.ToString();
rvAnno.ErrorMessage = strMensajeRangeValidator;
txtAno.Text = DateTime.Now.Year.ToString();
txtanno.Text = DateTime.Now.Year.ToString();
llenarDDLProvincia();
llenarDDLProvincias();
llenarDDLTipoterreno();
mostrarFilaTabla(1);
limpiarCampos();
if (ViewState["PKSOLICITUD"] != null)
{
strPKSolicitudTMP = ViewState["PKSOLICITUD"].ToString();
llenarGridSolicitudFolio();
//llenarGridTerreno();
}
ComandosxMenu();
}
else
{
if (Session.Count == 0)
{ ClientScript.RegisterStartupScript(this.GetType(), "Error", ""); }
}
}
catch (Exception ex)
{
MensajeError("Error en R2M0", ex);
}
}
#endregion
#region Eventos Controles Web (R3)
///
/// Activa el evento del boton guardar.1
///
///
///
///
protected void btnGuardar_Click(object sender, EventArgs e) //M1
{
int pkRegistro = 0;
try
{
ViewState["MODO"] = "Nuevo";
if (ddlProvincia.SelectedValue.ToString() != "-1" && txtConsultaFolio.Text != string.Empty && txtAno.Text != string.Empty)
{
if (VerificarFolio(false) == false)
{
pkRegistro = GuardarDatos();
limpiarCampos();
//MensajeInformativo(AyABL.BASESDEDATOS.ADS + "Interfaz: " + MensajesAplicacion.GuardadoExitoso.ToString());
EncriptaBL objEncripta = new EncriptaBL();
Session["FKREUTILIZA"] = " ";
if (pkRegistro != 0)
Response.Redirect("~/forms/tra/frwNuevaSolicitud.aspx?" + "l=" + objEncripta.Encryptar(Session["LOGIN"].ToString()) + "&u=" + objEncripta.Encryptar(Session["PKUSUARIO"].ToString()) + "&d=ingresodatos", false);
}
else
{
EncriptaBL objEncripta = new EncriptaBL();
Response.Redirect("~/forms/tra/frwBusquedaSolicitud.aspx?" + "l=" + objEncripta.Encryptar(Session["LOGIN"].ToString()) + "&u=" + objEncripta.Encryptar(Session["PKUSUARIO"].ToString()) + "&f=" + ddlProvincias.SelectedValue.ToString() + "-" + txtConsultaFolio.Text + "-" + txtDuplicado.Text + "-" + txtHorizontal.Text + "-" + txtDerecho.Text);
}
}
else
{
MensajeAlerta("Deben llenarse todos los datos antes de continuar....");
}
}
catch (Exception ex)
{
MensajeError("Error en R3M14", ex);
}
finally
{
}
}
///
/// Metodo que activa el botón de anterior
///
///
///
protected void btnActivar_Click(object sender, EventArgs e) //M2
{
try
{
limpiarCampos();
Response.Redirect("~/forms/tra/frwBusquedaSolicitud.aspx");
}
catch (Exception ex)
{
//MensajeError("Error en R3M9", ex);
}
}
///
/// Metodo que activa el botón de anterior
///
///
///
protected void imgGenerarcodigo_Click(object sender, EventArgs e) //M2
{
try
{
txtconsecutivoag.Text = obtenerNumAgrimensura();
}
catch (Exception ex)
{
MensajeError("Error en R3M9", ex);
}
}
///
/// Activa el evento del boton guardar.1
///
///
///
///
protected void ddlProvincias_SelectedIndexChanged(object sender, EventArgs e) //M3
{
}
///
/// Activa el evento del boton guardar.1
///
///
///
///
protected void ddlProvincia_SelectedIndexChanged(object sender, EventArgs e) //M4
{
divnum1.Visible = true;
divnum2.Visible = true;
divnum3.Visible = true;
divnum4.Visible = false;
}
///
/// Activa el evento del boton guardar.1
///
///
///
///
protected void ddlTipoTerreno_SelectedIndexChanged(object sender, EventArgs e) //M5
{
divnum1.Visible = false;
divnum2.Visible = false;
divnum3.Visible = false;
divnum4.Visible = false;
//divnum6.Visible = false;
divnum7.Visible = false;
divnum8.Visible = false;
divnum9.Visible = false;
rblNaturalezaInmueble.SelectedValue = "1";
//limpiarCampos();
// bool bVerifica = VerificarFolio(false);
if (ViewState["FOLIO"] != null)
{
terrenoBL objTerrenoBL = new terrenoBL();
if (ViewState["FOLIO"] != null)
{
objTerrenoBL.objterrenoEL.FKFOLIO = int.Parse(ViewState["FOLIO"].ToString());
DataSet ds = objTerrenoBL.dsListarTerrenos();
if (ds.Tables[0].Rows.Count > 0)
{
MensajeAlerta("El folio tiene terrenos asociados..");
imgVerSolicitudes.Visible = true;
btnAsignarFolioPlano.Visible = true;
grvListaTerrenos.DataSource = ds;
grvListaTerrenos.DataBind();
}
}
}
//if(ddlTipoTerreno.SelectedValue == "1")
// divnum6.Visible = true;
if (ddlTipoTerreno.SelectedValue != "1")
{
divnum1.Visible = false;
//limpiarCampos();
}
else
{
divnum1.Visible = true;
//limpiarCampos();
}
if (ddlTipoTerreno.SelectedValue != "2")
{
divnum1.Visible = true;
divnum2.Visible = false;
divnum7.Visible = false;
//limpiarCampos();
}
else
{
divnum1.Visible = true;
divnum2.Visible = true;
divnum7.Visible = true;
//limpiarCampos();
}
if (ddlTipoTerreno.SelectedValue != "4")
{
divnum1.Visible = true;
divnum3.Visible = false;
//limpiarCampos();
}
else
{
divnum1.Visible = true;
divnum2.Visible = false;
divnum3.Visible = true;
divnum7.Visible = true;
//limpiarCampos();
}
if (ddlTipoTerreno.SelectedValue != "5")
{
divnum4.Visible = false;
//limpiarCampos();
}
else
{
divnum1.Visible = false;
divnum2.Visible = false;
divnum3.Visible = false;
divnum4.Visible = true;
divnum7.Visible = false;
//limpiarCampos();
}
//limpiarCampos();
btnAgregarTerreno.Visible = true;
}
///
/// Activa el evento del boton guardar.1
///
///
///
///
protected void rbtltipoconcesion_SelectedIndexChanged(object sender, EventArgs e) //M6
{
}
///
/// Activa el evento del boton guardar.1
///
///
///
///
protected void rbtlarrendamiento_SelectedIndexChanged(object sender, EventArgs e) //M6
{
}
protected void chkSinFolio_CheckedChanged(object sender, EventArgs e)
{
try
{
if (chkSinFolio.Checked == true)
{
ddlProvincias.Enabled = false;
txtConsultaFolio.Enabled = false;
txtDuplicado.Enabled = false;
txtHorizontal.Enabled = false;
txtDerecho.Enabled = false;
}
else
{
ddlProvincias.Enabled = true;
txtConsultaFolio.Enabled = true;
txtDuplicado.Enabled = true;
txtHorizontal.Enabled = true;
txtDerecho.Enabled = true;
}
}
catch (Exception ex)
{
MensajeError("Se produjo un error al definir el folio",ex);
}
}
protected void btnAgregarTerreno_Click(object sender, EventArgs e)
{
try
{
bool bValidaCampos = true;
if (ddlTipoTerreno.SelectedValue == "5")
if (txtconsecutivoag.Text != string.Empty && txtanno.Text != string.Empty && txtCodigoAPT.Text != string.Empty)
bValidaCampos = true;
if (ddlTipoTerreno.SelectedValue != "5")
if (ddlProvincia.SelectedValue != "-1" && txtNumeroPlano.Text != string.Empty && txtAno.Text != string.Empty)
bValidaCampos = true;
if (rblNaturalezaInmueble.SelectedValue == "3" && (chkDeclaracionPrivada.Checked == false && chkDeclaracionProtocolizada.Checked == false))
{
MensajeAlerta("Debe seleccionar el tipo de declaracion para el terreno sin inscribir.");
bValidaCampos = false;
}
if (rblNaturalezaInmueble.SelectedValue == "4" && txtNumeroDocumentoAD.Text == string.Empty)
{
MensajeAlerta("Debe digitar el numero de documento AD para la zona indígena.");
bValidaCampos = false;
}
if ((ddlTipoTerreno.SelectedValue == "2" || ddlTipoTerreno.SelectedValue == "4") && txtContratoConcesion.Text == string.Empty)
{
MensajeAlerta("Debe digitar el número de contrato / concesión.");
bValidaCampos = false;
}
if (txtNumeroPlano.Text == string.Empty)
{
MensajeAlerta("Debe digitar el número de Inmueble");
bValidaCampos = false;
}
string strNumeroTerreno = string.Empty;
if (bValidaCampos)
{
if (VerificarPlano(false) == false)
{
ViewState["MODO"] = "Nuevo";
int nPkTerreno = GuardarDatos();
limpiarCampos();
}
else
{
MensajeInformativo("El terreno ya existe...");
}
llenarGridTerreno();
}
else
{
MensajeAlerta("Debe llenar todos los campos...");
}
}
catch (Exception ex)
{
MensajeError("Se produjo un error al ingresar el plano...", ex);
}
}
protected void imgVerSolicitudes_Click(object sender, ImageClickEventArgs e)
{
try
{
EncriptaBL objEncripta = new EncriptaBL();
Response.Redirect("~/forms/tra/frwBusquedaSolicitud.aspx?" + "l=" + objEncripta.Encryptar(Session["LOGIN"].ToString()) + "&u=" + objEncripta.Encryptar(Session["PKUSUARIO"].ToString()) + "&f=" + ddlProvincias.SelectedValue.ToString() + "-" + txtConsultaFolio.Text + "-" + txtDuplicado.Text + "-" + txtHorizontal.Text + "-" + txtDerecho.Text);
}
catch (Exception ex)
{
MensajeError("Se produjo un error al mostrar las solicitudes.", ex);
}
}
protected void grvListaTerrenos_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
try
{
grvListaTerrenos.PageIndex = e.NewPageIndex;
terrenoBL objTerrenoBL = new terrenoBL();
if (ViewState["FOLIO"] != null)
{
objTerrenoBL.objterrenoEL.FKFOLIO = int.Parse(ViewState["FOLIO"].ToString());
DataSet ds = objTerrenoBL.dsListarTerrenos();
if (ds.Tables[0].Rows.Count > 0)
{
imgVerSolicitudes.Visible = true;
grvListaTerrenos.DataSource = ds;
grvListaTerrenos.DataBind();
}
}
}
catch (Exception ex)
{
MensajeError("Error en R3M1", ex);
}
}
protected void grvFolio_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
try
{
grvFolio.PageIndex = e.NewPageIndex;
folioBL objFolioBL = new folioBL();
if (ViewState["FOLIO"] != null)
{
//objFolioBL.objfolioEL.NUMEROFOLIO = ;
DataSet ds = objFolioBL.dsListaFoliosSolicitud();
if (ds.Tables[0].Rows.Count > 0)
{
imgVerSolicitudes.Visible = true;
grvFolio.DataSource = ds;
grvFolio.DataBind();
}
}
}
catch (Exception ex)
{
MensajeError("Error en R3M1", ex);
}
}
protected void imgAsignacionExpediente_Click(object sender, ImageClickEventArgs e)
{
try
{
//MensajeInformativo(AyABL.BASESDEDATOS.ADS + "Interfaz: " + MensajesAplicacion.GuardadoExitoso.ToString());
EncriptaBL objEncripta = new EncriptaBL();
Session["FKREUTILIZA"] = " ";
Session["ESTADO"] = "Bloqueada";
Response.Redirect("~/forms/tra/frwNuevaSolicitud.aspx?" + "l=" + objEncripta.Encryptar(Session["LOGIN"].ToString()) + "&u=" + objEncripta.Encryptar(Session["PKUSUARIO"].ToString()) + "&d=ingresodatos", false);
}
catch (Exception ex)
{
MensajeError("Se dio un error al ingresar los datos intente mas tarde...", ex);
}
}
protected void btnAgregarFolio_Click(object sender, EventArgs e)
{
try
{
int nPkFolio = 0;
if (ddlProvincia.SelectedValue.ToString() != "-1" && txtConsultaFolio.Text != string.Empty && txtDuplicado.Text != string.Empty &&
txtHorizontal.Text != string.Empty && txtDerecho.Text != string.Empty &&
txtAno.Text != string.Empty || chkSinFolio.Checked == true)
{
if (VerificarFolio(true) == false)
{
ddlProvincia.SelectedValue = ddlProvincias.SelectedValue;
nPkFolio = GuardarFolio();
ViewState["FOLIO"] = nPkFolio;
VerificarFolio(false);
limpiarCampos();
grvListaTerrenos.DataSource = null;
grvListaTerrenos.DataBind();
btnAgregarTerreno.Visible = false;
btnAsignarFolioPlano.Visible = false;
llenarGridTerreno();
}
divnum5.Visible = true;
divnum6.Visible = true;
btnAgregarTerreno.Visible = true;
}
else
{
MensajeAlerta("Deben llenarse todos los datos antes de continuar...");
}
//llenarGridSolicitudFolio();
}
catch (Exception ex)
{
MensajeError("Se dio un error al ingresar el folio", ex);
}
}
protected void btnAsignarFolioPlano_Click(object sender, EventArgs e)
{
try
{
ViewState["MODO"] = "Nuevo";
AsignarFolioPlano();
//limpiarCampos();
}
catch (Exception ex)
{
MensajeError("Se presentó un problema al asignar el folio y plano seleccionados a la nueva solicitud...", ex);
}
}
protected void grvListaTerrenoSolicitud_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
try
{
grvListaTerrenoSolicitud.PageIndex = e.NewPageIndex;
llenarGridSolicitudFolio();
}
catch (Exception ex)
{
MensajeError("Error en R3M1", ex);
}
}
protected void grvListaTerrenoSolicitud_RowCommand(object sender, GridViewCommandEventArgs e)
{
try
{
int i = Convert.ToInt32(e.CommandArgument);
GridViewRow selectedRow = grvListaTerrenoSolicitud.Rows[i];
int nPk = int.Parse(selectedRow.Cells[1].Text);
if (e.CommandName == "borrar")
{
if (grvListaTerrenoSolicitud.Rows.Count > 1)
{
if (eliminarFolioPlano(nPk))
llenarGridSolicitudFolio();
GuardarEventoBitacora(
Session["LOGIN"].ToString(),
AccionBitacora.INSERT.ToString(),
MensajesBitacora.EliminarRegistro + ": Se ha eliminado el plano " + selectedRow.Cells[3].Text + " y el folio " + selectedRow.Cells[1].Text + " de la solicitud " + Session["SOLICITUD"].ToString(),
"frwValidarPlanosyFolios.aspx",
Convert.ToInt32(ConfigurationManager.AppSettings["pkApp"])
);
}
else
{
MensajeAlerta("La solicitud debe tener al menos un folio y plano asociado por esto no se puede eliminar.");
}
}
}
catch (Exception ex)
{
MensajeError("Error en R3M15", ex);
}
}
protected void grvListaTerrenos_RowCommand(object sender, GridViewCommandEventArgs e)
{
try
{
int i = Convert.ToInt32(e.CommandArgument);
GridViewRow selectedRow = grvListaTerrenos.Rows[i];
int nPk = int.Parse(selectedRow.Cells[2].Text);
if (e.CommandName == "borrar")
{
foreach (GridViewRow row in grvFolio.Rows)
{
HtmlInputCheckBox chkTemp = (HtmlInputCheckBox)row.Controls[1].Controls[1];
if (chkTemp != null)
{
//Si el registro esta marcado guarde
if (chkTemp.Checked)
{
objsolicitudfolioBL = new solicitudfolioBL();
objsolicitudfolioBL.objsolicitudfolioEL.FKTERRENO = int.Parse(selectedRow.Cells[2].Text);
DataSet dsSolicitudFolio = objsolicitudfolioBL.dsListaSolicitudFolio(null);
if (dsSolicitudFolio.Tables[0].Rows.Count == 0)
{
if (eliminarPlano(nPk))
llenarGridTerreno();
GuardarEventoBitacora(
Session["LOGIN"].ToString(),
AccionBitacora.DELETE.ToString(),
MensajesBitacora.EliminarRegistro + ": Se ha eliminado el plano " + selectedRow.Cells[3].Text,
"frwValidarPlanosyFolios.aspx",
Convert.ToInt32(ConfigurationManager.AppSettings["pkApp"])
);
}
else
{
MensajeAlerta("El plano no puede ser eliminado ya que se encuentra asociado a una o varias solicitudes....");
}
}
}
}
}
}
catch (Exception ex)
{
MensajeError("Error en R3M15", ex);
}
}
protected void grvFolio_RowCommand(object sender, GridViewCommandEventArgs e)
{
try
{
int i = Convert.ToInt32(e.CommandArgument);
GridViewRow selectedRow = grvFolio.Rows[i];
int nPk = int.Parse(selectedRow.Cells[2].Text);
objsolicitudfolioBL = new solicitudfolioBL();
objsolicitudfolioBL.objsolicitudfolioEL.FKFOLIO = int.Parse(selectedRow.Cells[2].Text);
DataSet dsSolicitudFolio = objsolicitudfolioBL.dsListaSolicitudFolio(null);
if (dsSolicitudFolio.Tables[0].Rows.Count == 0)
{
if (e.CommandName == "borrar")
{
if (eliminarFolio(nPk))
VerificarFolio(false);
GuardarEventoBitacora(
Session["LOGIN"].ToString(),
AccionBitacora.DELETE.ToString(),
MensajesBitacora.EliminarRegistro + ": Se ha eliminado el folio " + selectedRow.Cells[3].Text,
"frwValidarPlanosyFolios.aspx",
Convert.ToInt32(ConfigurationManager.AppSettings["pkApp"])
);
}
}
else
{
MensajeAlerta("El folio no puede ser eliminado ya que tiene planos asociados.....");
}
}
catch (Exception ex)
{
MensajeError("Error en R3M15", ex);
}
}
#endregion
#region Metodos Personalizados (R4)
///
/// Oculta las filas que lo requieran
///
///
///
private void mostrarFilaTabla(int p_intFila) //M0
{
try
{
divDatosSuperiores.Visible = false;
//divDatosInferiores.Visible = false;
switch (p_intFila)
{
case 1:
mostrarDatos();
divDatosSuperiores.Visible = true;
break;
case 2:
mostrarDatos();
//divDatosInferiores.Visible = true;
break;
case 3:
mostrarDatos();
//divDatosInferiores.Visible = true;
break;
}
}
catch (Exception ex)
{
throw ex;
}
}
///
/// Metodo que se utiliza para el despliegue de los botones
///
private void ComandosxMenu() //M4
{
try
{
DataSet dsComandos = getComandos();
if (dsComandos != null)
{
foreach (DataRow drTemp in dsComandos.Tables[0].Rows)
{
switch (drTemp["NOMBRECOMANDO"].ToString().ToUpper())
{
case "NUEVO":
break;
case "MODIFICA":
//Inicio de variable tipo VIEWSTATE
ViewState["PUEDEMODIFICAR"] = true;
btnGuardar.Visible = true;
break;
}
}
}
}
catch (Exception ex)
{
throw ex;
}
}
///
/// Metodo que se utiliza para obtener el número de solicitud
///
private string obtenerNumSolicitudPermanente() //M6
{
string strResultado = "";
try
{
objconsecutivoBL = new consecutivoBL();
objconsecutivoBL.objConsecutivoEL.USUARIO = int.Parse(Session["PKUSUARIOXDEPENDENCIA"].ToString());
objconsecutivoBL.objConsecutivoEL.ANNO = DateTime.Now.Year;
objconsecutivoBL.objConsecutivoEL.FKCANTONAL = int.Parse(Session["DEPENDENCIA"].ToString());
objconsecutivoBL.objConsecutivoEL.FKREGION = int.Parse(Session["REGION"].ToString());
int resultado = objconsecutivoBL.obtenerConsecutivo(objconsecutivoBL.objConsecutivoEL);
strResultado = DateTime.Now.Year.ToString() + "-" + Rellenar(resultado,8) + "-1";
}
catch (Exception ex)
{
throw ex;
}
return strResultado;
}
public string Rellenar(int p_nPKConsecutivo,int p_nLongitud)
{
try
{
string strResultado = p_nPKConsecutivo.ToString();
int nLongitudActual = p_nPKConsecutivo.ToString().Length;
for (int i = 0; i < p_nLongitud - nLongitudActual; i++)
{
strResultado = "0" + strResultado;
}
return strResultado;
}
catch (Exception ex)
{
throw ex;
}
}
///
/// Metodo que se utiliza para obtener el número de Agrimensura
///
private string obtenerNumAgrimensura() //M6
{
string strResultado = "";
try
{
objconsecutivoagBL = new consecutivoagBL();
objconsecutivoagBL.objconsecutivoagEL.FKUSUARIOXDEPENDENCIA = int.Parse(Session["PKUSUARIOXDEPENDENCIA"].ToString());
objconsecutivoagBL.objconsecutivoagEL.FECHA = DateTime.Now;
objconsecutivoagBL.objconsecutivoagEL.ASTATE = true;
int resultado = objconsecutivoagBL.insertarconsecutivoag();
strResultado = DateTime.Now.Year.ToString() + resultado.ToString() + "AG";
}
catch (Exception ex)
{
throw ex;
}
return strResultado;
}
//private string GenerarCodigo()
//{
// Random obj = new Random();
// string sCadena = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
// int longitud = sCadena.Length;
// char cletra;
// int nlongitud = 5;
// string sNuevacadena = string.Empty;
// for (int i = 0; i < nlongitud; i++)
// {
// cletra = posibles[obj.Next(nlongitud)];
// sNuevacadena += cletra.ToString();
// }
// return sNuevacadena;
//}
///
/// Limpia los campos
///
private void limpiarCampos()
{
txtConsultaFolio.Text = string.Empty;
txtNumeroPlano.Text = string.Empty;
txtDuplicado.Text = string.Empty;
txtHorizontal.Text = string.Empty;
txtDerecho.Text = string.Empty;
txtconsecutivoag.Text = string.Empty;
rbtlarrendamiento.ClearSelection();
//rbtlarrendamiento.SelectedValue = "";
//rbtltipoconcesion.ClearSelection();
//rbtltipoconcesion.SelectedValue = "";
//ddlTipoTerreno.ClearSelection();
//ddlTipoTerreno.SelectedValue = "";
//grvFolio.DataSource = null;
//grvFolio.DataBind();
dvPlanos.Visible = false;
dvFolioPlano.Visible = false;
}
public void llenarGridSolicitudFolio()
{
try
{
objsolicitudfolioBL = new solicitudfolioBL();
objsolicitudfolioBL.objsolicitudfolioEL.FKSOLICITUD = int.Parse(ViewState["PKSOLICITUD"].ToString());
if (objsolicitudfolioBL.objsolicitudfolioEL.FKSOLICITUD > 0)
{
DataSet ds = objsolicitudfolioBL.dsListaSolicitudFolio(null);
if (ds.Tables[0].Rows.Count > 0)
{
dvFolioPlano.Visible = true;
grvListaTerrenoSolicitud.DataSource = ds;
}
else
{
grvListaTerrenoSolicitud.DataSource = null;
}
grvListaTerrenoSolicitud.DataBind();
}
}
catch (Exception ex)
{
throw ex;
}
}
public void llenarGridTerreno()
{
try
{
terrenoBL objTerrenoBL = new terrenoBL();
if (ViewState["FOLIO"] != null)
{
objTerrenoBL.objterrenoEL.FKFOLIO = int.Parse(ViewState["FOLIO"].ToString());
grvListaTerrenos.DataSource = null;
grvListaTerrenos.DataBind();
dvPlanos.Visible = false;
dvFolioPlano.Visible = false;
DataSet ds = objTerrenoBL.dsListarTerrenos();
if (ds.Tables[0].Rows.Count > 0)
{
imgVerSolicitudes.Visible = true;
grvListaTerrenos.DataSource = ds;
grvListaTerrenos.DataBind();
btnAsignarFolioPlano.Visible = true;
dvPlanos.Visible = true;
}
else
{
btnAsignarFolioPlano.Visible = false;
}
}
}
catch (Exception ex)
{
throw ex;
}
}
public bool validarSesion() //M3
{
if (
Session["PKUSUARIOXDEPENDENCIA"] != null &&
Session["LOGIN"] != null &&
Session["TELEFONODEPENDENCIA"] != null
)
return true;
else
return false;
}
///
/// Metodo que se utiliza para remover el role asignado al usuario
///
///
private bool eliminarFolioPlano(int p_nPk) //M1
{
bool blnValorRetornado = false;
try
{
objsolicitudfolioBL = new solicitudfolioBL();
objsolicitudfolioBL.objsolicitudfolioEL.PK = p_nPk;
objsolicitudfolioBL.eliminarsolicitudfolio();
blnValorRetornado = true;
}
catch (Exception ex)
{
throw ex;
}
return blnValorRetornado;
}
///
/// Metodo que se utiliza para remover el role asignado al usuario
///
///
private bool eliminarPlano(int p_nPk) //M1
{
bool blnValorRetornado = false;
try
{
objterrenoBL = new terrenoBL();
objterrenoBL.objterrenoEL.PK = p_nPk;
objterrenoBL.eliminarterreno();
blnValorRetornado = true;
}
catch (Exception ex)
{
throw ex;
}
return blnValorRetornado;
}
///
/// Metodo que se utiliza para remover un registro
///
///
private bool eliminarFolio(int p_nPk) //M1
{
bool blnValorRetornado = false;
try
{
folioBL objFolioBL = new folioBL();
objFolioBL.objfolioEL.PK = p_nPk;
objFolioBL.eliminarfolio();
blnValorRetornado = true;
}
catch (Exception ex)
{
throw ex;
}
return blnValorRetornado;
}
#endregion
#region Metodos Controles a Datos (R5)
///
/// guarda y modifica registros en la tabla y guarda la información del Folio.
///
///
///
private int GuardarFolio() //M0
{
int nValorRetornado = 0;
//string strSolicitudes = null;
try
{
//string strModo = ViewState["MODO"].ToString();
objfolioBL = new folioBL();
if (chkSinFolio.Checked == true)
{
objfolioBL.objfolioEL.NUMEROFOLIO = "0-0000000-0-0-000";
ddlProvincia.Enabled = true;
}
else
{
if (txtConsultaFolio.Text != string.Empty && txtDerecho.Text != string.Empty || chkSinFolio.Checked == true)
objfolioBL.objfolioEL.NUMEROFOLIO = ddlProvincias.SelectedValue.ToString() + "-" + txtConsultaFolio.Text + "-" + txtDuplicado.Text + "-" + txtHorizontal.Text + "-" + txtDerecho.Text;
//if ((txtHorizontal.Text == string.Empty && txtDuplicado.Text == string.Empty) && (txtConsultaFolio.Text != string.Empty && txtDerecho.Text != string.Empty) || chkSinFolio.Checked == true)
// objfolioBL.objfolioEL.NUMEROFOLIO = ddlProvincias.SelectedValue.ToString() + "-" + txtConsultaFolio.Text + "-" + txtDerecho.Text;
ddlProvincia.Enabled = false;
}
objfolioBL.objfolioEL.FECHAFOLIO = DateTime.Now;
objfolioBL.objfolioEL.ASTATE = true;
nValorRetornado = objfolioBL.insertarfolio();
mostrarDatos();
GuardarEventoBitacora(
Session["LOGIN"].ToString(),
AccionBitacora.INSERT.ToString(),
MensajesBitacora.IngresarRegistro + ": Se ingreso folio nuevo para una solicitud " + txtConsultaFolio.Text.Trim(),
"frwValidarPlanosyFolios.aspx",
Convert.ToInt32(ConfigurationManager.AppSettings["pkApp"])
);
}
catch (Exception ex)
{
throw ex;
}
return nValorRetornado;
}
//se verifica el folio
public Boolean VerificarFolio(bool bMensaje)
{
bool bValorRetornado = false;
//string strSolicitudes = null;
imgVerSolicitudes.Visible = false;
ViewState["FOLIO"] = null;
try
{
grvFolio.DataSource = null;
grvFolio.DataBind();
grvListaTerrenos.DataSource = null;
grvListaTerrenos.DataBind();
if (txtConsultaFolio.Text != string.Empty && txtDerecho.Text != string.Empty || chkSinFolio.Checked == true)
{
objfolioBL = new folioBL();
if (chkSinFolio.Checked == true)
{
objfolioBL.objfolioEL.NUMEROFOLIO = "0-0000000-0-0-000" ;
ddlProvincia.Enabled = true;
limpiarCampos();
}
else
{
if (txtConsultaFolio.Text != string.Empty && txtDerecho.Text != string.Empty || chkSinFolio.Checked == true)
objfolioBL.objfolioEL.NUMEROFOLIO = ddlProvincias.SelectedValue.ToString() + "-" + txtConsultaFolio.Text + "-" + txtDuplicado.Text + "-" + txtHorizontal.Text + "-" + txtDerecho.Text;
//if ((txtHorizontal.Text == string.Empty && txtDuplicado.Text == string.Empty) && (txtConsultaFolio.Text != string.Empty && txtDerecho.Text != string.Empty) || chkSinFolio.Checked == true)
// objfolioBL.objfolioEL.NUMEROFOLIO = ddlProvincias.SelectedValue.ToString() + "-" + txtConsultaFolio.Text + "-" + txtDerecho.Text;
ddlProvincia.Enabled = false;
ddlProvincia.SelectedValue = ddlProvincias.SelectedValue;
}
objfolioBL.objfolioEL.ASTATE = true;
DataSet dsFolio = objfolioBL.dsListaFoliosSolicitud();
btnAgregarTerreno.Visible = false;
btnAsignarFolioPlano.Visible = false;
dvPlanos.Visible = false;
if (dsFolio.Tables[0].Rows.Count > 0)
{
grvFolio.DataSource = dsFolio;
grvFolio.DataBind();
if (bMensaje && chkSinFolio.Checked == false)
MensajeInformativo("Folio ya existe.");
ViewState["FOLIO"] = dsFolio.Tables[0].Rows[0]["PKFOLIO"].ToString();
imgVerSolicitudes.Visible = true;
btnAgregarTerreno.Visible = true;
//ViewState["FOLIO"] = dsFolio.Tables[0].Rows[0]["PKFOLIO"].ToString();
//string strNumeroTerreno = string.Empty;
//if (ddlTipoTerreno.SelectedValue == "5")
// strNumeroTerreno = "PA" + "-" + txtconsecutivoag.Text + "-" + txtanno.Text;
//else
// strNumeroTerreno = ddlProvincia.SelectedValue.ToString() + "-" + txtNumeroPlano.Text + "-" + txtAno.Text;
//terrenoBL objTerrenoBL = new terrenoBL();
//objTerrenoBL.objterrenoEL.NUMEROTERRENO = strNumeroTerreno;
//objTerrenoBL.objterrenoEL.FKFOLIO = int.Parse(dsFolio.Tables[0].Rows[0]["PKFOLIO"].ToString());
//DataSet ds = objTerrenoBL.dsListarTerrenos();
//if (ds.Tables[0].Rows.Count > 0)
//{
bValorRetornado = true;
//}
}
}
}
catch (Exception ex)
{
throw ex;
}
return bValorRetornado;
}
//se verifica el plano
public Boolean VerificarPlano(bool bMensaje)
{
bool bValorRetornado = false;
//string strSolicitudes = null;
//imgVerSolicitudes.Visible = false;
ViewState["FOLIO"] = null;
int nContador = 0;
try
{
foreach (GridViewRow row in grvFolio.Rows)
{
//HtmlInputCheckBox chkTemp = checked;
if (true)
{
//Si el registro esta marcado guarde
if (true)
{
nContador += 1;
string strNumeroTerreno = string.Empty;
if (ddlTipoTerreno.SelectedValue == "5")
strNumeroTerreno = "PA" + "-" + txtconsecutivoag.Text + "-" + txtanno.Text;
else
strNumeroTerreno = ddlProvincia.SelectedValue.ToString() + "-" + txtNumeroPlano.Text + "-" + txtAno.Text;
terrenoBL objTerrenoBL = new terrenoBL();
objTerrenoBL.objterrenoEL.NUMEROTERRENO = strNumeroTerreno;
var IDFolio = row.Cells[2].Text;
var NumeroFolio = row.Cells[3].Text;
objTerrenoBL.objterrenoEL.FKFOLIO = int.Parse(row.Cells[2].Text);
DataSet ds = objTerrenoBL.dsListarTerrenos();
if (ds.Tables[0].Rows.Count > 0)
{
bValorRetornado = true;
grvListaTerrenos.DataSource = ds;
grvListaTerrenos.DataBind();
btnAsignarFolioPlano.Visible = true;
}
}
}
}
if (nContador > 1)
{
bValorRetornado = false;
MensajeAlerta("Debe seleccionar un folio a la vez.");
}
if (nContador == 0)
{
bValorRetornado = false;
MensajeAlerta("Debe seleccionar al menos un folio.");
}
}
catch (Exception ex)
{
throw ex;
}
return bValorRetornado;
}
///
/// guarda y modifica registros en la tabla y guarda la información del Folio.
///
///
///
private int GuardarConcesionarrendamiento(int nPkTerreno, int nPkTipoconcesion)
{
int nValorRetornado = 0;
try
{
//string strModo = ViewState["MODO"].ToString();
objconcesionarrendamientoBL = new concesionarrendamientoBL();
objconcesionarrendamientoBL.objconcesionarrendamientoEL.DOCUMENTO = txtContratoConcesion.Text;
objconcesionarrendamientoBL.objconcesionarrendamientoEL.FKTIPOCONCESIONARRENDAMIENTO = int.Parse(rbtltipoconcesion.SelectedValue);
objconcesionarrendamientoBL.objconcesionarrendamientoEL.FKTERRENO = nPkTerreno;
objconcesionarrendamientoBL.objconcesionarrendamientoEL.ASTATE = true;
nValorRetornado = objconcesionarrendamientoBL.insertarconcesion();
mostrarDatos();
GuardarEventoBitacora(
Session["LOGIN"].ToString(),
AccionBitacora.INSERT.ToString(),
MensajesBitacora.IngresarRegistro + ": Se ingresa tipo de concesion " + txtNumeroPlano.Text.Trim(),
"frwValidarPlanosyFolios.aspx",
Convert.ToInt32(ConfigurationManager.AppSettings["pkApp"])
);
}
catch (Exception ex)
{
throw ex;
}
return nValorRetornado;
}
///
/// guarda y modifica registros en la tabla y guarda la información del Folio.
///
///
///
private int GuardarArrendamiento(int nPkTerreno, int nPkArrendamiento)
{
int nValorRetornado = 1;//franja fronteriza
try
{
//string strModo = ViewState["MODO"].ToString();
int pTipoConcesionArrendamiento = 0;
if (rbtlarrendamiento.SelectedValue != string.Empty)
pTipoConcesionArrendamiento = int.Parse(rbtlarrendamiento.SelectedValue);
objconcesionarrendamientoBL = new concesionarrendamientoBL();
objconcesionarrendamientoBL.objconcesionarrendamientoEL.DOCUMENTO = txtContratoConcesion.Text;
objconcesionarrendamientoBL.objconcesionarrendamientoEL.FKTIPOCONCESIONARRENDAMIENTO = pTipoConcesionArrendamiento;
objconcesionarrendamientoBL.objconcesionarrendamientoEL.FKTERRENO = nPkTerreno;
objconcesionarrendamientoBL.objconcesionarrendamientoEL.ASTATE = true;
nValorRetornado = objconcesionarrendamientoBL.insertarconcesion();
mostrarDatos();
GuardarEventoBitacora(
Session["LOGIN"].ToString(),
AccionBitacora.INSERT.ToString(),
MensajesBitacora.IngresarRegistro + ": Se ingresa tipo de concesion " + txtNumeroPlano.Text.Trim(),
"frwValidarPlanosyFolios.aspx",
Convert.ToInt32(ConfigurationManager.AppSettings["pkApp"])
);
}
catch (Exception ex)
{
throw ex;
}
return nValorRetornado;
}
///
/// guarda y modifica registros en la tabla y se guarda el número de terreno.
///
///
private int GuardarTerreno( int nPkFolio,string p_NumeroTerreno) //M1
{
int nValorRetornado = 0;
//int nPkFolio = 0;
try
{
//string strModo = ViewState["MODO"].ToString();
objterrenoBL = new terrenoBL();
objterrenoBL.objterrenoEL.FKFOLIO = nPkFolio;
objterrenoBL.objterrenoEL.NUMEROTERRENO = p_NumeroTerreno;
objterrenoBL.objterrenoEL.DOCUMENTOAD = txtNumeroDocumentoAD.Text;
objterrenoBL.objterrenoEL.DECLARACIONPRIVADA = chkDeclaracionPrivada.Checked;
objterrenoBL.objterrenoEL.DECLARACIONPROTOCOLIZADA = chkDeclaracionProtocolizada.Checked;
objterrenoBL.objterrenoEL.CODIGOAPT = txtCodigoAPT.Text ;
objterrenoBL.objterrenoEL.FECHATERRENO = DateTime.Now;
objterrenoBL.objterrenoEL.FKNATURALEZAINMUEBLE = Int32.Parse(rblNaturalezaInmueble.SelectedValue);
objterrenoBL.objterrenoEL.FKTIPOTERRENO = Int32.Parse(ddlTipoTerreno.SelectedValue);
objterrenoBL.objterrenoEL.FKUSUARIOXDEPENDENCIA = int.Parse(Session["PKUSUARIOXDEPENDENCIA"].ToString());
objterrenoBL.objterrenoEL.ASTATE = true;
nValorRetornado = objterrenoBL.insertarterreno();
mostrarDatos();
GuardarEventoBitacora(
Session["LOGIN"].ToString(),
AccionBitacora.INSERT.ToString(),
MensajesBitacora.IngresarRegistro + ": Se ingreso de numero de terreno " + txtNumeroPlano.Text.Trim(),
"frwValidarPlanosyFolios.aspx",
Convert.ToInt32(ConfigurationManager.AppSettings["pkApp"])
);
}
catch(Exception ex)
{
throw ex;
}
return nValorRetornado;
}
///
/// guarda y modifica registros en la tabla y se guarda el número de terreno.
///
///
private int GuardarDatos() //M0
{
int nPkFolio = 0;
int nPkTerreno = 0;
int nPkTipoconcesion = 0;
int nPkArrendamiento = 0;
//int nPkAgrimensura = 0;
int nContador = 0;
//TransaccionDAL tdlTransaccion = null;
try
{
string strModo = ViewState["MODO"].ToString();
foreach (GridViewRow row in grvFolio.Rows)
{
//HtmlInputCheckBox chkTemp = (HtmlInputCheckBox)row.Controls[1].Controls[1];
//if (chkTemp != null)
//{
// //Si el registro esta marcado guarde
// if (chkTemp.Checked)
// {
nContador += 1;
nPkFolio = int.Parse(row.Cells[2].Text);
// }
//}
}
if (nContador > 1 || nContador == 0)
{
MensajeAlerta("Debe seleccionar un folio.....");
return 0;
}
else
nContador = 0;
if (strModo == "Nuevo")
{
if (nPkFolio != 0)
{
ViewState["FOLIO"] = nPkFolio;
string strNumeroTerreno = string.Empty;
if (ddlTipoTerreno.SelectedValue == "5")
strNumeroTerreno = "PA" + "-" + txtconsecutivoag.Text + "-" + txtanno.Text;
else
strNumeroTerreno = ddlProvincia.SelectedValue.ToString() + "-" + txtNumeroPlano.Text + "-" + txtAno.Text;
nPkTerreno = GuardarTerreno(nPkFolio, strNumeroTerreno);
if (nPkTerreno != 0 && ddlTipoTerreno.SelectedValue == "2")
nPkTipoconcesion = GuardarConcesionarrendamiento(nPkTerreno, nPkTipoconcesion);
if (nPkTerreno != 0 && ddlTipoTerreno.SelectedValue == "4")
nPkArrendamiento = GuardarArrendamiento(nPkTerreno, nPkArrendamiento);
//if (nPkTerreno != 0 && ddlTipoTerreno.SelectedValue == "5")
// nPkAgrimensura = GuardarAgrimensura(nPkTerreno, nPkAgrimensura);
}
}
}
catch (Exception ex)
{
throw ex;
}
return nPkTerreno;
}
private bool AsignarFolioPlano()
{
bool bResultado = false;
int nPkFolio = 0;
int nPkTerreno = 0;
int nPkSolicitud = 0;
int nPkSolicitudFolio = 0;
int nContador = 0;
try
{
foreach (GridViewRow row in grvFolio.Rows)
{
//HtmlInputCheckBox chkTemp = (HtmlInputCheckBox)row.Controls[1].Controls[1];
//if (chkTemp != null)
//{
// //Si el registro esta marcado guarde
// if (chkTemp.Checked)
// {
nContador += 1;
nPkFolio = int.Parse(row.Cells[2].Text);
// }
//}
}
if (nContador > 1 || nContador == 0)
{
MensajeAlerta("Debe seleccionar un folio.....");
return false;
}
else
nContador = 0;
foreach (GridViewRow row in grvListaTerrenos.Rows)
{
//HtmlInputCheckBox chkTemp = (HtmlInputCheckBox)row.Controls[1].Controls[1];
//if (chkTemp != null)
//{
// //Si el registro esta marcado guarde
// if (chkTemp.Checked)
// {
nContador += 1;
nPkTerreno = int.Parse(row.Cells[2].Text);
//if (nContador > 1 || nContador == 0)
//{
// MensajeAlerta("Debe seleccionar un plano.....");
// return false;
//}
objsolicitudfolioBL = new solicitudfolioBL();
objsolicitudfolioBL.objsolicitudfolioEL.FKFOLIO = nPkFolio;
//objsolicitudfolioBL.objsolicitudfolioEL.FKSOLICITUD = nPkSolicitud;
objsolicitudfolioBL.objsolicitudfolioEL.FKTERRENO = nPkTerreno;
objsolicitudfolioBL.objsolicitudfolioEL.ASTATE = true;
DataSet dsSolicitudes = objsolicitudfolioBL.dsObtenerSolicitudxFolioPlano(null);
if (dsSolicitudes.Tables[0].Rows.Count == 0)
{
if (ViewState["PKSOLICITUD"] != null)
{
nPkSolicitud = int.Parse(ViewState["PKSOLICITUD"].ToString());
strPKSolicitudTMP = nPkSolicitud.ToString();
}
if (nPkSolicitud == 0)
{
strPKSolicitudTMP = GuardarSolicitud().ToString();
nPkSolicitud = int.Parse(strPKSolicitudTMP);
if (nPkSolicitud != 0)
{
Session["PKSOLICITUD"] = nPkSolicitud.ToString();
Session["PKPROGRAMACION"] = " ";
int nPKActividad = AsignaActividadesUsuarios();
ViewState["PKSOLICITUD"] = nPkSolicitud.ToString();
}
}
if (nPkSolicitud != 0)
{
if (nPkTerreno != 0)
nPkSolicitudFolio = GuardarSolicitudFolio(nPkFolio, nPkSolicitud, nPkTerreno);
imgAsignacionExpediente.Visible = true;
}
}
else
{
MensajeInformativo("Ya existe un expediente con el plano y folio asignados en proceso.");
}
// }
//}
}
if (nContador > 1 || nContador == 0)
{
MensajeAlerta("Debe seleccionar un terreno.....");
return false;
}
else
{
if (ViewState["PKSOLICITUD"] != null)
{
llenarGridSolicitudFolio();
bResultado = true;
MensajeInformativo("El folio y plano han sido asignados a la solicitud actual...");
}
else
{
MensajeAlerta("Se produjo un problema al crear la solicitud, intente de nuevo..");
}
}
}
catch (Exception ex)
{
throw ex;
}
return bResultado;
}
///
/// guarda y modifica registros en la tabla y guarda la información del plano de agrimensura.
///
///
///
private int GuardarAgrimensura(int nPkTerreno, int nPkAgrimensura) //M0
{
int nValorRetornado = 0;
try
{
//string strModo = ViewState["MODO"].ToString();
string strResultado = "";
objconsecutivoagBL = new consecutivoagBL();
objconsecutivoagBL.objconsecutivoagEL.FKUSUARIOXDEPENDENCIA = int.Parse(Session["PKUSUARIOXDEPENDENCIA"].ToString());
objconsecutivoagBL.objconsecutivoagEL.FECHA = DateTime.Now;
objconsecutivoagBL.objconsecutivoagEL.ASTATE = true;
//objconsecutivoagBL.objconsecutivoagEL. = obtenerNumAgrimensura();
nValorRetornado = objconsecutivoagBL.insertarconsecutivoag();
mostrarDatos();
GuardarEventoBitacora(
Session["LOGIN"].ToString(),
AccionBitacora.INSERT.ToString(),
MensajesBitacora.IngresarRegistro + ": Se ingreso un nuevo plano de agrimensura" + txtconsecutivoag.Text.Trim(),
"frwValidarPlanosyFolios.aspx",
Convert.ToInt32(ConfigurationManager.AppSettings["pkApp"])
);
}
catch (Exception ex)
{
throw ex;
}
return nValorRetornado;
}
///
/// guarda y modifica registros en la tabla del número de solicitud.
///
///
///
private int GuardarSolicitud()
{
int nValorRetornado = 0;
//int nConsecutivo = 0;
//string[] strArrayTmp;
//string strSolicitudes = null;
try
{
//string strModo = ViewState["MODO"].ToString();
string strNumSolicitudTMP = "";
string strNis = "N/A";
string strCedula = "N/A";
string strNombre = "N/A";
string str1Apellido = "N/A";
string str2Apellido = "N/A";
string strDireccion = "N/A";
string strNumTel1 = "N/A";
string strNumTel2 = "N/A";
string strFax = "N/A";
string strCorreo = "N/A";
string strDescripcion = "N/A";
string strSolicita = "N/A";
objsolicitudBL = new solicitudBL();
objsolicitudBL.objSolicitudEL.NUMEROSOLICITUD = strNumSolicitudTMP;
objsolicitudBL.objSolicitudEL.TIENESERVICIOSOLICITUD = false;
objsolicitudBL.objSolicitudEL.SOLICITAMUNICIPALIDAD = false;
objsolicitudBL.objSolicitudEL.SOLICITAMINISTERIOSALUD = false;
objsolicitudBL.objSolicitudEL.SOLICITACFIA = false;
objsolicitudBL.objSolicitudEL.ASTATE = true;
objsolicitudBL.objSolicitudEL.NUMERONIS = strNis;
objsolicitudBL.objSolicitudEL.CEDULASOLICITANTE = strCedula;
objsolicitudBL.objSolicitudEL.NOMBRESOLICITANTE = strNombre;
objsolicitudBL.objSolicitudEL.APELLIDO1SOLICITANTE = str1Apellido;
objsolicitudBL.objSolicitudEL.APELLIDO2SOLICITANTE = str2Apellido;
objsolicitudBL.objSolicitudEL.DIRECCIONEXACTAPROPIEDAD = strDireccion;
objsolicitudBL.objSolicitudEL.NUMEROTELEFONO1 = strNumTel1;
objsolicitudBL.objSolicitudEL.NUMEROTELEFONO2 = strNumTel2;
objsolicitudBL.objSolicitudEL.FAX = strFax;
objsolicitudBL.objSolicitudEL.CORREOELECTRONICO = strCorreo;
objsolicitudBL.objSolicitudEL.CORREOELECTRONICO2 = strCorreo;
objsolicitudBL.objSolicitudEL.DESCRIPCIONUSOEDIFICACION = strDescripcion;
objsolicitudBL.objSolicitudEL.SOLICITAOTROENTE = strSolicita;
objsolicitudBL.objSolicitudEL.FECHAINSERTA = DateTime.Now;
objsolicitudBL.objSolicitudEL.FKTIPOINSPECCION = 4;
objsolicitudBL.objSolicitudEL.FKTIPODISPONIBILIDAD = 1;
objsolicitudBL.objSolicitudEL.SOLICITACFIA = false;
objsolicitudBL.objSolicitudEL.SOLICITAMUNICIPALIDAD = false;
objsolicitudBL.objSolicitudEL.SOLICITAMINISTERIOSALUD = false;
objsolicitudBL.objSolicitudEL.FKDEPENDENCIA = int.Parse(Session["DEPENDENCIA"].ToString());
objsolicitudBL.objSolicitudEL.FKPROVINCIA = int.Parse(Session["PKPROVINCIA"].ToString());
objsolicitudBL.objSolicitudEL.FKCANTON = int.Parse(Session["PKCANTON"].ToString());
objsolicitudBL.objSolicitudEL.FKDISTRITO = int.Parse(Session["PKDISTRITO"].ToString());
DataSet ds = objsolicitudBL.dsExisteSolicitud(null);
objsolicitudBL.objSolicitudEL.NUMEROSOLICITUD = obtenerNumSolicitudPermanente();
//MODIFICAR PARA QUE SI DEVUELVE NO EXISTE SE ENVIE UN 0 HACIA ARRIBA
Session["SOLICITUD"] = objsolicitudBL.objSolicitudEL.NUMEROSOLICITUD.ToString();
nValorRetornado = objsolicitudBL.insertarSolicitud();
if (nValorRetornado > 0)
{
string xmlTexto = ToXmls(ds);
AyAEL.TRA.historialxmlEL objHistorialEL = new AyAEL.TRA.historialxmlEL();
objHistorialEL.REGISTRO = xmlTexto;
objHistorialEL.FKSOLICITUD = nValorRetornado;
objHistorialEL.FECHAINSERTA = DateTime.Now;
descripcioncfiaBL objdescripcionCFIABL = new descripcioncfiaBL();
objdescripcionCFIABL.objdescripcioncfiaEL.FKSOLICITUD = nValorRetornado;
objdescripcionCFIABL.objdescripcioncfiaEL.DESCRIPCION = "N/A";
objdescripcionCFIABL.objdescripcioncfiaEL.ASTATE = true;
int nCFIA = objdescripcionCFIABL.insertarDescripcionCFIA();
GuardarEventoBitacora(
Session["LOGIN"].ToString(),
AccionBitacora.INSERT.ToString(),
MensajesBitacora.IngresarRegistro + ": Se ha ingresado la solicitud " + Session["SOLICITUD"].ToString(),
"frwValidaPlanosyfolios.aspx",
Convert.ToInt32(ConfigurationManager.AppSettings["pkApp"])
);
}
else
{
MensajeAlerta("Se dio un problema al insertar la nueva solicitud.");
}
}
catch (Exception ex)
{
throw ex;
}
return nValorRetornado;
}
///
/// guarda y modifica registros en la tabla del número de solicitudfolio.
///
///
///
private int GuardarSolicitudFolio(int nPkFolio, int nPkSolicitud, int nPkTerreno) //M0
{
int nValorRetornado = 0;
try
{
//string strModo = ViewState["MODO"].ToString();
objsolicitudfolioBL = new solicitudfolioBL();
objsolicitudfolioBL.objsolicitudfolioEL.FKFOLIO = nPkFolio;
objsolicitudfolioBL.objsolicitudfolioEL.FKSOLICITUD = nPkSolicitud;
objsolicitudfolioBL.objsolicitudfolioEL.FKTERRENO = nPkTerreno;
objsolicitudfolioBL.objsolicitudfolioEL.ASTATE = true;
nValorRetornado = objsolicitudfolioBL.insertarsolicitudfolio();
//mostrarDatos();
if(nValorRetornado !=0)
GuardarEventoBitacora(
Session["LOGIN"].ToString(),
AccionBitacora.INSERT.ToString(),
MensajesBitacora.IngresarRegistro + ": Se asigno el folio " + nPkFolio.ToString() + " y el plano " + nPkTerreno.ToString() + " a la solicitud " + Session["SOLICITUD"].ToString() + " , con el registro de folioPlano N°" + nValorRetornado.ToString(),
"frwValidarPlanosyFolios.aspx",
Convert.ToInt32(ConfigurationManager.AppSettings["pkApp"])
);
}
catch (Exception ex)
{
throw ex;
}
return nValorRetornado;
}
///
/// Se crea el DS que guarda en el historialxmlEL
///
///
///
private string ToXmls(DataSet ds)
{
MemoryStream memoryStream = new MemoryStream();
using (TextWriter streamWriter = new StreamWriter(memoryStream))
{
var xmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(DataSet));
xmlSerializer.Serialize(streamWriter, ds);
}
return System.Text.Encoding.UTF8.GetString(memoryStream.ToArray());
}
///
/// Asigna la actividad 1 Ingreso y asignacion de expedientes al usuario que esta realizando la tarea
///
///
private int AsignaActividadesUsuarios() //M0
{
ActividadesBL objActividadesBL = new ActividadesBL();
ArrayList arlCondicionesFiltroBusqueda = new ArrayList();
int nPkSolicitud = 0;
int nValorRetornado = 0;
string strPiePagina = " AVISO DE CONFIDENCIALIDAD: este mensaje y la información incluida en él es confidencial y está dirigida únicamente al destinatario. Puede contener información privilegiada, confidencial, amparada por el secreto profesional o que no debe ser revelada. Si usted ha recibido este correo por error, por favor comunicarlo inmediatamente vía correo y tener la amabilidad de eliminarlo de su sistema. Queda notificado que no deberá copiar este mensaje, ni utilizar, divulgar, publicar o distribuir su contenido de modo alguno. Todo mensaje enviado a esta dirección de correo electrónico puede ser sujeto a inspección por alguien distinto de su receptor originario. La transmisión de correos no garantiza que el correo electrónico sea seguro o libre de error. Por consiguiente, se advierte que esta información pueda estar incompleta o ser poco precisa ya que toda información está sujeta a alterarse sin previo aviso.”";
try
{
string strModo = ViewState["MODO"].ToString();
solicitudBL objresponsableActividadBL = new solicitudBL();
objresponsableActividadBL.objresponsableActividadEL.FECHAASIGNACION = DateTime.Now;
objresponsableActividadBL.objresponsableActividadEL.FECHARECIBIDO = DateTime.Now;
objresponsableActividadBL.objresponsableActividadEL.FECHADEVOLUCION = DateTime.Now.AddDays(-1);
objresponsableActividadBL.objresponsableActividadEL.VALIDACIONFIRMA = false;
objresponsableActividadBL.objresponsableActividadEL.FKACTIVIDAD = 1;
objresponsableActividadBL.objresponsableActividadEL.FKUSUARIOXDEPENDENCIA = int.Parse(Session["PKUSUARIOXDEPENDENCIA"].ToString());
objresponsableActividadBL.objresponsableActividadEL.FKESTADO = 1;//asignada
objresponsableActividadBL.objresponsableActividadEL.ASTATE = true;
if (Session["PKPROGRAMACION"].ToString() == " ") //se verifica que ya se haya asignado la actividad 1
{
programacionsolicitudBL objprogramacionsolicitudBL = new programacionsolicitudBL();
objprogramacionsolicitudBL.objprogramacionsolicitudEL.FKESTADOPROGRAMACION = 6;//al ser el primer ingreso y no estar completos los requisitos se pone bloqueada
objprogramacionsolicitudBL.objprogramacionsolicitudEL.FKSOLICITUD = int.Parse(Session["PKSOLICITUD"].ToString());
int nPKProgramacionSolicitud = objprogramacionsolicitudBL.insertarprogramacionsolicitud();
objresponsableActividadBL.objresponsableActividadEL.FKPROGRAMACIONSOLICITUD = nPKProgramacionSolicitud;
Session["PKPROGRAMACION"] = nPKProgramacionSolicitud;
}
else
{
objresponsableActividadBL.objresponsableActividadEL.FKPROGRAMACIONSOLICITUD = int.Parse(Session["PKPROGRAMACION"].ToString());
}
if (strModo == "Nuevo")
{
objsolicitudBL = new solicitudBL();
objsolicitudBL.objSolicitudEL.FKSOLICITUD = int.Parse(Session["PKSOLICITUD"].ToString());
objsolicitudBL.objSolicitudEL.FKUSUARIOXDEPENDENCIA = int.Parse(Session["PKUSUARIOXDEPENDENCIA"].ToString());
objsolicitudBL.objSolicitudEL.FKACTIVIDAD = 1;
DataSet dsActividad = objsolicitudBL.dsListaActividadesEncargado(arlCondicionesFiltroBusqueda);
if (dsActividad.Tables[0].Rows.Count == 0)
{
nValorRetornado = objresponsableActividadBL.insertarAsignacionActividadEncargado();
if (nValorRetornado > 0)
{
#region Envio de correo
arlCondicionesFiltroBusqueda = new ArrayList();
// condicionesBusqueda();
objsolicitudBL = new solicitudBL();
objsolicitudBL.objSolicitudEL.PK = int.Parse(Session["PKPROGRAMACION"].ToString());
{
DataSet dsEncargadosActividades = objsolicitudBL.dsListaActividadesEncargado(arlCondicionesFiltroBusqueda);
if (dsEncargadosActividades.Tables.Count > 0)
{
nPkSolicitud = Convert.ToInt32(dsEncargadosActividades.Tables[0].Rows[0][1].ToString());//AQUI INSERTAMOS LA PK DE LA SOLICITUD
}
}
AyABL.TRA.correoBL objcorreoBL = new AyABL.TRA.correoBL();
objcorreoBL.objcorreoEL.FKNUMSOLICITUD = nPkSolicitud;
// objcorreoBL.objcorreoEL.CORREO = dsActividad.Tables[0].Rows[0]["LOGINUSUARIO"].ToString() + "@aya.go.cr";
objcorreoBL.objcorreoEL.ASUNTO = "Asignación de actividades - SIGDD";
objcorreoBL.objcorreoEL.CONTENIDO = "Se ha finalizado la actividad de Ingreso y asignación de expedientes de la solicitud de disponibilidad " + Session["SOLICITUD"].ToString() + ", para ver mas detalles ingrese al sistema SIGDD" + strPiePagina;
objcorreoBL.objcorreoEL.FKUSUARIO = int.Parse(Session["PKUSUARIOXDEPENDENCIA"].ToString());
objcorreoBL.objcorreoEL.Fecha = DateTime.Now;
nValorRetornado = objcorreoBL.insertarCorreo();
#endregion
}
GuardarEventoBitacora(
Session["LOGIN"].ToString(),
AccionBitacora.INSERT.ToString(),
MensajesBitacora.IngresarRegistro + ": Se ha asignado la actividad Ingreso y asignación de expedientes para la solicitud " + Session["SOLICITUD"].ToString(),
"frwValidarPlanosyfolios.aspx",
Convert.ToInt32(ConfigurationManager.AppSettings["pkApp"])
);
}
else
{
MensajeAlerta("El usuario ya tiene asignada la actividad.");
}
}
}
catch (Exception ex)
{
throw ex;
}
return nValorRetornado;
}
#endregion
#region Metodos Datos a Controles (R6)
///
/// Muestra los datos del registro
///
///
///
private void mostrarDatos() //M1
{
try
{
//limpiarCampos();
//objObservacionesBL = new ObservacionesActividadesBL();
//objObservacionesBL.objobservacionesEL.PKSOLICITUD = int.Parse(Session["PKSOLICITUD"].ToString());
//objObservacionesBL.objobservacionesEL.PKPROGRAMACIONSOLICITUD = int.Parse(Session["PKPROGRAMACION"].ToString());
//objObservacionesBL.objobservacionesEL.PKACTIVIDAD = int.Parse(Session["NACTIVIDAD"].ToString());
//objObservacionesBL.objobservacionesEL.PKRESPONSABLEACTIVIDAD = int.Parse(Session["PKRESPONSABLEACTIVIDAD"].ToString());
//DataSet dsObservaciones = objObservacionesBL.dsListarObservacionesActividades(null);
}
catch (Exception ex)
{
throw ex;
}
}
///
/// Llena el dropdownlist de la provincia
///
private void llenarDDLProvincia() //M6
{
try
{
//Limpia el control
ddlProvincia.Items.Clear();
//Instancia el bjeto
objprovinciaBL = new provinciaBL();
//Asigna datos al atributo
//Carga la información en un dataset
DataSet ds = objprovinciaBL.dsListaProvincias(null);
if (ds.Tables[0].Rows.Count != 0)
{
ddlProvincia.DataSource = ds;
ddlProvincia.DataTextField = ds.Tables[0].Columns["PKPROVINCIA"].ColumnName;
ddlProvincia.DataValueField = ds.Tables[0].Columns["PKPROVINCIA"].ColumnName;
ddlProvincia.DataBind();
// ddlProvincia.Items.Insert(0, new ListItem("Seleccione", "-1"));
}
else
ddlProvincia.Items.Insert(0, new ListItem("----- No existen opciones -----", "-1"));
}
catch (Exception ex)
{
throw ex;
}
}
///
/// Llena el dropdownlist de tipo de terreno
///
///
private void llenarDDLTipoterreno() //M6
{
try
{
//Limpia el control
ddlTipoTerreno.Items.Clear();
//Instancia el bjeto
objtipoterrenoBL = new tipoterrenoBL();
//Asigna datos al atributo
//Carga la información en un dataset
DataSet ds = objtipoterrenoBL.dsListaTerrenos(null);
if (ds.Tables[0].Rows.Count != 0)
{
ddlTipoTerreno.DataSource = ds;
ddlTipoTerreno.DataTextField = ds.Tables[0].Columns["DESCRIPCIONTIPOTERRENO"].ColumnName;
ddlTipoTerreno.DataValueField = ds.Tables[0].Columns["PKTIPOTERRENO"].ColumnName;
ddlTipoTerreno.DataBind();
ddlTipoTerreno.Items.Insert(0, new ListItem("Seleccione", "-1"));
}
else
ddlTipoTerreno.Items.Insert(0, new ListItem("----- No existen opciones -----", "-1"));
}
catch (Exception ex)
{
throw ex;
}
}
///
/// Llena el dropdownlist de la provincia
///
private void llenarDDLProvincias() //M6
{
try
{
//Limpia el control
ddlProvincias.Items.Clear();
//Instancia el bjeto
objprovinciaBL = new provinciaBL();
//Asigna datos al atributo
//Carga la información en un dataset
DataSet ds = objprovinciaBL.dsListaProvincias(null);
if (ds.Tables[0].Rows.Count != 0)
{
ddlProvincias.DataSource = ds;
ddlProvincias.DataTextField = ds.Tables[0].Columns["PKPROVINCIA"].ColumnName;
ddlProvincias.DataValueField = ds.Tables[0].Columns["PKPROVINCIA"].ColumnName;
ddlProvincias.DataBind();
// ddlProvincia.Items.Insert(0, new ListItem("Seleccione", "-1"));
}
else
ddlProvincias.Items.Insert(0, new ListItem("----- No existen opciones -----", "-1"));
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
protected void rblNaturalezaInmueble_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
if (rblNaturalezaInmueble.SelectedValue == "3")
divnum8.Visible = true;
else
divnum8.Visible = false;
if (rblNaturalezaInmueble.SelectedValue == "4")
divnum9.Visible = true;
else
divnum9.Visible = false;
}
catch (Exception ex)
{
MensajeError("Se produjo un error al seleccionar la naturaleza del inmueble", ex);
}
}
protected void grvListaTerrenoSolicitud_RowDataBound(object sender, GridViewRowEventArgs e)
{
GridViewRow selectedRow = e.Row;
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (ViewState["PKSOLICITUD"] != null)
{
if (int.Parse(ViewState["PKSOLICITUD"].ToString()) != int.Parse(e.Row.Cells[4].Text))
{
e.Row.Cells[0].Enabled = false;
e.Row.Cells[0].Style.Add("Opacity", "0.5");
}
}
else
{
e.Row.Cells[0].Enabled = false;
e.Row.Cells[0].Style.Add("Opacity", "0.5");
}
}
}
}