private void GetData() { PromoList.Clear(); PromotionDb db = new PromotionDb(); PromoList = db.GetList(startYear: StartYear, endYear: EndYear, cls: SchoolClass[SchoolClassIndex], section: SchoolSection[SchoolSectionIndex], newStartYear: NewSessionStartYear, newEndYear: NewSessionEndYear); PlistIndex = -1; NewSessionStartYear = StartYear + 1; NewSessionEndYear = EndYear + 1; RollUpdateHandler(); MapperData(); }
private void bw_DoWork(object sender, DoWorkEventArgs e) { DupMsg = "Please wait. Saving Data.."; foreach (var item in PromoList) { if (item.DuplicateCode == 0) { SavablePromoList.Add(item); } } PromotionDb db = new PromotionDb(); db.MakePromotion(SavablePromoList); // reset }
private void MapperData() { PromotionDb db = new PromotionDb(); int oldFromACount = db.GetPreviousToNewCount(prevStartYear: StartYear, prevEndYear: EndYear, newStartYear: NewSessionStartYear, newEndYear: NewSessionEndYear, oldClass: SchoolClass[SchoolClassIndex], oldSection: "A"); int oldFromBCount = db.GetPreviousToNewCount(prevStartYear: StartYear, prevEndYear: EndYear, newStartYear: NewSessionStartYear, newEndYear: NewSessionEndYear, oldClass: SchoolClass[SchoolClassIndex], oldSection: "B"); int oldFromCCount = db.GetPreviousToNewCount(prevStartYear: StartYear, prevEndYear: EndYear, newStartYear: NewSessionStartYear, newEndYear: NewSessionEndYear, oldClass: SchoolClass[SchoolClassIndex], oldSection: "C"); int oldFromDCount = db.GetPreviousToNewCount(prevStartYear: StartYear, prevEndYear: EndYear, newStartYear: NewSessionStartYear, newEndYear: NewSessionEndYear, oldClass: SchoolClass[SchoolClassIndex], oldSection: "D"); int oldFromECount = db.GetPreviousToNewCount(prevStartYear: StartYear, prevEndYear: EndYear, newStartYear: NewSessionStartYear, newEndYear: NewSessionEndYear, oldClass: SchoolClass[SchoolClassIndex], oldSection: "E"); int newACount = db.GetNewCount(newStartYear: NewSessionStartYear, newEndYear: NewSessionEndYear, oldClass: SchoolClass[SchoolClassIndex], newSection: "A"); int newBCount = db.GetNewCount(newStartYear: NewSessionStartYear, newEndYear: NewSessionEndYear, oldClass: SchoolClass[SchoolClassIndex], newSection: "B"); int newCCount = db.GetNewCount(newStartYear: NewSessionStartYear, newEndYear: NewSessionEndYear, oldClass: SchoolClass[SchoolClassIndex], newSection: "C"); int newDCount = db.GetNewCount(newStartYear: NewSessionStartYear, newEndYear: NewSessionEndYear, oldClass: SchoolClass[SchoolClassIndex], newSection: "D"); int newECount = db.GetNewCount(newStartYear: NewSessionStartYear, newEndYear: NewSessionEndYear, oldClass: SchoolClass[SchoolClassIndex], newSection: "E"); int oldACount = db.GetPreviousCount(prevStartYear: StartYear, prevEndYear: EndYear, oldClass: SchoolClass[SchoolClassIndex], oldSection: "A"); int oldBCount = db.GetPreviousCount(prevStartYear: StartYear, prevEndYear: EndYear, oldClass: SchoolClass[SchoolClassIndex], oldSection: "B"); int oldCCount = db.GetPreviousCount(prevStartYear: StartYear, prevEndYear: EndYear, oldClass: SchoolClass[SchoolClassIndex], oldSection: "C"); int oldDCount = db.GetPreviousCount(prevStartYear: StartYear, prevEndYear: EndYear, oldClass: SchoolClass[SchoolClassIndex], oldSection: "D"); int oldECount = db.GetPreviousCount(prevStartYear: StartYear, prevEndYear: EndYear, oldClass: SchoolClass[SchoolClassIndex], oldSection: "E"); PrevSecA = $"Section A : {oldFromACount} of {oldACount}"; PrevSecB = $"Section B : {oldFromBCount} of {oldBCount}"; PrevSecC = $"Section C : {oldFromCCount} of {oldCCount}"; PrevSecD = $"Section D : {oldFromDCount} of {oldDCount}"; PrevSecE = $"Section E : {oldFromECount} of {oldECount}"; NewSecA = $"Section A : {newACount}"; NewSecB = $"Section B : {newBCount}"; NewSecC = $"Section C : {newCCount}"; NewSecD = $"Section D : {newDCount}"; NewSecE = $"Section E : {newECount}"; OldToNewMapA = db.GetPreviousToNewMap(prevStartYear: StartYear, prevEndYear: EndYear, newStartYear: NewSessionStartYear, newEndYear: NewSessionEndYear, oldClass: SchoolClass[SchoolClassIndex], oldSection: "A"); OldToNewMapB = db.GetPreviousToNewMap(prevStartYear: StartYear, prevEndYear: EndYear, newStartYear: NewSessionStartYear, newEndYear: NewSessionEndYear, oldClass: SchoolClass[SchoolClassIndex], oldSection: "B"); OldToNewMapC = db.GetPreviousToNewMap(prevStartYear: StartYear, prevEndYear: EndYear, newStartYear: NewSessionStartYear, newEndYear: NewSessionEndYear, oldClass: SchoolClass[SchoolClassIndex], oldSection: "C"); OldToNewMapD = db.GetPreviousToNewMap(prevStartYear: StartYear, prevEndYear: EndYear, newStartYear: NewSessionStartYear, newEndYear: NewSessionEndYear, oldClass: SchoolClass[SchoolClassIndex], oldSection: "D"); OldToNewMapE = db.GetPreviousToNewMap(prevStartYear: StartYear, prevEndYear: EndYear, newStartYear: NewSessionStartYear, newEndYear: NewSessionEndYear, oldClass: SchoolClass[SchoolClassIndex], oldSection: "E"); NewFromOldMapA = db.GetNewFromPreviousMap(prevStartYear: StartYear, prevEndYear: EndYear, newStartYear: NewSessionStartYear, newEndYear: NewSessionEndYear, oldClass: SchoolClass[SchoolClassIndex], NewSection: "A"); NewFromOldMapB = db.GetNewFromPreviousMap(prevStartYear: StartYear, prevEndYear: EndYear, newStartYear: NewSessionStartYear, newEndYear: NewSessionEndYear, oldClass: SchoolClass[SchoolClassIndex], NewSection: "B"); NewFromOldMapC = db.GetNewFromPreviousMap(prevStartYear: StartYear, prevEndYear: EndYear, newStartYear: NewSessionStartYear, newEndYear: NewSessionEndYear, oldClass: SchoolClass[SchoolClassIndex], NewSection: "C"); NewFromOldMapD = db.GetNewFromPreviousMap(prevStartYear: StartYear, prevEndYear: EndYear, newStartYear: NewSessionStartYear, newEndYear: NewSessionEndYear, oldClass: SchoolClass[SchoolClassIndex], NewSection: "D"); NewFromOldMapE = db.GetNewFromPreviousMap(prevStartYear: StartYear, prevEndYear: EndYear, newStartYear: NewSessionStartYear, newEndYear: NewSessionEndYear, oldClass: SchoolClass[SchoolClassIndex], NewSection: "E"); }
private void EventConnector_RollUpdateEvent(object sender, EventArgs e) { PromotionDb db = new PromotionDb(); if (PlistIndex > -1) { List <string> alreadyAssignedList = db.HasAlreadyAssignedOrNot(startYear: NewSessionStartYear, endYear: NewSessionEndYear, cls: PromoList[PlistIndex].NewStudyClass, section: PromoList[PlistIndex].NewSection, roll: PromoList[PlistIndex].NewRoll); if (alreadyAssignedList.Count > 0) { PromoList[PlistIndex].NewRoll = 0; System.Windows.MessageBox.Show("This section & roll already assigned to " + alreadyAssignedList.Count.ToString() + " student(s)"); } else { Promotion prm = PromoList[PlistIndex]; if (prm.NewRoll > 0 && !string.IsNullOrWhiteSpace(prm.NewSection)) { db.MakePromotion(prm); } } MapperData(); } }
private void RollUpdateHandler() { PromotionDb db = new PromotionDb(); // Refresh the row background color foreach (var item in PromoList) { item.DuplicateCode = 0; } // check for duplicate in grid var promosGrp = from p in PromoList group p by new { p.NewSection, p.NewRoll }; foreach (var itemGrp in promosGrp) { if (itemGrp.Count() > 1) { foreach (var item in itemGrp) { item.DuplicateCode = 1; } } } }