Esempio n. 1
0
        /// <summary>
        /// 添加与编辑Position记录
        /// </summary>
        /// <param name="page">当前页面指针</param>
        /// <param name="model">Position表实体</param>
        /// <param name="content">更新说明</param>
        /// <param name="isCache">是否更新缓存</param>
        /// <param name="isAddUseLog">是否添加用户操作日志</param>
        public void Save(Page page, Position model, string content = null, bool isCache = true, bool isAddUseLog = true)
        {
            try {
                //保存
                model.Save();

                //判断是否启用缓存
                if (CommonBll.IsUseCache() && isCache)
                {
                    SetModelForCache(model);
                }

                if (isAddUseLog)
                {
                    if (string.IsNullOrEmpty(content))
                    {
                        content = "{0}" + (model.Id == 0 ? "添加" : "编辑") + "Position记录成功,ID为【" + model.Id + "】";
                    }

                    //添加用户访问记录
                    UseLogBll.GetInstence().Save(page, content);
                }
            }
            catch (Exception e) {
                var result = "执行PositionBll.Save()函数出错!";

                //出现异常,保存出错日志信息
                CommonBll.WriteLog(result, e);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 数据保存
        /// </summary>
        /// <returns></returns>
        public override string Save()
        {
            string result = string.Empty;
            var branchId = ConvertHelper.Cint0(hidBranchId.Text);
            var positionId = ConvertHelper.Cint0(hidPositionId.Text);
            try
            {
                #region 数据验证

                if (branchId == 0)
                {
                    return "非法路径进入!";
                }

                if (string.IsNullOrEmpty(txtName.Text.Trim()))
                {
                    return txtName.Label + "不能为空!";
                }
                //同一个部门里职位不能样同,不同部门可以有同名称的职位
                var sName = StringHelper.Left(txtName.Text, 30);
                if (PositionBll.GetInstence().Exist(x => x.Branch_Id == branchId && x.Name == sName && x.Id != positionId))
                {
                    return txtName.Label + "已存在!请重新输入!";
                }
                #endregion

                #region 赋值
                //定义是否更新其他关联表变量
                bool isUpdate = false;

                //获取实体
                var model = new Position(x => x.Id == positionId);

                //判断是否有改变名称
                if (positionId > 0 && sName != model.Name)
                {
                    isUpdate = true;
                }

                //修改时间与管理员
                model.UpdateDate = DateTime.Now;
                model.Manager_Id = OnlineUsersBll.GetInstence().GetManagerId();
                model.Manager_CName = OnlineUsersBll.GetInstence().GetManagerCName();

                //设置名称
                model.Name = sName;

                //设置部门
                var branchModel = BranchBll.GetInstence().GetModelForCache(branchId);
                model.Branch_Id = branchId;
                model.Branch_Name = branchModel.Name;
                model.Branch_Code = branchModel.Code;

                //设置职位权限
                //从树列表中获取勾选的节点
                GetCheckTreeNode(MenuTree.Nodes);
                //赋予权限
                model.PagePower = StringHelper.FilterSql(_hidPositionPagePower);
                model.ControlPower = StringHelper.FilterSql(_hidPositionControlPower);

                #endregion

                //----------------------------------------------------------
                //存储到数据库
                PositionBll.GetInstence().Save(this, model);

                //如果本次修改改变了相关名称,则同步更新其他关联表的对应名称
                if (isUpdate)
                {
                    ManagerBll.GetInstence().UpdatePositionName(model.Id, model.Name);
                }
            }
            catch (Exception e)
            {
                result = "保存失败!";

                //出现异常,保存出错日志信息
                CommonBll.WriteLog(result, e);
            }

            return result;
        }
Esempio n. 3
0
        /// <summary>
        /// 将Position记录实体(SubSonic实体)转换为普通的实体(DataAccess.Model.Position)
        /// </summary>
        /// <param name="model">SubSonic插件生成的实体</param>
        /// <returns>DataAccess.Model.Position</returns>
        public DataAccess.Model.Position Transform(Position model)
        {
            if (model == null)
                return null;

            return new DataAccess.Model.Position
            {
                Id = model.Id,
                Name = model.Name,
                Branch_Id = model.Branch_Id,
                Branch_Code = model.Branch_Code,
                Branch_Name = model.Branch_Name,
                PagePower = model.PagePower,
                ControlPower = model.ControlPower,
                IsSetBranchPower = model.IsSetBranchPower,
                SetBranchCode = model.SetBranchCode,
                Manager_Id = model.Manager_Id,
                Manager_CName = model.Manager_CName,
                UpdateDate = model.UpdateDate,
            };
        }
Esempio n. 4
0
 /// <summary>
 /// 更新IIS缓存中指定Id记录
 /// </summary>
 /// <param name="model">记录实体</param>
 public void SetModelForCache(Position model)
 {
     SetModelForCache(Transform(model));
 }
Esempio n. 5
0
 public static void Setup(int testItems)
 {
     SetTestRepo();
     for(int i=0;i<testItems;i++){
         Position item=new Position();
         _testRepo._items.Add(item);
     }
 }
Esempio n. 6
0
 public static void Setup(Position item)
 {
     SetTestRepo();
     _testRepo._items.Add(item);
 }
        //#region 页面控件绑定
        ///// <summary>下拉列表改变事件
        ///// </summary>
        ///// <param name="sender"></param>
        ///// <param name="e"></param>
        //protected void ddlParentId_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //    //初始化路径值

        //    //获取当前节点的父节点Id
        //   // txtParent.Text = ddlParentId.SelectedValue;
        //    if (!ddlParentId.SelectedValue.Equals("0"))
        //    {
        //        try
        //        {
        //            //获取当前节点的父节点url
        //            txtUrl.Text = MenuInfoBll.GetInstence().GetFieldValue(ConvertHelper.Cint0(ddlParentId.SelectedValue), MenuInfoTable.Url) + "";
        //        }
        //        catch
        //        {
        //        }
        //    }
        //}
        //#endregion

        #region 保存
        /// <summary>
        /// 数据保存
        /// </summary>
        /// <returns></returns>
        public override string Save()
        {
            string result = string.Empty;
            int    id     = ConvertHelper.Cint0(hidId.Text);

            //  int Branch_Id = int.Parse(ddlParentId.SelectedValue);

            try
            {
                #region 数据验证

                if (string.IsNullOrEmpty(txtPosition.Text.Trim()))
                {
                    return(txtPosition.Label + "不能为空!");
                }

                if (txtPosition.Text.Trim() == "请选择菜单")
                {
                    return(txtPosition.Label + "不能为请选择菜单!");
                }


                #endregion

                #region 赋值
                //读取指定部门资料
                var model = new Solution.DataAccess.DataModel.Position(x => x.Id == id);

                //设置名称
                model.Name = txtPosition.Text;
                //连接地址
                model.Branch_Id   = 100;    // int.Parse(ddlParentId.SelectedValue);
                model.Branch_Code = "0100"; // +ddlParentId.SelectedValue;
                model.Branch_Name = "";     //ddlParentId.SelectedText;


                ////设定当前的深度与设定当前的层数级
                //if (model.ParentId == 0)
                //{
                //    //设定当前的层数级
                //    model.Depth = 0;
                //}
                //else
                //{
                //    try
                //    {
                //        //设定当前的层数级
                //        model.Depth = ConvertHelper.Cint0(MenuInfoBll.GetInstence().GetFieldValue(ConvertHelper.Cint0(ddlParentId.SelectedValue), MenuInfoTable.Depth)) + 1;
                //    }
                //    catch
                //    {
                //        model.Depth = 0;
                //    }
                //}

                ////设置排序
                //if (txtSort.Text == "0")
                //{
                //    //model.Sort = ConvertHelper.Cint0(SPs.P_All_GetOrderId(MenuInfoTable.TableName, MenuInfoTable.ParentId, model.ParentId.ToString(), MenuInfoTable.Sort).ExecuteScalar()) + 1;
                //}
                //else
                //{
                //    model.Sort = ConvertHelper.Cint0(txtSort.Text);
                //}
                ////设定当前项属于菜单还是页面
                //model.IsMenu = ConvertHelper.StringToByte(rblIsMenu.SelectedValue);
                ////设定当前项是否显示
                //model.IsDisplay = ConvertHelper.StringToByte(rblIsDisplay.SelectedValue);
                #endregion

                //----------------------------------------------------------
                //存储到数据库
                PositionBll.GetInstence().Save(this, model);
            }
            catch (Exception e)
            {
                result = "保存失败!";

                //出现异常,保存出错日志信息
                CommonBll.WriteLog(result, e);
            }

            return(result);
        }