Esempio n. 1
0
        public int UpdateExampaper(Cde_SurveyExampaper exampaper)
        {
            var count = _dataAccess.GetCount <SurveyInfo>("Cde_SurveyInfo.ExampaperId=" + exampaper.ExampaperID);

            if (count > 0)
            {
                //已被调用,不修改原记录
                return(AddExampaper(exampaper));
            }
            else
            {
                //修改时,把问卷和问题的关联删除,重新添加关联
                var sqlwhere = "Cde_SurveyQuestion.ExampaperID=" + exampaper.ExampaperID;
                _dataAccess.DeleteEntities <Cde_SurveyQuestion>(sqlwhere);
                _dataAccess.UpdateEntity(exampaper);
                var questions = new List <Cde_SurveyQuestion>();
                for (int index = 0; index < exampaper.Questions.Count; index++)
                {
                    var question = exampaper.Questions[index];
                    questions.Add(new Cde_SurveyQuestion()
                    {
                        ExampaperID = exampaper.ExampaperID,
                        QuestionID  = question.QuestionId,
                        ShowOrder   = index
                    });
                }
                _dataAccess.AddEntities(questions);
                return(_dataAccess.UpdateEntity(exampaper));
            }
        }
Esempio n. 2
0
        public int LevelCodeCount(int id, string code)
        {
            string sqlwhere = "Int_UserLevel.IsDelete=0 AND Int_UserLevel.LevelId<>" + id +
                              " AND Int_UserLevel.LevelCode='" + code.ReplaceSql() + "'";

            return(_dataAccess.GetCount <UserLevel>(sqlwhere));
        }
Esempio n. 3
0
        public int GetCountKnowledgeBySortId(int id)
        {
            var sqlwhere = "KL_Resource.IsDeleted=0 AND KL_Resource.SortId=" + id;
            int count    = _dataAccess.GetCount <KL_Resource>(sqlwhere);

            return(count);
        }
Esempio n. 4
0
        public int GetResourceCountByTime(DateTime auditTime)
        {
            var sqlwhere = "KL_Resource.IsDeleted=0 AND KL_Resource.Status=1 AND KL_Resource.AuditTime>='" +
                           auditTime.ToString("yyyy-MM-dd HH:mm:ss") + "'";

            return(_dataAccess.GetCount <KL_Resource>(sqlwhere));
        }
Esempio n. 5
0
        /// <summary>
        /// 确定版块名称是否存在
        /// </summary>
        /// <param name="sectionName"></param>
        /// <param name="sectionId"></param>
        /// <returns></returns>
        public bool ExistsMainSectionName(string sectionName, int sectionId)
        {
            var sqlwhere = "bbs_MainSection.IsDelete=0 AND bbs_MainSection.SectionName='" + sectionName.ReplaceSql() +
                           "' AND bbs_MainSection.SectionId<>" + sectionId;
            var count = _dataAccess.GetCount <MainSection>(sqlwhere);

            return(count > 0);
        }
Esempio n. 6
0
        /// <summary>
        /// 获取系统中未解决问题的数量(不包含过期问题)
        /// </summary>
        /// <returns></returns>
        public int GetNoCompleteQuestionCount(int tenantId)
        {
            var sqlwhere =
                string.Format("Int_Question.IsThematic=0 AND Int_Question.IsDelete=0 AND Int_Question.TenantId={0} AND Int_Question.AnswerId=0 AND ( Int_Question.Expired>'{1}' OR Expired IS NULL)"
                              , tenantId, DateTime.Now.ToString("yyyy-MM-dd"));
            var count = _dataAccess.GetCount <IntQuestion>(sqlwhere);

            return(count);
        }
Esempio n. 7
0
        /// <summary>
        /// 是否存在该记录
        /// true:已存在;false:不存在
        /// </summary>
        /// <param name="groupId"></param>
        /// <param name="groupName"></param>
        /// <param name="tenantId"></param>
        /// <returns></returns>
        public bool Exists(int groupId, string groupName, int tenantId)
        {
            string where = "Int_Group.IsDelete = 0 AND  Int_Group.TenantId = @TenantId AND Int_Group.GroupName = @GroupName";
            if (groupId > 0)
            {
                where += " and Int_Group.GroupId <> " + groupId;
            }
            int count = _dataAccess.GetCount <Group>(where, new { GroupName = groupName, TenantId = tenantId });

            return(count > 0);
        }
Esempio n. 8
0
        /// <summary>
        /// 验证书籍重名
        /// </summary>
        /// <param name="bookName"></param>
        /// <param name="tenantId"></param>
        /// <param name="bookId"></param>
        /// <returns></returns>
        public bool IsExistName(string bookName, int tenantId, int bookId)
        {
            string where = "Res_EBook.IsDelete = 0 AND  Res_EBook.TenantId = @tenantId AND Res_EBook.BookName = @bookName";
            if (bookId > 0)
            {
                where += " and Res_EBook.BookId <> " + bookId;
            }
            int count = _dataAccess.GetCount <EBook>(where, new { bookName, tenantId });

            return(count > 0);
        }
Esempio n. 9
0
        /// <summary>
        /// 获取指定课程体系下的课程数
        /// </summary>
        /// <param name="cateId">课程体系Id</param>
        /// <param name="tenantId">租户Id</param>
        /// <returns></returns>
        public int GetCourseCountByCategoryId(int cateId, int tenantId)
        {
            var allCategorys =
                _dataAccess.GetList <ResCourseCategory>("Res_CourseCategory.Status=0 ");
            var allChilds = new List <int>();

            GetAllChilds(cateId, allCategorys, allChilds);
            allChilds.Add(cateId);
            var idStrings = allChilds.GetString();
            var sqlwhere  = " Res_Course.Status=0 AND Res_Course.CategoryId IN (" + idStrings + ")";
            int count     = _dataAccess.GetCount <ResCourse>(sqlwhere);

            return(count);
        }
Esempio n. 10
0
        public int GetSurveyCountByTitle(string title, int id)
        {
            var sqlwhere = "Res_SurveyInfo.SurveyTitle=@title AND Res_SurveyInfo.SurveyID<>@id AND Res_SurveyInfo.Status!=2";
            var count    = _dataAccess.GetCount <ResSurveyInfo>(sqlwhere, new { title, id });

            return(count);
        }
Esempio n. 11
0
        /// <summary>
        /// 数审批通过的人数
        /// </summary>
        /// <param name="classId"></param>
        /// <returns></returns>
        public int GetApprovalNum(int classId)
        {
            string sql = string.Format(@"
select * from Tr_TrainClassToUser where tc.IsDelete=0 and tc.ClassId={0} and ApproveStatus=2", classId);

            return(_dataAccess.GetCount <Tr_TrainClassToUser>(sql));
        }
Esempio n. 12
0
        /// <summary>
        /// 判断类别名称是否存在
        /// </summary>
        /// <param name="type"></param>
        /// <param name="id"></param>
        /// <param name="tenantId"></param>
        /// <param name="sortName"></param>
        /// <param name="parentID"></param>
        /// <returns></returns>
        public bool IsExist(int tenantId, string sortName, int type = 0, int id = 0, int parentID = 0)
        {
            string sql = string.Format(@"select count(*) from Sys_NotesSort 
WHERE tenantId = {0} and SortName='{1}' 
and ParentID={2} and type={3} and IsDelete = 0",
                                       tenantId, sortName.ReplaceSql(), parentID, type);

            if (id > 0)
            {
                sql += " and Id <> " + id;
            }

            int count = _dataAccess.GetCount <Sys_NotesSort>(sql);

            return(count > 0);
        }
Esempio n. 13
0
        /// <summary>
        /// 检查公司名称是否存在
        /// </summary>
        /// <param name="name"></param>
        /// <param name="companyId"></param>
        /// <returns></returns>
        public bool CheckCompanyNameExists(string name, string companyId)
        {
            var sql = string.Format(@" company_name='{0}' and company_id != '{1}' ", name,
                                    companyId);

            return(_dataAccess.GetCount <CompanyModel>(sql) > 0);
        }
Esempio n. 14
0
        /// <summary>
        /// 检查部门代码是否存在
        /// </summary>
        /// <param name="deptcode"></param>
        /// <param name="deptId"></param>
        /// <param name="parentId"></param>
        /// <param name="tenantId"></param>
        /// <returns></returns>
        public bool CheckDeptCodeExists(string deptcode, int deptId, int parentId, int tenantId)
        {
            if (string.IsNullOrEmpty(deptcode))
            {
                return(false);
            }
            string where = "Sys_Department.Status = 0 AND Sys_Department.TenantId=@tenantId AND Sys_Department.DeptCode=@deptcode";
            //" AND Sys_Department.parentId=@parentId";
            if (deptId > 0)
            {
                where += " and Sys_Department.DeptId <> " + deptId;
            }
            int count = _dataAccess.GetCount <SysDepartment>(where, new { tenantId, deptcode, parentId });

            return(count > 0);
        }
Esempio n. 15
0
        public bool CheckPlanname(string planName, int planId, int userId)
        {
            const string where =
                "Len_LearnPlan.Status = 0 AND  Len_LearnPlan.CreateUser=@userId AND Len_LearnPlan.PlanName=@planName and Len_LearnPlan.PlanId <> @planId";
            int count = _dataAccess.GetCount <LenLearnPlan>(where, new { planId, userId, planName });

            return(count > 0);
        }
Esempio n. 16
0
        public bool IsExsitName(int tenantId, int categoryId, string categoryName, int parentId)
        {
            string where = "Ab_AbilityCategory.IsDelete = 0 AND  Ab_AbilityCategory.TenantId = @tenantId AND Ab_AbilityCategory.CategoryName = @categoryName AND Ab_AbilityCategory.parentId=" + parentId;
            if (categoryId > 0)
            {
                where += " and Ab_AbilityCategory.CategoryId <> " + categoryId;
            }
            int count = _dataAccess.GetCount <AbilityCategory>(where, new { categoryName, tenantId });

            return(count == 0);
        }
Esempio n. 17
0
        /// <summary>
        ///     检查名称是否存在
        /// </summary>
        /// <param name="deptId"></param>
        /// <param name="tenantId"></param>
        /// <param name="deptname"></param>
        /// <returns></returns>
        public bool CheckDeptname(string deptname, int deptId, int tenantId)
        {
            string where = "Sys_Department.IsDelete=0 AND Sys_Department.TenantId=@tenantId AND Sys_Department.DeptName =@deptname";
            if (deptId > 0)
            {
                where += " and Sys_Department.DepartmentId  <> " + deptId;
            }
            int count = _dataAccess.GetCount <SysDepartment>(where, new { deptname, tenantId });

            return(count > 0);
        }
Esempio n. 18
0
        public bool IsExsitName(int tenantId, int promotionId, string promotionName)
        {
            string where = "Ab_PromotionWay.IsDelete = 0 AND  Ab_PromotionWay.TenantId = @tenantId AND Ab_PromotionWay.PromotionName = @promotionName";
            if (promotionId > 0)
            {
                where += " and Ab_PromotionWay.PromotionId <> " + promotionId;
            }
            int count = _dataAccess.GetCount <PromotionWay>(where, new { promotionName, tenantId });

            return(count == 0);
        }
Esempio n. 19
0
        public int GetCountByAdress(string adress, int ID)
        {
            var sql = "Sys_Adress.Adress=@adress and Sys_Adress.IsDelete=0";

            if (ID > 0)
            {
                sql += " AND Sys_Adress.ID <>" + ID;
            }
            var count = _dataAccess.GetCount <SysAdress>(sql, new { adress });

            return(count);
        }
Esempio n. 20
0
        /// <summary>
        /// 出发特定的积分事件
        /// </summary>
        /// <param name="ruleCode">规则代码</param>
        /// <param name="userId">用户id</param>
        /// <param name="tenantId">租户Id</param>
        /// <returns></returns>
        public int FireIntegrationEvent(IntegrationEvents ruleCode, int userId, int tenantId)
        {
            var code = ruleCode.ToString();

            if (!IntegrationRules.Instance.IsExistsCode(code))
            {
                //规则代码不匹配
                throw new Exception("规则代码不匹配");
            }
            //找到规则
            var rule = _dataAccess.GetList <IntegralRule>(string.Format("IsEnabled=1 AND RuleCode='{0}' AND TenantId={1}", ruleCode, tenantId)).FirstOrDefault();

            if (rule == null)
            {
                //该租户木有配置规则
                return(0);
            }
            //判断规则周期
            var startTime = DateTime.Now;

            switch (rule.TimeRange)
            {
            case -1:
                startTime     = new DateTime(1901, 1, 1);
                rule.MaxTimes = 1;
                break;

            case 0:
                AddIntegration(rule.RuleId, rule.Integral, userId, tenantId);
                return(rule.Integral);

            case 2:
                startTime = startTime.Accuracy("h");
                break;

            case 3:
                startTime = startTime.Accuracy("d");
                break;
            }
            //查找本周期内,积分奖惩次数
            var count = _dataAccess.GetCount <UserIntegral>(string.Format("Int_UserIntegral.RuleId={0} AND Int_UserIntegral.TimeToGet>'{1}' AND Int_UserIntegral.UserId={2}", rule.RuleId, startTime.ToString("yyyy-MM-dd HH:mm:00"), userId));

            if (count >= rule.MaxTimes)
            {
                return(0);
            }
            AddIntegration(rule.RuleId, rule.Integral, userId, tenantId, rule.RuleDesc);
            return(rule.Integral);
        }
Esempio n. 21
0
        /// <summary>
        ///     检查岗位名称是否存在
        /// </summary>
        /// <param name="postname"></param>
        /// <param name="postId"></param>
        /// <param name="deptId"></param>
        /// <param name="tenantId"></param>
        /// <returns></returns>
        public bool CheckPostNameExists(string postname, int postId, int deptId, int tenantId)
        {
            if (string.IsNullOrEmpty(postname))
            {
                return(false);
            }
            string where = "Sys_Posts.Status = 0  AND Sys_Posts.PostName=@postname AND Sys_Posts.DeptId=@deptId";
            if (postId > 0)
            {
                where += " and Sys_Posts.PostId <> " + postId;
            }
            int count = _dataAccess.GetCount <SysPost>(where, new { postname, deptId });

            return(count > 0);
        }
Esempio n. 22
0
        /// <summary>
        /// 检查学习卡数量是否大于教材库存
        /// </summary>
        /// <param name="bookIds"></param>
        /// <param name="number"></param>
        /// <returns></returns>
        public bool CheckBookNumber(string bookIds, int number = 0)
        {
            if (string.IsNullOrEmpty(bookIds))
            {
                return(false);
            }
            if (number == 0)
            {
                return(false);
            }
            string where = " Stock<" + number + " AND BookId IN (" + bookIds + ") ";
            int count = _dataAccess.GetCount <ResTeacherBook>(where);

            return(count > 0?false:true);
        }
Esempio n. 23
0
        /// <summary>
        ///     检查角色名称是否存在
        /// </summary>
        /// <param name="roleName"></param>
        /// <param name="roleId"></param>
        /// <param name="deptId"></param>
        /// <returns></returns>
        public bool CheckRoleNameExists(string roleName, int roleId, int deptId)
        {
            if (string.IsNullOrEmpty(roleName))
            {
                return(false);
            }
            string where = "Dept_Roles.IsDelete = 0 AND  Dept_Roles.DeptId=@deptId  AND Dept_Roles.RoleName=@roleName";
            if (roleId > 0)
            {
                where += " and Dept_Roles.RoleId <> " + roleId;
            }
            int count = _dataAccess.GetCount <DeptRole>(where, new { roleName, deptId });

            return(count > 0);
        }
Esempio n. 24
0
        /// <summary>
        ///     检查角色名称是否存在
        /// </summary>
        /// <param name="roleName"></param>
        /// <param name="roleId"></param>
        /// <param name="tenantId"></param>
        /// <returns></returns>
        public bool CheckRoleNameExists(string roleName, int roleId, int tenantId)
        {
            if (string.IsNullOrEmpty(roleName))
            {
                return(false);
            }
            string where = "Sys_Roles.IsDelete = 0 AND  Sys_Roles.TenantId=@tenantId AND Sys_Roles.RoleName=@roleName";
            if (roleId > 0)
            {
                where += " and Sys_Roles.RoleId <> " + roleId;
            }
            int count = _dataAccess.GetCount <SysRole>(where, new { roleName, tenantId });

            return(count > 0);
        }
Esempio n. 25
0
 /// <summary>
 /// 获取当前系统中注册的总人数
 /// </summary>
 /// <param name="tenantId"></param>
 /// <returns></returns>
 public int GetUserCount(int tenantId)
 {
     return(_dataAccess.GetCount <SysUser>("Sys_Users.Status=0"));
 }
Esempio n. 26
0
 /// <summary>
 /// 验证重命名
 /// </summary>
 /// <param name="where"></param>
 /// <returns></returns>
 public int GetCountWareName(string where = "1=1")
 {
     return(_dataAccess.GetCount <ResCourseware>(where));
 }
Esempio n. 27
0
 public int QuestionUseCount(int qid)
 {
     return(_dataAccess.GetCount <Cde_SurveyQuestion>("Cde_SurveyQuestion.QuestionId=" + qid));
 }
Esempio n. 28
0
 /// <summary>
 /// 获取当前系统中注册的总人数
 /// </summary>
 /// <param name="tenantId"></param>
 /// <returns></returns>
 public int GetUserCount(int tenantId)
 {
     return(_dataAccess.GetCount <SysUser>("Sys_Users.IsDelete=0 and isnull(Sys_Users.IsTeacher,0)=2"));
 }
Esempio n. 29
0
 /// <summary>
 /// 验证分类重命名
 /// </summary>
 /// <param name="where"></param>
 /// <returns></returns>
 public int GetCountSortName(string where = "1=1")
 {
     return(_dataAccess.GetCount <ResCourseCategory>(where));
 }
Esempio n. 30
0
 /// <summary>
 /// Raises the user count event.
 /// </summary>
 /// <param name="tenantId">Tenant identifier.</param>
 public static int OnlineUserCount(int tenantId)
 {
     return(_dataAccess.GetCount <OnlineUser>("TenantId=" + tenantId));
 }