Пример #1
0
    protected void rptVacaciones_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        try
        {
            if (e.CommandName.Equals("Eliminar"))
            {
                HiddenField hdnIdVacaciones = (HiddenField)e.Item.FindControl("hdnIdVacaciones");

                YouCom.DTO.VacacionesDTO myVacacionesDTO = new YouCom.DTO.VacacionesDTO();

                myVacacionesDTO.IdVacaciones        = decimal.Parse(hdnIdVacaciones.Value);
                myVacacionesDTO.UsuarioModificacion = myUsuario.Rut;

                if (YouCom.bll.VacacionesBLL.Delete(myVacacionesDTO))
                {
                    if (!Page.ClientScript.IsClientScriptBlockRegistered("SET"))
                    {
                        string script = "alert('Vacación eliminada correctamente.');";
                        script += "parent.location = '" + retorno1 + "';";
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true);
                    }
                }
            }

            if (e.CommandName.Equals("Detalle"))
            {
                HiddenField hdnIdVacaciones = (HiddenField)e.Item.FindControl("hdnIdVacaciones");
            }
        }
        catch (Exception ex)
        {
        }
    }
    protected void BtnEnviar_Click(object sender, EventArgs e)
    {
        try
        {
            if (Page.IsValid)
            {
                YouCom.DTO.VacacionesDTO myVacacionesDTO = new YouCom.DTO.VacacionesDTO();

                myVacacionesDTO.DestinoVacaciones = this.TxtComentarios.Text;
                myVacacionesDTO.FechaInicio       = DateTime.ParseExact(this.TxtDesde.Text + " " + DateTime.Now.ToString("HH:mm"), "dd/MM/yyyy HH:mm", System.Globalization.CultureInfo.InvariantCulture);
                myVacacionesDTO.FechaTermino      = DateTime.ParseExact(this.TxtHasta.Text + " " + DateTime.Now.ToString("HH:mm"), "dd/MM/yyyy HH:mm", System.Globalization.CultureInfo.InvariantCulture);
                myVacacionesDTO.TheCasaDTO        = myUsuario.TheFamiliaDTO.TheCasaDTO;
                myVacacionesDTO.TheCondominioDTO  = myUsuario.TheCondominioSeleccionDTO;
                myVacacionesDTO.TheComunidadDTO   = myUsuario.TheComunidadSeleccionDTO;

                YouCom.DTO.Propietario.ParentescoDTO myParentescoDTO = new YouCom.DTO.Propietario.ParentescoDTO();
                myParentescoDTO.IdParentesco = decimal.Parse(ddlParentesco.SelectedValue);

                myVacacionesDTO.TheParentescoDTO = myParentescoDTO;
                myVacacionesDTO.NombreContacto   = this.TxtNombreContacto.Text;
                myVacacionesDTO.TelefonoContacto = this.TxtTelefonoContacto.Text;

                myVacacionesDTO.UsuarioIngreso = myUsuario.Rut;

                bool respuesta = YouCom.bll.VacacionesBLL.Insert(myVacacionesDTO);
                if (respuesta)
                {
                    if (enviarMail())
                    {
                        if (!Page.ClientScript.IsClientScriptBlockRegistered("SET"))
                        {
                            string script = "alert('Estimado Cliente, hemos recibido su mensaje, en breve nos contactaremos con usted.');";
                            script += "parent.location = '" + retorno1 + "';";
                            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 = '" + retorno1 + "';";
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true);
                        }
                    }
                }
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }
    }