protected void btnGrabar_Click(object sender, EventArgs e)
    {
        UserControl  wucCondominio = (UserControl)Page.Master.FindControl("ContentPlaceHolder1").FindControl("wucCondominio1");
        DropDownList ddlCondominio = (DropDownList)wucCondominio.FindControl("ddlCondominio");
        DropDownList ddlComunidad  = (DropDownList)wucCondominio.FindControl("ddlComunidad");

        List <EmpresaServicioDTO> empresa_servicio = new List <EmpresaServicioDTO>();

        empresa_servicio = (Session["empresa_servicio"] as List <EmpresaServicioDTO>);

        EmpresaServicioDTO theEmpresaServicioDTO = new EmpresaServicioDTO();

        theEmpresaServicioDTO.RazonSocialEmpresaServicio = this.txtRazonSocialEmpresaServicio.Text.ToUpper();
        theEmpresaServicioDTO.RutEmpresaServicio         = this.txtRutEmpresaServicio.Text.ToUpper();
        theEmpresaServicioDTO.DireccionEmpresaServicio   = this.txtEmpresaServicioDireccion.Text.ToUpper();
        theEmpresaServicioDTO.TelefonoEmpresaServicio    = this.txtEmpresaServicioTelefono.Text;
        theEmpresaServicioDTO.CelularEmpresaServicio     = this.txtEmpresaServicioTelefono.Text;
        theEmpresaServicioDTO.UrlEmpresaServicio         = this.txtEmpresaServicioURL.Text.ToUpper();
        theEmpresaServicioDTO.EmailEmpresaServicio       = this.txtEmail.Text;

        YouCom.DTO.Servicio.ServiciosDTO myServiciosDTO = new YouCom.DTO.Servicio.ServiciosDTO();
        myServiciosDTO.IdServicio             = decimal.Parse(ddlServicio.SelectedValue);
        theEmpresaServicioDTO.TheServiciosDTO = myServiciosDTO;

        YouCom.DTO.GiroDTO myGiroDTO = new YouCom.DTO.GiroDTO();
        myGiroDTO.IdGiro = decimal.Parse(ddlGiro.SelectedValue);
        theEmpresaServicioDTO.TheGiroDTO = myGiroDTO;

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

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

        YouCom.DTO.ComunaDTO myComunaDTO = new YouCom.DTO.ComunaDTO();
        myComunaDTO.IdComuna = decimal.Parse(ddlComuna.SelectedValue);
        theEmpresaServicioDTO.TheComunaDTO = myComunaDTO;

        YouCom.DTO.CiudadDTO myCiudadDTO = new YouCom.DTO.CiudadDTO();
        myCiudadDTO.IdCiudad = decimal.Parse(ddlCiudad.SelectedValue);
        theEmpresaServicioDTO.TheComunaDTO.TheCiudadDTO = myCiudadDTO;

        YouCom.DTO.RegionDTO myRegionDTO = new YouCom.DTO.RegionDTO();
        myRegionDTO.IdRegion = decimal.Parse(ddlRegion.SelectedValue);
        theEmpresaServicioDTO.TheComunaDTO.TheCiudadDTO.TheRegionDTO = myRegionDTO;

        YouCom.DTO.PaisDTO myPaisDTO = new YouCom.DTO.PaisDTO();
        myPaisDTO.IdPais = decimal.Parse(ddlPais.SelectedValue);
        theEmpresaServicioDTO.TheComunaDTO.TheCiudadDTO.TheRegionDTO.ThePaisDTO = myPaisDTO;

        theEmpresaServicioDTO.UsuarioIngreso = myUsuario.Rut;

        if (this.FileImagenEmpresaServicio.HasFile)
        {
            if (System.IO.Path.GetExtension(FileImagenEmpresaServicio.PostedFile.FileName) == ".swf")
            {
                theEmpresaServicioDTO.LogoEmpresaServicio = this.ProcessOtherFile(FileImagenEmpresaServicio, null, YouCom.Service.Generales.General.GetPropiedad("UploadsPathEmpresaServicioPub"));
            }
            else
            {
                theEmpresaServicioDTO.LogoEmpresaServicio = YouCom.Service.Imagenes.Imagen.ProcessFileResize(FileImagenEmpresaServicio, YouCom.Service.Generales.General.GetPropiedad("UploadsPathEmpresaServicioPub"), 198, 118, Page);
            }
        }

        empresa_servicio = empresa_servicio.Where(x => x.RazonSocialEmpresaServicio == theEmpresaServicioDTO.RazonSocialEmpresaServicio).ToList();
        if (empresa_servicio.Any())
        {
            foreach (var item in empresa_servicio)
            {
                if (item.Estado == "2")
                {
                    string script = "alert('Empresa Servicio existe pero fue eliminado para activarlo dirigase a Papelera.');";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true);
                    return;
                }
                else
                {
                    string script = "alert('Empresa Servicio ya Existe .');";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true);
                    return;
                }
            }
        }

        bool respuesta = YouCom.bll.EmpresaServicioBLL.Insert(theEmpresaServicioDTO);

        if (respuesta)
        {
            this.txtRutEmpresaServicio.Text         = string.Empty;
            this.txtRazonSocialEmpresaServicio.Text = string.Empty;
            this.txtEmpresaServicioDireccion.Text   = string.Empty;
            this.txtEmpresaServicioTelefono.Text    = string.Empty;
            this.txtEmpresaServicioCelular.Text     = string.Empty;
            this.txtEmpresaServicioURL.Text         = string.Empty;
            this.txtEmail.Text = string.Empty;

            string script = "alert('Empresa Servicio ingresado correctamente.');";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true);
            cargarEmpresaServicio();
        }
        else
        {
        }
    }
    protected void btnEditar_Click(object sender, EventArgs e)
    {
        UserControl  wucCondominio = (UserControl)Page.Master.FindControl("ContentPlaceHolder1").FindControl("wucCondominio1");
        DropDownList ddlCondominio = (DropDownList)wucCondominio.FindControl("ddlCondominio");
        DropDownList ddlComunidad  = (DropDownList)wucCondominio.FindControl("ddlComunidad");

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

        EmpresaServicioDTO theEmpresaServicioDTO = new EmpresaServicioDTO();

        theEmpresaServicioDTO.IdEmpresaServicio          = decimal.Parse(this.hdnIdEmpresaServicio.Value);
        theEmpresaServicioDTO.RazonSocialEmpresaServicio = this.txtRazonSocialEmpresaServicio.Text.ToUpper();
        theEmpresaServicioDTO.RutEmpresaServicio         = this.txtRutEmpresaServicio.Text.ToUpper();
        theEmpresaServicioDTO.DireccionEmpresaServicio   = this.txtEmpresaServicioDireccion.Text.ToUpper();
        theEmpresaServicioDTO.TelefonoEmpresaServicio    = this.txtEmpresaServicioTelefono.Text;
        theEmpresaServicioDTO.CelularEmpresaServicio     = this.txtEmpresaServicioCelular.Text;
        theEmpresaServicioDTO.UrlEmpresaServicio         = this.txtEmpresaServicioURL.Text.ToUpper();
        theEmpresaServicioDTO.EmailEmpresaServicio       = this.txtEmail.Text;

        YouCom.DTO.Servicio.ServiciosDTO myServiciosDTO = new YouCom.DTO.Servicio.ServiciosDTO();
        myServiciosDTO.IdServicio             = decimal.Parse(ddlServicio.SelectedValue);
        theEmpresaServicioDTO.TheServiciosDTO = myServiciosDTO;

        YouCom.DTO.GiroDTO myGiroDTO = new YouCom.DTO.GiroDTO();
        myGiroDTO.IdGiro = decimal.Parse(ddlGiro.SelectedValue);
        theEmpresaServicioDTO.TheGiroDTO = myGiroDTO;

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

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

        YouCom.DTO.ComunaDTO myComunaDTO = new YouCom.DTO.ComunaDTO();
        myComunaDTO.IdComuna = decimal.Parse(ddlComuna.SelectedValue);
        theEmpresaServicioDTO.TheComunaDTO = myComunaDTO;

        YouCom.DTO.CiudadDTO myCiudadDTO = new YouCom.DTO.CiudadDTO();
        myCiudadDTO.IdCiudad = decimal.Parse(ddlCiudad.SelectedValue);
        theEmpresaServicioDTO.TheComunaDTO.TheCiudadDTO = myCiudadDTO;

        YouCom.DTO.RegionDTO myRegionDTO = new YouCom.DTO.RegionDTO();
        myRegionDTO.IdRegion = decimal.Parse(ddlRegion.SelectedValue);
        theEmpresaServicioDTO.TheComunaDTO.TheCiudadDTO.TheRegionDTO = myRegionDTO;

        YouCom.DTO.PaisDTO myPaisDTO = new YouCom.DTO.PaisDTO();
        myPaisDTO.IdPais = decimal.Parse(ddlPais.SelectedValue);
        theEmpresaServicioDTO.TheComunaDTO.TheCiudadDTO.TheRegionDTO.ThePaisDTO = myPaisDTO;

        theEmpresaServicioDTO.UsuarioModificacion = myUsuario.Rut;

        if (this.FileImagenEmpresaServicio.HasFile)
        {
            theEmpresaServicioDTO.LogoEmpresaServicio = YouCom.Service.Imagenes.Imagen.ProcessFileResize(FileImagenEmpresaServicio, YouCom.Service.Generales.General.GetPropiedad("UploadsPathEmpresaServicioPub"), 198, 118, Page);
        }
        else
        {
            EmpresaServicioDTO myEmpresaServicioDTO = new EmpresaServicioDTO();
            myEmpresaServicioDTO = YouCom.bll.EmpresaServicioBLL.detalleEmpresaServicio(decimal.Parse(hdnIdEmpresaServicio.Value));

            theEmpresaServicioDTO.LogoEmpresaServicio = myEmpresaServicioDTO.LogoEmpresaServicio;
        }


        bool respuesta = YouCom.bll.EmpresaServicioBLL.Update(theEmpresaServicioDTO);

        if (respuesta)
        {
            cargarEmpresaServicio();
            this.txtRutEmpresaServicio.Text         = string.Empty;
            this.txtRazonSocialEmpresaServicio.Text = string.Empty;
            this.txtEmpresaServicioDireccion.Text   = string.Empty;
            this.txtEmpresaServicioTelefono.Text    = string.Empty;
            this.txtEmpresaServicioCelular.Text     = string.Empty;
            this.txtEmpresaServicioURL.Text         = string.Empty;
            this.txtEmail.Text = string.Empty;

            if (!Page.ClientScript.IsClientScriptBlockRegistered("SET"))
            {
                string script = "alert('Empresa Servicio editado correctamente.');";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true);
            }
        }
        else
        {
        }
    }
Esempio n. 3
0
    protected void rptServicio_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        try
        {
            HiddenField myHdnIdServicio = (HiddenField)e.Item.FindControl("hdnIdServicio");

            TextBox myTxtMensaje = (TextBox)e.Item.FindControl("txtMensaje");

            Repeater myRptRespuestas = (Repeater)e.Item.FindControl("rptRespuestas");

            LinkButton myLnkBtnMeGusta           = (LinkButton)e.Item.FindControl("LnkBtnMeGusta");
            LinkButton myLnkBtnNoMeGusta         = (LinkButton)e.Item.FindControl("LnkBtnNoMeGusta");
            LinkButton myLnkBtnAgregarComentario = (LinkButton)e.Item.FindControl("LnkBtnAgregarComentario");

            Panel PnlResultado = (Panel)e.Item.FindControl("pnlResultado");
            Panel PnlComentar  = (Panel)e.Item.FindControl("pnlComentar");
            Panel pnlMensajes  = (Panel)e.Item.FindControl("pnlMensajes");

            Literal LitMensaje = (Literal)e.Item.FindControl("litMensaje");

            if (e.CommandName.Equals("EnviarComentario"))
            {
                PnlComentar.Visible  = false;
                PnlResultado.Visible = true;
                myTxtMensaje.Text    = string.Empty;

                LitMensaje.Text = "<strong>Estimado Usuario,</strong> El comentario ha sido enviado correctamente.";
            }

            if (e.CommandName.Equals("AgregarComentario"))
            {
                if (PnlComentar.Visible)
                {
                    PnlResultado.Visible           = false;
                    PnlComentar.Visible            = false;
                    myLnkBtnAgregarComentario.Text = "<span class=\"glyphicon glyphicon-pencil\"></span> Agregar Comentario";
                }
                else
                {
                    PnlResultado.Visible           = false;
                    PnlComentar.Visible            = true;
                    myLnkBtnAgregarComentario.Text = "<span class=\"glyphicon glyphicon-pencil\"></span> Ocultar Comentario";
                }
            }
            if (e.CommandName.Equals("VerDescripcion"))
            {
                Literal myLitServicioDescripcion = new Literal();
                myLitServicioDescripcion = (Literal)e.Item.FindControl("LitServicioDescripcion");

                LinkButton myLnkBtnVerMas = (LinkButton)e.Item.FindControl("LnkBtnVerMas");

                YouCom.DTO.Servicio.ServiciosDTO myServiciosDTO = new YouCom.DTO.Servicio.ServiciosDTO();
                myServiciosDTO = YouCom.bll.ServiciosBLL.detalleServicios(decimal.Parse(myHdnIdServicio.Value));

                myLitServicioDescripcion.Text = myServiciosDTO.DescripcionServicio;
                myLnkBtnVerMas.Visible        = false;
            }

            if (e.CommandName.Equals("VerComentarios"))
            {
                //getVerComentarios(decimal.Parse(myHdnIdMensaje.Value), myHdnQuienEnvia.Value, pnlMensajes, myRptRespuestas, myLnkBtnAgregarComentario, false);
            }
        }
        catch (Exception ex)
        {
        }
    }