public List <ShowFinalClasses> GetSplitClassParts(Guid show_ID) { List <ShowFinalClasses> retVal = new List <ShowFinalClasses>(); try { ShowFinalClassesBL showfinalclasses = new ShowFinalClassesBL(_connString); tblShowFinalClasses = showfinalclasses.GetSplitClassParts(show_ID); if (tblShowFinalClasses != null && tblShowFinalClasses.Rows.Count > 0) { foreach (DataRow row in tblShowFinalClasses.Rows) { ShowFinalClasses showFinalClass = new ShowFinalClasses(_connString, Utils.DBNullToGuid(row["Show_Final_Class_ID"])); retVal.Add(showFinalClass); } } } catch (Exception ex) { throw ex; } return(retVal); }
public static void SetClassesAndDrawQty(Guid show_ID) { bool lowestClassSet = false; List<ClassesAndDrawQty> classesAndDrawQtyList = new List<ClassesAndDrawQty>(); ShowFinalClasses showFinalClasses = new ShowFinalClasses(); List<ShowFinalClasses> showFinalClassList = showFinalClasses.GetShow_Final_ClassesByShow_ID(show_ID); foreach (ShowFinalClasses row in showFinalClassList) { if (row.Show_Final_Class_Description != "NFC" && !row.Show_Final_Class_Description.Contains("YKC") && !row.Show_Final_Class_Description.Contains("Champ")) { int drawQty = 10; DogClasses dogClass = new DogClasses(); int entryCount = dogClass.GetEntryCountByShow_Final_Class_ID(row.Show_Final_Class_ID); if (entryCount <= Constants.DRAW_QTY_LESS_THAN) { drawQty = 6; } ClassesAndDrawQty classAndDrawQty = new ClassesAndDrawQty(); classAndDrawQty.Show_Final_Class_ID = row.Show_Final_Class_ID; classAndDrawQty.DrawQty = drawQty; if (!lowestClassSet) { classAndDrawQty.LowestClass = true; lowestClassSet = true; } classesAndDrawQtyList.Add(classAndDrawQty); } } ClassesAndDrawQtyList = classesAndDrawQtyList; }
public static void AllocateRunningOrdersStage3(Guid show_ID, Guid user_ID) { if (AllEntriesInClass != null && AllEntriesInClass.Count > 0) { SetClassesAndDrawQty(show_ID); if (ClassesAndDrawQtyList != null && ClassesAndDrawQtyList.Count > 0) { //All Classes - Lowest to Highest //Owner has more than one class entered for (int i = (ClassesAndDrawQtyList.Count-1); i > -1; i--) { Guid thisClass_ID = ClassesAndDrawQtyList[i].Show_Final_Class_ID; DogClasses dogClass = new DogClasses(); short thisClassRunningOrder = dogClass.GetMaxRunningOrderForClass(thisClass_ID); foreach (OwnersDogsClassesDrawn thisClassRow in AllEntriesInClass) { if (OwnersDrawn.IndexOf(thisClassRow.Owner_ID) == -1 && DogsDrawn.IndexOf(thisClassRow.Dog_ID) == -1) //if (!thisClassRow.OwnerDrawnOnDay) { if (thisClassRow.Show_Final_Class_ID == thisClass_ID) { if (!thisClassRow.Helper && !(thisClassRow.OwnerDogCount == 1 && thisClassRow.ClassesPerOwnerEnteredCount == 1)) { if (thisClassRow.ClassesPerOwnerEnteredCount > 1) { thisClassRunningOrder += 1; if (thisClassRunningOrder <= ClassesAndDrawQtyList[i].DrawQty) { UpdateRunningOrder(thisClassRow, thisClassRunningOrder, user_ID); if (OwnersDrawn.IndexOf(thisClassRow.Owner_ID) == -1) OwnersDrawn.Add(thisClassRow.Owner_ID); ShowFinalClasses sfc = new ShowFinalClasses(thisClassRow.Show_Final_Class_ID); if (sfc.Show_ID == Day1_Show_ID) { if (OwnersDrawnOnDay1.IndexOf(thisClassRow.Owner_ID) == -1) OwnersDrawnOnDay1.Add(thisClassRow.Owner_ID); } else { if (OwnersDrawnOnDay2.IndexOf(thisClassRow.Owner_ID) == -1) OwnersDrawnOnDay2.Add(thisClassRow.Owner_ID); } if (DogsDrawn.IndexOf(thisClassRow.Dog_ID) == -1) DogsDrawn.Add(thisClassRow.Dog_ID); } } } } } } } } } }
private void SetOwnerDogCounts(sss.tblOwnersDogsClassesDrawnListRow row, Guid show_ID) { RunningOrders.OwnerDogCount = 0; RunningOrders.OwnerDogsInClassCount = 0; RunningOrders.ClassesPerOwnerEnteredCount = 0; RunningOrders.ClassesPerDogEnteredCount = 0; List<Guid> ownerDogsList = new List<Guid>(); List<Guid> ownerDogsInClassList = new List<Guid>(); List<Guid> classesPerOwnerEnteredList = new List<Guid>(); List<Guid> classesPerDogEnteredList = new List<Guid>(); DogClasses dogClass = new DogClasses(); List<DogClasses> dogClasses1 = dogClass.GetDog_ClassesByDog_ID((Guid)row.Dog_ID); foreach (DogClasses dogClass1 in dogClasses1) { ShowFinalClasses sfc = new ShowFinalClasses((Guid)dogClass1.Show_Final_Class_ID); if ((Guid)sfc.Show_ID == show_ID) { if (classesPerDogEnteredList.IndexOf((Guid)dogClass1.Show_Entry_Class_ID) == -1) classesPerDogEnteredList.Add((Guid)dogClass1.Show_Entry_Class_ID); } } DogOwners dogOwner = new DogOwners(); List<DogOwners> dogOwnerList = dogOwner.GetDogOwnersByOwner_ID(row.Owner_ID); foreach (DogOwners dogOwnerRow in dogOwnerList) { List<DogClasses> dogClasses = dogClass.GetDog_ClassesByEntrant_ID(row.Entrant_ID); foreach (DogClasses dcRow in dogClasses) { ShowFinalClasses sfc = new ShowFinalClasses((Guid)dcRow.Show_Final_Class_ID); if ((Guid)sfc.Show_ID == show_ID) { Guid dog_ID = (Guid)dcRow.Dog_ID; Guid dog_Class_ID = (Guid)dcRow.Dog_Class_ID; Guid show_Entry_Class_ID = (Guid)dcRow.Show_Entry_Class_ID; ShowEntryClasses sec = new ShowEntryClasses(show_Entry_Class_ID); ClassNames cn = new ClassNames(int.Parse(sec.Class_Name_ID.ToString())); if (cn.Class_Name_Description != "NFC") { if (ownerDogsList.IndexOf(dog_ID) == -1) ownerDogsList.Add(dog_ID); if (classesPerOwnerEnteredList.IndexOf(show_Entry_Class_ID) == -1) classesPerOwnerEnteredList.Add(show_Entry_Class_ID); if (dcRow.Show_Entry_Class_ID == sfc.Show_Entry_Class_ID) { if (ownerDogsInClassList.IndexOf(dog_ID) == -1) ownerDogsInClassList.Add(dog_ID); } } } } } RunningOrders.OwnerDogCount = ownerDogsList.Count; RunningOrders.OwnerDogsInClassCount = ownerDogsInClassList.Count; RunningOrders.ClassesPerOwnerEnteredCount = classesPerOwnerEnteredList.Count; RunningOrders.ClassesPerDogEnteredCount = classesPerDogEnteredList.Count; }
private void SetDrawnFlags(sss.tblOwnersDogsClassesDrawnListRow row, Guid show_ID) { bool setFlags = true; //if((row.Show_Final_Class_Description.Contains("Champ") || row.Show_Final_Class_Description.Contains("YKC")) && row.Running_Order <= 20) //{ // setFlags=false; //} if (setFlags) { //Dog Level Flag if (RunningOrders.DogsDrawn.IndexOf(row.Dog_ID) == -1) { RunningOrders.DogsDrawn.Add(row.Dog_ID); } //Owner Level Flag if (RunningOrders.OwnersDrawn.IndexOf(row.Owner_ID) == -1) { RunningOrders.OwnersDrawn.Add(row.Owner_ID); } ShowFinalClasses sfc = new ShowFinalClasses(row.Show_Final_Class_ID); if ((Guid)sfc.Show_ID == RunningOrders.Day1_Show_ID) { if (RunningOrders.OwnersDrawnOnDay1.IndexOf(row.Owner_ID) == -1) RunningOrders.OwnersDrawnOnDay1.Add(row.Owner_ID); } else { if (RunningOrders.OwnersDrawnOnDay2.IndexOf(row.Owner_ID) == -1) RunningOrders.OwnersDrawnOnDay2.Add(row.Owner_ID); } } }
private bool IsHighestClass(sss.tblOwnersDogsClassesDrawnListRow row) { bool isHighestClass = true; ShowFinalClasses sfcCurrent = new ShowFinalClasses(row.Show_Final_Class_ID); short currentClassNo = sfcCurrent.Show_Final_Class_No; DogClasses dc = new DogClasses(); List<DogClasses> dogClassesList = dc.GetDog_ClassesByDog_ID(row.Dog_ID); foreach (DogClasses dcRow in dogClassesList) { if (dcRow.Show_Final_Class_ID != null) { Guid show_Final_Class_ID = (Guid)dcRow.Show_Final_Class_ID; ShowFinalClasses sfc = new ShowFinalClasses(show_Final_Class_ID); if (sfc.Show_Final_Class_No > currentClassNo) isHighestClass = false; } } return isHighestClass; }
public List<OwnersDogsClassesDrawn> GetOwnerDogsClassesDrawnList(Guid show_ID, Guid? show_Final_Class_ID, bool display) { RunningOrdersBL rOBL = new RunningOrdersBL(); tblOwnersDogsClassesDrawnList = rOBL.GetOwnersDogsClassesDrawn(display); List<OwnersDogsClassesDrawn> displayList = new List<OwnersDogsClassesDrawn>(); OwnersDogsClassesDrawn displayItem = new OwnersDogsClassesDrawn(); if (tblOwnersDogsClassesDrawnList != null && tblOwnersDogsClassesDrawnList.Count > 0) { short ring_No = 0; Shows show = new Shows(show_ID); string show_Final_Class_Description = string.Empty; ClearDrawnFlags(); int rowCount = 0; int rowCountRO = 0; int rowCountInScope = 0; foreach (sss.tblOwnersDogsClassesDrawnListRow oDCDLRow in tblOwnersDogsClassesDrawnList) { rowCount += 1; if (!oDCDLRow.IsRunning_OrderNull()) { rowCountRO += 1; displayItem.Running_Order = oDCDLRow.Running_Order; if (oDCDLRow.Running_Order > 0 && oDCDLRow.Running_Order < 21) { rowCountInScope += 1; //if (display) SetDrawnFlags(oDCDLRow, show_ID); displayItem.DogDrawnInClass = true; } } } foreach (sss.tblOwnersDogsClassesDrawnListRow row in tblOwnersDogsClassesDrawnList) { ShowFinalClasses sfc = new ShowFinalClasses(row.Show_Final_Class_ID); if ((ring_No != row.Ring_No && ring_No != 0) || (ring_No == row.Ring_No && show_Final_Class_Description != row.Show_Final_Class_Description)) { //new ring number OwnersDogsClassesDrawn completeRow = BuildCompleteRow(displayItem); displayList.Add(completeRow); displayItem = new OwnersDogsClassesDrawn(); } if (!row.IsRunning_OrderNull()) { displayItem.Running_Order = row.Running_Order; if (row.Running_Order > 0 && row.Running_Order < 21) { //if (display) SetDrawnFlags(row, show_ID); displayItem.DogDrawnInClass = true; } } displayItem.Ring_No = row.Ring_No; displayItem.Owners.Add(row.Owner); if (RunningOrders.OwnersDrawn.IndexOf(row.Owner_ID) != -1) displayItem.OwnerDrawn = true; if ((Guid)sfc.Show_ID == RunningOrders.Day1_Show_ID) { if (RunningOrders.OwnersDrawnOnDay1.IndexOf(row.Owner_ID) != -1) displayItem.OwnerDrawnOnDay = true; } else { if (RunningOrders.OwnersDrawnOnDay2.IndexOf(row.Owner_ID) != -1) displayItem.OwnerDrawnOnDay = true; } displayItem.Dog_KC_Name = row.Dog_KC_Name; if (!row.IsOffer_Of_HelpNull()) { displayItem.Offer_Of_Help = row.Offer_Of_Help; displayItem.Helper = row.Offer_Of_Help; } else displayItem.Helper = false; displayItem.HighestClass = IsHighestClass(row); displayItem.OldestDog = IsOldestDog(row); displayItem.Entrant_ID = row.Entrant_ID; if (!row.IsEntry_DateNull()) displayItem.Entry_Date = row.Entry_Date; displayItem.Owner_ID = row.Owner_ID; displayItem.Dog_ID = row.Dog_ID; if (RunningOrders.DogsDrawn.IndexOf(row.Dog_ID) != -1) displayItem.DogDrawn = true; displayItem.Dog_Class_ID = row.Dog_Class_ID; displayItem.Show_Final_Class_ID = row.Show_Final_Class_ID; SetOwnerDogCounts(row, show_ID); displayItem.OwnerDogCount = RunningOrders.OwnerDogCount; displayItem.OwnerDogsInClassCount = RunningOrders.OwnerDogsInClassCount; displayItem.ClassesPerOwnerEnteredCount = RunningOrders.ClassesPerOwnerEnteredCount; displayItem.ClassesPerDogEnteredCount = RunningOrders.ClassesPerDogEnteredCount; displayItem.Show_Final_Class_Description = row.Show_Final_Class_Description; show_Final_Class_Description = row.Show_Final_Class_Description; //displayList.Add(displayItem); ring_No = row.Ring_No; } OwnersDogsClassesDrawn completeRowFinal = BuildCompleteRow(displayItem); displayList.Add(completeRowFinal); } return displayList; }
public List<ShowFinalClasses> GetShow_Final_ClassesByShow_ID(Guid show_ID) { List<ShowFinalClasses> showFinalClassList = new List<ShowFinalClasses>(); ShowFinalClassesBL showfinalclasses = new ShowFinalClassesBL(); tblShowFinalClasses = showfinalclasses.GetShow_Final_ClassesByShow_ID(show_ID); if (tblShowFinalClasses != null && tblShowFinalClasses.Count > 0) { foreach (sss.tblShow_Final_ClassesRow row in tblShowFinalClasses) { ShowFinalClasses showFinalClass = new ShowFinalClasses(row.Show_Final_Class_ID); showFinalClassList.Add(showFinalClass); } } return showFinalClassList; }
private ListItemCollection GetClassParts(Guid show_Entry_Class_ID) { ListItemCollection listItems = new ListItemCollection(); ShowFinalClasses showFinalClasses = new ShowFinalClasses(); List<ShowFinalClasses> showFinalClassList = showFinalClasses.GetShow_Final_ClassesByShow_Entry_Class_ID(show_Entry_Class_ID); foreach (ShowFinalClasses row in showFinalClassList) { ListItem item = new ListItem(row.Show_Final_Class_Description, row.Show_Final_Class_ID.ToString()); listItems.Add(item); } return listItems; }
protected void SpecialRequestGridView_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { ListItemCollection listItems = new ListItemCollection(); Guid show_Entry_Class_ID = new Guid(SpecialRequestGridView.DataKeys[e.Row.RowIndex].Values[1].ToString()); listItems = GetClassParts(show_Entry_Class_ID); Guid show_Final_Class_ID = new Guid(SpecialRequestGridView.DataKeys[e.Row.RowIndex].Values[2].ToString()); ShowFinalClasses showFinalClasses = new ShowFinalClasses(show_Final_Class_ID); Label lblNewPart = (Label)e.Row.FindControl("lblNewPart"); if (lblNewPart != null) { lblNewPart.Text = showFinalClasses.Show_Final_Class_Description; } DropDownList ddlNewPart = (DropDownList)e.Row.FindControl("ddlNewPart"); if (ddlNewPart != null) { foreach (ListItem item in listItems) { ddlNewPart.Items.Add(item); } ddlNewPart.DataBind(); ddlNewPart.SelectedValue = SpecialRequestGridView.DataKeys[e.Row.RowIndex].Values[2].ToString(); } } }
public static bool AllocateDogsToFinalClasses(Guid show_ID, Guid user_ID) { bool success = false; List<ShowEntryClasses> showEntryClassList = new List<ShowEntryClasses>(); ShowEntryClasses showEntryClasses = new ShowEntryClasses(); showEntryClassList = showEntryClasses.GetShow_Entry_ClassesByShow_ID(show_ID); foreach (ShowEntryClasses showEntryClass in showEntryClassList) { List<ShowFinalClasses> showFinalClassList = new List<ShowFinalClasses>(); ShowFinalClasses showFinalClasses = new ShowFinalClasses(); showFinalClassList = showFinalClasses.GetShow_Final_ClassesByShow_Entry_Class_ID(showEntryClass.Show_Entry_Class_ID); if (showFinalClassList != null && showFinalClassList.Count > 0) { List<DogClasses> dogClassList = new List<DogClasses>(); DogClasses dogClasses = new DogClasses(); dogClassList = dogClasses.GetDog_ClassesByShow_Entry_Class_ID(showEntryClass.Show_Entry_Class_ID); if (showFinalClassList.Count == 1) { foreach (DogClasses dogClass in dogClassList) { dogClass.Show_Final_Class_ID = showFinalClassList[0].Show_Final_Class_ID; Guid dog_Class_ID = new Guid(dogClass.Dog_Class_ID.ToString()); success = dogClass.Update_Dog_Class(dog_Class_ID, user_ID); } } else { List<ClassParts> classParts = new List<ClassParts>(); foreach (ShowFinalClasses showFinalClass in showFinalClassList) { ClassParts classPart = new ClassParts(); FinalClassNames finalClassNames = new FinalClassNames(showFinalClass.Show_Final_Class_No); classPart.Show_Final_Class_ID = showFinalClass.Show_Final_Class_ID; classPart.Show_Final_Class_Description = showFinalClass.Show_Final_Class_Description; classPart.MaxDogsInPart = finalClassNames.Entries; classParts.Add(classPart); } List<DogsInClass> allDogsInClass = new List<DogsInClass>(); allDogsInClass = AllocateDogsToClassParts(dogClassList, classParts); List<DogClasses> failedUpdateList = new List<DogClasses>(); foreach (DogsInClass dog in allDogsInClass) { DogClasses dogClass = new DogClasses(dog.Dog_Class_ID); dogClass.Show_Final_Class_ID = dog.Show_Final_Class_ID; success = dogClass.Update_Dog_Class(dog.Dog_Class_ID, user_ID); if (!success) failedUpdateList.Add(dogClass); } } } } return success; }
private void PopulateClassList(string Show_ID) { if (!string.IsNullOrEmpty(Show_ID)) { Guid show_ID = new Guid(Show_ID); ShowFinalClasses showFinalClasses = new ShowFinalClasses(); List<ShowFinalClasses> tblShowFinalClasses = showFinalClasses.GetShow_Final_ClassesByShow_ID(show_ID); List<ShowFinalClasses> classList = new List<ShowFinalClasses>(); ShowFinalClasses allClasses = new ShowFinalClasses(); allClasses.Show_Final_Class_Description = "All Classes"; allClasses.Show_Final_Class_ID = new Guid(); classList.Add(allClasses); foreach (ShowFinalClasses row in tblShowFinalClasses) { classList.Add(row); } lstClasses.DataSource = classList; lstClasses.DataBind(); } }
public static bool AllocateDogsToFinalClasses(string connString, Guid show_ID, Guid user_ID) { bool retVal = false; try { List <ShowEntryClasses> showEntryClassList = new List <ShowEntryClasses>(); ShowEntryClasses showEntryClasses = new ShowEntryClasses(connString); showEntryClassList = showEntryClasses.GetShow_Entry_ClassesByShow_ID(show_ID); foreach (ShowEntryClasses showEntryClass in showEntryClassList) { List <ShowFinalClasses> showFinalClassList = new List <ShowFinalClasses>(); ShowFinalClasses showFinalClasses = new ShowFinalClasses(connString); showFinalClassList = showFinalClasses.GetShow_Final_ClassesByShow_Entry_Class_ID(showEntryClass.Show_Entry_Class_ID); if (showFinalClassList != null && showFinalClassList.Count > 0) { List <DogClasses> dogClassList = new List <DogClasses>(); DogClasses dogClasses = new DogClasses(connString); dogClassList = dogClasses.GetDog_ClassesByShow_Entry_Class_ID(showEntryClass.Show_Entry_Class_ID); if (showFinalClassList.Count == 1) { foreach (DogClasses dogClass in dogClassList) { dogClass.Show_Final_Class_ID = showFinalClassList[0].Show_Final_Class_ID; Guid dog_Class_ID = new Guid(dogClass.Dog_Class_ID.ToString()); retVal = dogClass.Update_Dog_Class(dog_Class_ID, user_ID); } } else { List <ClassParts> classParts = new List <ClassParts>(); foreach (ShowFinalClasses showFinalClass in showFinalClassList) { ClassParts classPart = new ClassParts(); FinalClassNames finalClassNames = new FinalClassNames(connString, showFinalClass.Show_Final_Class_No); classPart.Show_Final_Class_ID = showFinalClass.Show_Final_Class_ID; classPart.Show_Final_Class_Description = showFinalClass.Show_Final_Class_Description; classPart.MaxDogsInPart = finalClassNames.Entries; classParts.Add(classPart); } List <DogsInClass> allDogsInClass = new List <DogsInClass>(); allDogsInClass = AllocateDogsToClassParts(connString, dogClassList, classParts, show_ID); List <DogClasses> failedUpdateList = new List <DogClasses>(); foreach (DogsInClass dog in allDogsInClass) { DogClasses dogClass = new DogClasses(connString, dog.Dog_Class_ID); dogClass.Show_Final_Class_ID = dog.Show_Final_Class_ID; retVal = dogClass.Update_Dog_Class(dog.Dog_Class_ID, user_ID); if (!retVal) { failedUpdateList.Add(dogClass); } } } } } } catch (Exception ex) { throw ex; } return(retVal); }
protected void btnCommit_Click(object sender, EventArgs e) { FinalClassNameList = SplitClasses.DisplayFinalClassNames(); StoreCommon(); if (FinalClassNameList != null && FinalClassNameList.Count > 0) { MembershipUser userInfo = Membership.GetUser(); Guid user_ID = (Guid)userInfo.ProviderUserKey; ClearFinalClassNames(); foreach (FinalClassNames finalClassName in FinalClassNameList) { Guid? show_Final_Class_ID = null; ShowEntryClasses showEntryClass = new ShowEntryClasses(finalClassName.Show_Entry_Class_ID); ShowFinalClasses showFinalClass = new ShowFinalClasses(); showFinalClass.Show_ID = showEntryClass.Show_ID; showFinalClass.Show_Entry_Class_ID = showEntryClass.Show_Entry_Class_ID; showFinalClass.Show_Final_Class_Description = finalClassName.Show_Final_Class_Description; showFinalClass.Show_Final_Class_No = finalClassName.OrderBy; show_Final_Class_ID = showFinalClass.Insert_Show_Final_Class(user_ID); if (show_Final_Class_ID == null) { MessageLabel.Text = "Show Final Class Insert Failed!"; break; } else { MessageLabel.Text = "Show Final Class Insert Successful."; } } } }
private void ClearFinalClassNames() { StringBuilder sb = new StringBuilder("Error List:"); if (FinalClassNameList != null && FinalClassNameList.Count > 0) { foreach (FinalClassNames finalClassName in FinalClassNameList) { int delCount = 0; ShowFinalClasses showFinalClasses = new ShowFinalClasses(); delCount = showFinalClasses.DeleteShowFinalClassesByShowEntryClass(finalClassName.Show_Entry_Class_ID); if (delCount <= 0) { sb.AppendLine(string.Format("\nShow Final Class Delete Failed for {0}!", finalClassName.Class_Name_Description)); } } } //MessageLabel.Text = sb.ToString(); }