Esempio n. 1
0
        protected void ZButton1_OnClick(object sender, EventArgs e)
        {
            mycms_class mc = new mycms_class();

            mc.Id          = mcm.GetMaxID() + 1;
            mc.ClassName   = PubCom.CheckString(txtClassName.Text.Trim());
            mc.ParentId    = int.Parse(PubCom.CheckString(txtParentClassID.Text.Trim()));
            mc.SortRank    = int.Parse(PubCom.CheckString(txtClassSort.Text.Trim()));
            mc.IsOnNav     = CheckboxNav.Checked;
            mc.IsOnIndex   = CheckboxIndex.Checked;
            mc.IsForbidden = CheckIsforbidden.Checked;
            if (mcm.Insert(mc) != 1)
            {
                Message.ShowWrong(this, "添加栏目失败");
                return;
            }

            else
            {
                string sPath = Server.MapPath(@"~/") + "Html\\" + mc.Id;
                if (!Directory.Exists(sPath))
                {
                    Directory.CreateDirectory(sPath);
                }
                Message.ShowOK(this, "添加栏目成功");
                BindClass();
            }
        }
Esempio n. 2
0
 protected void rpmenu_OnItemCommand(object source, RepeaterCommandEventArgs e)
 {
     if (e.CommandName == "bj")
     {
         _id = int.Parse(e.CommandArgument.ToString()); //获取命令ID号
     }
     else if (e.CommandName == "qx")
     {
         _id = -1;
     }
     else if (e.CommandName == "sc")
     {
         _id = int.Parse(e.CommandArgument.ToString()); //获取命令ID号
         //这里是删除方法
         Query qm = Query.Build(new { SortFields = "ParentId,SortRank" });
         qm.Add("IsForbidden", 0);
         qm.Append("ParentId=" + _id);
         if (mcm.GetClassList(qm).Count != 0)
         {
             Message.ShowWrong(this, "请删除子栏目");
             return;
         }
         if (mcm.Delete(new mycms_class()
         {
             Id = _id
         }) != 1)
         {
             Message.ShowWrong(this, "删除失败");
             return;
         }
         else
         {
             string        sPath = Server.MapPath(@"~/") + "Html\\" + _id;
             DirectoryInfo di    = new DirectoryInfo(sPath);
             di.Delete(true);
             Message.ShowOK(this, "删除栏目成功");
         }
     }
     else if (e.CommandName == "qd")
     {
         mycms_class mc = new mycms_class();
         mc.Id          = int.Parse(((ZLinkButton)e.Item.FindControl("zlsc")).CommandArgument);
         mc.ClassName   = ((TextBox)e.Item.FindControl("TextBox1")).Text.Trim();
         mc.ParentId    = int.Parse(((TextBox)e.Item.FindControl("TextBox2")).Text.Trim());
         mc.SortRank    = int.Parse(((TextBox)e.Item.FindControl("TextBox3")).Text.Trim());
         mc.IsOnNav     = ((CheckBox)e.Item.FindControl("CheckBox1")).Checked;
         mc.IsOnIndex   = ((CheckBox)e.Item.FindControl("CheckBox2")).Checked;
         mc.IsForbidden = ((CheckBox)e.Item.FindControl("CheckBox3")).Checked;
         UpdateClass(mc);
     }
     BindClass();
 }
Esempio n. 3
0
 private void UpdateClass(mycms_class mc)
 {
     mcm.Update(mc);
     Message.ShowOK(this, "更新栏目成功");
 }