示例#1
0
        public Topics getTopicsByName(string name)
        {
            String sql = "Select *From Topic where nameTopic = '"+name+"'";
            Topics top = new Topics();
            using (SqlConnection connection = BD.getConnection())
            {
                SqlCommand Comando = new SqlCommand(string.Format(sql, name), connection);

                SqlDataReader reader = Comando.ExecuteReader();
                while (reader.Read())
                {

                    top.id_topic = reader.GetInt32(0);
                    top.id_categoria = reader.GetInt32(1);
                    top.id_user = reader.GetInt32(2);
                    top.name = reader.GetString(3);
                    top.descripcion = reader.GetString(4);
                    top.mensaje = reader.GetString(5);
                    top.publico = reader.GetInt32(6);

                }
            }

            return top;
        }
示例#2
0
        public List<Topics> getAllTopics()
        {
            List<Topics> ListTop = new List<Topics>();
            String sql = "Select *From Topic";

            using (SqlConnection connection = BD.getConnection())
            {
                SqlCommand Comando = new SqlCommand(string.Format(sql), connection);

                SqlDataReader reader = Comando.ExecuteReader();
                while (reader.Read())
                {

                    Topics top = new Topics();
                    top.id_topic = reader.GetInt32(0);
                    top.id_categoria = reader.GetInt32(1);
                    top.id_user = reader.GetInt32(2);
                    top.name = reader.GetString(3);
                    top.descripcion = reader.GetString(4);
                    top.mensaje = reader.GetString(5);
                    top.publico = reader.GetInt32(6);
                    ListTop.Add(top);
                }
            }

            return ListTop;
        }
示例#3
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");
        }
示例#4
0
 public ActionResult NuevoTopic(string cat)
 {
     ViewBag.Message = "Nuevo Topic";
     ViewData["CatName2"] = cat;
     Topics topic = new Topics();
     List<string> names = topic.getAllNamesTopic();
     ViewBag.Items = names;
     ViewBag.Serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
     return View();
 }
示例#5
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();
 }
示例#6
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();
        }
示例#7
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"] });
        }