Exemple #1
0
        private bool DoAdd()
        {
            try
            {
                Model.Section model = new Model.Section();
                BLL.Section   bll   = new BLL.Section();

                model.Name     = txtName.Text.Trim();
                model.Sort     = int.Parse(txtSortId.Text.Trim());
                model.Ext1     = txtRemark.Text.Trim();
                model.ParentId = int.Parse(ddlParentId.SelectedValue);
                model.LevelNum = 1;
                if (model.ParentId != 0)
                {
                    Model.Section ParModel = bll.GetModel(model.ParentId);
                    if (ParModel != null)
                    {
                        model.LevelNum = ParModel.LevelNum + 1;
                    }
                }

                if (bll.Insert(model) > 0)
                {
                    AddAdminLog(MXEnums.ActionEnum.Add.ToString(), "添加部门信息:" + model.Name); //记录日志
                    return(true);
                }
            }
            catch
            {
                return(false);
            }
            return(false);
        }
Exemple #2
0
        private void SectionBind()
        {
            BLL.Section bll = new BLL.Section();

            List <Model.SectionView> list = bll.GetListByOrder(0);

            this.ddlSection.Items.Clear();
            this.ddlSection.Items.Add(new ListItem("请选择部门...", ""));
            foreach (var m in list)
            {
                string Id         = m.Id.ToString();
                int    ClassLayer = m.LevelNum;
                string Title      = m.Name;

                if (ClassLayer == 1)
                {
                    this.ddlSection.Items.Add(new ListItem(Title, Id));
                }
                else
                {
                    Title = "├ " + Title;
                    Title = Utils.StringOfChar(ClassLayer - 1, " ") + Title;
                    this.ddlSection.Items.Add(new ListItem(Title, Id));
                }
            }
        }
Exemple #3
0
        //数据绑定
        private void RptBind()
        {
            BLL.Section B_Sect            = new BLL.Section();
            List <Model.SectionView> list = B_Sect.GetListByOrder(0);

            rptList.DataSource = list;
            rptList.DataBind();
        }
Exemple #4
0
        private void ShowInfo(int _id)
        {
            BLL.Section   bll   = new BLL.Section();
            Model.Section model = bll.GetModel(_id);

            ddlParentId.SelectedValue = model.ParentId.ToString();
            txtSortId.Text            = model.Sort.ToString();
            txtName.Text   = model.Name;
            txtRemark.Text = model.Ext1;
        }
Exemple #5
0
 //删除导航
 protected void btnDelete_Click(object sender, EventArgs e)
 {
     ChkAdminLevel(LevelName, MXEnums.ActionEnum.Delete.ToString()); //检查权限
     BLL.Section   bll   = new BLL.Section();
     Model.Section model = new Model.Section();
     for (int i = 0; i < rptList.Items.Count; i++)
     {
         int      id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value);
         CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId");
         if (cb.Checked)
         {
             model.Id       = id;
             model.IsDelete = 1;
             bll.Update(model);
         }
     }
     AddAdminLog(MXEnums.ActionEnum.Delete.ToString(), "删除部门信息"); //记录日志
     JscriptMsg("删除数据成功!", backUrl, "Success", "parent.loadMenuTree");
 }
Exemple #6
0
 //保存排序
 protected void btnSave_Click(object sender, EventArgs e)
 {
     ChkAdminLevel(LevelName, MXEnums.ActionEnum.Edit.ToString()); //检查权限
     Model.Section model = new Model.Section();
     BLL.Section   bll   = new BLL.Section();
     for (int i = 0; i < rptList.Items.Count; i++)
     {
         int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value);
         int sortId;
         if (!int.TryParse(((TextBox)rptList.Items[i].FindControl("txtSortId")).Text.Trim(), out sortId))
         {
             sortId = 99;
         }
         model.Id   = id;
         model.Sort = sortId;
         bll.Update(model);
     }
     AddAdminLog(MXEnums.ActionEnum.Edit.ToString(), "保存区域排序"); //记录日志
     JscriptMsg("保存排序成功!", ThisUrl, "Success");
 }
Exemple #7
0
        private bool DoEdit(int _id)
        {
            try
            {
                BLL.Section   bll   = new BLL.Section();
                Model.Section model = new Model.Section();
                model.Id   = _id;
                model.Name = txtName.Text.Trim();
                model.Sort = int.Parse(txtSortId.Text.Trim());

                model.Ext1 = txtRemark.Text.Trim();

                int parentId = int.Parse(ddlParentId.SelectedValue);
                //如果选择的父ID不是自己,则更改
                if (parentId != model.Id)
                {
                    model.ParentId = parentId;
                    model.LevelNum = 1;
                    if (parentId != 0)
                    {
                        Model.Section ParModel = bll.GetModel(parentId);
                        if (ParModel != null)
                        {
                            model.LevelNum = ParModel.LevelNum + 1;
                        }
                    }
                }
                if (bll.Update(model))
                {
                    AddAdminLog(MXEnums.ActionEnum.Add.ToString(), "修改部门信息:" + model.Name); //记录日志
                    return(true);
                }
            }
            catch
            {
                return(false);
            }
            return(false);
        }