Esempio n. 1
0
 public ActionResult Create(Areas.Models.DanhMuc tin, string selectDM)
 {
     if (Session["login"] == null)
     {
         return(RedirectToAction("Index", "Login"));
     }
     else
     {
         tin.DanhMucCha = Int32.Parse(selectDM);
         DAL.DanhMuc.insert(tin);
         return(RedirectToAction("Index", "ChuyenMuc"));
     }
 }
Esempio n. 2
0
 public ActionResult Update(Areas.Models.DanhMuc danhmuc, int id)
 {
     if (Session["login"] == null)
     {
         return(RedirectToAction("Index", "Login"));
     }
     else
     {
         danhmuc        = DAL.DanhMuc.selectDM(id.ToString());
         ViewBag.listDM = DAL.DanhMuc.select();
         return(View(danhmuc));
     }
 }
Esempio n. 3
0
        public static void insert(Areas.Models.DanhMuc tin)
        {
            openConnect();
            SqlCommand cmd = new SqlCommand("sp_insert_DanhMuc", con);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@Ten", tin.Ten.Trim());
            cmd.Parameters.AddWithValue("@DanhMucCha", tin.DanhMucCha);
            cmd.Parameters.AddWithValue("@MetaTitle", XuLiChuoi.xoaKhoangTrang(tin.MetaTitle.Trim()));
            cmd.Parameters.AddWithValue("@HienThi", tin.HienThi);
            cmd.ExecuteNonQuery();
            closeConnect();
        }
Esempio n. 4
0
 public ActionResult Update(Areas.Models.DanhMuc danhmuc, int id, string selectDM)
 {
     if (Session["login"] == null)
     {
         return(RedirectToAction("Index", "Login"));
     }
     else
     {
         ViewBag.listDM     = DAL.DanhMuc.select();
         danhmuc.DanhMucCha = Int32.Parse(selectDM);
         danhmuc.Id         = id;
         DAL.DanhMuc.update(danhmuc);
         return(RedirectToAction("Index", "ChuyenMuc"));
     }
 }
Esempio n. 5
0
        public static List <Areas.Models.DanhMuc> select()
        {
            openConnect();
            List <Areas.Models.DanhMuc> list = new List <Areas.Models.DanhMuc>();
            SqlCommand cmd = new SqlCommand("select * from DanhMuc where DanhMucCha is null", con);

            SqlDataReader rd = cmd.ExecuteReader(CommandBehavior.CloseConnection);

            while (rd.Read())
            {
                Areas.Models.DanhMuc tt = new Areas.Models.DanhMuc();
                tt.Id  = rd["Id"] is DBNull ? 0 : rd.GetInt32(0);
                tt.Ten = rd["Ten"] is DBNull ? "" : rd.GetString(1).Trim();
                list.Add(tt);
            }
            rd.Close();
            closeConnect();
            return(list);
        }
Esempio n. 6
0
        public static List <Areas.Models.DanhMuc> selectDSNV(string id)
        {
            openConnect();
            List <Areas.Models.DanhMuc> list = new List <Areas.Models.DanhMuc>();
            SqlCommand cmd = new SqlCommand("sp_select_dm", con);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@nhanvien", id);
            SqlDataReader rd = cmd.ExecuteReader(CommandBehavior.CloseConnection);

            while (rd.Read())
            {
                Areas.Models.DanhMuc tt = new Areas.Models.DanhMuc();
                tt.Id  = rd["Id"] is DBNull ? 0 : rd.GetInt32(1);
                tt.Ten = rd["Ten"] is DBNull ? "" : rd.GetString(0).Trim();
                list.Add(tt);
            }
            rd.Close();
            closeConnect();
            return(list);
        }
Esempio n. 7
0
        public static List <Areas.Models.DanhMuc> selectALLDM()
        {
            openConnect();
            List <Areas.Models.DanhMuc> list = new List <Areas.Models.DanhMuc>();

            SqlCommand    cmd = new SqlCommand("select a.id,a.Ten,a.DanhMucCha,b.Ten as 'TenDanhMucCha',a.MetaTitle,a.HienThi from DanhMuc a LEFT JOIN DanhMuc b on b.Id = a.DanhMucCha", con);
            SqlDataReader rd  = cmd.ExecuteReader(CommandBehavior.CloseConnection);

            while (rd.Read())
            {
                Areas.Models.DanhMuc tt = new Areas.Models.DanhMuc();
                tt.Id            = rd["id"] is DBNull ? 0 : rd.GetInt32(0);
                tt.Ten           = rd["Ten"] is DBNull ? "" : rd.GetString(1).Trim();
                tt.DanhMucCha    = rd["DanhMucCha"] is DBNull ? 0 : rd.GetInt32(2);
                tt.TenDanhMucCha = rd["TenDanhMucCha"] is DBNull ? "Không có" : rd.GetString(3).Trim();
                tt.MetaTitle     = rd["MetaTitle"] is DBNull ? "" : rd.GetString(4).Trim();
                tt.HienThi       = rd["HienThi"] is DBNull ? false : rd.GetBoolean(5);
                list.Add(tt);
            }
            rd.Close();
            closeConnect();
            return(list);
        }
Esempio n. 8
0
        public static Areas.Models.DanhMuc selectDM(string idDM)
        {
            openConnect();
            Areas.Models.DanhMuc tt  = new Areas.Models.DanhMuc();
            SqlCommand           cmd = new SqlCommand("sp_select_dm_update", con);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@id", idDM);
            SqlDataReader rd = cmd.ExecuteReader(CommandBehavior.CloseConnection);

            while (rd.Read())
            {
                tt.Id            = rd["id"] is DBNull ? 0 : rd.GetInt32(0);
                tt.Ten           = rd["Ten"] is DBNull ? "" : rd.GetString(1).Trim();
                tt.DanhMucCha    = rd["DanhMucCha"] is DBNull ? 0 : rd.GetInt32(2);
                tt.TenDanhMucCha = rd["TenDanhMucCha"] is DBNull ? "Không có" : rd.GetString(3).Trim();
                tt.MetaTitle     = rd["MetaTitle"] is DBNull ? "" : rd.GetString(4).Trim();
                tt.HienThi       = rd["HienThi"] is DBNull ? false : rd.GetBoolean(5);
            }
            rd.Close();
            closeConnect();
            return(tt);
        }
Esempio n. 9
0
        public List <Areas.Models.DanhMuc> chuyenMuc()
        {
            openConnect();
            List <Areas.Models.DanhMuc> list = new List <Areas.Models.DanhMuc>();
            SqlCommand cmd = new SqlCommand("sp_select_danhMuc", con);

            cmd.CommandType = CommandType.StoredProcedure;
            SqlDataReader rd = cmd.ExecuteReader(CommandBehavior.CloseConnection);

            while (rd.Read())
            {
                Areas.Models.DanhMuc tt = new Areas.Models.DanhMuc();
                tt.Id            = rd["Id"] is DBNull ? 0 : rd.GetInt32(0);
                tt.DanhMucCha    = rd["TieuDe"] is DBNull ? 0 : rd.GetInt32(1);
                tt.MetaTitle     = rd["Tag"] is DBNull ? "" : rd.GetString(2).Trim();
                tt.Ten           = rd["NoiDung"] is DBNull ? "" : rd.GetString(3).Trim();
                tt.TenDanhMucCha = rd["NgayDang"] is DBNull ? "" : rd.GetString(4).Trim();
                tt.HienThi       = rd["NgayDang"] is DBNull ? false : rd.GetBoolean(4);
                list.Add(tt);
            }
            rd.Close();
            closeConnect();
            return(list);
        }