Ejemplo n.º 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);
        }
Ejemplo n.º 2
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;
        }
Ejemplo n.º 3
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);
        }