protected void LnkBtnComprar_Click(object sender, EventArgs e)
    {
        try
        {
            YouCom.DTO.Avisos.AvisoDTO myAvisoDTO = new YouCom.DTO.Avisos.AvisoDTO();
            myAvisoDTO = YouCom.bll.Avisos.AvisoBLL.detalleAviso(decimal.Parse(this.HdnIdAviso.Value));

            YouCom.DTO.Avisos.AvisoEstadoDTO myAvisoEstadoDTO = new YouCom.DTO.Avisos.AvisoEstadoDTO();
            myAvisoEstadoDTO.IdAvisoEstado = 4;
            myAvisoDTO.TheAvisosEstadoDTO  = myAvisoEstadoDTO;
            myAvisoDTO.RutComprador        = myUsuario.Rut;

            myAvisoDTO.FechaCompra = DateTime.Now;

            bool respuesta = YouCom.bll.Avisos.AvisoBLL.Update(myAvisoDTO);

            if (respuesta)
            {
                if (!Page.ClientScript.IsClientScriptBlockRegistered("SET"))
                {
                    string script = "alert('Estimado Cliente,se ha confirmado la compra, el publicador del aviso se contactara con usted para cerrar la compra.');";
                    script += "parent.location = '" + YouCom.Service.Configuracion.Config.getPageName(true) + "';";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true);
                }
            }
            else
            {
                if (!Page.ClientScript.IsClientScriptBlockRegistered("SET"))
                {
                    string script = "alert('A ocurrido un error. Favor envíe su solicitud al mail [email protected] intente más tarde.');";
                    script += "parent.location = '" + YouCom.Service.Configuracion.Config.getPageName(true) + "';";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true);
                }
            }
        }
        catch (Exception ex)
        {
        }
    }
示例#2
0
    protected void btnEditar_Click(object sender, EventArgs e)
    {
        UserControl  wucCondominio = (UserControl)Page.Master.FindControl("ContentPlaceHolder1").FindControl("wucCondominioCasaFamilia1");
        DropDownList ddlCondominio = (DropDownList)wucCondominio.FindControl("ddlCondominio");
        DropDownList ddlComunidad  = (DropDownList)wucCondominio.FindControl("ddlComunidad");
        DropDownList ddlCasa       = (DropDownList)wucCondominio.FindControl("ddlCasa");
        DropDownList ddlFamilia    = (DropDownList)wucCondominio.FindControl("ddlFamilia");

        btnEditar.Visible = false;
        btnGrabar.Visible = true;

        AvisoDTO theAvisosDTO = new AvisoDTO();

        theAvisosDTO.IdAviso          = decimal.Parse(this.hdnIdAviso.Value);
        theAvisosDTO.TituloAviso      = this.txtAvisoTitulo.Text.ToUpper();
        theAvisosDTO.DescripcionAviso = this.txtAvisoDescripcion.Text.ToUpper();
        theAvisosDTO.PrecioAviso      = decimal.Parse(this.txtAvisoPrecio.Text);

        YouCom.DTO.Seguridad.CondominioDTO myCondominioDTO = new YouCom.DTO.Seguridad.CondominioDTO();
        myCondominioDTO.IdCondominio  = decimal.Parse(ddlCondominio.SelectedValue);
        theAvisosDTO.TheCondominioDTO = myCondominioDTO;

        YouCom.DTO.Seguridad.ComunidadDTO myComunidadDTO = new YouCom.DTO.Seguridad.ComunidadDTO();
        myComunidadDTO.IdComunidad   = decimal.Parse(ddlComunidad.SelectedValue);
        theAvisosDTO.TheComunidadDTO = myComunidadDTO;

        YouCom.DTO.CategoriaDTO myCategoriaDTO = new YouCom.DTO.CategoriaDTO();
        myCategoriaDTO.IdCategoria   = decimal.Parse(ddlCategoria.SelectedValue);
        theAvisosDTO.TheCategoriaDTO = myCategoriaDTO;

        YouCom.DTO.Avisos.TipoAvisoDTO myTipoAvisoDTO = new YouCom.DTO.Avisos.TipoAvisoDTO();
        myTipoAvisoDTO.IdTipoAviso   = decimal.Parse(ddlTipoAviso.SelectedValue);
        theAvisosDTO.TheTipoAvisoDTO = myTipoAvisoDTO;

        YouCom.DTO.Propietario.FamiliaDTO myFamiliaDTO = new YouCom.DTO.Propietario.FamiliaDTO();
        myFamiliaDTO.IdFamilia     = decimal.Parse(ddlFamilia.SelectedValue);
        theAvisosDTO.TheFamiliaDTO = myFamiliaDTO;

        YouCom.DTO.MonedaDTO myMonedaDTO = new YouCom.DTO.MonedaDTO();
        myMonedaDTO.IdMoneda      = 1;
        theAvisosDTO.TheMonedaDTO = myMonedaDTO;

        YouCom.DTO.Avisos.AvisoEstadoDTO myAvisosEstadoDTO = new YouCom.DTO.Avisos.AvisoEstadoDTO();
        myAvisosEstadoDTO.IdAvisoEstado = decimal.Parse(ddlEstado.SelectedValue);
        theAvisosDTO.TheAvisosEstadoDTO = myAvisosEstadoDTO;

        if (ddlEstado.SelectedValue == "3")
        {
            theAvisosDTO.FechaPublicacion = DateTime.Now;
            theAvisosDTO.FechaTermino     = DateTime.Now.AddMonths(1);
        }

        theAvisosDTO.MotivoAvisoEstado = this.txtMotivoEstado.Text;

        theAvisosDTO.UsuarioModificacion = myUsuario.Rut;

        bool respuesta = YouCom.bll.Avisos.AvisoBLL.Update(theAvisosDTO);

        if (respuesta)
        {
            cargarAviso();
            this.txtAvisoDescripcion.Text = string.Empty;
            this.txtAvisoPrecio.Text      = string.Empty;
            this.txtAvisoTitulo.Text      = string.Empty;

            if (!Page.ClientScript.IsClientScriptBlockRegistered("SET"))
            {
                string script = "alert('Aviso editado correctamente.');";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true);
            }
        }
        else
        {
        }
    }
    //protected void cargarDatosPropietario()
    //{
    //    YouCom.DTO.Propietario.FamiliaDTO myFamiliaDTO = new YouCom.DTO.Propietario.FamiliaDTO();

    //    myFamiliaDTO = YouCom.bll.FamiliaBLL.detalleFamiliabyRut(myUsuario.Rut);

    //    this.TxtNombre.Text = myFamiliaDTO.NombreFamilia;
    //    this.TxtPaterno.Text = myFamiliaDTO.ApellidoPaternoFamilia;
    //    this.TxtMaterno.Text = myFamiliaDTO.ApellidoMaternoFamilia;
    //}

    protected bool setEnviaAviso()
    {
        bool retorno = false;
        bool salida  = false;

        AvisoDTO theAvisosDTO = new AvisoDTO();

        theAvisosDTO.TituloAviso      = this.TxtTitulo.Text.ToUpper();
        theAvisosDTO.DescripcionAviso = this.TxtDescripcion.Text.ToUpper();
        theAvisosDTO.PrecioAviso      = decimal.Parse(this.TxtPrecio.Text);

        theAvisosDTO.TheCondominioDTO = myUsuario.TheCondominioSeleccionDTO;

        theAvisosDTO.TheComunidadDTO = myUsuario.TheComunidadSeleccionDTO;

        YouCom.DTO.CategoriaDTO myCategoriaDTO = new YouCom.DTO.CategoriaDTO();
        myCategoriaDTO.IdCategoria   = decimal.Parse(ddlCategoria.SelectedValue);
        theAvisosDTO.TheCategoriaDTO = myCategoriaDTO;

        YouCom.DTO.Avisos.TipoAvisoDTO myTipoAvisoDTO = new YouCom.DTO.Avisos.TipoAvisoDTO();
        myTipoAvisoDTO.IdTipoAviso   = decimal.Parse(ddlTipoAviso.SelectedValue);
        theAvisosDTO.TheTipoAvisoDTO = myTipoAvisoDTO;

        YouCom.DTO.Propietario.FamiliaDTO myFamiliaDTO = new YouCom.DTO.Propietario.FamiliaDTO();

        myFamiliaDTO = YouCom.bll.FamiliaBLL.detalleFamiliabyRut(myUsuario.Rut);
        theAvisosDTO.TheFamiliaDTO = myFamiliaDTO;

        YouCom.DTO.MonedaDTO myMonedaDTO = new YouCom.DTO.MonedaDTO();
        myMonedaDTO.IdMoneda      = 1;
        theAvisosDTO.TheMonedaDTO = myMonedaDTO;

        YouCom.DTO.Avisos.AvisoEstadoDTO myAvisosEstadoDTO = new YouCom.DTO.Avisos.AvisoEstadoDTO();
        myAvisosEstadoDTO.IdAvisoEstado = 1;
        theAvisosDTO.TheAvisosEstadoDTO = myAvisosEstadoDTO;

        theAvisosDTO.FechaPublicacion = DateTime.Now;
        theAvisosDTO.FechaTermino     = DateTime.Now.AddMonths(1);

        theAvisosDTO.UsuarioIngreso = myUsuario.Rut;

        if (this.FileImagenAviso.HasFile)
        {
            theAvisosDTO.ImagenAviso = this.ProcessOtherFile(FileImagenPrincipalAviso, null, YouCom.Service.Generales.General.GetPropiedad("UploadsPathAvisosPub"));
        }

        retorno = YouCom.bll.Avisos.AvisoBLL.Insert(theAvisosDTO);

        if (retorno)
        {
            string ruta          = YouCom.Service.Generales.General.GetPropiedad("UploadsPathAvisosPub");
            string valor_retorno = string.Empty;
            foreach (var file in FileImagenAviso.PostedFiles)
            {
                if (!string.IsNullOrEmpty(file.FileName))
                {
                    YouCom.DTO.Avisos.ImagenAvisoDTO myImagenAvisoDTO = new YouCom.DTO.Avisos.ImagenAvisoDTO();

                    Random myRandom = new Random();
                    string xName    = myRandom.Next(1, 1000000).ToString();

                    if (Intermedia.IMSystem.IMFile.IMFile.GetNameFile(file.FileName).Length > 16)
                    {
                        valor_retorno = xName + "_" + Intermedia.IMSystem.IMFile.IMFile.GetNameFile(file.FileName).Substring(0, 16) + Intermedia.IMSystem.IMFile.IMFile.GetExtensionFile(file.FileName);
                    }
                    else
                    {
                        valor_retorno = xName + "_" + Intermedia.IMSystem.IMFile.IMFile.GetNameFile(file.FileName).Substring(0, Intermedia.IMSystem.IMFile.IMFile.GetNameFile(file.FileName).Length) + Intermedia.IMSystem.IMFile.IMFile.GetExtensionFile(file.FileName);
                    }

                    myImagenAvisoDTO.ThumbailImagenAviso = valor_retorno;
                    myImagenAvisoDTO.GrandeImagenAviso   = valor_retorno;
                    myImagenAvisoDTO.TituloImagenAviso   = this.TxtTitulo.Text;

                    YouCom.DTO.Avisos.AvisoDTO myAvisoDTO = new YouCom.DTO.Avisos.AvisoDTO();
                    myAvisoDTO.IdAviso            = YouCom.bll.Avisos.AvisoBLL.getObtenerUltimoAviso().IdAviso;
                    myImagenAvisoDTO.TheAvisosDTO = myAvisoDTO;

                    YouCom.bll.Avisos.ImagenAvisoBLL.Insert(myImagenAvisoDTO);

                    file.SaveAs(Server.MapPath(ruta + valor_retorno));
                }
            }

            salida = true;
        }

        return(salida);
    }