Esempio n. 1
0
        /// <summary>
        /// 验证用户是否有权限进行操作
        /// </summary>
        /// <param name="account">用户账号</param>
        /// <param name="token">用户所在组织</param>
        /// <param name="projectId">项目标示</param>
        /// <param name="operate">操作标示,0为查看,1为编辑,2为删除</param>
        /// <param name="recursion">验证用户项目是否需要递归操作,默认为1需要递归,0时不需要递归</param>
        /// <returns></returns>
        public bool IsAuthProject(string account, string token, int projectId, int operate, int recursion = 1)
        {
            bool bRet = false;

            if (IsAdmin(account, token))
            {
                bRet = true;
                return(bRet);
            }
            //获取最高一层项目编号(只验证最高一层权限)
            if (recursion == 1)
            {
                projectId = new ProjectService().GetRootId(projectId);
            }
            List <RoleProjectModel> lrm = ur.Find(account).UserRole.Role.RoleProject.ToList();

            if (lrm.Count() <= 0)
            {
                return(bRet);
            }
            if (operate == 0)
            {
                bRet = true;
                return(bRet);
            }
            else
            {
                RoleProjectModel rmm = lrm.Find(a => a.ProjectId == projectId && a.TypeId >= (RoleProject)operate);
                if (rmm != null)
                {
                    bRet = true;
                }
            }
            return(bRet);
        }
Esempio n. 2
0
        public RoleProjectModel GetModel(int RoleProjectID)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("select  top 1  ");
            builder.Append(" RoleProjectID,RoleID,UserCode,ProjectCodes ");
            builder.Append(" from WF_RoleProject ");
            builder.Append(" where RoleProjectID=" + RoleProjectID + " ");
            RoleProjectModel model = new RoleProjectModel();
            DataSet          set   = publicDbOpClass.DataSetQuary(builder.ToString());

            if (set.Tables[0].Rows.Count <= 0)
            {
                return(null);
            }
            if (set.Tables[0].Rows[0]["RoleProjectID"].ToString() != "")
            {
                model.RoleProjectID = int.Parse(set.Tables[0].Rows[0]["RoleProjectID"].ToString());
            }
            if (set.Tables[0].Rows[0]["RoleID"].ToString() != "")
            {
                model.RoleID = new int?(int.Parse(set.Tables[0].Rows[0]["RoleID"].ToString()));
            }
            model.UserCode     = set.Tables[0].Rows[0]["UserCode"].ToString();
            model.ProjectCodes = set.Tables[0].Rows[0]["ProjectCodes"].ToString();
            return(model);
        }
Esempio n. 3
0
 public void Remove(RoleProjectModel entity)
 {
     using (var db = new HXContext())
     {
         db.Entry <RoleProjectModel>(entity).State = System.Data.Entity.EntityState.Deleted;
         db.SaveChanges();
     }
 }
Esempio n. 4
0
 public void Add(RoleProjectModel entity)
 {
     using (var db = new HXContext())
     {
         db.RoleProject.Add(entity);
         db.SaveChanges();
     }
 }
Esempio n. 5
0
        public int Update(RoleProjectModel model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("update WF_RoleProject set ");
            builder.Append("RoleID=" + model.RoleID + ",");
            builder.Append("UserCode='" + model.UserCode + "',");
            builder.Append("ProjectCodes='" + model.ProjectCodes + "'");
            builder.Append(" where RoleProjectID=" + model.RoleProjectID + " ");
            return(publicDbOpClass.ExecSqlString(builder.ToString()));
        }
Esempio n. 6
0
    protected void GetPageData()
    {
        RoleProjectModel model        = this.rpa.GetModel(this.rid);
        userManageDb     userManageDb = new userManageDb();

        this.txtUserName.Text     = userManageDb.GetUserName(model.UserCode);
        this.hdnUserCode.Value    = model.UserCode;
        this.hdnProjectCode.Value = model.ProjectCodes;
        SqlDataSource expr_57 = this.SqlProjectList;

        expr_57.SelectCommand = expr_57.SelectCommand + " WHERE ([i_xh] in ( " + this.hdnProjectCode.Value + "))";
        this.GVProjectList.DataBind();
    }
Esempio n. 7
0
        public int Add(RoleProjectModel model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("insert into WF_RoleProject(");
            builder.Append("RoleID,UserCode,ProjectCodes");
            builder.Append(")");
            builder.Append(" values (");
            builder.Append(model.RoleID + ",");
            builder.Append("'" + model.UserCode + "',");
            builder.Append("'" + model.ProjectCodes + "'");
            builder.Append(")");
            builder.Append(";select @@IDENTITY");
            return(publicDbOpClass.ExecSqlString(builder.ToString()));
        }
Esempio n. 8
0
    protected void BtnSave_Click(object sender, System.EventArgs e)
    {
        RoleProjectModel roleProjectModel = this.getRoleProjectModel();

        if (!(roleProjectModel.ProjectCodes.ToString().Trim() != "") || !(roleProjectModel.UserCode.ToString().Trim() != ""))
        {
            base.RegisterScript(" top.ui.alert('没有选择人员或所负责的项目为空'); \n");
            return;
        }
        if (this.Type == "Add")
        {
            if (!(this.hdnProjectCode.Value != "123456789"))
            {
                base.RegisterScript(" top.ui.alert('请选择所关联的项目,关联项目不能为空'); \n");
                return;
            }
            if (this.rpa.Add(this.getRoleProjectModel()) == 1)
            {
                base.RegisterScript("top.ui.tabSuccess({ parentName: '_roleprojectlist'} );");
                return;
            }
            base.RegisterScript("top.ui.tabError();");
            return;
        }
        else
        {
            if (!(this.hdnProjectCode.Value != "123456789"))
            {
                base.RegisterScript(" top.ui.alert('请选择所关联的项目,关联项目不能为空'); \n");
                return;
            }
            if (this.rpa.Update(this.getRoleProjectModel()) == 1)
            {
                base.RegisterScript("top.ui.tabSuccess({ parentName: '_roleprojectlist'} );");
                return;
            }
            base.RegisterScript("top.ui.tabError();");
            return;
        }
    }