Ejemplo n.º 1
0
        public ActionResult EliminarCa(int id)
        {
            Session["UserIDG"] = Session["UserIDG"];
            Session["UserID"] = Session["UserID"];
            Session["User"] = Session["User"];
            string texto = "Estas seguro de Eliminar la categoria?";
            string titulo = "Eliminar Categoria";
            MessageBoxButtons button = MessageBoxButtons.YesNoCancel;
            MessageBoxIcon icon = MessageBoxIcon.Question;
            DialogResult result = MessageBox.Show(texto, titulo, button, icon);
            List<Topics> topics = new List<Topics>();
            Comments comments = new Comments();
            Topics top = new Topics();
            topics = top.getAllTopicsByCatID(id);
            if (result.Equals(System.Windows.Forms.DialogResult.Yes))
            {

                for (int i = 0; i < topics.Count; i++)
                {
                    if (!comments.DeleteCommentsByIDTopic(topics[i].id_topic))
                    {

                        MessageBox.Show("Comentario de " + topics[i].id_topic + "no eliminado");
                    }
                }
                if (!top.DeleteTopicsByIDCat(id))
                {
                    MessageBox.Show("Topic de " + id + "no eliminado");
                }

                String sql = "Delete from Category where id_category = '" + id.ToString() + "'";
                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("Categoria Borrada Con Exito!!", "Eliminada", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("No se pudo borrar la Categoria", "Fallo!!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            return RedirectToAction("Categorias", "Home");
        }
Ejemplo n.º 2
0
        public ActionResult GeneralCat(string name)
        {
            Session["UserIDG"] = Session["UserIDG"];
            Session["UserID"] = Session["UserID"];
            Session["User"] = Session["User"];
            Session["CatName"] = name;
            Categorias cat = new Categorias();
            int id = cat.getIDCatName(name);
            List<Topics> topics = new List<Topics>();
            Topics top = new Topics();
            List<string> items = new List<string>();
            topics = top.getAllTopicsByCatID(id);

            for (int i = 0; i < topics.Count; i++)
            {

                items.Add(topics[i].name);

            }
            ViewBag.Items = items;
            ViewData["TCount"] = topics.Count;
            return View();
        }