示例#1
0
        public static bool Add(Model.HelpDoc helpDocModel, List <string> lstShareDeptIdList, bool isDefault,
                               List <string> viewRoleList, List <string> editRoleList)
        {
            using (TransactionScope ts = new TransactionScope())
            {
                int           rows   = 0;
                StringBuilder strSql = new StringBuilder();
                strSql.Append("insert into helpdoc(");
                strSql.Append("docId,crdt,updt,docTypeId,docTitle,docContent,docFullText,docNum,docDeptId,docCount,crUsrId,upUsrId,docState,docAttachment)");
                strSql.Append(" values (");
                strSql.Append("@docId,@crdt,@updt,@docTypeId,@docTitle,@docContent,@docFullText,@docNum,@docDeptId,@docCount,@crUsrId,@upUsrId,@docState,@docAttachment)");

                DynamicParameters parameters = new DynamicParameters();
                parameters.Add("?docId", helpDocModel.docId);
                parameters.Add("?crdt", helpDocModel.crdt);
                parameters.Add("?updt", helpDocModel.updt);
                parameters.Add("?docTypeId", helpDocModel.docTypeId);
                parameters.Add("?docTitle", helpDocModel.docTitle);
                parameters.Add("?docContent", helpDocModel.docContent);
                parameters.Add("?docFullText", helpDocModel.docFullText);
                parameters.Add("?docNum", helpDocModel.docNum);
                parameters.Add("?docDeptId", helpDocModel.docDeptId);
                parameters.Add("?docCount", helpDocModel.docCount);
                parameters.Add("?crUsrId", helpDocModel.crUsrId);
                parameters.Add("?upUsrId", helpDocModel.upUsrId);
                parameters.Add("?docState", helpDocModel.docState);
                parameters.Add("?docAttachment", helpDocModel.docAttachment);

                Model.DocDeptRole docDeptRole = new Model.DocDeptRole()
                {
                    Crdt          = DateTime.Now,
                    CrUsrId       = helpDocModel.crUsrId,
                    DocDeptRoleId = Guid.NewGuid().ToString(),
                    DocDeptState  = 1,
                    Updt          = DateTime.Now,
                    UpUsrId       = helpDocModel.crUsrId,
                    DocId         = helpDocModel.docId
                };

                DocDeptRole.Set(docDeptRole, lstShareDeptIdList);


                //有编辑权限即有查看权限
                foreach (var item in editRoleList)
                {
                    if (!viewRoleList.Contains(item))
                    {
                        viewRoleList.Add(item);
                    }
                }

                SaveDocRole(viewRoleList, helpDocModel.crUsrId, helpDocModel.docId, isDefault);

                SaveDocRoleCtrl(editRoleList, helpDocModel.crUsrId, helpDocModel.docId);

                rows = mysql.ExcuteNonQuery <Model.HelpDoc>(DapperMySQLHelper.ConnectionString, strSql.ToString(), parameters, false);
                ts.Complete();
                return(rows > 0);
            }
        }
示例#2
0
        public static bool Delete(string strDeptId, out string tips)
        {
            //有子部门不允许删除
            var nodes = GetChildNodes(strDeptId);

            if (null != nodes && nodes.Count > 0)
            {
                tips = ResponseMessageTips.MSG_DEPT_HAS_CHILD_DEL_FAIL;
                return(false);
            }

            //有绑定文档关系不允许删除
            var checkExist = DocDeptRole.GetModel(strDeptId);

            if (null != checkExist)
            {
                tips = ResponseMessageTips.MSG_DEPT_HAS_BIND_DOC_DEL_FAIL;
                return(false);
            }

            //部门下有人员
            var checkUser = Usr.GetUsrsByDeptId(strDeptId);

            if (checkUser != null && checkUser.Count > 0)
            {
                tips = ResponseMessageTips.MSG_DEPT_HAS_BIND_USER_DEL_FAIL;
                return(false);
            }

            DynamicParameters parameters = new DynamicParameters();

            parameters.Add("_deptId", strDeptId);
            parameters.Add("isErr", dbType: DbType.Int32, direction: ParameterDirection.Output);

            mysql.ExcuteNonQuery <Model.Usr>(DapperMySQLHelper.ConnectionString, "SP_DEL_DEPT_ACCOUNT", parameters, true);
            if (parameters.Get <int>("isErr") == 0)
            {
                tips = ResponseMessageTips.MSG_DEPT_DELETE_SUCCESS;
                return(true);
            }
            else
            {
                tips = ResponseMessageTips.MSG_DEPT_DELETE_FAIL;
                return(false);
            }
        }