123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433 |
- using Ant.Data;
- using Ant.ORM;
- using Ant.SuperSocket.Common;
- using Ant.Service.Common;
- using Ant.Service.Common.Enums;
- using Central.Control.Domain;
- using MES.Production.Entity;
- using MES.Production.Entity.Entity;
- using MES.Production.Entity.Enum;
- using Ant.Service.Mongodb;
- using MES.Production.Service.IService;
- using MES.Production.Service.ServiceImp;
- using Ant.Service.Utility;
- using ChangFa.Machinery.WebPage.Areas.SysManage.Models;
- using ChangFa.Machinery.WebPage.Controllers;
- using MongoDB.Driver.Builders;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Web;
- using System.Web.Mvc;
- using JsonHelper = Ant.Service.Common.JsonHelper;
- namespace ChangFa.Machinery.WebPage.Areas.SysManage.Controllers
- {
- public class EntryConditionsController : BaseController
- {
- // GET: SysManage/EntryConditions
- public ActionResult Index()
- {
- return View();
- }
- [UserAuthorize(ModuleAlias = "SportsEventList", OperaAction = "Add,Edit")]
- [ValidateInput(false)]
- [HttpPost]
- public ActionResult Save(YW_EntryConditions entity)
- {
- JsonHelper json = new JsonHelper() { Msg = "保存组别设置成功", Status = "n", ReUrl = "/Sys/EntryConditions/SetEntryConditions" };
- try
- {
- entity.BigEventCode = Request.Form["sportsId"];
- entity.BigEventName = Request.Form["sportsName"];
- entity.SEPID = Request.Form["SEPID"].ToInt32();
- //2021-05-17jjg把限制设置条件去掉
- //if (entity.BoysMax > 0 || entity.GirlsMax > 0)
- //{
- // if (entity.MixedMax > 0)
- // {
- // json.Msg = "混合和男女不能同时填写!";
- // return Json(json);
- // }
- //}
- //if(entity.BoysMax==0&&entity.GirlsMax==0&&entity.MixedMax==0)
- //{
- // json.Msg = "混合和男女不能同时为零!";
- // return Json(json);
- //}
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel request = new RequestModel();
- request.newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "保存赛事" };
- if (entity.ID > 0)
- {
- request.Oid = entity.ID.ToString();
- var reslut = orm.UpdateById(entity, request);
- if (reslut.IsSuccess)
- {
- json.Status = "y";
- }
- else
- {
- json.Msg = "保存组别设置失败";
- }
- }
- else
- {
- entity.Createper = this.CurrentUser.Name;
- entity.CreateDate = DateTime.Now;
- var reslut = orm.Save(entity, request);
- if (reslut.IsSuccess)
- {
- json.Status = "y";
- }
- else
- {
- json.Msg = "保存组别设置失败";
- }
- }
- }
- }
- catch (Exception ex)
- {
- json.Msg = "保存组别设置发生内部错误!";
- WriteLog(enumOperator.None, "保存组别设置:", ex);
- }
- return Json(json);
- }
- public ActionResult SaveSportsEntries(string sportsName, string sportsId, string SEPID, string sportsNames, string sportsIds)
- {
- JsonHelper json = new JsonHelper()
- {
- Msg = "保存失败",
- Status = "n"
- };
- int i = 0;
- if (sportsIds.IndexOf(',') > 0)
- {
- var arr = sportsNames.Split(',');
- foreach (var s in sportsIds.Split(','))
- {
- if (!s.IsEmpty())
- {
- YW_SportsEntries entity = new YW_SportsEntries();
- entity.BigEventCode = sportsId;
- entity.BigEventName = sportsName;
- entity.SmallEventCode = s;
- entity.SmallEventName = arr[i];
- entity.SEPID = SEPID;
- entity.State = 1;
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel request = new RequestModel();
- request.newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "保存赛事" };
- var num = orm.Queryable<YW_SportsEntries>().Where(p => p.SmallEventCode == s && p.BigEventCode == sportsId).Count();
- if (num == 0)
- {
- var reslut = orm.Save(entity, request);
- if (reslut.IsSuccess)
- {
- json.Msg = "保存成功";
- json.Status = "y";
- }
- }
- }
- }
- i++;
- }
- }
- return Json(json);
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="idList"></param>
- /// <returns></returns>
- public ActionResult Delete(string idList)
- {
- JsonHelper json = new JsonHelper() { Status = "n", Msg = "删除裁判成功" };
- try
- {
- //是否为空
- if (string.IsNullOrEmpty(idList)) { json.Msg = "未找到要删除的裁判"; return Json(json); }
- string[] id = idList.Trim(',').Split(',');
- for (int i = 0; i < id.Length; i++)
- {
- var userId = (id[i]);
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel request = new RequestModel
- {
- newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "删除裁判" },
- Oid = userId.ToString()
- };
- var reslut = orm.DeleteById<YW_EntryConditions>(request);
- if (reslut.IsSuccess)
- {
- var dreslut = orm.DeleteByLambda<YW_ProjectEntry>(p => p.SCID == userId, request);
- int ecid = userId.ToInt32();
- var reportreslut = orm.DeleteByLambda<YW_MatchReport>(p => p.ECID == ecid, request);
- json.Status = "y";
- WriteLog(enumOperator.Remove, json.Msg, enumLog4net.WARN);
- }
- }
- }
- }
- catch (Exception e)
- {
- json.Msg = "删除裁判发生内部错误!";
- WriteLog(enumOperator.Remove, "删除教练:", e);
- }
- return Json(json);
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="id"></param>
- /// <param name="sportsName"></param>
- /// <param name="sportsId"></param>
- /// <param name="SEPID"></param>
- /// <returns></returns>
- [UserAuthorize(ModuleAlias = "SportsEventList", OperaAction = "Detail")]
- public ActionResult Detail(int? id, string sportsName, string sportsId, string SEPID)
- {
- ViewData["Year"] = DateTime.Now.ToString("yyyy");
- ViewData["sportsName"] = sportsName;
- ViewData["sportsId"] = sportsId;
- ViewData["SEPID"] = SEPID;
- YW_EntryConditions mod = new YW_EntryConditions();
- mod.BigEventCode = sportsId;
- mod.BigEventName = sportsName;
- mod.SEPID = SEPID.ToInt32();
- if (id != null)
- {
- using (AntORM orm = new AntORM())
- {
- try
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel request = new RequestModel
- {
- newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "查询赛事的单个实体方法" },
- Oid = id.ToString()
- };
- var reslut = orm.GetEntity<YW_EntryConditions>(request);
- if (reslut.IsSuccess)
- {
- mod = reslut.ResultModel;
- }
- }
- catch (Exception e)
- {
- }
- }
- }
- else
- {
- mod.GirlsMin = 0;
- mod.BoysMin = 0;
- mod.MixedMin = 0;
- }
- List<SelectListItem> items = new List<SelectListItem>();
- items.Add(new SelectListItem { Text = "请选择", Value = "" });
- var sysCodes = CommonEnumHelper.LoadDic(CommonCodeType.年级);
- foreach (var item in sysCodes)
- {
- items.Add(new SelectListItem { Text = item.NAMETEXT, Value = item.NAMETEXT });
- }
- ViewBag.Grades = items;
- items = new List<SelectListItem>();
- items.Add(new SelectListItem { Text = "请选择", Value = "" });
- sysCodes = CommonEnumHelper.LoadDic(CommonCodeType.学校小类);
- foreach (var item in sysCodes)
- {
- items.Add(new SelectListItem { Text = item.NAMETEXT, Value = item.NAMETEXT });
- }
- ViewBag.SchoolSmallTypes = items;
- return View(mod);
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="id"></param>
- /// <param name="sports"></param>
- /// <returns></returns>
- [UserAuthorize(ModuleAlias = "SportsEventList", OperaAction = "View,Add,Edit")]
- public ActionResult SetEntryConditions(int id, string sportsId, string sportsName, string state)
- {
- PageInfo pageInfo = new PageInfo(base.page, base.pagesize, 0, JsonConverter.JsonClass(new List<YW_EntryConditions>()));
- ViewData["sportsName"] = sportsName;
- ViewData["sportsId"] = sportsId;
- ViewData["ID"] = id;
- ViewData["state"] = state;
- string sportsNames = "";
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel request = new RequestModel();
- request.newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "保存赛事" };
- var SportsReslut = orm.Queryable<YW_SportsEntries>().Where(p => p.BigEventCode == sportsId).ToList(request);
- if (SportsReslut.IsSuccess)
- {
- foreach (YW_SportsEntries mod in SportsReslut.ResultModel)
- {
- sportsNames += mod.SmallEventName + ",";
- }
- }
- }
- if (sportsNames.IndexOf(',') >= 0)
- {
- ViewData["SmallEventName"] = sportsNames.Substring(0, sportsNames.LastIndexOf(","));
- }
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel res = new RequestModel();
- res.newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取比赛级别条件列表" };
- var coachList = orm.Queryable<YW_EntryConditions>();
- int pageno = (base.page - 1) * base.pagesize;
- //if (!nameOrProject.IsEmpty())
- //{
- // coachList = coachList.Where(p => (!string.IsNullOrEmpty(p.SportType) && p.SportType.Contains(nameOrProject)));
- //}
- if (id > 0)
- {
- coachList = coachList.Where(p => p.SEPID == id);
- }
- var reslut = coachList.OrderByDesc(p => p.CreateDate).Skip(pageno).Top(pagesize).ToList(res);
- if (reslut.IsSuccess)
- {
- reslut.RecordNum = coachList.Count();
- pageInfo = new PageInfo(base.page, base.pagesize, reslut.RecordNum, JsonConverter.JsonClass(reslut.ResultModel));
- }
- }
- return View(pageInfo);
- }
- public ActionResult SetProjectEntry(string sportsName, string sportsId, string SEPID, string SCID, string smallSport, string smallSportId)
- {
- JsonHelper json = new JsonHelper()
- {
- Msg = "保存失败",
- Status = "n"
- };
- int i = 0;
- RequestModel request = new RequestModel();
- request.newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "保存项目规则" };
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- orm.DeleteByLambda<YW_ProjectEntry>(p => p.SCID == SCID, request);
- }
- YW_EntryConditions entryConditions = new YW_EntryConditions();
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- int cid = SCID.ToInt32();
- var entryResult = orm.Queryable<YW_EntryConditions>().Where(p => p.ID == cid).FirstOrDefault(request);
- if (entryResult.IsSuccess)
- {
- entryConditions = entryResult.ResultModel;
- }
- }
- if (smallSportId.IndexOf(',') >= 0)
- {
- var arr = smallSport.Split(',');
- foreach (var s in smallSportId.Split(','))
- {
- if (!s.IsEmpty())
- {
- YW_ProjectEntry entity = new YW_ProjectEntry();
- entity.BigEventCode = sportsId;
- entity.BigEventName = sportsName;
- entity.SmallEventCode = s;
- entity.SmallEventName = arr[i];
- entity.SEPID = SEPID;
- entity.BoysMum = entryConditions.BoysMax;
- entity.GirlsMum = entryConditions.GirlsMax;
- entity.MixedMum = entryConditions.MixedMax;
- entity.State = 1;
- entity.SCID = SCID;
- entity.Createper = this.CurrentUser.LogName;
- entity.CreateDate = DateTime.Now;
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- var reslut = orm.Save(entity, request);
- if (reslut.IsSuccess)
- {
- json.Msg = "设置成功";
- json.Status = "y";
- }
- }
- }
- i++;
- }
- }
- else
- {
- YW_ProjectEntry entity = new YW_ProjectEntry();
- entity.BigEventCode = sportsId;
- entity.BigEventName = sportsName;
- entity.SmallEventCode = smallSportId;
- entity.SmallEventName = smallSport;
- entity.SEPID = SEPID;
- entity.BoysMum = entryConditions.BoysMax;
- entity.GirlsMum = entryConditions.GirlsMax;
- entity.MixedMum = entryConditions.MixedMax;
- entity.State = 1;
- entity.SCID = SCID;
- entity.Createper = this.CurrentUser.LogName;
- entity.CreateDate = DateTime.Now;
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- var reslut = orm.Save(entity, request);
- if (reslut.IsSuccess)
- {
- json.Msg = "设置成功";
- json.Status = "y";
- }
- }
- }
- return Json(json);
- }
- }
- }
|