protected void dplCondominio_SelectedIndexChanged(object sender, EventArgs e) { try { long condominio = Convert.ToInt64(dplCondominio.SelectedValue); dplAño.SelectedIndex = 0; List <EDIFICIO> lista = new List <EDIFICIO>(); if (prop == false) { lista = Controller.ControllerEdificio.buscarEdificioCondominio(condominio); } else { foreach (EDIFICIO item in listaEdificio) { if (item.ID_CONDOMINIO == condominio) { lista.Add(item); } } } dplEdificio.DataSource = lista; dplEdificio.DataValueField = "ID_EDIFICIO"; dplEdificio.DataTextField = "NOMBRE_EDIFICIO"; dplEdificio.DataBind(); dplEdificio.Items.Insert(0, "Seleccione un Edificio"); dplEdificio.SelectedIndex = 0; listaGastos = new List <Adapter.AdapterGastoComun>(); foreach (EDIFICIO item in lista) { Adapter.AdapterGastoComun gasto = new Adapter.AdapterGastoComun(); gasto = Controller.ControllerGastoComun.buscarAdapterGastoComunEdificio(item.ID_EDIFICIO); listaGastos.Add(gasto); } grDetalle.DataSource = listaGastos; grDetalle.DataBind(); } catch (Exception ex) { dplEdificio.SelectedIndex = 0; dplAño.SelectedIndex = 0; System.Diagnostics.Debug.WriteLine("Error: " + ex); } }
protected void dplEdificio_SelectedIndexChanged(object sender, EventArgs e) { try { long edificio = Convert.ToInt64(dplEdificio.SelectedValue); dplAño.SelectedIndex = 0; listaGastos = new List <Adapter.AdapterGastoComun>(); Adapter.AdapterGastoComun gasto = Controller.ControllerGastoComun.buscarAdapterGastoComunEdificio(edificio); listaGastos.Add(gasto); grDetalle.DataSource = listaGastos; grDetalle.DataBind(); } catch (Exception ex) { dplAño.SelectedIndex = 0; System.Diagnostics.Debug.WriteLine("Error: " + ex); } }
protected void btnAgregarGasto_Click(object sender, EventArgs e) { Adapter.AdapterGastoComun gasto = new Adapter.AdapterGastoComun(); grGastos.Visible = true; lbGastos.Visible = true; lbError.Visible = false; Boolean option = true; EDIFICIO edificio = Controller.ControllerEdificio.buscarIdEdificio(Convert.ToInt64(dplEdificio.SelectedValue)); gasto._NOMBRE_EDIFICIO = edificio.NOMBRE_EDIFICIO; gasto._ID_EDIFICIO = edificio.ID_EDIFICIO; gasto._GASTO_CONSERJE = Convert.ToInt32(txtGConserje.Text); gasto._GASTO_GUARDIA = Convert.ToInt32(txtGGuardia.Text); gasto._GASTO_MANTENCION_AREAS = Convert.ToInt32(txtGMantAreas.Text); gasto._GASTO_CAMARAS = Convert.ToInt32(txtGCamaras.Text); gasto._GASTO_ARTICULOS_ASEO = Convert.ToInt32(txtGArtAseo.Text); gasto._GASTOS_ASEO = Convert.ToInt32(txtGAseo.Text); gasto._GASTO_ASCENSOR = Convert.ToInt32(txtGAscensor.Text); gasto._GASTO_AGUA_CALIENTE = Convert.ToInt32(txtGAgua.Text); gasto._GASTO_OTRO = Convert.ToInt32(txtGOtro.Text); gasto._TOTAL_GASTO = Convert.ToInt32(lbTotal.Text); if (listaGastos.Count > 0) { foreach (Adapter.AdapterGastoComun item in listaGastos) { if (item._ID_EDIFICIO == edificio.ID_EDIFICIO) { option = false; } } } if (option == true) { listaGastos.Add(gasto); grGastos.DataSource = listaGastos; grGastos.DataBind(); } else { lbError.Visible = true; } }