private void LoadUltraMenu(int NhomChaID)
    {
        try
        {
            NhomSanPhamCuaHang nsp = new NhomSanPhamCuaHang();
            DataSet ds;
            string cachemenu = "nsp" + CuaHangID + "_" + NhomChaID;
            if (Cache[cachemenu] == null)
            {
                ds = nsp.SelectByCuaHangIDAndNhomChaID(CuaHangID, NhomChaID);
                Cache[cachemenu] = ds;
            }
            else
            {
                ds = (DataSet)Cache[cachemenu];
            }

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                Item mni = new Item();
                mni.Text = dr["TenNhomSanPham"].ToString().Length > 30
                               ? dr["TenNhomSanPham"].ToString().Substring(0, 30) + "..."
                               : dr["TenNhomSanPham"].ToString();
                mni.Tag = dr["NhomSanPhamCuaHangID"].ToString();
                //mni.ToolTip = dr["TenNhomSanPham"].ToString();

                LoadUltraMenuItems(mni, int.Parse(dr["NhomSanPhamCuaHangID"].ToString()),false);
                if (LoaiGianHangID == LoaiGianHang)
                {
                    mni.TargetUrl = "newestore.aspx?sid=" + CuaHangID + "&cid=" + dr["NhomSanPhamCuaHangID"];
                }
                else
                {
                    mni.TargetUrl = "estore.aspx?sid=" + CuaHangID + "&cid=" + dr["NhomSanPhamCuaHangID"];
                }
                uwmMenu.Items.Add(mni);
            }
        }
        catch (Exception ex)
        {
            Response.Redirect("../message.aspx?msg=" + ex.ToString().Replace("\r\n", ""));
        }
    }
    private void LoadUltraMenuItems(Item mi, int NhomSanPhamID,Boolean bl)
    {
        NhomSanPhamCuaHang nsp = new NhomSanPhamCuaHang();
        DataSet ds = nsp.SelectByCuaHangIDAndNhomChaID(CuaHangID, NhomSanPhamID);

        foreach (DataRow dr in ds.Tables[0].Rows)
        {
            Item mni = new Item();
            mni.Text = dr["TenNhomSanPham"].ToString().Length > 30
                           ? dr["TenNhomSanPham"].ToString().Substring(0, 30) + "..."
                           : dr["TenNhomSanPham"].ToString();
            mni.Tag = dr["NhomSanPhamCuaHangID"].ToString();
            //mni.ToolTip = dr["TenNhomSanPham"].ToString();

            LoadUltraMenuItems(mni, int.Parse(dr["NhomSanPhamCuaHangID"].ToString()),true);
            if (bl)
            {
                if (LoaiGianHangID == LoaiGianHang)
                {
                    mni.TargetUrl = "Newestore.aspx?sid=" + CuaHangID + "&cid=" + dr["NhomSanPhamID"];
                }
                else
                {
                    mni.TargetUrl = "estore.aspx?sid=" + CuaHangID + "&cid=" + dr["NhomSanPhamID"];
                }
            }
            else
            {
                if (LoaiGianHangID == LoaiGianHang)
                {
                    mni.TargetUrl = "Newestore.aspx?sid=" + CuaHangID + "&cid=" + dr["NhomSanPhamCuahangID"];
                }
                else
                {
                    mni.TargetUrl = "estore.aspx?sid=" + CuaHangID + "&cid=" + dr["NhomSanPhamCuahangID"];
                }

            }
            mi.Items.Add(mni);
        }
    }
Example #3
0
    private void LoadDanhMucCon(int NhomChaID, int CuaHangID, int loaddm)
    {
        loaddm++;
        try
        {
            NhomSanPhamCuaHang nhomsanpham = new NhomSanPhamCuaHang();
            DataSet ds = nhomsanpham.SelectByCuaHangIDAndNhomChaID(CuaHangID, NhomChaID);
            ds.Tables[0].DefaultView.Sort = "SapXep ASC";

            if (ds.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    //if (dr["NhomChaID"].ToString() == "" || dr["NhomChaID"].ToString() == "0")
                    //{
                    HtmlTableRow tbr = new HtmlTableRow();
                    tbr.Style.Add("padding-left", (loaddm*10) + "px");
                    HtmlTableCell tbc1 = new HtmlTableCell();
                    HtmlTableCell tbc2 = new HtmlTableCell();
                    //image cells
                    HtmlTableCell tbc3 = new HtmlTableCell();
                    HtmlTableCell tbc4 = new HtmlTableCell();
                    HtmlTableCell tbc5 = new HtmlTableCell();

                    //tbc1.Style.Add("width", "3%");
                    tbc2.InnerText = dr["SapXep"] + "." + dr["TenNhomSanPham"];
                    tbc2.ColSpan = 2;

                    tbc4.Style.Add("width", "16px");
                    tbc5.Style.Add("width", "16px");

                    tbc4.Style.Add("padding", "0");
                    tbc4.Style.Add("margin", "0");
                    tbc4.Style.Add("cursor", "hand");
                    tbc5.Style.Add("padding", "0");
                    tbc5.Style.Add("margin", "0");
                    tbc5.Style.Add("cursor", "hand");

                    HtmlImage img2 = new HtmlImage();
                    HtmlImage img3 = new HtmlImage();

                    img2.Src = "../images/delete.gif";
                    img3.Src = "../images/add.gif";
                    img2.Alt = "Xóa danh mục cha";
                    img3.Alt = "Thêm danh mục con";
                    tbc3.Style.Add("width", "16px");
                    tbc3.Style.Add("padding", "0");
                    tbc3.Style.Add("margin", "0");
                    tbc3.Style.Add("cursor", "hand");
                    HtmlImage img1 = new HtmlImage();
                    img1.Src = "../images/edit.gif";
                    img1.Alt = "Sửa danh mục";

                    if (loaddm < 3)
                    {
                        img1.Attributes.Add("onclick", "Edit(" + dr["NhomSanPhamCuaHangID"] + "," + CuaHangID + ");");
                        img3.Attributes.Add("onclick", "AddSub(" + dr["NhomSanPhamCuaHangID"] + "," + CuaHangID + ",'" +
                                                   dr["TenNhomSanPham"] + "');");
                    }
                    else if (loaddm==3)
                    {
                        img1.Attributes.Add("onclick", "EditSub(" + dr["NhomSanPhamCuaHangID"] + ",'" +
                            dr["TenNhomSanPham"] + "'," + CuaHangID + ");");
                    }
                    tbc3.Controls.Add(img1);
                    img2.Attributes.Add("onclick", "Delete(" + dr["NhomSanPhamCuaHangID"] + ");");

                    tbc4.Controls.Add(img2);
                    if (loaddm<3)
                    tbc5.Controls.Add(img3);

                    tbr.Cells.Add(tbc1);
                    tbr.Cells.Add(tbc2);
                    tbr.Cells.Add(tbc3);
                    tbr.Cells.Add(tbc4);
                    tbr.Cells.Add(tbc5);
                    tblDanhMuc.Rows.Add(tbr);
                    //if (dr["NhomSanPhamID"].ToString()!="0")
                    LoadDanhMucCon(int.Parse(dr["NhomSanPhamCuaHangID"].ToString()), CuaHangID, loaddm);
                    // }
                }
            }
            //            tblDanhMuc.Controls.Add(tbl);
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }
    }