/// <summary> /// 检测是否能报名 /// </summary> /// <param name="ClassId"></param> /// <returns></returns> public static bool CheckCanEnroll(int ClassId) { Class_Detail class_Detail = new Class_Detail(); Member_ClassRegisterBLL member_ClassRegisterBLL = new Member_ClassRegisterBLL(); Member_ClassRegister member_ClassRegister = new Member_ClassRegister(); member_ClassRegister.ClassId = ClassId; member_ClassRegister.PlanId = Code.SiteCache.Instance.PlanId; Class_DetailBLL class_DetailBLL = new Class_DetailBLL(); member_ClassRegister.TrainingId = class_DetailBLL.GetModel(ClassId).TraningId; member_ClassRegister.AccountId = Code.SiteCache.Instance.LoginInfo.UserId; member_ClassRegister.Status = 1; member_ClassRegister.ManagerId = Code.SiteCache.Instance.LoginInfo.UserId; member_ClassRegister.Delflag = false; member_ClassRegister.CreateDate = DateTime.Now; Course_UnitDetailBLL course_UnitDetailBLL = new Course_UnitDetailBLL(); member_ClassRegister.TotalSchedule = course_UnitDetailBLL.GetList(" TrainingId='" + class_DetailBLL.GetModel(ClassId).TraningId + "' and ParentId=0 and Display=1 and Delflag='false'", "").Count; List<Member_ClassRegister> listno = member_ClassRegisterBLL.GetList(" ClassId='" + ClassId + "' and AccountId='" + Code.SiteCache.Instance.LoginInfo.UserId + "' and delflag='false' and Status in (1,2,4)", ""); if (listno.Count > 0) { return false; } //List<Member_ClassRegister> listpass = member_ClassRegisterBLL.GetList(" TrainingId='" + member_ClassRegister.TrainingId + "' and AccountId='" + Code.SiteCache.Instance.LoginInfo.UserId + "' and delflag='false' and (Result=1 or (Result is NULL and Status=4))", ""); //if (listpass.Count > 0) //{ // return false; //} return true; }
/// <summary> /// 获取数据集 /// </summary> /// <param name="where"></param> /// <param name="orderBy"></param> /// <returns></returns> public List<Class_Detail> GetList(string where, string orderBy) { StringBuilder sql = new StringBuilder(); sql.Append("select * from [dbo].[Class_Detail]"); if (!string.IsNullOrEmpty(where)) sql.Append(" where " + where); if (!string.IsNullOrEmpty(orderBy)) sql.Append(" order by " + orderBy); List<Class_Detail> list = new List<Class_Detail>(); using (IDataReader reader = MSEntLibSqlHelper.ExecuteDataReaderBySql(sql.ToString())) { while (reader.Read()) { Class_Detail model = new Class_Detail(); ConvertToModel(reader, model); list.Add(model); } } return list; }
/// <summary> /// 新增一条记录 /// </summary> /// <param name="model"></param> /// <returns></returns> public int Add(Class_Detail model) { StringBuilder sql = new StringBuilder(); sql.Append("insert into [dbo].[Class_Detail] ([Title],[TraningId],[PlanId],[SignUpStartTime],[SignUpEndTime],[OpenClassFrom],[OpenClassTo],[ClassForm],[People],[LimitPeopleCnt],[Address],[Content],[ManagerId],[OrganId],[Subject],[StudyLevel],[TeachGrade],[TeachRank],[OrganRange],[Instructor],[Status],[ApplyRemark],[Display],[Delflag],[CreateDate],[PartitionId])"); sql.Append(" values (@Title,@TraningId,@PlanId,@SignUpStartTime,@SignUpEndTime,@OpenClassFrom,@OpenClassTo,@ClassForm,@People,@LimitPeopleCnt,@Address,@Content,@ManagerId,@OrganId,@Subject,@StudyLevel,@TeachGrade,@TeachRank,@OrganRange,@Instructor,@Status,@ApplyRemark,@Display,@Delflag,@CreateDate,@PartitionId)"); sql.Append(" set @Id=@@IDENTITY"); SqlParameter[] cmdParams = new SqlParameter[]{ new SqlParameter("@Id", SqlDbType.Int, 4) { Value = model.Id, Direction = ParameterDirection.Output }, new SqlParameter("@Title", SqlDbType.VarChar, 200) { Value = model.Title }, new SqlParameter("@TraningId", SqlDbType.Int, 4) { Value = model.TraningId }, new SqlParameter("@PlanId", SqlDbType.Int, 4) { Value = model.PlanId }, new SqlParameter("@SignUpStartTime", SqlDbType.DateTime, 8) { Value = model.SignUpStartTime }, new SqlParameter("@SignUpEndTime", SqlDbType.DateTime, 8) { Value = model.SignUpEndTime }, new SqlParameter("@OpenClassFrom", SqlDbType.DateTime, 8) { Value = model.OpenClassFrom }, new SqlParameter("@OpenClassTo", SqlDbType.DateTime, 8) { Value = model.OpenClassTo }, new SqlParameter("@ClassForm", SqlDbType.Int, 4) { Value = model.ClassForm }, new SqlParameter("@People", SqlDbType.Int, 4) { Value = model.People }, new SqlParameter("@LimitPeopleCnt", SqlDbType.Int, 4) { Value = model.LimitPeopleCnt }, new SqlParameter("@Address", SqlDbType.VarChar, 200) { Value = model.Address }, new SqlParameter("@Content", SqlDbType.VarChar, 500) { Value = model.Content }, new SqlParameter("@ManagerId", SqlDbType.Int, 4) { Value = model.ManagerId }, new SqlParameter("@OrganId", SqlDbType.Int, 4) { Value = model.OrganId }, new SqlParameter("@Subject", SqlDbType.VarChar, 200) { Value = model.Subject }, new SqlParameter("@StudyLevel", SqlDbType.VarChar, 200) { Value = model.StudyLevel }, new SqlParameter("@TeachGrade", SqlDbType.VarChar, 200) { Value = model.TeachGrade }, new SqlParameter("@TeachRank", SqlDbType.VarChar, 200) { Value = model.TeachRank }, new SqlParameter("@OrganRange", SqlDbType.VarChar, 500) { Value = model.OrganRange }, new SqlParameter("@Instructor", SqlDbType.Int, 4) { Value = model.Instructor }, new SqlParameter("@Status", SqlDbType.Int, 4) { Value = model.Status }, new SqlParameter("@ApplyRemark", SqlDbType.VarChar, 500) { Value = model.ApplyRemark }, new SqlParameter("@Display", SqlDbType.Bit, 1) { Value = model.Display }, new SqlParameter("@Delflag", SqlDbType.Bit, 1) { Value = model.Delflag }, new SqlParameter("@CreateDate", SqlDbType.DateTime, 8) { Value = model.CreateDate }, new SqlParameter("@PartitionId", SqlDbType.Int, 4) { Value = model.PartitionId } }; int result = Convert.ToInt32(MSEntLibSqlHelper.ExecuteNonQueryBySql(sql.ToString(), cmdParams)); model.Id = Convert.ToInt32(cmdParams[0].Value); return result; }
/// <summary> /// 更新一条记录 /// </summary> /// <param name="model"></param> /// <returns></returns> public int Update(Class_Detail model) { StringBuilder sql = new StringBuilder(); sql.Append("update [dbo].[Class_Detail] set "); sql.Append("[Title]=@Title,[TraningId]=@TraningId,[PlanId]=@PlanId,[SignUpStartTime]=@SignUpStartTime,[SignUpEndTime]=@SignUpEndTime,[OpenClassFrom]=@OpenClassFrom,[OpenClassTo]=@OpenClassTo,[ClassForm]=@ClassForm,[People]=@People,[LimitPeopleCnt]=@LimitPeopleCnt,[Address]=@Address,[Content]=@Content,[ManagerId]=@ManagerId,[OrganId]=@OrganId,[Subject]=@Subject,[StudyLevel]=@StudyLevel,[TeachGrade]=@TeachGrade,[TeachRank]=@TeachRank,[OrganRange]=@OrganRange,[Instructor]=@Instructor,[Status]=@Status,[ApplyRemark]=@ApplyRemark,[Display]=@Display,[Delflag]=@Delflag,[CreateDate]=@CreateDate,[PartitionId]=@PartitionId"); sql.Append(" where [Id]=@Id"); SqlParameter[] cmdParams = new SqlParameter[] { new SqlParameter("@Id", SqlDbType.Int, 4) { Value = model.Id }, new SqlParameter("@Title", SqlDbType.VarChar, 200) { Value = model.Title }, new SqlParameter("@TraningId", SqlDbType.Int, 4) { Value = model.TraningId }, new SqlParameter("@PlanId", SqlDbType.Int, 4) { Value = model.PlanId }, new SqlParameter("@SignUpStartTime", SqlDbType.DateTime, 8) { Value = model.SignUpStartTime }, new SqlParameter("@SignUpEndTime", SqlDbType.DateTime, 8) { Value = model.SignUpEndTime }, new SqlParameter("@OpenClassFrom", SqlDbType.DateTime, 8) { Value = model.OpenClassFrom }, new SqlParameter("@OpenClassTo", SqlDbType.DateTime, 8) { Value = model.OpenClassTo }, new SqlParameter("@ClassForm", SqlDbType.Int, 4) { Value = model.ClassForm }, new SqlParameter("@People", SqlDbType.Int, 4) { Value = model.People }, new SqlParameter("@LimitPeopleCnt", SqlDbType.Int, 4) { Value = model.LimitPeopleCnt }, new SqlParameter("@Address", SqlDbType.VarChar, 200) { Value = model.Address }, new SqlParameter("@Content", SqlDbType.VarChar, 500) { Value = model.Content }, new SqlParameter("@ManagerId", SqlDbType.Int, 4) { Value = model.ManagerId }, new SqlParameter("@OrganId", SqlDbType.Int, 4) { Value = model.OrganId }, new SqlParameter("@Subject", SqlDbType.VarChar, 200) { Value = model.Subject }, new SqlParameter("@StudyLevel", SqlDbType.VarChar, 200) { Value = model.StudyLevel }, new SqlParameter("@TeachGrade", SqlDbType.VarChar, 200) { Value = model.TeachGrade }, new SqlParameter("@TeachRank", SqlDbType.VarChar, 200) { Value = model.TeachRank }, new SqlParameter("@OrganRange", SqlDbType.VarChar, 500) { Value = model.OrganRange }, new SqlParameter("@Instructor", SqlDbType.Int, 4) { Value = model.Instructor }, new SqlParameter("@Status", SqlDbType.Int, 4) { Value = model.Status }, new SqlParameter("@ApplyRemark", SqlDbType.VarChar, 500) { Value = model.ApplyRemark }, new SqlParameter("@Display", SqlDbType.Bit, 1) { Value = model.Display }, new SqlParameter("@Delflag", SqlDbType.Bit, 1) { Value = model.Delflag }, new SqlParameter("@CreateDate", SqlDbType.DateTime, 8) { Value = model.CreateDate }, new SqlParameter("@PartitionId", SqlDbType.Int, 4) { Value = model.PartitionId } }; return MSEntLibSqlHelper.ExecuteNonQueryBySql(sql.ToString(), cmdParams); }
/// <summary> /// 取得一条记录 /// </summary> /// <param name="id"></param> /// <param name="where"></param> /// <returns></returns> public Class_Detail GetModel(int id, string where) { string sql = "select * from [dbo].[Class_Detail] where [Id]=@Id"; if (!string.IsNullOrEmpty(where)) sql += " and " + where; SqlParameter[] cmdParams = new SqlParameter[]{ new SqlParameter("@Id", SqlDbType.Int, 4) { Value = id } }; using (IDataReader reader = MSEntLibSqlHelper.ExecuteDataReaderBySql(sql, cmdParams)) { if (reader.Read()) { Class_Detail model = new Class_Detail(); ConvertToModel(reader, model); return model; } else { return null; } } }
public JsonResult CreateClass(string Title, string TraningId, string PlanId, string SignUpStartTime, string SignUpEndTime , string OpenClassFrom, string OpenClassTo, string ClassForm, string People, string LimitPeopleCnt, string Address , string Content, string Subject, string StudyLevel, string TeachGrade, string TeachRank, string OrganRange , string OrganId, string Status, string PartitionId) { try { var model = new Dianda.AP.Model.Class_Detail(); model.Title = Title; model.TraningId = TraningId.ToInt(); model.PlanId = PlanId.ToInt(); model.SignUpStartTime = SignUpStartTime.ToDateTime(); model.SignUpEndTime = SignUpEndTime.ToDateTime(); model.OpenClassFrom = OpenClassFrom.ToDateTime(); model.OpenClassTo = OpenClassTo.ToDateTime(); model.ClassForm = ClassForm.ToInt(); model.People = People.ToInt(); model.LimitPeopleCnt = LimitPeopleCnt.ToInt(); model.Address = Address; model.Content = Content; model.Subject = Subject.Contains("all") ? true : false; model.StudyLevel = StudyLevel.Contains("all") ? true : false; ; model.TeachGrade = TeachGrade.Contains("all") ? true : false; ; model.TeachRank = TeachRank.Contains("all") ? true : false; model.OrganRange = OrganRange.Contains("all") ? "0" : OrganRange; ; model.ManagerId = SiteCache.Instance.ManagerId; model.Status = Status.ToInt(); model.CreateDate = DateTime.Now; model.OrganId = OrganId.ToInt(); model.PartitionId = PartitionId.ToInt(); model.Display = true; var bll = new Dianda.AP.BLL.Class_DetailBLL(); var cid = bll.Add(model); if (!model.Subject)//不是全部则建立关联数据 { var arr = Subject.Split(','); var subject = new Class_TeachSubjectBLL(); foreach (var item in arr) { var classSubject = new Dianda.AP.Model.Class_TeachSubject(); classSubject.ClassId = cid; classSubject.CreateDate = DateTime.Now; classSubject.Delflag = false; classSubject.TeachSubject = item.ToInt(); subject.Add(classSubject); } } if (!model.StudyLevel)//不是全部则建立关联数据 { var arr = StudyLevel.Split(','); foreach (var item in arr) { var section = new Class_StudySectionBLL(); var teachSection = new Dianda.AP.Model.Class_StudySection(); teachSection.ClassId = cid; teachSection.CreateDate = DateTime.Now; teachSection.Delflag = false; teachSection.StudySection = item.ToInt(); section.Add(teachSection); } } if (!model.TeachGrade)//不是全部则建立关联数据 { var arr = TeachGrade.Split(','); var section = new Class_TeachGradeBLL(); foreach (var item in arr) { var classSection = new Dianda.AP.Model.Class_TeachGrade(); classSection.ClassId = cid; classSection.CreateDate = DateTime.Now; classSection.Delflag = false; classSection.TeachGrade = item.ToInt(); section.Add(classSection); } } if (!model.TeachRank)//不是全部则建立关联数据 { var arr = TeachRank.Split(','); var section = new Class_TeachRankBLL(); foreach (var item in arr) { var classSection = new Dianda.AP.Model.Class_TeachRank(); classSection.ClassId = cid; classSection.CreateDate = DateTime.Now; classSection.Delflag = false; classSection.TeachRank = item.ToInt(); section.Add(classSection); } } if (Status == "2")//为提交状态时,新建审核记录 { var apply = new Dianda.AP.Model.Class_ApplyApplication(); apply.ClassId = cid; apply.AccountId = SiteCache.Instance.LoginInfo.UserId; apply.Remark = "提交审核"; apply.CreateDate = DateTime.Now; var applyBll = new Class_ApplyApplicationBLL(); applyBll.Add(apply); } return Json(new { Code = 0, Msg = "提交成功" }, JsonRequestBehavior.AllowGet); } catch (Exception ex) { return Json(new { Code = -1, Msg = ex.Message }, JsonRequestBehavior.AllowGet); } }
public JsonResult MyVerifyAll(int Status, string Ids) { try { string[] myIds = Ids.Trim(',').Split(','); foreach (string Id in myIds) { Member_ClassRegisterBLL member_ClassRegisterBLL = new Member_ClassRegisterBLL(); Member_ClassRegister member_ClassRegister = new Member_ClassRegister(); member_ClassRegister = member_ClassRegisterBLL.GetModel(Convert.ToInt32(Id), ""); if ((Status == 3 && member_ClassRegister.Status != 3) || (Status == 5 && member_ClassRegister.Status != 5)) { Class_DetailBLL class_DetailBLL = new Class_DetailBLL(); Class_Detail class_Detail = new Class_Detail(); class_Detail = class_DetailBLL.GetModel(member_ClassRegister.ClassId); class_Detail.People -= 1; class_DetailBLL.Update(class_Detail); } else if ((Status == 2 && member_ClassRegister.Status == 3) || (Status == 4 && member_ClassRegister.Status == 5) || (Status == 2 && member_ClassRegister.Status == 5)) { Class_DetailBLL class_DetailBLL = new Class_DetailBLL(); Class_Detail class_Detail = new Class_Detail(); class_Detail = class_DetailBLL.GetModel(member_ClassRegister.ClassId); class_Detail.People += 1; class_DetailBLL.Update(class_Detail); } member_ClassRegister.Status = Status; member_ClassRegisterBLL.Update(member_ClassRegister); Member_ClassRegisterApplicationBLL member_ClassRegisterApplicationBLL = new Member_ClassRegisterApplicationBLL(); Member_ClassRegisterApplication member_ClassRegisterApplication = new Member_ClassRegisterApplication(); member_ClassRegisterApplication.ClassRegisterId = Convert.ToInt32(Id); member_ClassRegisterApplication.Status = Status; member_ClassRegisterApplication.Creater = Code.SiteCache.Instance.LoginInfo.UserId; member_ClassRegisterApplication.Delflag = false; member_ClassRegisterApplication.CreateDate = DateTime.Now; member_ClassRegisterApplicationBLL.Add(member_ClassRegisterApplication); } return Json(new { Code = 0, Msg = "提交成功" }, JsonRequestBehavior.AllowGet); } catch (Exception ex) { return Json(new { Code = -1, Msg = ex.Message }, JsonRequestBehavior.AllowGet); } }
/// <summary> /// 更新一条记录 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool Update(Class_Detail model) { return dal.Update(model) > 0; }
/// <summary> /// 获取分页数据集 /// </summary> /// <param name="pageSize"></param> /// <param name="pageIndex"></param> /// <param name="where"></param> /// <param name="orderBy"></param> /// <param name="recordCount"></param> /// <returns></returns> public List<Class_Detail> GetList(int pageSize, int pageIndex, string where, string orderBy, out int recordCount) { if (string.IsNullOrEmpty(orderBy)) throw new ArgumentNullException(); StringBuilder sb = new StringBuilder(); sb.Append("select count(1) from [dbo].[Class_Detail]"); if (!string.IsNullOrEmpty(where)) sb.Append(" where " + where); recordCount = Convert.ToInt32(MSEntLibSqlHelper.ExecuteScalarBySql(sb.ToString())); int start = (pageIndex - 1) * pageSize + 1; int end = pageIndex * pageSize; StringBuilder sql = new StringBuilder(); sql.Append("select * from (select *,ROW_NUMBER() over (order by " + orderBy + ") as [RowNum] from [dbo].[Class_Detail]"); if (!string.IsNullOrEmpty(where)) sql.Append(" where " + where); sql.Append(") as T where [RowNum] between " + start + " and " + end); List<Class_Detail> list = new List<Class_Detail>(); using (IDataReader reader = MSEntLibSqlHelper.ExecuteDataReaderBySql(sql.ToString())) { while (reader.Read()) { Class_Detail model = new Class_Detail(); ConvertToModel(reader, model); list.Add(model); } } return list; }
public ActionResult CoursemarketVerifyPage(int Id) { int groupId = Code.SiteCache.Instance.GroupId;//4,学校管理7,普通教师 ViewData["groupId"] = groupId; ViewData["mId"] = Id; ViewBag.Title = "报名审核"; Member_ClassRegisterBLL member_ClassRegisterBLL = new Member_ClassRegisterBLL(); Member_ClassRegister member_ClassRegister = new Member_ClassRegister(); member_ClassRegister = member_ClassRegisterBLL.GetModel(Id, ""); Class_DetailBLL class_DetailBLL = new Class_DetailBLL(); Class_Detail class_Detail = new Class_Detail(); class_Detail = class_DetailBLL.GetModel(member_ClassRegister.ClassId); Member_AccountBLL member_AccountBLL = new Member_AccountBLL(); ViewBag.AcountInfo = member_AccountBLL.GetModel(member_ClassRegister.AccountId, ""); Member_BaseInfoBLL member_BaseInfoBLL = new Member_BaseInfoBLL(); ViewBag.BaseInfo = member_BaseInfoBLL.GetModelByAccountId(member_ClassRegister.AccountId); Member_ClassRegisterApplicationBLL member_ClassRegisterApplicationBLL = new Member_ClassRegisterApplicationBLL(); ViewBag.CApplicationList = member_ClassRegisterApplicationBLL.GetList(" Delflag='false' and ClassRegisterId='" + member_ClassRegister.Id + "'", "CreateDate"); return View(class_Detail); }
public ActionResult CoursemarketSingleEnroll(int Id) { ViewBag.Title = "课程报名"; Class_DetailBLL class_DetailBLL = new Class_DetailBLL(); Class_Detail class_Detail = new Class_Detail(); class_Detail = class_DetailBLL.GetModel(Id); return View(class_Detail); }
public JsonResult ClassRegisterAll(int ClassId, string Members, string MembersNames) { Class_DetailBLL class_DetailBLL = new Class_DetailBLL(); string[] members = Members.Trim().Substring(1, Members.Length - 2).Split(','); string[] membersNames = MembersNames.Trim().Substring(1, MembersNames.Length - 2).Split(','); string names = ""; string namespass = ""; string namescannotmessage = ""; string message = ""; for (int i = 0; i < members.Length; i++) { Member_ClassRegisterBLL member_ClassRegisterBLL = new Member_ClassRegisterBLL(); Member_ClassRegister member_ClassRegister = new Member_ClassRegister(); List<Member_ClassRegister> listno = member_ClassRegisterBLL.GetList(" ClassId='" + ClassId + "' and AccountId='" + members[i] + "' and delflag='false' and Status in (1,2,4)", ""); if (listno.Count > 0) { names += membersNames[i] + ","; } List<Member_ClassRegister> listpass = member_ClassRegisterBLL.GetList(" TrainingId='" + member_ClassRegister.TrainingId + "' and AccountId='" + members[i] + "' and delflag='false' and (Result=1 or (Result is NULL and Status in(1,2,4)))", ""); if (listpass.Count > 0) { namespass += membersNames[i] + ","; } string checkmessage = IsCanRegisterAll(ClassId, false, Convert.ToInt32(members[i])); if (checkmessage != "") { namescannotmessage += membersNames[i] + checkmessage; } } if (names != "") { message += names.Trim(',') + "已报名该课程;"; } if (namespass != "") { message += namespass.Trim(',') + "已学过该课程;"; } if (namescannotmessage != "") { message += namescannotmessage; } if (message != "") { return Json(new { Code = -1, Msg = message }, JsonRequestBehavior.AllowGet); } else { Class_Detail class_Detail = new Class_Detail(); class_Detail = class_DetailBLL.GetModel(ClassId); class_Detail.People += members.Length; class_DetailBLL.Update(class_Detail); for (int i = 0; i < members.Length; i++) { Member_ClassRegisterBLL member_ClassRegisterBLL = new Member_ClassRegisterBLL(); Member_ClassRegister member_ClassRegister = new Member_ClassRegister(); member_ClassRegister.ClassId = ClassId; member_ClassRegister.PlanId = Code.SiteCache.Instance.PlanId; member_ClassRegister.TrainingId = class_DetailBLL.GetModel(ClassId).TraningId; member_ClassRegister.AccountId = Convert.ToInt32(members[i]); member_ClassRegister.Status = 2; member_ClassRegister.BatchCode = Guid.NewGuid(); member_ClassRegister.ManagerId = Code.SiteCache.Instance.LoginInfo.UserId; member_ClassRegister.Delflag = false; member_ClassRegister.CreateDate = DateTime.Now; Course_UnitDetailBLL course_UnitDetailBLL = new Course_UnitDetailBLL(); member_ClassRegister.TotalSchedule = course_UnitDetailBLL.GetList(" TrainingId='" + class_DetailBLL.GetModel(ClassId).TraningId + "' and ParentId=0 and Display=1 and Delflag='false'", "").Count; List<Member_ClassRegister> listup = member_ClassRegisterBLL.GetList(" ClassId='" + ClassId + "' and AccountId='" + members[i] + "' and delflag='false' and Status in (3,5)", ""); if (listup.Count > 0) { member_ClassRegister.Id = listup[0].Id; member_ClassRegister.Status = 2; member_ClassRegisterBLL.Update(member_ClassRegister); if (member_ClassRegister.Id > 0) { Member_ClassRegisterApplicationBLL member_ClassRegisterApplicationBLL = new Member_ClassRegisterApplicationBLL(); Member_ClassRegisterApplication member_ClassRegisterApplication = new Member_ClassRegisterApplication(); member_ClassRegisterApplication.ClassRegisterId = member_ClassRegister.Id; member_ClassRegisterApplication.Status = 2; member_ClassRegisterApplication.Creater = Code.SiteCache.Instance.LoginInfo.UserId; member_ClassRegisterApplication.CreateDate = DateTime.Now; member_ClassRegisterApplication.Delflag = false; member_ClassRegisterApplicationBLL.Add(member_ClassRegisterApplication); } else { return Json(new { Code = -1, Msg = "提交失败" }, JsonRequestBehavior.AllowGet); } } else { int RegisterId = member_ClassRegisterBLL.Add(member_ClassRegister); if (RegisterId > 0) { Member_ClassRegisterApplicationBLL member_ClassRegisterApplicationBLL = new Member_ClassRegisterApplicationBLL(); Member_ClassRegisterApplication member_ClassRegisterApplication = new Member_ClassRegisterApplication(); member_ClassRegisterApplication.ClassRegisterId = RegisterId; member_ClassRegisterApplication.Status = 2; member_ClassRegisterApplication.Creater = Code.SiteCache.Instance.LoginInfo.UserId; member_ClassRegisterApplication.CreateDate = DateTime.Now; member_ClassRegisterApplication.Delflag = false; member_ClassRegisterApplicationBLL.Add(member_ClassRegisterApplication); } else { return Json(new { Code = -1, Msg = "提交失败" }, JsonRequestBehavior.AllowGet); } } } } return Json(new { Code = 0, Msg = "提交成功" }, JsonRequestBehavior.AllowGet); }
public JsonResult ClassRegister(int ClassId) { Class_Detail class_Detail = new Class_Detail(); Member_ClassRegisterBLL member_ClassRegisterBLL = new Member_ClassRegisterBLL(); Member_ClassRegister member_ClassRegister = new Member_ClassRegister(); member_ClassRegister.ClassId = ClassId; member_ClassRegister.PlanId = Code.SiteCache.Instance.PlanId; Class_DetailBLL class_DetailBLL = new Class_DetailBLL(); member_ClassRegister.TrainingId = class_DetailBLL.GetModel(ClassId).TraningId; member_ClassRegister.AccountId = Code.SiteCache.Instance.LoginInfo.UserId; member_ClassRegister.Status = 1; member_ClassRegister.ManagerId = Code.SiteCache.Instance.LoginInfo.UserId; member_ClassRegister.Delflag = false; member_ClassRegister.CreateDate = DateTime.Now; Course_UnitDetailBLL course_UnitDetailBLL = new Course_UnitDetailBLL(); member_ClassRegister.TotalSchedule = course_UnitDetailBLL.GetList(" TrainingId='" + class_DetailBLL.GetModel(ClassId).TraningId + "' and ParentId=0 and Display=1 and Delflag='false'", "").Count; //if (!IsCanRegister(ClassId, true, Code.SiteCache.Instance.LoginInfo.UserId)) string checkmessage = IsCanRegisterAll(ClassId, true, Code.SiteCache.Instance.LoginInfo.UserId); if (checkmessage != "") { return Json(new { Code = -1, Msg = checkmessage }, JsonRequestBehavior.AllowGet); } List<Member_ClassRegister> listno = member_ClassRegisterBLL.GetList(" ClassId='" + ClassId + "' and AccountId='" + Code.SiteCache.Instance.LoginInfo.UserId + "' and delflag='false' and Status in (1,2,4)", ""); if (listno.Count > 0) { return Json(new { Code = -1, Msg = "您已经提交了报名申请" }, JsonRequestBehavior.AllowGet); } List<Member_ClassRegister> listpass = member_ClassRegisterBLL.GetList(" TrainingId='" + member_ClassRegister.TrainingId + "' and AccountId='" + Code.SiteCache.Instance.LoginInfo.UserId + "' and delflag='false' and (Result=1 or (Result is NULL and Status in(1,2,4)))", ""); if (listpass.Count > 0) { return Json(new { Code = -1, Msg = "您已经学过该课程或已报名该课程下的其他班级" }, JsonRequestBehavior.AllowGet); } List<Member_ClassRegister> listup = member_ClassRegisterBLL.GetList(" ClassId='" + ClassId + "' and AccountId='" + Code.SiteCache.Instance.LoginInfo.UserId + "' and delflag='false' and Status in (3,5)", ""); if (listup.Count > 0) { member_ClassRegister.Id = listup[0].Id; member_ClassRegister.Status = 1; member_ClassRegisterBLL.Update(member_ClassRegister); if (member_ClassRegister.Id > 0) { class_Detail = class_DetailBLL.GetModel(member_ClassRegister.ClassId); class_Detail.People += 1; class_DetailBLL.Update(class_Detail); Member_ClassRegisterApplicationBLL member_ClassRegisterApplicationBLL = new Member_ClassRegisterApplicationBLL(); Member_ClassRegisterApplication member_ClassRegisterApplication = new Member_ClassRegisterApplication(); member_ClassRegisterApplication.ClassRegisterId = member_ClassRegister.Id; member_ClassRegisterApplication.Status = 1; member_ClassRegisterApplication.Creater = Code.SiteCache.Instance.LoginInfo.UserId; member_ClassRegisterApplication.CreateDate = DateTime.Now; member_ClassRegisterApplication.Delflag = false; member_ClassRegisterApplicationBLL.Add(member_ClassRegisterApplication); return Json(new { Code = 0, Msg = "提交成功" }, JsonRequestBehavior.AllowGet); } else { return Json(new { Code = -1, Msg = "提交失败" }, JsonRequestBehavior.AllowGet); } } else { int RegisterId = member_ClassRegisterBLL.Add(member_ClassRegister); class_Detail = class_DetailBLL.GetModel(member_ClassRegister.ClassId); class_Detail.People += 1; class_DetailBLL.Update(class_Detail); if (RegisterId > 0) { Member_ClassRegisterApplicationBLL member_ClassRegisterApplicationBLL = new Member_ClassRegisterApplicationBLL(); Member_ClassRegisterApplication member_ClassRegisterApplication = new Member_ClassRegisterApplication(); member_ClassRegisterApplication.ClassRegisterId = RegisterId; member_ClassRegisterApplication.Status = 1; member_ClassRegisterApplication.Creater = Code.SiteCache.Instance.LoginInfo.UserId; member_ClassRegisterApplication.CreateDate = DateTime.Now; member_ClassRegisterApplication.Delflag = false; member_ClassRegisterApplicationBLL.Add(member_ClassRegisterApplication); return Json(new { Code = 0, Msg = "提交成功" }, JsonRequestBehavior.AllowGet); } else { return Json(new { Code = -1, Msg = "提交失败" }, JsonRequestBehavior.AllowGet); } } }
/// <summary> /// 新增一条记录 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool Add(Class_Detail model) { return dal.Add(model) > 0; }
private void ConvertToModel(IDataReader reader, Class_Detail model) { if (reader["Id"] != DBNull.Value) model.Id = Convert.ToInt32(reader["Id"]); if (reader["Title"] != DBNull.Value) model.Title = reader["Title"].ToString(); if (reader["TraningId"] != DBNull.Value) model.TraningId = Convert.ToInt32(reader["TraningId"]); if (reader["PlanId"] != DBNull.Value) model.PlanId = Convert.ToInt32(reader["PlanId"]); if (reader["SignUpStartTime"] != DBNull.Value) model.SignUpStartTime = Convert.ToDateTime(reader["SignUpStartTime"]); if (reader["SignUpEndTime"] != DBNull.Value) model.SignUpEndTime = Convert.ToDateTime(reader["SignUpEndTime"]); if (reader["OpenClassFrom"] != DBNull.Value) model.OpenClassFrom = Convert.ToDateTime(reader["OpenClassFrom"]); if (reader["OpenClassTo"] != DBNull.Value) model.OpenClassTo = Convert.ToDateTime(reader["OpenClassTo"]); if (reader["ClassForm"] != DBNull.Value) model.ClassForm = Convert.ToInt32(reader["ClassForm"]); if (reader["People"] != DBNull.Value) model.People = Convert.ToInt32(reader["People"]); if (reader["LimitPeopleCnt"] != DBNull.Value) model.LimitPeopleCnt = Convert.ToInt32(reader["LimitPeopleCnt"]); if (reader["Address"] != DBNull.Value) model.Address = reader["Address"].ToString(); if (reader["Content"] != DBNull.Value) model.Content = reader["Content"].ToString(); if (reader["ManagerId"] != DBNull.Value) model.ManagerId = Convert.ToInt32(reader["ManagerId"]); if (reader["OrganId"] != DBNull.Value) model.OrganId = Convert.ToInt32(reader["OrganId"]); if (reader["Subject"] != DBNull.Value) model.Subject = Convert.ToBoolean(reader["Subject"]); if (reader["StudyLevel"] != DBNull.Value) model.StudyLevel = Convert.ToBoolean(reader["StudyLevel"]); if (reader["TeachGrade"] != DBNull.Value) model.TeachGrade = Convert.ToBoolean(reader["TeachGrade"]); if (reader["TeachRank"] != DBNull.Value) model.TeachRank = Convert.ToBoolean(reader["TeachRank"].ToString()); if (reader["OrganRange"] != DBNull.Value) model.OrganRange = reader["OrganRange"].ToString(); if (reader["Instructor"] != DBNull.Value) model.Instructor = Convert.ToInt32(reader["Instructor"]); if (reader["Status"] != DBNull.Value) model.Status = Convert.ToInt32(reader["Status"]); if (reader["ApplyRemark"] != DBNull.Value) model.ApplyRemark = reader["ApplyRemark"].ToString(); if (reader["Display"] != DBNull.Value) model.Display = Convert.ToBoolean(reader["Display"]); if (reader["Delflag"] != DBNull.Value) model.Delflag = Convert.ToBoolean(reader["Delflag"]); if (reader["CreateDate"] != DBNull.Value) model.CreateDate = Convert.ToDateTime(reader["CreateDate"]); if (reader["PartitionId"] != DBNull.Value) model.PartitionId = Convert.ToInt32(reader["PartitionId"]); }
public ActionResult DetailInformation(int Id) { ViewBag.Title = "报名详细信息"; Member_ClassRegisterBLL member_ClassRegisterBLL = new Member_ClassRegisterBLL(); Member_ClassRegister member_ClassRegister = new Member_ClassRegister(); member_ClassRegister = member_ClassRegisterBLL.GetModel(Id, ""); Class_DetailBLL class_DetailBLL = new Class_DetailBLL(); Class_Detail class_Detail = new Class_Detail(); class_Detail = class_DetailBLL.GetModel(member_ClassRegister.ClassId); Member_AccountBLL member_AccountBLL = new Member_AccountBLL(); ViewBag.AcountInfo = member_AccountBLL.GetModel(member_ClassRegister.AccountId, ""); Member_BaseInfoBLL member_BaseInfoBLL = new Member_BaseInfoBLL(); ViewBag.BaseInfo = member_BaseInfoBLL.GetModelByAccountId(member_ClassRegister.AccountId); Member_ClassRegisterApplicationBLL member_ClassRegisterApplicationBLL = new Member_ClassRegisterApplicationBLL(); ViewBag.CApplicationList = member_ClassRegisterApplicationBLL.GetList(" Delflag='false' and ClassRegisterId='" + member_ClassRegister.Id + "'", "CreateDate"); return View(class_Detail); }
public ActionResult MyVerify(int Status, int mpId, string content) { try { Member_ClassRegisterBLL member_ClassRegisterBLL = new Member_ClassRegisterBLL(); Member_ClassRegister member_ClassRegister = member_ClassRegisterBLL.GetModel(mpId, ""); member_ClassRegister = member_ClassRegisterBLL.GetModel(mpId, ""); if ((Status == 3 && member_ClassRegister.Status != 3) || (Status == 5 && member_ClassRegister.Status != 5)) { Class_DetailBLL class_DetailBLL = new Class_DetailBLL(); Class_Detail class_Detail = new Class_Detail(); class_Detail = class_DetailBLL.GetModel(member_ClassRegister.ClassId); class_Detail.People -= 1; class_DetailBLL.Update(class_Detail); } else if ((Status == 2 && member_ClassRegister.Status == 3) || (Status == 4 && member_ClassRegister.Status == 5) || (Status == 2 && member_ClassRegister.Status == 5)) { Class_DetailBLL class_DetailBLL = new Class_DetailBLL(); Class_Detail class_Detail = new Class_Detail(); class_Detail = class_DetailBLL.GetModel(member_ClassRegister.ClassId); class_Detail.People += 1; if (class_Detail.LimitPeopleCnt != -1) { if (class_Detail.LimitPeopleCnt < class_Detail.People) { TempData["Msg"] = "超过报名限制!"; return RedirectToAction("../../Market/Coursemarket/CoursemarketVerify"); } } class_DetailBLL.Update(class_Detail); } member_ClassRegister.Status = Status; member_ClassRegister.ApplyRemark = content; member_ClassRegisterBLL.Update(member_ClassRegister); Member_ClassRegisterApplicationBLL member_ClassRegisterApplicationBLL = new Member_ClassRegisterApplicationBLL(); Member_ClassRegisterApplication member_ClassRegisterApplication = new Member_ClassRegisterApplication(); member_ClassRegisterApplication.ClassRegisterId = mpId; member_ClassRegisterApplication.Status = Status; member_ClassRegisterApplication.Remark = content; member_ClassRegisterApplication.Creater = Code.SiteCache.Instance.LoginInfo.UserId; member_ClassRegisterApplication.Delflag = false; member_ClassRegisterApplication.CreateDate = DateTime.Now; member_ClassRegisterApplicationBLL.Add(member_ClassRegisterApplication); TempData["Msg"] = "提交成功!"; return RedirectToAction("../../Market/Coursemarket/CoursemarketVerify"); } catch (Exception) { TempData["Msg"] = "提交失败!"; return RedirectToAction("../../Market/Coursemarket/CoursemarketVerify"); } }
public List<Member_AccountBaseInfo> GetMarketMemberList(int pageSize, int pageIndex, int Type, Class_Detail ClassModel, int TrainingId, int OrganId, int Groupid, string orderBy, out int recordCount) { if (string.IsNullOrEmpty(orderBy)) throw new ArgumentNullException(); StringBuilder s = new StringBuilder(); s.Append("(select ma.*,mbi.RealName,mbi.Mobile,mbi.Job,mpc.Status as mpcStatus,mpc.Delflag as mpcDelflag, sum(CASE mpt.Result WHEN 1 THEN 1 WHEN 2 THEN 0 ELSE 0 END) as mptResult "); s.Append(" ,sum(CASE mpt2.Status WHEN 1 THEN 1 WHEN 2 THEN 1 WHEN 4 THEN 1 ELSE 0 END) as mptStatus from Member_Account ma"); s.Append(" left join Member_StudySection mss on ma.Id=mss.AccountId"); s.Append(" left join Member_TeachSubject mts on ma.Id=mts.AccountId"); s.Append(" left join Member_TeachGrade mtg on ma.Id=mtg.AccountId"); s.Append(" left join Member_WorkRank mwr on ma.Id=mwr.AccountId"); s.Append(" left join Member_BaseInfo mbi on ma.Id=mbi.AccountId"); s.Append(" left join (select * from dbo.Member_ClassRegister where ClassId='" + ClassModel.Id + "' and Delflag='false')as mpc on ma.Id=mpc.AccountId "); s.Append(" left join (select * from dbo.Member_ClassRegister where TrainingId='" + TrainingId + "' and Delflag='false')as mpt on ma.Id=mpt.AccountId"); s.Append(" left join (select * from dbo.Member_ClassRegister where TrainingId='" + TrainingId + "' and Delflag='false' and Result is null)as mpt2 on ma.Id=mpt2.AccountId "); if (Groupid == 2) { s.Append(" where ma.OrganId in( select Id from Organ_Detail where ParentId='" + OrganId + "')"); } else if (Groupid == 4) { s.Append(" where ma.OrganId ='" + OrganId + "'"); } else if (Groupid == 3) { //s.Append(" where ma.OrganId='" + OrganId + "' "); s.Append(" where 1=1"); } else { s.Append(" where 1=2"); } if (Groupid == 2 || Groupid == 4) { s.Append(" and mbi.Id is not null "); } s.Append(" and ma.Delflag='false' and ma.Status=2 "); s.Append(" and (mpc.delflag='false' or mpc.Delflag is null) "); s.Append(" and (mpt.delflag='false' or mpt.Delflag is null) "); if (Type == 1) { if (Groupid == 2 || Groupid == 4) { if (ClassModel.StudyLevel == false) { s.Append(" and mss.StudySection in(select css.StudySection from Class_Detail cd left join Class_StudySection css on cd.Id=css.ClassId "); s.Append(" where cd.Id='" + ClassModel.Id + "' and cd.StudyLevel=0 and css.Delflag='false') "); } if (ClassModel.Subject == false) { s.Append(" and mts.TeachSubject in(select cts.TeachSubject from Class_Detail cd left join Class_TeachSubject cts on cd.Id=cts.ClassId "); s.Append(" where cd.Id='" + ClassModel.Id + "' and cd.Subject=0 and cts.Delflag='false') "); } if (ClassModel.TeachGrade == false) { s.Append(" and mtg.TeachGrade in(select ctg.TeachGrade from Class_Detail cd left join Class_TeachGrade ctg on cd.Id=ctg.ClassId "); s.Append(" where cd.Id='" + ClassModel.Id + "' and cd.TeachGrade=0 and ctg.Delflag='false') "); } if (ClassModel.TeachRank==false) { //s.Append(" and (mbi.WorkRank is null or charindex(','+cast(mbi.WorkRank as varchar)+',',','+(select TeachRank from Class_Detail where Id='" + ClassModel.Id + "')+',')>0) "); //s.Append(" and (mbi.WorkRank is null or mbi.WorkRank in(select TeachRank from Class_Detail where Id='" + ClassModel.Id + "')) "); s.Append(" and mwr.WorkRank in(select ctr.TeachRank from Class_Detail cd left join Class_TeachRank ctr on cd.Id=ctr.ClassId "); s.Append(" where cd.Id='" + ClassModel.Id + "' and cd.TeachRank=0 and ctr.Delflag='false') "); } if (ClassModel.OrganRange != "0") { s.Append(" and charindex(','+cast(ma.OrganId as varchar)+',',','+(select OrganRange from Class_Detail where Id='" + ClassModel.Id + "')+',')>0 "); //s.Append(" and ma.OrganId in(select OrganRange from Class_Detail where Id='" + ClassModel.Id + "') "); } s.Append(" and ((mpc.Status is Null or mpc.Status in(3,5))or mpc.delflag=1 ) "); } } s.Append(" group by ma.Id,ma.UserName,ma.Password,ma.Email,ma.Status,ma.RegisterIP,ma.OrganId,ma.Pic,ma.Nickname,ma.IsRealName,ma.originUserId,ma.origin,ma.OriginUserName,ma.IsNeedReName,ma.Delflag,ma.CreateDate,ma.OutSourceId,mbi.RealName,mbi.Mobile,mbi.Job,mpc.Status,mpc.Delflag) as n"); if (Type == 1) { s.Append(" where mptResult=0 and mptStatus=0 "); } StringBuilder sb = new StringBuilder(); sb.Append("select count(1) from " + s.ToString()); recordCount = Convert.ToInt32(MSEntLibSqlHelper.ExecuteScalarBySql(sb.ToString())); int start = (pageIndex - 1) * pageSize + 1; int end = pageIndex * pageSize; StringBuilder sql = new StringBuilder(); sql.Append("select * from (select *,ROW_NUMBER() over (order by " + orderBy + ") as [RowNum] from " + s.ToString()); sql.Append(") as T where [RowNum] between " + start + " and " + end); List<Member_AccountBaseInfo> list = new List<Member_AccountBaseInfo>(); using (IDataReader reader = MSEntLibSqlHelper.ExecuteDataReaderBySql(sql.ToString())) { while (reader.Read()) { Member_AccountBaseInfo model = new Member_AccountBaseInfo(); ConvertToModel2(reader, model); list.Add(model); } } return list; }
//public List<Member_AccountBaseInfo> GetMABList(int pageSize, int pageIndex, string where,string where2,int ClassId,int TrainingId, string orderBy, out int recordCount) //{ // return dal.GetMABList(pageSize, pageIndex, where,where2, ClassId, TrainingId,orderBy, out recordCount); //} public List<Member_AccountBaseInfo> GetMarketMemberList(int pageSize, int pageIndex, int Type, Class_Detail ClassModel, int TrainingId, int OrganId, int Groupid, string orderBy, out int recordCount) { return dal.GetMarketMemberList(pageSize, pageIndex, Type, ClassModel, TrainingId, OrganId, Groupid, orderBy, out recordCount); }