public String eliminarComentario(DataComentario dc)
    {
        string msg = "";

        SqlCommand cmd = new SqlCommand("usp_eliminar_comentario", cn.getCn);
        cmd.CommandType = CommandType.StoredProcedure;

        cmd.Parameters.Add("@id", SqlDbType.VarChar).Value = dc.Id;

        cn.getCn.Open();

        try
        {
            msg = cmd.ExecuteNonQuery() + " Comentario eliminado";
        }
        catch (Exception ex)
        {
            msg = ex.Message;
        }
        finally
        {
            cn.getCn.Close();
        }

        return msg;
    }
    protected void btnComentar_Click(object sender, EventArgs e)
    {
        if (!Context.User.Identity.IsAuthenticated)
        {
            FormsAuthentication.RedirectToLoginPage("Login_Usuario.aspx");
        }
        else
        {
            imgComentario1.ImageUrl = string.Format("img/avatar/{0}.jpg", Context.User.Identity.Name);

            try
            {
                if (txtComentario.Text == string.Empty)
                {
                    lblMensaje.Text = "Escribe un comentario...";
                }
                else
                {
                    DataComentario dc = new DataComentario();

                    dc.Comentario = txtComentario.Text;
                    dc.Usuario = Context.User.Identity.Name;
                    dc.Cliente = razonSocial;

                    string msg = c.registrarComentario(dc);

                    lblMensaje.Text = msg;
                    string script = @"<script type='text/javascript'> alert('{0}'); </script>";
                    script = string.Format(script, msg);
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", script, false);
                }
            }
            catch (Exception ex)
            {
                lblMensaje.Text = ex.Message;
            }
        }
    }
Beispiel #3
0
 protected override bool Validar()
 {
     return(!string.IsNullOrEmpty(DataComentario.ToString()) &&
            !string.IsNullOrWhiteSpace(TextoComentario));
 }
Beispiel #4
0
 protected override bool Validar()
 {
     return(!string.IsNullOrEmpty(DataComentario.ToString()) &&
            !string.IsNullOrWhiteSpace(QuantidadeEstrelas.ToString()));
 }