Esempio n. 1
0
 public ActionResult GeneralTop(string name)
 {
     Session["UserIDG"] = Session["UserIDG"];
     Session["UserID"] = Session["UserID"];
     Session["User"] = Session["User"];
     Session["TopicName"] = name;
     Topics top = new Topics();
     List<string> items = new List<string>();
     top = top.getTopicsByName(name);
     items.Add(top.name);
     items.Add(top.descripcion);
     items.Add(top.mensaje);
     ViewData["TopicIDU"] = top.id_user;
     ViewData["TopicID"] = top.id_topic;
     ViewBag.Items = items;
     return View();
 }
Esempio n. 2
0
        public ActionResult EliminarTop(string name)
        {
            Session["UserIDG"] = Session["UserIDG"];
            Session["UserID"] = Session["UserID"];
            Session["User"] = Session["User"];
            string texto = "Estas seguro de Eliminar el topic?";
            string titulo = "Eliminar Topic";
            MessageBoxButtons button = MessageBoxButtons.YesNoCancel;
            MessageBoxIcon icon = MessageBoxIcon.Question;
            DialogResult result = MessageBox.Show(texto, titulo, button, icon);
            Comments comments = new Comments();
            Topics topic = new Topics();
            topic = topic.getTopicsByName(name);
            if (result.Equals(System.Windows.Forms.DialogResult.Yes))
            {
                if (!comments.DeleteCommentsByIDTopic(topic.id_topic))
                {
                    MessageBox.Show("Comentario de " + topic.id_topic + "no eliminado");
                    return Redirect("GeneralCat");
                }
                String sql = "Delete from Topic where nameTopic = '" + name + "'";
                int retorno = 0;
                using (SqlConnection connection = BD.getConnection())
                {
                    SqlCommand Comando = new SqlCommand(string.Format(sql), connection);
                    retorno = Comando.ExecuteNonQuery();
                    connection.Close();

                }
                if (retorno > 0)
                {
                    MessageBox.Show("Topic Borrado Con Exito!!", "Eliminado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("No se pudo borrar el Topic", "Fallo!!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            return RedirectToAction("GeneralCat", new { name = Session["CatName"] });
        }