コード例 #1
0
ファイル: DbHelperHR.cs プロジェクト: pcstx/OA
 public string UpDateFolderPermissionBySysRole(DocSysRoleRight _DocSysRoleRight)
 {
     DbParameter[] pramsUpDate = {
                                 MakeInParam("@SysRoleID",(DbType)SqlDbType.Int,4,_DocSysRoleRight.SysRoldID),
                                  MakeInParam("@FolderID",(DbType)SqlDbType.Int,4,_DocSysRoleRight.FolderID),
                                    MakeInParam("@Permission",(DbType)SqlDbType.VarChar,50,_DocSysRoleRight.Permission),
                 };
     StringBuilder sb = new StringBuilder();
     sb.Append("UpDate [dbo].[Doc_SysRoleRight]");
     sb.Append(" set ");
     sb.Append(" [SysRoleID]=@SysRoleID,");
     sb.Append(" [FolderID]=@FolderID,");
     sb.Append(" [Permission]=@Permission");
     sb.Append(" where [SysRoleID]=@SysRoleID  and [FolderID]=@FolderID");
     sb.Append(" select @SysRoleID ");
     return ExecuteScalar(CommandType.Text, sb.ToString(), pramsUpDate).ToString();
 }
コード例 #2
0
ファイル: SetFilePermissions.aspx.cs プロジェクト: pcstx/OA
        protected void SaveRight(object sender, EventArgs e)
        {
            string result = "-1";
            string Permission = "";
            string SelectVaue = ListChoice.SelectedValue;
            string AllPermission = "";
            if (ckRead.Checked)
            {
                Permission = "1";  //可读
                AllPermission = AllPermission + Permission + ",";
            }
            if (ckWrite.Checked)
            {
                Permission = "2";  //可写
                AllPermission = AllPermission  + Permission + ",";

            }
            if (ckDelete.Checked)
            {
                Permission = "3";  //可删除
                AllPermission = AllPermission + Permission + ",";
            }

            if (ckCancel.Checked)  // 可作废
            {
                Permission = "4";
                AllPermission = AllPermission  + Permission + ",";
            }

            if (SelectVaue == "1")
            {
                DocUserRight _docUser = new DocUserRight();
                _docUser.UserID = Int32.Parse(MyList.SelectedValue);
                _docUser.FolderID = FolderId;
                _docUser.Permission = AllPermission;
                if (DbHelper.GetInstance().GetFolderPermissFromID(Int32.Parse(MyList.SelectedValue), FolderId).Rows.Count > 0)
                    result = DbHelper.GetInstance().UpDateFolderPermission(_docUser);
                else
                    result = DbHelper.GetInstance().AddNewsFolderPermission(_docUser);
            }
            else if (SelectVaue == "2")
            {
                DocDepartRight _docDepartRight = new DocDepartRight();
                _docDepartRight.DepartMentID = Int32.Parse(MyList.SelectedValue);
                _docDepartRight.FolderID = FolderId;
                _docDepartRight.Permission = AllPermission;
                if (DbHelper.GetInstance().GetFolderPermissFromDepart(Int32.Parse(MyList.SelectedValue), FolderId).Rows.Count > 0)
                    result = DbHelper.GetInstance().UpDateFolderPermissionByDepart(_docDepartRight);
                else
                    result = DbHelper.GetInstance().AddNewFolderPermissionByDepart(_docDepartRight);

            }
            else if (SelectVaue == "3")
            {
                DocSysRoleRight _docSysRoleRight = new DocSysRoleRight();
                _docSysRoleRight.SysRoldID = Int32.Parse(MyList.SelectedValue);
                _docSysRoleRight.FolderID = FolderId;
                _docSysRoleRight.Permission = AllPermission;
                if (DbHelper.GetInstance().GetFolderPermissFromSysRole(Int32.Parse(MyList.SelectedValue), FolderId).Rows.Count > 0)
                    result = DbHelper.GetInstance().UpDateFolderPermissionBySysRole(_docSysRoleRight);
                else
                    result = DbHelper.GetInstance().AddNewFolderPermissionBySysRole(_docSysRoleRight);

            }

             if (result != "-1")
             {
             lblMsg.Text = "数据保存成功";
             lblMsg.ForeColor = System.Drawing.Color.Blue;
             }
             else
             {
             lblMsg.Text = "数据保存失败";
             lblMsg.ForeColor = System.Drawing.Color.Red;
             }
        }
コード例 #3
0
ファイル: DbHelperHR.cs プロジェクト: pcstx/OA
        public string AddNewFolderPermissionBySysRole(DocSysRoleRight _DocSysRoleRight)
        {
            DbParameter[] pramsInsert = {

                                       MakeInParam("@SysRoleID",(DbType)SqlDbType.Int,4,_DocSysRoleRight.SysRoldID),
                                         MakeInParam("@FolderID",(DbType)SqlDbType.Int,4,_DocSysRoleRight.FolderID),
                                           MakeInParam("@Permission",(DbType)SqlDbType.VarChar,50,_DocSysRoleRight.Permission),
                                             };
            StringBuilder sb = new StringBuilder();
            sb.Append("INSERT INTO [dbo].[Doc_SysRoleRight]");
            sb.Append("([SysRoleID]");
            sb.Append(",[FolderID]");
            sb.Append(",[Permission]");
            sb.Append(")");
            sb.Append("VALUES");
            sb.Append("(@SysRoleID");
            sb.Append(",@FolderID");
            sb.Append(",@Permission");
            sb.Append(")");
            sb.Append(" select @@identity;");

            return ExecuteScalar(CommandType.Text, sb.ToString(), pramsInsert).ToString();
        }