269 lines
No EOL
9 KiB
C#
269 lines
No EOL
9 KiB
C#
using AyABL.ADM;
|
|
using AyABL.RCS;
|
|
using AyAEL.ADM;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.Script.Serialization;
|
|
using System.Web.Services;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
public partial class webforms_AGP_wfrAdministrarUbicaciones : General
|
|
{
|
|
|
|
#region Variables
|
|
UbicacionBL objUbicacionBL;
|
|
#endregion
|
|
|
|
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);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MensajeError("Error en R0M1", ex);
|
|
}
|
|
}
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if ((!IsPostBack) && (Session.Count > 0))
|
|
{
|
|
llenarDDLUbicacion(ddlProvincia, -1);
|
|
llenarGridAdminUbicaciones();
|
|
txtNombreProyecto.Text = Session["NOMBREPROYECTO"].ToString();
|
|
}
|
|
}
|
|
|
|
protected void btnAgregarUbicacion_Click(object sender, EventArgs e) //M14
|
|
{
|
|
try
|
|
{
|
|
var FKDISTRITO = txtDistrito.Text;
|
|
var FKBARRIO = txtBarrio.Text;
|
|
|
|
objUbicacionBL = new UbicacionBL();
|
|
objUbicacionBL.objUbicacionEL.FK = Int32.Parse(Session["PKPROYECTO"].ToString());
|
|
objUbicacionBL.objUbicacionEL.FKUBICACIONBARRIO = string.IsNullOrWhiteSpace(FKBARRIO) ? 0 : Convert.ToInt32(FKBARRIO);
|
|
objUbicacionBL.objUbicacionEL.FKUBICACIONDISTRITO = string.IsNullOrWhiteSpace(FKDISTRITO) ? 0 : Convert.ToInt32(FKDISTRITO);
|
|
|
|
if (objUbicacionBL.InsertarUbicacionProyecto())
|
|
{
|
|
GuardarEventoBitacora(
|
|
Session["LOGIN"].ToString(),
|
|
AccionBitacora.INSERT.ToString(),
|
|
MensajesBitacora.IngresarRegistro + ": Proyecto: " + Session["PKPROYECTO"].ToString() + "."
|
|
+ "Descripcion: " + txtNombreProyecto.Text
|
|
+ "Distrito: " + FKDISTRITO
|
|
+ "Barrio: " + FKBARRIO,
|
|
"wfrAspectosGenerales.aspx");
|
|
|
|
MensajeInformativo("Ubicación agregada correctamente");
|
|
llenarGridAdminUbicaciones();
|
|
ddlProvincia.SelectedValue = "0";
|
|
}
|
|
else
|
|
{
|
|
MensajeAdvertencia("No se pudo agregar la ubicación indicada, por favor verifique que no exista un registro con el mismo valor");
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MensajeError("Error en R3M14", ex);
|
|
}
|
|
}
|
|
|
|
protected void grvAdministrarUbicaciones_RowCommand(object sender, GridViewCommandEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
int i = Convert.ToInt32(e.CommandArgument);
|
|
int FKUBICACIONBARRIO;
|
|
int FKUBICACIONDISTRITO;
|
|
GridViewRow selectedRow = grvAdministrarUbicaciones.Rows[i];
|
|
FKUBICACIONDISTRITO = Convert.ToInt32(selectedRow.Cells[4].Text);
|
|
FKUBICACIONBARRIO = string.IsNullOrWhiteSpace(selectedRow.Cells[6].Text) || selectedRow.Cells[6].Text == " " ? 0 : Convert.ToInt32(selectedRow.Cells[5].Text);
|
|
|
|
objUbicacionBL = new UbicacionBL();
|
|
objUbicacionBL.objUbicacionEL.FK = Int32.Parse(Session["PKPROYECTO"].ToString());
|
|
objUbicacionBL.objUbicacionEL.FKUBICACIONBARRIO = FKUBICACIONBARRIO;
|
|
objUbicacionBL.objUbicacionEL.FKUBICACIONDISTRITO = FKUBICACIONDISTRITO;
|
|
|
|
switch (e.CommandName)
|
|
{
|
|
case "remover":
|
|
if (objUbicacionBL.borradoLogicoUbicacionProyecto())
|
|
{
|
|
MensajeInformativo("Ubicación eliminada correctamente");
|
|
llenarGridAdminUbicaciones();
|
|
ddlProvincia.SelectedValue = "0";
|
|
}
|
|
else
|
|
MensajeAdvertencia("Error al tratar de eliminar la ubicación");
|
|
break;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo encargado de obtener las ubicaciones asociadas
|
|
/// </summary>
|
|
/// <param name="PKUBICACION">Corresponde al identificador de la ubicacion</param>
|
|
/// <returns></returns>
|
|
private DataSet obtenerUbicaciones(int? PKUBICACION) //M14
|
|
{
|
|
try
|
|
{
|
|
//Instancia el objeto
|
|
objUbicacionBL = new UbicacionBL();
|
|
objUbicacionBL.objUbicacionEL.PK = 0;
|
|
objUbicacionBL.objUbicacionEL.Padre = PKUBICACION;
|
|
objUbicacionBL.objUbicacionEL.ASTATE = true;
|
|
return objUbicacionBL.getUbicacion();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MensajeError("Error en R6M14", ex);
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
private void llenarDDLUbicacion(DropDownList pDropDownList, int? PKUBICACION) //M6
|
|
{
|
|
try
|
|
{
|
|
|
|
pDropDownList.Items.Clear();
|
|
|
|
|
|
if (!PKUBICACION.HasValue || PKUBICACION == 0)
|
|
{
|
|
pDropDownList.Items.Insert(0, new ListItem("Sin ubicaciones asociadas", "0"));
|
|
return;
|
|
}
|
|
|
|
|
|
var vUbicaciones = obtenerUbicaciones(PKUBICACION);
|
|
|
|
if (vUbicaciones.Tables[0].Rows.Count != 0)
|
|
{
|
|
pDropDownList.DataSource = vUbicaciones;
|
|
pDropDownList.DataTextField = vUbicaciones.Tables[0].Columns["NOMBREUBICACION"].ColumnName;
|
|
pDropDownList.DataValueField = vUbicaciones.Tables[0].Columns["PKUBICACION"].ColumnName;
|
|
pDropDownList.DataBind();
|
|
pDropDownList.Items.Insert(0, new ListItem("Seleccione una ubicación", "0"));
|
|
}
|
|
else
|
|
{
|
|
pDropDownList.Items.Insert(0, new ListItem("Sin ubicaciones asociadas", "0"));
|
|
}
|
|
|
|
pDropDownList.SelectedValue = "0";
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MensajeError("Error en R6M6", ex);
|
|
}
|
|
|
|
}
|
|
|
|
private void llenarGridAdminUbicaciones()
|
|
{
|
|
try
|
|
{
|
|
objUbicacionBL = new UbicacionBL();
|
|
DataSet dsUbicaciones = objUbicacionBL.getUbicacionProyecto(Int32.Parse(Session["PKPROYECTO"].ToString()));
|
|
detalleGRVDatos(dsUbicaciones, grvAdministrarUbicaciones);
|
|
updPanel.Update();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MensajeError("Error en R6M15", ex);
|
|
}
|
|
|
|
}
|
|
|
|
#region WebMethods
|
|
|
|
[WebMethod]
|
|
public static string llenarDDLUbicaciones(int PKUBICACION)
|
|
{
|
|
List<UbicacionEL> lstBarrios = new List<UbicacionEL>();
|
|
JavaScriptSerializer _Json = new JavaScriptSerializer();
|
|
try
|
|
{
|
|
//Instancia el objeto
|
|
AyABL.ADM.UbicacionBL objUbicacionBL = new AyABL.ADM.UbicacionBL();
|
|
objUbicacionBL.objUbicacionEL.PK = 0;
|
|
objUbicacionBL.objUbicacionEL.Padre = PKUBICACION;
|
|
objUbicacionBL.objUbicacionEL.ASTATE = true;
|
|
DataSet dsProvincia = objUbicacionBL.getUbicacion();
|
|
|
|
foreach (DataRow drProvincia in dsProvincia.Tables[0].Rows)
|
|
{
|
|
var infoProvincia = new UbicacionEL { PK = int.Parse(drProvincia["PKUBICACION"].ToString()), Nombre = drProvincia["NOMBREUBICACION"].ToString() };
|
|
lstBarrios.Add(infoProvincia);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return null;
|
|
//MensajeError("Error en R6M", ex);
|
|
}
|
|
|
|
return _Json.Serialize(lstBarrios);
|
|
}
|
|
|
|
[WebMethod]
|
|
public static string agregarUbicacion(string FKDISTRITO, string FKBARRIO, int FKPROYECTO)
|
|
{
|
|
var msg = string.Empty;
|
|
try
|
|
{
|
|
|
|
|
|
AyABL.ADM.UbicacionBL objUbicacionBL = new UbicacionBL();
|
|
objUbicacionBL.objUbicacionEL.FK = FKPROYECTO;
|
|
objUbicacionBL.objUbicacionEL.FKUBICACIONBARRIO = string.IsNullOrWhiteSpace(FKBARRIO) ? 0 : Convert.ToInt32(FKBARRIO);
|
|
objUbicacionBL.objUbicacionEL.FKUBICACIONDISTRITO = string.IsNullOrWhiteSpace(FKDISTRITO) ? 0 : Convert.ToInt32(FKDISTRITO);
|
|
|
|
if (objUbicacionBL.InsertarUbicacionProyecto())
|
|
msg = "OK";
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
msg = ex.ToString();
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
#endregion
|
|
} |