Пример #1
0
    public string CariSubMenu(int IDPenggunaGrup, TBMenubar MenuBar, int width)
    {
        string SubMenu = string.Empty;

        foreach (var item in MenuBar.TBMenubars.OrderBy(item => item.Urutan))
        {
            if (item.TBMenubars.Count == 0)
            {
                if (item.TBMenubarPenggunaGrups.FirstOrDefault(item2 => item2.IDGrupPengguna == IDPenggunaGrup) != null)
                {
                    SubMenu += @"
                            <li class='nav-item'>
                                <a class='nav-link nav-link-child' href='" + item.Url + @"'>
                                    <span " + (width == 0 ? "data-feather='circle'" : string.Empty) + " style='padding-left:" + width + "px;'></span>" + item.Nama + @"
                                </a>
                            </li>   
                        ";
                }
            }
            else
            {
                if (item.TBMenubarPenggunaGrups.FirstOrDefault(item2 => item2.IDGrupPengguna == IDPenggunaGrup) != null)
                {
                    SubMenu += @"
                            <li class='nav-item'>
                                <a class='nav-link nav-link-child' data-toggle='collapse' href='#collapse" + item.IDMenubar + @"'>
                                    <span " + (width == 0 ? "data-feather='circle'" : string.Empty) + " style='padding-left:" + width + "px;'></span>" + item.Nama + @"
                                </a>
                                <div class='collapse bg-gainsboro' id='collapse" + item.IDMenubar + @"'>
                                    <ul class='nav flex-column'>";

                    SubMenu += CariSubMenu(IDPenggunaGrup, item, width + 24);

                    SubMenu += @"
                                    </ul>
                                </div>
                            </li>";
                }
            }
        }

        return(SubMenu);
    }
Пример #2
0
    public TBMenubar Tambah(int IDMenubarParent, EnumMenubarModul enumMenubarModul, int Urutan, string Kode, string Nama, string Url, string Icon, int LevelMenu)
    {
        TBMenubar Menubar = new TBMenubar
        {
            //IDMenubar
            IDMenubarParent  = (IDMenubarParent == 0) ? (int?)null : IDMenubarParent,
            EnumMenubarModul = (int)enumMenubarModul,
            Urutan           = Urutan,
            Kode             = Kode,
            Nama             = Nama,
            Url       = Url,
            Icon      = Icon,
            LevelMenu = LevelMenu
        };

        db.TBMenubars.InsertOnSubmit(Menubar);

        Notifikasi(EnumAlert.success, Pengguna.IDPengguna, "Tambah Menubar " + Menubar.Nama + " berhasil");

        return(Menubar);
    }
Пример #3
0
    private void LoadRole(int idGrupPengguna)
    {
        using (DataClassesDatabaseDataContext db = new DataClassesDatabaseDataContext())
        {
            TBMenubarPenggunaGrup[] menu = db.TBMenubarPenggunaGrups.Where(item => item.IDGrupPengguna == idGrupPengguna).ToArray();

            foreach (RepeaterItem item in RepeaterMenu.Items)
            {
                Repeater    RepeaterMenuLevel2      = (Repeater)item.FindControl("RepeaterMenuLevel2");
                CheckBox    CheckBoxPilihLevel1     = (CheckBox)item.FindControl("CheckBoxPilih");
                HiddenField HiddenFieldIDMenuLevel1 = (HiddenField)item.FindControl("HiddenFieldIDMenu");

                TBMenubar menuLevel1 = db.TBMenubars.FirstOrDefault(lebel1 => lebel1.IDMenubar == HiddenFieldIDMenuLevel1.Value.ToInt());

                if (menuLevel1.TBMenubars.Count > 0)
                {
                    foreach (RepeaterItem item2 in RepeaterMenuLevel2.Items)
                    {
                        Repeater    RepeaterMenuLevel3      = (Repeater)item2.FindControl("RepeaterMenuLevel3");
                        CheckBox    CheckBoxPilihLevel2     = (CheckBox)item2.FindControl("CheckBoxPilih");
                        HiddenField HiddenFieldIDMenuLevel2 = (HiddenField)item2.FindControl("HiddenFieldIDMenu");

                        TBMenubar menuLevel2 = db.TBMenubars.FirstOrDefault(lebel1 => lebel1.IDMenubar == HiddenFieldIDMenuLevel2.Value.ToInt());

                        if (menuLevel2.TBMenubars.Count > 0)
                        {
                            foreach (RepeaterItem item3 in RepeaterMenuLevel3.Items)
                            {
                                CheckBox    CheckBoxPilihLevel3     = (CheckBox)item3.FindControl("CheckBoxPilih");
                                HiddenField HiddenFieldIDMenuLevel3 = (HiddenField)item3.FindControl("HiddenFieldIDMenu");

                                TBMenubarPenggunaGrup cariMenuLevel3 = menu.FirstOrDefault(level3 => level3.IDMenubar == HiddenFieldIDMenuLevel3.Value.ToInt());
                                if (cariMenuLevel3 != null)
                                {
                                    CheckBoxPilihLevel3.Checked = true;
                                }
                                else
                                {
                                    CheckBoxPilihLevel3.Checked = false;
                                }
                            }
                        }
                        else
                        {
                            TBMenubarPenggunaGrup cariMenuLevel2 = menu.FirstOrDefault(level2 => level2.IDMenubar == HiddenFieldIDMenuLevel2.Value.ToInt());
                            if (cariMenuLevel2 != null)
                            {
                                CheckBoxPilihLevel2.Checked = true;
                            }
                            else
                            {
                                CheckBoxPilihLevel2.Checked = false;
                            }
                        }
                    }
                }
                else
                {
                    TBMenubarPenggunaGrup cariMenuLevel1 = menu.FirstOrDefault(level1 => level1.IDMenubar == HiddenFieldIDMenuLevel1.Value.ToInt());
                    if (cariMenuLevel1 != null)
                    {
                        CheckBoxPilihLevel1.Checked = true;
                    }
                    else
                    {
                        CheckBoxPilihLevel1.Checked = false;
                    }
                }
            }
        }
    }
Пример #4
0
    protected void ButtonSimpan_Click(object sender, EventArgs e)
    {
        using (DataClassesDatabaseDataContext db = new DataClassesDatabaseDataContext())
        {
            db.TBMenubarPenggunaGrups.DeleteAllOnSubmit(db.TBMenubarPenggunaGrups.Where(item => item.IDGrupPengguna == DropDownListGrupPengguna.SelectedValue.ToInt()));
            db.SubmitChanges();

            int subMenu1;
            int subMenu2;

            foreach (RepeaterItem item in RepeaterMenu.Items)
            {
                subMenu1 = 0;
                Repeater    RepeaterMenuLevel2      = (Repeater)item.FindControl("RepeaterMenuLevel2");
                CheckBox    CheckBoxPilihLevel1     = (CheckBox)item.FindControl("CheckBoxPilih");
                HiddenField HiddenFieldIDMenuLevel1 = (HiddenField)item.FindControl("HiddenFieldIDMenu");

                TBMenubar menuLevel1 = db.TBMenubars.FirstOrDefault(lebel1 => lebel1.IDMenubar == HiddenFieldIDMenuLevel1.Value.ToInt());

                if (menuLevel1.TBMenubars.Count > 0)
                {
                    foreach (RepeaterItem item2 in RepeaterMenuLevel2.Items)
                    {
                        subMenu2 = 0;
                        Repeater    RepeaterMenuLevel3      = (Repeater)item2.FindControl("RepeaterMenuLevel3");
                        CheckBox    CheckBoxPilihLevel2     = (CheckBox)item2.FindControl("CheckBoxPilih");
                        HiddenField HiddenFieldIDMenuLevel2 = (HiddenField)item2.FindControl("HiddenFieldIDMenu");

                        TBMenubar menuLevel2 = db.TBMenubars.FirstOrDefault(lebel1 => lebel1.IDMenubar == HiddenFieldIDMenuLevel2.Value.ToInt());

                        if (menuLevel2.TBMenubars.Count > 0)
                        {
                            foreach (RepeaterItem item3 in RepeaterMenuLevel3.Items)
                            {
                                CheckBox    CheckBoxPilihLevel3     = (CheckBox)item3.FindControl("CheckBoxPilih");
                                HiddenField HiddenFieldIDMenuLevel3 = (HiddenField)item3.FindControl("HiddenFieldIDMenu");

                                TBMenubar menuLevel3 = db.TBMenubars.FirstOrDefault(lebel1 => lebel1.IDMenubar == HiddenFieldIDMenuLevel3.Value.ToInt());

                                if (CheckBoxPilihLevel3.Checked == true)
                                {
                                    db.TBMenubarPenggunaGrups.InsertOnSubmit(new TBMenubarPenggunaGrup()
                                    {
                                        TBMenubar = menuLevel3, IDGrupPengguna = DropDownListGrupPengguna.SelectedValue.ToInt()
                                    });
                                    subMenu2++;
                                }
                            }
                        }
                        else
                        {
                            if (CheckBoxPilihLevel2.Checked == true)
                            {
                                db.TBMenubarPenggunaGrups.InsertOnSubmit(new TBMenubarPenggunaGrup()
                                {
                                    TBMenubar = menuLevel2, IDGrupPengguna = DropDownListGrupPengguna.SelectedValue.ToInt()
                                });
                                subMenu1++;
                            }
                        }

                        if (subMenu2 > 0)
                        {
                            db.TBMenubarPenggunaGrups.InsertOnSubmit(new TBMenubarPenggunaGrup()
                            {
                                TBMenubar = menuLevel2, IDGrupPengguna = DropDownListGrupPengguna.SelectedValue.ToInt()
                            });
                            subMenu1++;
                        }
                    }
                }
                else
                {
                    if (CheckBoxPilihLevel1.Checked == true)
                    {
                        db.TBMenubarPenggunaGrups.InsertOnSubmit(new TBMenubarPenggunaGrup()
                        {
                            TBMenubar = menuLevel1, IDGrupPengguna = DropDownListGrupPengguna.SelectedValue.ToInt()
                        });
                    }
                }

                if (subMenu1 > 0)
                {
                    db.TBMenubarPenggunaGrups.InsertOnSubmit(new TBMenubarPenggunaGrup()
                    {
                        TBMenubar = menuLevel1, IDGrupPengguna = DropDownListGrupPengguna.SelectedValue.ToInt()
                    });
                }
            }

            db.SubmitChanges();
        }

        LoadRole(DropDownListGrupPengguna.SelectedValue.ToInt());
    }