protected void btnGrabar_Click(object sender, EventArgs e) { UserControl wucCondominio = (UserControl)Page.Master.FindControl("ContentPlaceHolder1").FindControl("wucCondominioCasa1"); DropDownList ddlCondominio = (DropDownList)wucCondominio.FindControl("ddlCondominio"); DropDownList ddlComunidad = (DropDownList)wucCondominio.FindControl("ddlComunidad"); DropDownList ddlCasa = (DropDownList)wucCondominio.FindControl("ddlCasa"); IList <YouCom.DTO.GastosComunes.GastoComunDTO> gastoComun = new List <YouCom.DTO.GastosComunes.GastoComunDTO>(); gastoComun = (Session["gastoComun"] as List <YouCom.DTO.GastosComunes.GastoComunDTO>); YouCom.DTO.GastosComunes.GastoComunDTO theGastosComunesDTO = new YouCom.DTO.GastosComunes.GastoComunDTO(); theGastosComunesDTO.DescripcionGasto = this.txtDescripcion.Text.ToUpper(); theGastosComunesDTO.MontoGasto = decimal.Parse(this.txtMonto.Text); theGastosComunesDTO.FechaGasto = DateTime.ParseExact(this.FechaGasto.Text + " " + DateTime.Now.ToString("HH:mm"), "dd/MM/yyyy HH:mm", System.Globalization.CultureInfo.InvariantCulture); YouCom.DTO.Seguridad.CondominioDTO myCondominioDTO = new YouCom.DTO.Seguridad.CondominioDTO(); myCondominioDTO.IdCondominio = decimal.Parse(ddlCondominio.SelectedValue); theGastosComunesDTO.TheCondominioDTO = myCondominioDTO; YouCom.DTO.Seguridad.ComunidadDTO myComunidadDTO = new YouCom.DTO.Seguridad.ComunidadDTO(); myComunidadDTO.IdComunidad = decimal.Parse(ddlComunidad.SelectedValue); theGastosComunesDTO.TheComunidadDTO = myComunidadDTO; YouCom.DTO.Propietario.CasaDTO myCasa = new YouCom.DTO.Propietario.CasaDTO(); myCasa.IdCasa = decimal.Parse(ddlCasa.SelectedValue); theGastosComunesDTO.TheCasaDTO = myCasa; YouCom.DTO.GastosComunes.GastoComunEstadoDTO myGastoComunEstadoDTO = new YouCom.DTO.GastosComunes.GastoComunEstadoDTO(); myGastoComunEstadoDTO.IdGastoComunEstado = decimal.Parse(this.ddlEstado.SelectedValue); theGastosComunesDTO.TheGastoComunEstadoDTO = myGastoComunEstadoDTO; theGastosComunesDTO.FechaPagoGasto = DateTime.MaxValue; theGastosComunesDTO.UsuarioIngreso = myUsuario.Rut; if (this.FileArchivo.HasFile) { theGastosComunesDTO.ArchivoGasto = this.ProcessOtherFile(FileArchivo, null, YouCom.Service.Generales.General.GetPropiedad("UploadsPathGastoComunPub")); } gastoComun = gastoComun.Where(x => x.DescripcionGasto == theGastosComunesDTO.DescripcionGasto).ToList(); if (gastoComun.Any()) { foreach (var item in gastoComun) { if (item.Estado == "2") { string script = "alert('Gasto Común existe pero fue eliminado para activarlo dirigase a Papelera.');"; Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true); return; } else { string script = "alert('Gasto Común ya Existe .');"; Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true); return; } } } bool respuesta = YouCom.bll.GastosComunes.GastoComunBLL.Insert(theGastosComunesDTO); if (respuesta) { this.txtComentario.Text = string.Empty; this.txtDescripcion.Text = string.Empty; this.txtMonto.Text = string.Empty; this.ddlEstado.ClearSelection(); ddlCondominio.ClearSelection(); ddlCasa.ClearSelection(); string script = "alert('Gasto Común ingresado correctamente.');"; Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true); cargarGastoComun(); } else { } }
protected void btnEditar_Click(object sender, EventArgs e) { UserControl wucCondominio = (UserControl)Page.Master.FindControl("ContentPlaceHolder1").FindControl("wucCondominioCasa1"); DropDownList ddlCondominio = (DropDownList)wucCondominio.FindControl("ddlCondominio"); DropDownList ddlComunidad = (DropDownList)wucCondominio.FindControl("ddlComunidad"); DropDownList ddlCasa = (DropDownList)wucCondominio.FindControl("ddlCasa"); btnEditar.Visible = false; btnGrabar.Visible = true; YouCom.DTO.GastosComunes.GastoComunDTO theGastosComunesDTO = new YouCom.DTO.GastosComunes.GastoComunDTO(); theGastosComunesDTO.IdGastoComun = decimal.Parse(this.hdnIdGastoComun.Value); theGastosComunesDTO.DescripcionGasto = this.txtDescripcion.Text.ToUpper(); theGastosComunesDTO.MontoGasto = decimal.Parse(this.txtMonto.Text); theGastosComunesDTO.FechaGasto = DateTime.ParseExact(this.FechaGasto.Text + " " + DateTime.Now.ToString("HH:mm"), "dd/MM/yyyy HH:mm", System.Globalization.CultureInfo.InvariantCulture); YouCom.DTO.Seguridad.CondominioDTO myCondominioDTO = new YouCom.DTO.Seguridad.CondominioDTO(); myCondominioDTO.IdCondominio = decimal.Parse(ddlCondominio.SelectedValue); theGastosComunesDTO.TheCondominioDTO = myCondominioDTO; YouCom.DTO.Seguridad.ComunidadDTO myComunidadDTO = new YouCom.DTO.Seguridad.ComunidadDTO(); myComunidadDTO.IdComunidad = decimal.Parse(ddlComunidad.SelectedValue); theGastosComunesDTO.TheComunidadDTO = myComunidadDTO; YouCom.DTO.Propietario.CasaDTO myCasa = new YouCom.DTO.Propietario.CasaDTO(); myCasa.IdCasa = decimal.Parse(ddlCasa.SelectedValue); theGastosComunesDTO.TheCasaDTO = myCasa; YouCom.DTO.GastosComunes.GastoComunEstadoDTO myGastoComunEstadoDTO = new YouCom.DTO.GastosComunes.GastoComunEstadoDTO(); myGastoComunEstadoDTO.IdGastoComunEstado = decimal.Parse(this.ddlEstado.SelectedValue); theGastosComunesDTO.TheGastoComunEstadoDTO = myGastoComunEstadoDTO; theGastosComunesDTO.FechaPagoGasto = DateTime.ParseExact(this.FechaPago.Text + " " + DateTime.Now.ToString("HH:mm"), "dd/MM/yyyy HH:mm", System.Globalization.CultureInfo.InvariantCulture); theGastosComunesDTO.ComentarioGasto = this.txtComentario.Text; theGastosComunesDTO.UsuarioModificacion = myUsuario.Rut; if (this.FileArchivo.HasFile) { theGastosComunesDTO.ArchivoGasto = this.ProcessOtherFile(FileArchivo, null, YouCom.Service.Generales.General.GetPropiedad("UploadsPathGastoComunPub")); } else { YouCom.DTO.GastosComunes.GastoComunDTO myGastosComunesDTO = new YouCom.DTO.GastosComunes.GastoComunDTO(); myGastosComunesDTO = YouCom.bll.GastosComunes.GastoComunBLL.detalleGastosComunes(decimal.Parse(hdnIdGastoComun.Value)); theGastosComunesDTO.ArchivoGasto = myGastosComunesDTO.ArchivoGasto; } bool respuesta = YouCom.bll.GastosComunes.GastoComunBLL.Update(theGastosComunesDTO); if (respuesta) { cargarGastoComun(); this.txtComentario.Text = string.Empty; this.txtDescripcion.Text = string.Empty; this.txtMonto.Text = string.Empty; this.ddlEstado.ClearSelection(); ddlCondominio.ClearSelection(); ddlCasa.ClearSelection(); if (!Page.ClientScript.IsClientScriptBlockRegistered("SET")) { string script = "alert('Gasto Común editado correctamente.');"; Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true); } } else { } }