Example #1
0
        /// <summary>
        /// 移动栏目,委托:OperModule类型
        /// </summary>
        /// <param name="module">要栏目的栏目对象</param>
        /// <param name="yunEntities"></param>
        /// <returns>信息集对象</returns>
        private ResultInfo MoveOper(YD_Sys_Module module, IYunEntities yunEntities)
        {
            var resultInfo = new ResultInfo {
                Info = Safe("/SysAdmin/Module", PowerFlag.Update)
            };

            if (module.y_parentID == module.id)
            {
                resultInfo.Success = false;
                resultInfo.Message = "自身不能成为自身的子栏目";
                return(resultInfo);
            }
            var moduleLast = yunEntities.YD_Sys_Module.FirstOrDefault(u => u.id == module.y_parentID);

            if (IsChildrenModule(module, moduleLast, yunEntities))
            {
                resultInfo.Success = false;
                resultInfo.Message = "自身不能成为自身子栏目的子栏目";
                return(resultInfo);
            }
            MoveOperChildrenModule(module, yunEntities);
            resultInfo.Success = yunEntities.SaveChanges() > 0;
            resultInfo.Message = "";
            if (resultInfo.Success)
            {
                LogHelper.DbLog(Convert.ToInt32(HttpContext.Current.Session[KeyValue.Admin_id]), HttpContext.Current.Session[KeyValue.Admin_Name].ToString(), (int)LogType.Update, "移动栏目,栏目名为" + module.y_name + "级别为" + module.y_level + ",移动到parentID:" + module.y_parentID + ",id:" + module.id);
            }
            return(resultInfo);
        }
        /// <summary>
        /// 增加方法,委托:OperModule类型
        /// </summary>
        /// <param name="module">要新增的层次类型对象</param>
        /// <param name="yunEntities"></param>
        /// <returns>信息集对象</returns>
        private ResultInfo AddOper(HttpRequestBase request, YD_Edu_TeachPlan module, IYunEntities yunEntities)
        {
            var yearStr        = request["year"];
            var majorIdStr     = request["majorId"];
            var teaPlanTypeStr = request["y_teaPlanType"];

            if (string.IsNullOrEmpty(yearStr) || string.IsNullOrEmpty(majorIdStr) || string.IsNullOrEmpty(teaPlanTypeStr))
            {
                return(new ResultInfo {
                    Success = false, Info = PowerInfo.Unknow, Message = "未知错误"
                });
            }
            var year        = Convert.ToInt32(yearStr);
            var majorId     = Convert.ToInt32(majorIdStr);
            var teaPlanType = Convert.ToInt32(teaPlanTypeStr);
            var resultInfo  = BaseAddEntity(module, "/Edu/TeachPlan", yunEntities);

            if (resultInfo.Success)
            {
                var entity = new YD_Edu_MajorTeachPlan()
                {
                    y_majorId     = majorId,
                    y_teachPlanId = module.id,
                    y_year        = year,
                    y_teaPlanType = teaPlanType
                };
                yunEntities.Entry(entity).State = EntityState.Added;
                yunEntities.SaveChanges();
                LogHelper.DbLog(Convert.ToInt32(HttpContext.Current.Session[KeyValue.Admin_id]), HttpContext.Current.Session[KeyValue.Admin_Name].ToString(), (int)LogType.Insert, "添加教学计划,教学计划名为" + module.y_teaPlanName + ",id:" + module.id);
            }
            return(resultInfo);
        }
        /// <summary>
        /// 同步学生
        /// </summary>
        /// <returns></returns>
        public bool TongBuStudent()
        {
            string content =
                "{\"data\":{\"displayName\":\"\",\"gender\":\"\",\"idCard\":\"\",\"phoneNum\":\"\",\"centerId\":0,\"majorId\":0,\"semesterId\":0,\"studentNumber\":\"\",\"studyStatusId\":0,\"pageIndex\":0,\"pageSize\":99999}}";

            sen = sing(content);
            string content1 = "{\"data\":{\"displayName\":\"\",\"gender\":\"\",\"idCard\":\"\",\"phoneNum\":\"\",\"centerId\":0,\"majorId\":0,\"semesterId\":0,\"studentNumber\":\"\",\"studyStatusId\":0,\"pageIndex\":0,\"pageSize\":99999},\"signature\": \"" + sen + "\"}";

            html = WebPost("http://www.qingshuxuetang.com/QingShuSchoolWebService/jxsf/v1/student/search", content1, Encoding.UTF8);
            if (!html.Contains("服务器"))
            {
                var results = JsonConvert.DeserializeObject <QingShuStuMessage>(html);

                if (results.hr == 0)
                {
                    var list = results.data;
                    using (var yunEntities = new IYunEntities())
                    {
                        var qingCourses = new List <YD_Edu_QingStuInfo>();
                        for (var i = 0; i < list.Count; i++)
                        {
                            var qingStu = new YD_Edu_QingStuInfo();
                            qingStu.y_qingId = list[i].id;
                            qingStu.y_name   = list[i].displayName;
                            qingStu.y_stuNum = list[i].studentNumber;

                            qingStu.y_qingSubId   = list[i].centerId;
                            qingStu.y_qingMajorId = list[i].majorId;
                            var stuNum = list[i].name.Replace("jxsf_", "");
                            var obj    = yunEntities.YD_Sts_StuInfo.FirstOrDefault(u => u.y_stuNum == stuNum);
                            if (obj == null)
                            {
                                continue;
                            }
                            qingStu.y_nid    = obj.id;
                            qingStu.y_cardId = obj.y_cardId;
                            if (!yunEntities.YD_Edu_QingStuInfo.Any(u => u.y_qingId == qingStu.y_qingId))//本地已映射的学生不再映射
                            {
                                qingCourses.Add(qingStu);
                            }
                        }
                        yunEntities.Configuration.AutoDetectChangesEnabled = false;
                        yunEntities.Configuration.ValidateOnSaveEnabled    = false;
                        yunEntities.Set <YD_Edu_QingStuInfo>().AddRange(qingCourses);
                        yunEntities.SaveChanges();
                        //yunEntities.BulkInsert(qingCourses);
                        //yunEntities.SaveChanges();
                        return(true);
                    }
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Example #4
0
        /// <summary>
        /// 修改栏目排序
        /// </summary>
        /// <param name="request">请求上下文对象</param>
        /// <param name="yunEntities">EF上下文对象</param>
        /// <returns></returns>
        public string ModuleUpdateSort(HttpRequestBase request, IYunEntities yunEntities)
        {
            var ids   = request["ids"];
            var sorts = request["sorts"];

            if (string.IsNullOrEmpty(ids) || string.IsNullOrEmpty(sorts))
            {
                return("未知错误");
            }
            var mids   = ids.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            var msorts = sorts.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            if (mids.Count() != msorts.Count())
            {
                return("未知错误");
            }
            for (var j = 0; j < mids.Count(); j++)
            {
                var id     = Convert.ToInt32(mids[j]);
                var module = yunEntities.YD_Sys_Module.FirstOrDefault(u => u.id == id);
                if (module != null)
                {
                    module.y_sort = Convert.ToInt32(msorts[j]);
                }
                yunEntities.Entry(module).State = EntityState.Modified;
                if (module != null)
                {
                    LogHelper.DbLog(Convert.ToInt32(HttpContext.Current.Session[KeyValue.Admin_id]), HttpContext.Current.Session[KeyValue.Admin_Name].ToString(), (int)LogType.Update, "修改栏目排序,栏目名为" + module.y_name + ",级别为" + module.y_level + ",排序修改为:" + module.y_sort + ",id:" + module.id);
                }
            }
            var i = yunEntities.SaveChanges();

            return(i > 0 ? "ok" : "保存栏目排序失败");
        }
        /// <summary>
        /// 同步课程
        /// </summary>
        /// <returns></returns>
        public bool TongBuCourse()
        {
            string content =
                "{\"data\":{\"ids\":[]}}";

            sen = sing(content);
            string content1 = "{\"data\":{\"ids\":[]},\"signature\": \"" + sen + "\"}";

            html = WebPost("http://www.qingshuxuetang.com/QingShuSchoolWebService/jxsf/v1/course/search", content1, Encoding.UTF8);
            if (!html.Contains("服务器"))
            {
                var results = JsonConvert.DeserializeObject <QingShuCourseMessage>(html);

                if (results.hr == 0)
                {
                    var list = results.data;
                    using (var yunEntities = new IYunEntities())
                    {
                        var qingCourses = new List <YD_Edu_QingCourse>();
                        for (var i = 0; i < list.Count; i++)
                        {
                            var course = new YD_Edu_QingCourse();
                            course.y_qingId = list[i].id;
                            course.y_name   = list[i].name;
                            var name = list[i].name;
                            var obj  = yunEntities.YD_Edu_Course.FirstOrDefault(u => u.y_name == name);
                            if (obj == null)
                            {
                                continue;
                            }
                            course.y_nid = obj.id;
                            if (!yunEntities.YD_Edu_QingCourse.Any(u => u.y_qingId == course.y_qingId))//本地已映射的科目不再映射
                            {
                                qingCourses.Add(course);
                            }
                        }
                        yunEntities.Configuration.AutoDetectChangesEnabled = false;
                        yunEntities.Configuration.ValidateOnSaveEnabled    = false;
                        yunEntities.Set <YD_Edu_QingCourse>().AddRange(qingCourses);
                        yunEntities.SaveChanges();
                        //yunEntities.BulkInsert(qingCourses);
                        //yunEntities.SaveChanges();
                        return(true);
                    }
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
        public JsonResult Upload(HttpPostedFileBase filebase)
        {
            string fileName = Request["filename"] as string;
            var    role     = Request["role"];

            if (string.IsNullOrWhiteSpace(fileName))
            {
                return(Json("文件名不能为空"));
            }
            if (Request.Files.Count == 0)
            {
                return(Json("文件不能为空"));
            }
            var file = Request.Files[0];

            if (file.ContentLength == 0 || file.ContentLength > 10 * 1024 * 1024)
            {
                return(Json("文件大小超出限制范围(10MB)"));
            }
            else
            {
                int roleid = 0;
                if (!string.IsNullOrWhiteSpace(role))
                {
                    roleid = Convert.ToInt32(role);
                }
                string target          = Server.MapPath("~/File/Upload/");
                string currentFileName = fileName + DateTime.Now.ToString("yyyyMMddhhmmss");
                string path            = target + currentFileName + file.FileName.Substring(file.FileName.LastIndexOf('.'));
                file.SaveAs(path);
                using (var yunEntities = new IYunEntities())
                {
                    yunEntities.YD_Sys_File.Add(new YD_Sys_File()
                    {
                        y_name        = fileName,
                        y_path        = path,
                        y_createdName = YdAdminRelName,
                        y_createduser = YdAdminId,
                        y_role        = roleid,
                        y_time        = DateTime.Now
                    });
                    int flag = yunEntities.SaveChanges();
                    if (flag > 0)
                    {
                        return(Json(true));
                    }
                    else
                    {
                        return(Json(false));
                    }
                }
            }
        }
Example #7
0
        /// <summary>
        /// 删除层次类型
        /// </summary>
        /// <param name="id">层次类型id</param>
        /// <param name="yunEntities">EF上下文对象</param>
        /// <returns></returns>
        public string EntityDelete(int id, IYunEntities yunEntities)
        {
            var module = yunEntities.YD_Edu_TeachplanDes.FirstOrDefault(u => u.y_teaPlanId == id);

            if (module != null)
            {
                yunEntities.Entry(module).State = EntityState.Deleted;
                LogHelper.DbLog(Convert.ToInt32(HttpContext.Current.Session[KeyValue.Admin_id]), HttpContext.Current.Session[KeyValue.Admin_Name].ToString(), (int)LogType.Delete, "删除教学计划课程,id:" + module.id);
            }
            var i = yunEntities.SaveChanges();

            return(i > 0 ? "ok" : "删除教学计划课程失败");
        }
Example #8
0
        /// <summary>
        /// 删除课程
        /// </summary>
        /// <param name="id">课程id</param>
        /// <param name="yunEntities">EF上下文对象</param>
        /// <returns></returns>
        public string EntityDelete(int id, IYunEntities yunEntities)
        {
            var Course = yunEntities.YD_Edu_Score.FirstOrDefault(u => u.id == id);

            if (Course != null)
            {
                yunEntities.Entry(Course).State = EntityState.Deleted;
                LogHelper.DbLog(Convert.ToInt32(HttpContext.Current.Session[KeyValue.Admin_id]), HttpContext.Current.Session[KeyValue.Admin_Name].ToString(), (int)LogType.Delete, "删除成绩,学生id为" + Course.y_stuId + ",id:" + Course.id);
            }
            var i = yunEntities.SaveChanges();

            return(i > 0 ? "ok" : "删除成绩失败");
        }
        /// <summary>
        /// 删除用户
        /// </summary>
        /// <returns></returns>
        public string DeleteStrange(HttpRequestBase request, IYunEntities yunEntities)
        {
            var ids = request["ids"];

            if (string.IsNullOrEmpty(ids))
            {
                return("数据为空");
            }

            #region “删除”权限验证

            var powerInfo = Safe("/Student/StudentInfoChangeAll", PowerFlag.Delete);
            switch (powerInfo)
            {
            case PowerInfo.NoPower:
                return("无权限");

            case PowerInfo.NoLogin:
                return("未登录");

            case PowerInfo.Unknow:
                return("未知状况");

            case PowerInfo.HasPower:
                break;

            default:
                return("未知状况");
            }

            #endregion

            var idsstr  = ids.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            var idsList = new List <int>();
            for (var i = 0; i < idsstr.Count(); i++)
            {
                idsList.Add(Convert.ToInt32(idsstr[i]));
            }
            var admins = yunEntities.YD_Sts_StuStrange.Where(u => idsList.Contains(u.id)).ToList();

            foreach (var admin in admins)
            {
                admin.y_isdel = (int)YesOrNo.Yes;
                yunEntities.Entry(admin).State = EntityState.Modified;
                LogHelper.DbLog(Convert.ToInt32(HttpContext.Current.Session[KeyValue.Admin_id]),
                                HttpContext.Current.Session[KeyValue.Admin_Name].ToString(), (int)LogType.Delete,
                                "删除学籍异动,id:" + admin.id);
            }
            var j = yunEntities.SaveChanges();
            return(j > 0 ? "ok" : "删除学籍异动失败");
        }
Example #10
0
        /// <summary>
        /// 开启栏目
        /// </summary>
        /// <param name="id">栏目id</param>
        /// <param name="yunEntities">EF上下文对象</param>
        /// <returns></returns>
        public string ModuleOpen(int id, IYunEntities yunEntities)
        {
            var module = yunEntities.YD_Sys_Module.FirstOrDefault(u => u.id == id);

            if (module != null)
            {
                module.y_vaild = (Int32)DataState.Able;
                yunEntities.Entry(module).State = EntityState.Modified;
                LogHelper.DbLog(Convert.ToInt32(HttpContext.Current.Session[KeyValue.Admin_id]), HttpContext.Current.Session[KeyValue.Admin_Name].ToString(), (int)LogType.Update, "开启栏目,栏目名为" + module.y_name + ",级别为" + module.y_level + ",id:" + module.id);
            }
            var i = yunEntities.SaveChanges();

            return(i > 0 ? "ok" : "开启栏目失败");
        }
Example #11
0
        /// <summary>
        /// 删除角色
        /// </summary>
        /// <returns></returns>
        public string DeleteRole(HttpRequestBase request, IYunEntities yunEntities)
        {
            var ids = request["ids"];

            if (string.IsNullOrEmpty(ids))
            {
                return("数据为空");
            }
            #region “删除”权限验证
            var powerInfo = Safe("/SysAdmin/Role", PowerFlag.Delete);
            switch (powerInfo)
            {
            case PowerInfo.NoPower:
                return("无权限");

            case PowerInfo.NoLogin:
                return("未登录");

            case PowerInfo.Unknow:
                return("未知状况");

            case PowerInfo.HasPower:
                break;

            default:
                return("未知状况");
            }
            #endregion
            var idsstr  = ids.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            var idsList = new List <int>();
            for (var i = 0; i < idsstr.Count(); i++)
            {
                idsList.Add(Convert.ToInt32(idsstr[i]));
            }

            var roles = yunEntities.YD_Sys_Role.Where(u => idsList.Contains(u.id)).ToList();

            foreach (var role in roles)
            {
                if (yunEntities.YD_Sys_Admin.FirstOrDefault(u => u.y_roleID == role.id) != null)
                {
                    return("删除角色失败,因为该角色下已经存在用户");
                }
                yunEntities.Entry(role).State = EntityState.Deleted;
                LogHelper.DbLog(Convert.ToInt32(HttpContext.Current.Session[KeyValue.Admin_id]), HttpContext.Current.Session[KeyValue.Admin_Name].ToString(), (int)LogType.Delete, "删除角色,角色名为" + role.y_name + ",id:" + role.id);
            }
            var j = yunEntities.SaveChanges();
            return(j > 0 ? "ok" : "删除角色失败");
        }
 public string Tuixue(YD_Sts_StuStrange stra)
 {
     using (var yunEntity = new IYunEntities())
     {
         var stu = yunEntity.YD_Sts_StuInfo.Find(stra.y_stuId);
         if (stu == null)
         {
             return("退学失败,目标学生不存在!");
         }
         stu.y_stuStateId     = 4;              //退学状态
         stra.y_isExecutive   = (int)YesOrNo.Yes;
         stra.y_ExecutiveTime = DateTime.Now;
         return(yunEntity.SaveChanges() > 0 ? "ok" : "未知错误!");
     }
 }
        public string SupplementaryTax(SupplementaryTaxInput input)
        {
            #region 权限验证

            if (!IsLogin())
            {
                Redirect("/AdminBase/Index");
            }
            var re = new Hashtable();
            #endregion

            using (var yunEntities = new IYunEntities())
            {
                var stu = yunEntities.YD_Sts_StuInfo.FirstOrDefault(u => u.id == input.Id);
                stu.y_IsWorking       = (input.IsWorking == true ? 1 : 0);
                stu.y_cardType        = input.CardType;
                stu.y_parentCard1     = input.ParentCard1;
                stu.y_parentCard2     = input.ParentCard2;
                stu.y_parentCardType1 = input.ParentCardType1;
                stu.y_parentCardType2 = input.ParentCardType2;
                stu.y_parentName1     = input.ParentName1;
                stu.y_parentName2     = input.ParentName2;
                if (string.IsNullOrEmpty(input.ParentCard1) || string.IsNullOrEmpty(input.ParentCardType1) || string.IsNullOrEmpty(input.ParentName1))
                {
                    re["msg"]  = "父母或监护人1信息需要填写完整";
                    re["isok"] = false;
                    return(JsonConvert.SerializeObject(re));
                }
                if (input.ParentCard1.Length != 18)
                {
                    re["msg"]  = "父母或监护人1身份证不为18位";
                    re["isok"] = false;
                    return(JsonConvert.SerializeObject(re));
                }
                int r = yunEntities.SaveChanges();
                if (r > 0)
                {
                    re["msg"]  = "补录完毕";
                    re["isok"] = true;
                }
                else
                {
                    re["msg"]  = "补录失败";
                    re["isok"] = false;
                }
                return(JsonConvert.SerializeObject(re));
            }
        }
Example #14
0
        /// <summary>
        /// 修改用户密码
        /// </summary>
        /// <returns></returns>
        public ResultInfo UpdatePwd(HttpRequestBase request, IYunEntities yunEntities)
        {
            var nowPwd     = request["nowPwd"];
            var newPwd     = request["newPwd"];
            var rePwd      = request["rePwd"];
            var resultInfo = new ResultInfo();

            if (!IsLogin())
            {
                resultInfo.Success = false;
                resultInfo.Message = "未登录";
                return(resultInfo);
            }

            var admin = yunEntities.YD_Sys_Admin.Find(YdAdminId);

            if (string.IsNullOrEmpty(newPwd) || string.IsNullOrEmpty(nowPwd) || string.IsNullOrEmpty(rePwd))
            {
                resultInfo.Success = false;
                resultInfo.Message = "还有未填项";
                return(resultInfo);
            }
            if (rePwd != newPwd)
            {
                resultInfo.Success = false;
                resultInfo.Message = "两次密码不一致";
                return(resultInfo);
            }
            if (PageValidate.GetMd5StrT(nowPwd).ToUpper() != admin.y_password.ToUpper())
            {
                resultInfo.Success = false;
                resultInfo.Message = "原始密码不正确";
                return(resultInfo);
            }
            admin.y_password               = PageValidate.GetMd5StrL(newPwd);
            admin.y_realpassword           = newPwd;
            yunEntities.Entry(admin).State = EntityState.Modified;
            var t = yunEntities.SaveChanges();

            if (t > 0)
            {
                resultInfo.Success = true;
                return(resultInfo);
            }
            resultInfo.Success = false;
            resultInfo.Message = "未知错误";
            return(resultInfo);
        }
Example #15
0
        /// <summary>
        /// 记录数据库日志
        /// </summary>
        /// <param name="userId">操作员id</param>
        /// <param name="userName">操作员当前名</param>
        /// <param name="logTypeId">操作类型</param>
        /// <param name="remark">备注</param>
        public static void DbLog(int userId, string userName, int logTypeId, string remark)
        {
            var yunEntities = new IYunEntities();
            var dbLog       = new YD_Sys_DbLog()
            {
                y_userID    = userId,
                y_remark    = remark,
                y_time      = DateTime.Now,
                Y_userName  = userName,
                Y_logTypeID = logTypeId,
            };

            yunEntities.Entry(dbLog).State = EntityState.Added;
            yunEntities.SaveChanges();
            yunEntities.Dispose();
        }
        /// <summary>
        /// 学生信息编辑AJAX
        /// </summary>
        /// <param name="stu">学生信息对象</param>
        /// <returns>处理结果json</returns>
        public string EditStudentInfo(YD_Sts_StuInfo stu)
        {
            #region 权限验证

            if (!IsLogin())
            {
                Redirect("/AdminBase/Index");
            }

            #endregion

            using (var yunEntities = new IYunEntities())
            {
                yunEntities.Configuration.ValidateOnSaveEnabled = false;
                var stus = yunEntities.YD_Sts_StuInfo.FirstOrDefault(u => u.id == stu.id);

                var re = new Hashtable();


                //var msg = _stuInfoDal.EditStuInfoExtended(stu, Request, yunEntities);

                stus.y_sex      = stu.y_sex;
                stus.y_birthday = stu.y_birthday;
                stus.y_tel      = stu.y_tel;
                stus.y_mail     = stu.y_mail;
                stus.y_address  = stu.y_address;
                stus.y_img      = stu.y_img;
                yunEntities.Entry(stus).State = EntityState.Modified;

                int r = yunEntities.SaveChanges();
                if (r > 0)
                {
                    // LogHelper.DbLog(Convert.ToInt32(Session[KeyValue.Admin_id]),
                    //Session[KeyValue.Admin_Name].ToString(), (int)LogType.Update,
                    // "修改学生," + ",id:" + stu.id + "姓名,入学年份,身份证号,出生日期,学号,考生号,学籍状态" + stu.y_name + "," + stu.y_inYear + "," + stu.y_cardId + "," + stu.y_birthday + "," + stu.y_stuNum + "," + stu.y_examNum + "," + stu.y_stuStateId);
                    re["msg"]  = "修改成功";
                    re["isok"] = true;
                }
                else
                {
                    re["msg"]  = "修改失败";
                    re["isok"] = false;
                }
                return(JsonConvert.SerializeObject(re));
            }
        }
Example #17
0
        /// <summary>
        /// 删除层次类型
        /// </summary>
        /// <param name="id">层次类型id</param>
        /// <param name="yunEntities">EF上下文对象</param>
        /// <returns></returns>
        public string EntityDelete(int id, IYunEntities yunEntities)
        {
            var module = yunEntities.YD_Edu_EduType.FirstOrDefault(u => u.id == id);

            if (module != null)
            {
                if (module.YD_Edu_Major.Count != 0)
                {
                    return("该类型不能删除,其已经关联了指定专业");
                }
                yunEntities.Entry(module).State = EntityState.Deleted;
                LogHelper.DbLog(Convert.ToInt32(HttpContext.Current.Session[KeyValue.Admin_id]), HttpContext.Current.Session[KeyValue.Admin_Name].ToString(), (int)LogType.Delete, "删除层次类型,层次名为" + module.y_name + ",id:" + module.id);
            }
            var i = yunEntities.SaveChanges();

            return(i > 0 ? "ok" : "删除层次类型失败");
        }
        /// <summary>
        /// 删除课程类型类型
        /// </summary>
        /// <param name="id">课程类型类型id</param>
        /// <param name="yunEntities">EF上下文对象</param>
        /// <returns></returns>
        public string EntityDelete(int id, IYunEntities yunEntities)
        {
            var courseType = yunEntities.YD_Edu_CourseType.FirstOrDefault(u => u.id == id);

            if (courseType != null)
            {
                if (courseType.YD_Edu_TeachplanDes.Count != 0)
                {
                    return("该类型不能删除,其已经关联了教学计划");
                }
                yunEntities.Entry(courseType).State = EntityState.Deleted;
                LogHelper.DbLog(Convert.ToInt32(HttpContext.Current.Session[KeyValue.Admin_id]), HttpContext.Current.Session[KeyValue.Admin_Name].ToString(), (int)LogType.Delete, "删除课程类型类型,课程类型名为" + courseType.y_name + ",id:" + courseType.id);
            }
            var i = yunEntities.SaveChanges();

            return(i > 0 ? "ok" : "删除课程类型类型失败");
        }
        /// <summary>
        /// 删除函授站类型
        /// </summary>
        /// <param name="id">函授站类型id</param>
        /// <param name="yunEntities">EF上下文对象</param>
        /// <returns></returns>
        public string EntityDelete(int id, IYunEntities yunEntities)
        {
            var module = yunEntities.YD_Sys_SubSchool.FirstOrDefault(u => u.id == id);

            if (module != null)
            {
                if (yunEntities.YD_Sts_StuInfo.Any(u => u.y_subSchoolId == module.id))
                {
                    return("该类型不能删除,其已经关联了指定学生");
                }
                yunEntities.Entry(module).State = EntityState.Deleted;
                LogHelper.DbLog(Convert.ToInt32(HttpContext.Current.Session[KeyValue.Admin_id]), HttpContext.Current.Session[KeyValue.Admin_Name].ToString(), (int)LogType.Delete, "删除函授站,函授站名为" + module.y_name + ",id:" + module.id);
            }
            var i = yunEntities.SaveChanges();

            return(i > 0 ? "ok" : "删除函授站失败");
        }
Example #20
0
        /// <summary>
        /// 删除栏目
        /// </summary>
        /// <param name="id">栏目id</param>
        /// <param name="yunEntities">EF上下文对象</param>
        /// <returns></returns>
        public string ModuleDelete(int id, IYunEntities yunEntities)
        {
            if (id == 10 || id == 11)
            {
                return("该栏目为必要栏目,不能删除");
            }
            var module = yunEntities.YD_Sys_Module.FirstOrDefault(u => u.id == id);

            //删除对应的权限记录
            if (module != null)
            {
                DeleteModule(module, yunEntities);
                LogHelper.DbLog(Convert.ToInt32(HttpContext.Current.Session[KeyValue.Admin_id]), HttpContext.Current.Session[KeyValue.Admin_Name].ToString(), (int)LogType.Delete, "删除栏目,栏目名为" + module.y_name + ",级别为" + module.y_level + ",id:" + module.id);
            }
            var i = yunEntities.SaveChanges();

            return(i > 0 ? "ok" : "删除栏目失败");
        }
 /// <summary>
 /// 学生毕业申请
 /// </summary>
 /// <returns></returns>
 public string StuGradInfoSome()
 {
     using (var yunEntities = new IYunEntities())
     {
         var stu = yunEntities.YD_Sts_StuInfo.Include(x => x.YD_Edu_Major).FirstOrDefault(x => x.id == LoginId);
         stu.y_isgraduate             = true;
         yunEntities.Entry(stu).State = EntityState.Modified;
         int r = yunEntities.SaveChanges();
         if (r > 0)
         {
             return("ok");
         }
         else
         {
             return("设置失败");
         }
     }
 }
        public string UpdateStuStrange(YD_Sts_StuStrange stra)
        {
            using (var yunEntity = new IYunEntities())
            {
                var stu = yunEntity.YD_Sts_StuInfo.Find(stra.y_stuId);
                if (stu == null)
                {
                    return("修改信息失败,目标学生不存在!");
                }
                if (stra.y_contentA != null)
                {
                    var nationid = Convert.ToInt32(stra.y_contentA);
                    if (!yunEntity.YD_Sts_Nation.Any(u => u.id == nationid))
                    {
                        return("改民族失败,目标民族不存在!");
                    }
                    stu.y_nationId = nationid;
                }
                if (stra.y_contentI != null)
                {
                    stu.y_name = stra.y_contentI;
                }
                if (stra.y_contentG != null)
                {
                    stu.y_cardId = stra.y_contentG;
                }
                if (stra.y_contentC != null)
                {
                    var sex = Convert.ToInt32(stra.y_contentC);
                    stu.y_sex = sex;
                }
                if (stra.y_contentE != null)
                {
                    var birstry = Convert.ToDateTime(stra.y_contentE);
                    stu.y_birthday = birstry;
                }

                stra.y_isExecutive   = (int)YesOrNo.Yes;
                stra.y_ExecutiveTime = DateTime.Now;
                return(yunEntity.SaveChanges() > 0 ? "ok" : "未知错误!");
            }
        }
 public string TrunChangeSchool(YD_Sts_StuStrange stra)
 {
     using (var yunEntity = new IYunEntities())
     {
         var schoolid = Convert.ToInt32(stra.y_contentB);
         if (!yunEntity.YD_Sys_SubSchool.Any(u => u.id == schoolid))
         {
             return("转函授站失败,目标函授站不存在!");
         }
         var stu = yunEntity.YD_Sts_StuInfo.Find(stra.y_stuId);
         if (stu == null)
         {
             return("转函授站失败,目标学生不存在!");
         }
         stu.y_subSchoolId    = schoolid;
         stra.y_isExecutive   = (int)YesOrNo.Yes;
         stra.y_ExecutiveTime = DateTime.Now;
         return(yunEntity.SaveChanges() > 0 ? "ok" : "未知错误!");
     }
 }
 public string TrunChangeMajor(YD_Sts_StuStrange stra)
 {
     using (var yunEntities = new IYunEntities())
     {
         var majorid = Convert.ToInt32(stra.y_contentB);
         if (!yunEntities.YD_Edu_Major.Any(u => u.id == majorid))
         {
             return("转专业失败,目标专业不存在!");
         }
         var stu = yunEntities.YD_Sts_StuInfo.Find(stra.y_stuId);
         if (stu == null)
         {
             return("转专业失败,目标学生不存在!");
         }
         stu.y_majorId        = majorid;
         stra.y_isExecutive   = (int)YesOrNo.Yes;
         stra.y_ExecutiveTime = DateTime.Now;
         return(yunEntities.SaveChanges() > 0 ? "ok" : "未知错误!");
     }
 }
 /// <summary>
 /// 将成绩数据进行导入
 /// </summary>
 /// <returns></returns>
 public string UploadScore(List <QingShuStuScore> scores)
 {
     scores = scores.Where(u => u.examScore != 0m).ToList();//未参加考试的成绩不同步
     using (var yunEntities = new IYunEntities())
     {
         var scoreList = new List <YD_Edu_Score>();
         for (var i = 0; i < scores.Count; i++)
         {
             var score    = new YD_Edu_Score();
             var courseId = scores[i].courseId;
             var obj      = yunEntities.YD_Edu_QingCourse.FirstOrDefault(u => u.y_qingId == courseId);
             if (obj == null)
             {
                 continue;
             }
             score.y_courseId    = obj.y_nid;
             score.y_normalScore = scores[i].usualScore;
             score.y_termScore   = scores[i].examScore;
             score.y_totalScore  = scores[i].finalScore;
             var stuId = scores[i].studentId;
             var stu   = yunEntities.YD_Edu_QingStuInfo.FirstOrDefault(u => u.y_qingId == stuId);
             if (stu == null)
             {
                 continue;
             }
             score.y_stuId = stu.y_nid;
             score.y_term  = scores[i].term;
             if (!yunEntities.YD_Edu_Score.Any(u => u.y_courseId == obj.y_nid && u.y_stuId == stu.y_nid && u.y_term == score.y_term))//本地已有的成绩不同步
             {
                 scoreList.Add(score);
             }
         }
         yunEntities.Configuration.AutoDetectChangesEnabled = false;
         yunEntities.Configuration.ValidateOnSaveEnabled    = false;
         yunEntities.Set <YD_Edu_Score>().AddRange(scoreList);
         yunEntities.SaveChanges();
         //yunEntities.BulkInsert(scoreList);
         //yunEntities.BulkSaveChanges();
         return("同步完成");
     }
 }
Example #26
0
        /// <summary>
        /// 批量删除对象集合
        /// </summary>
        /// <param name="list">要删除的对象集合</param>
        /// <param name="moduleUrl">操作该方法的栏目url(例:/SysAdmin/Site)</param>
        /// <param name="yunEntities"></param>
        /// <returns>信息集对象</returns>
        public ResultInfo BaseDeleteEntities(List <T> list, string moduleUrl, IYunEntities yunEntities)
        {
            var resultInfo = new ResultInfo {
                Info = Safe(moduleUrl, PowerFlag.Delete)
            };

            switch (resultInfo.Info)
            {
            case PowerInfo.NoPower:
                resultInfo.Success = false;
                resultInfo.Message = "没有权限";
                return(resultInfo);

            case PowerInfo.NoLogin:
                resultInfo.Success = false;
                resultInfo.Message = "没有登录";
                return(resultInfo);

            case PowerInfo.Unknow:
                resultInfo.Success = false;
                resultInfo.Message = "未知错误";
                return(resultInfo);

            case PowerInfo.HasPower:
                break;

            default:
                resultInfo.Success = false;
                resultInfo.Message = "未知错误";
                return(resultInfo);
            }

            foreach (var entity in list)
            {
                yunEntities.Entry(entity).State = EntityState.Deleted;
            }
            resultInfo.Success = yunEntities.SaveChanges() > 0;
            resultInfo.Message = "";
            return(resultInfo);
        }
Example #27
0
        /// <summary>
        /// 删除课程
        /// </summary>
        /// <param name="id">课程id</param>
        /// <param name="yunEntities">EF上下文对象</param>
        /// <returns></returns>
        public string EntityDelete(int id, IYunEntities yunEntities)
        {
            var course = yunEntities.YD_Edu_Course.FirstOrDefault(u => u.id == id);

            if (course != null)
            {
                if (course.YD_Edu_TeachplanDes.Count != 0)
                {
                    return("该类型不能删除,其已经关联了指定教学计划");
                }
                var adminCourse = yunEntities.YD_Sys_AdminCourseLink.Where(u => u.y_courseId == id).ToList();
                for (int j = 0; j < adminCourse.Count; j++)
                {
                    yunEntities.Entry(adminCourse[j]).State = EntityState.Deleted;
                }
                yunEntities.Entry(course).State = EntityState.Deleted;
                LogHelper.DbLog(Convert.ToInt32(HttpContext.Current.Session[KeyValue.Admin_id]), HttpContext.Current.Session[KeyValue.Admin_Name].ToString(), (int)LogType.Delete, "删除课程,课程名为" + course.y_name + ",id:" + course.id);
            }
            var i = yunEntities.SaveChanges();

            return(i > 0 ? "ok" : "删除课程失败");
        }
Example #28
0
        /// <summary>
        /// 新增一个实体对象
        /// </summary>
        /// <param name="entity">要新增的实体对象</param>
        /// <param name="moduleUrl">操作该方法的栏目url(例:/SysAdmin/Site)</param>
        /// <param name="yunEntities"></param>
        /// <returns>信息集对象</returns>
        public ResultInfo BaseAddEntity(T entity, string moduleUrl, IYunEntities yunEntities)
        {
            var resultInfo = new ResultInfo {
                Info = Safe(moduleUrl, PowerFlag.Insert)
            };

            switch (resultInfo.Info)
            {
            case PowerInfo.NoPower:
                resultInfo.Success = false;
                resultInfo.Message = "没有权限";
                return(resultInfo);

            case PowerInfo.NoLogin:
                resultInfo.Success = false;
                resultInfo.Message = "没有登录";
                return(resultInfo);

            case PowerInfo.Unknow:
                resultInfo.Success = false;
                resultInfo.Message = "未知错误";
                return(resultInfo);

            case PowerInfo.HasPower:
                break;

            default:
                resultInfo.Success = false;
                resultInfo.Message = "未知错误";
                return(resultInfo);
            }
            yunEntities.Set <T>().Add(entity);
            yunEntities.Configuration.AutoDetectChangesEnabled = false;
            yunEntities.Configuration.ValidateOnSaveEnabled    = false;
            resultInfo.Success = yunEntities.SaveChanges() > 0;
            resultInfo.Message = "";
            return(resultInfo);
        }
        /// <summary>
        /// 删除层次类型
        /// </summary>
        /// <param name="id">层次类型id</param>
        /// <param name="yunEntities">EF上下文对象</param>
        /// <returns></returns>
        public string EntityDelete(int id, IYunEntities yunEntities)
        {
            var module = yunEntities.YD_Edu_TeachPlan.FirstOrDefault(u => u.id == id);

            if (module != null)
            {
                var majorTeachPlanList = module.YD_Edu_MajorTeachPlan.ToList();
                for (var j = 0; j < majorTeachPlanList.Count; j++)
                {
                    yunEntities.Entry(majorTeachPlanList[j]).State = EntityState.Deleted;
                }
                var teachPlanDesList = module.YD_Edu_TeachplanDes.ToList();
                for (var j = 0; j < teachPlanDesList.Count; j++)
                {
                    yunEntities.Entry(teachPlanDesList[j]).State = EntityState.Deleted;
                }
                yunEntities.Entry(module).State = EntityState.Deleted;
                LogHelper.DbLog(Convert.ToInt32(HttpContext.Current.Session[KeyValue.Admin_id]), HttpContext.Current.Session[KeyValue.Admin_Name].ToString(), (int)LogType.Delete, "删除教学计划,教学计划名为" + module.y_teaPlanName + ",id:" + module.id);
            }
            var i = yunEntities.SaveChanges();

            return(i > 0 ? "ok" : "删除教学计划失败");
        }
 public JsonResult FileDelete(int?id)
 {
     if (id > 0)
     {
         using (var yunEntities = new IYunEntities())
         {
             var me = yunEntities.YD_Sys_File.FirstOrDefault(u => u.id == id);
             yunEntities.YD_Sys_File.Remove(me);
             var j = yunEntities.SaveChanges();
             if (j > 0)
             {
                 return(Json(true));
             }
             else
             {
                 return(Json("删除失败"));
             }
         }
     }
     else
     {
         return(Json("id不能为空"));
     }
 }