Exemplo n.º 1
0
        protected void rptData_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            try
            {
                PageInfo objData = new PageInfo();
                string   strCA   = e.CommandArgument.ToString();
                string   strId   = ((HiddenField)e.Item.FindControl("hdId")).Value;
                objData.Id = int.Parse(strId);
                switch (e.CommandName)
                {
                case "AddSub":
                    Response.Redirect("PageAdd.aspx?Level=" + strCA, false);
                    break;

                case "Edit":
                    if (strCA.Length > 5)
                    {
                        strCA = strCA.Substring(0, strCA.Length - 5);
                    }
                    else
                    {
                        strCA = "";
                    }
                    Response.Redirect("PageAdd.aspx?Id=" + strId + "&Level=" + strCA, false);
                    break;

                case "Active":
                    string strA   = "";
                    string active = e.CommandArgument.ToString();
                    strA           = active == "1" ? "0" : "1";
                    objData.Id     = int.Parse(strId);
                    objData.Active = int.Parse(strA);
                    objData.UpdateActive();
                    BinData();
                    break;

                case "Delete":
                    objData.Delete(strId);
                    BinData();
                    break;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 2
0
 private void DeleteItem()
 {
     if (nItemId > -1)
     {
         MapItem m = sm.All[nItemId];
         m.Remove();
         if (m._type == MapItemType.Page)
         {
             PageInfo.Delete(sPagePath);
         }
     }
     else if (nItemId == -1)
     {
         sm.Remove();
     }
     sm.Save();
 }
Exemplo n.º 3
0
 protected void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         foreach (RepeaterItem item in rptData.Items)
         {
             if (item.ItemType == ListItemType.AlternatingItem | item.ItemType == ListItemType.Item)
             {
                 if (((HtmlInputCheckBox)item.FindControl("chkItem")).Checked)
                 {
                     string   strId   = ((HiddenField)item.FindControl("hdId")).Value;
                     PageInfo objData = new PageInfo();
                     objData.Delete(strId);
                 }
             }
         }
         BinData();
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 4
0
        private void SaveItem()
        {
            MapItem m     = sm;
            string  title = SiteMap.RemoveBadChars(rRequest[this.txtText.ClientID].ToString());
            string  url   = rRequest[this.txtUrl.ClientID].ToString();

            if (nItemId != -1)
            {
                sPagePath = rRequest[this.txtPath.ClientID].ToString().Replace("admin/", "admin1/");
                if (nItemId == -2)
                {
                    if (sPagePath != "/")
                    {
                        sPagePath = sPagePath.Trim('/');
                    }
                    if (rRequest[this.cmbType.ClientID].ToString() == "Page" && PageInfo.Exists(sPagePath))
                    {
                        return;
                    }
                    m         = new MapItem();
                    m._parent = sm;
                }
                else
                {
                    m = sm.All[nItemId];
                }
                m.SetType(rRequest[this.cmbType.ClientID].ToString());
                if (m._type == MapItemType.Page)
                {
                    PageInfo pi = new PageInfo(sPagePath);
                    if (m._path != sPagePath && m._path.Length > 0)
                    {
                        if (PageInfo.Exists(sPagePath))
                        {
                            sPagePath = m._path;
                            pi        = new PageInfo(sPagePath);
                        }
                        else
                        {
                            pi = new PageInfo(m._path);
                            PageInfo.Delete(m._path);
                        }
                    }
                    if (rRequest[this.cmbPart.ClientID].ToString() == string.Empty)
                    {
                        rRequest[this.cmbPart.ClientID] = -1;
                    }
                    title = title == string.Empty ? PageInfo.CreateName(sPagePath) : title;
                    PageInfo.SavePage(
                        sPagePath,
                        rRequest[this.txtCodeFile.ClientID].ToString(),
                        rRequest[this.cmbTemplate.ClientID].ToString(),
                        pi.Body,
                        pi.Description,
                        pi.Title.Length == 0 || pi.Title == m.Text ? title : pi.Title,
                        pi.KeyWords,
                        pi.Head,
                        pi.Header,
                        rRequest[this.chkSecure2.ClientID].ToString() == "1",
                        rRequest[this.chkDeleted.ClientID].ToString() == "1",
                        pi.Cache,
                        Convert.ToInt32(rRequest[this.cmbPart.ClientID]),
                        pi.StatusCode,
                        pi.GenerateLastModified,
                        pi.Fields);
                    if (url == string.Empty || url == null)
                    {
                        url = Path.VRoot + sPagePath + Config.Main.Extension;
                    }
                }
                m._hidden = rRequest[this.chkShow.ClientID].ToString() == "0";
                int pid   = int.Parse(rRequest[this.cmbParent.ClientID].ToString().Split('#')[0]);
                int index = int.Parse(rRequest[this.cmbIndex.ClientID].ToString());
                if (pid != m.Parent.ID || index != m.Index)
                {
                    MapItem p = pid == -1 ? sm : sm.All[pid];
                    m.Remove();
                    if (p.Items.Count > index)
                    {
                        p.Items.Insert(index, m);
                    }
                    else
                    {
                        p.Items.Add(m);
                    }
                }
            }
            m._text = title;
            m._url  = url;
            m._path = sPagePath;
            sm.Save();

            sm = new SiteMap();
            Response.Write(sm.GetItemByPath(m._path).ID);
        }