/// <summary> /// Считает количество заявлений в конкурсной группе /// </summary> /// <param name="currentCompetitiveGroup">Конкурсная группа</param> /// <param name="countFact">Возвращаемое кол-во всех заявлений</param> /// <param name="countOriginal">Возвращаемое кол-во заявлений с оригиналами документов</param> void CalculateClaimCountInCompetitiveGroup(CompetitiveGroup currentCompetitiveGroup, out int countFact, out int countOriginal) { countFact = 0; countOriginal = 0; // Считаем количество заявлений в конкурсной группе // Все заявления // На сегодня if (_isTodayStatistic) { countFact = (from condition in currentCompetitiveGroup.ClaimConditions where condition.Claim != null && condition.Priority == 1 && (condition.Claim.ClaimStatus.Id == 1 || condition.Claim.ClaimStatus.Id == 2 || condition.Claim.ClaimStatus.Id == 3) && condition.Claim.RegistrationDate == DateTime.Now.Date select condition.Claim).Count(); } // Общее else { countFact = (from condition in currentCompetitiveGroup.ClaimConditions where condition.Claim != null && condition.Priority == 1 && (condition.Claim.ClaimStatus.Id == 1 || condition.Claim.ClaimStatus.Id == 2 || condition.Claim.ClaimStatus.Id == 3) select condition.Claim).Count(); } // Оригиналы // На сегодня if (_isTodayStatistic) { countOriginal = (from condition in currentCompetitiveGroup.ClaimConditions where condition.Claim != null && condition.Priority == 1 && (condition.Claim.ClaimStatus.Id == 1 || condition.Claim.ClaimStatus.Id == 2 || condition.Claim.ClaimStatus.Id == 3) && condition.Claim.RegistrationDate == DateTime.Now.Date select condition.Claim).Where(c => c.IsOriginal).Count(); } // Общее else { countOriginal = (from condition in currentCompetitiveGroup.ClaimConditions where condition.Claim != null && condition.Priority == 1 && (condition.Claim.ClaimStatus.Id == 1 || condition.Claim.ClaimStatus.Id == 2 || condition.Claim.ClaimStatus.Id == 3) select condition.Claim).Where(c => c.IsOriginal).Count(); } }
void GenerateRegistrationNumber() { //получаем конкурсную группу CompetitiveGroup compGroup = null; try { compGroup = (from condition in EditedClaim.ClaimConditions where condition.Priority == 1 select condition.CompetitiveGroup).Single(); } catch (Exception) { compGroup = null; } // генерируем номер, если он еще не сгенерирован и если абитуриент записан // на какую-либо конкурсную группу с первым приоритетом if (EditedClaim.Number == null && compGroup != null) { //составные части регистрационного номера string yearPart = string.Empty; string educationFormPart = string.Empty; string competitiveGroupPart = string.Empty; string sequenceNumberPart = string.Empty; //заполняем части номера yearPart = DateTime.Now.Year.ToString().Remove(0, 2); educationFormPart = compGroup.EducationForm.RegistrationNumberMemberPart; competitiveGroupPart = compGroup.RegistrationNumberMemberPart; string sql = string.Format("SELECT IF(RIGHT(MAX(c.Number), 4) IS NOT NULL, RIGHT(MAX(c.Number), 4), 0) + 1 FROM Claims c WHERE LEFT(c.Number, 4) = {0}{1}{2};", yearPart, educationFormPart, competitiveGroupPart); sequenceNumberPart = (Session.DataModel.Database.SqlQuery <string>(sql)).First(); //забиваем порядковый номер нулями до длины 4 символов while (sequenceNumberPart.Length < 4) { sequenceNumberPart = string.Format("0{0}", sequenceNumberPart); } //все EditedClaim.Number = string.Format("{0}{1}{2}{3}", yearPart, educationFormPart, competitiveGroupPart, sequenceNumberPart); RaisePropertyChanged("EditedClaim"); } }
public ActionResult CompetitiveGroup(int id, string Name, string cgName, string EdLvlId, string EdFrmId, string DrctnId, int cgDate = 0) { ViewBag.compGroups = new List <CompetitiveGroup>(); if (String.IsNullOrEmpty(cgName) && String.IsNullOrEmpty(EdLvlId) && String.IsNullOrEmpty(EdFrmId) && String.IsNullOrEmpty(DrctnId)) { ViewBag.emptyResult = "hide"; } var cg = new CompetitiveGroup(); cg.InstitutionID = id; cg.Name = cgName; if (cgName != null) { var data = SearchCompetitiveGroup(id, cgName); SelectList eduFormName = new SelectList(EduForm, "ItemTypeID", "Name"); ViewBag.eduFormName = eduFormName; SelectList eduLevelName = new SelectList(EduLevel, "ItemTypeID", "Name"); ViewBag.eduLevelName = eduLevelName; SelectList drctnName = new SelectList(direction, "DirectionID", "Name"); ViewBag.drctnName = drctnName; SelectList Dates = new SelectList(cmpGrDates, "CreatedDate"); ViewBag.Dates = Dates; ViewBag.compGroups = data; } if (cgDate == 0) { ViewBag.cgDate = "Выберите год"; } else { ViewBag.cgDate = cgDate.ToString(); } return(View(cg)); }
public ActionResult UpdateCompetitiveGroup(int id, CompetitiveGroup cg, FormCollection form, string EdLvlId, string EdFrmId, string DrctnId, string save) { //int selectDate = 0; //string date = form["CreatedDate"]; //if (form.AllKeys.Contains("CreatedDate") && !String.IsNullOrEmpty(date)) //{ // selectDate = int.Parse(date); //} ViewBag.compGroups = new List <CompetitiveGroup>(); var compGroups = new List <CompetitiveGroup>(); if (cg.EducationLevelID != 0) { EdLvlId = cg.EducationLevelID.ToString(); } if (cg.EducationFormId != 0) { EdFrmId = cg.EducationFormId.ToString(); } if (cg.DirectionID != 0) { DrctnId = cg.DirectionID.ToString(); } var rowsAffected = EditCompetitiveGroup(id, cg.CompetitiveGroupID, EdLvlId, EdFrmId, DrctnId, save); if (rowsAffected > 0) { return(RedirectToAction("CompetitiveGroup", "CompetitiveGroup", new { id = id, cgName = cg.Name, EdLvlId = EdLvlId, EdFrmId = EdFrmId, DrctnId = DrctnId })); } return(RedirectToAction("CompetitiveGroup", "CompetitiveGroup", new { id = id, cgName = cg.Name })); }
public ActionResult CompetitiveGroup(int id, CompetitiveGroup cg) { return(RedirectToAction("CompetitiveGroup", "CompetitiveGroup", new { id = id, cgName = cg.Name })); }