public static AllocationOfSeatsAmongCategories GetBranchSeatsWithCatogaries(double seatsAvailableInBranch)
        {
            AllocationOfSeatsAmongCategories casteWiseSeats = new AllocationOfSeatsAmongCategories();

            casteWiseSeats.CAP  = Round(GetSeats(seatsAvailableInBranch, 2), 0);
            casteWiseSeats.CAPG = Round((casteWiseSeats.CAP * 33.33) / 100, 0);
            casteWiseSeats.CAP  = casteWiseSeats.CAP - casteWiseSeats.CAPG;

            seatsAvailableInBranch = seatsAvailableInBranch - (casteWiseSeats.CAP + casteWiseSeats.CAPG);

            casteWiseSeats.PH  = Round(GetSeats(seatsAvailableInBranch, 3), 0);
            casteWiseSeats.PHG = Round((casteWiseSeats.PH * 33.33) / 100, 0);
            casteWiseSeats.PH  = casteWiseSeats.PH - casteWiseSeats.PHG;

            casteWiseSeats.NCC  = Round(GetSeats(seatsAvailableInBranch, 1), 0);
            casteWiseSeats.NCCG = Round((casteWiseSeats.NCC * 33.33) / 100, 0);
            casteWiseSeats.NCC  = casteWiseSeats.NCC - casteWiseSeats.NCCG;

            casteWiseSeats.SPORTS  = Round(GetSeats(seatsAvailableInBranch, 0.5), 0);
            casteWiseSeats.SPORTSG = Round((casteWiseSeats.SPORTS * 33.33) / 100, 0);
            casteWiseSeats.SPORTS  = casteWiseSeats.SPORTS - casteWiseSeats.SPORTSG;


            seatsAvailableInBranch = seatsAvailableInBranch - (casteWiseSeats.PH + casteWiseSeats.NCC + casteWiseSeats.SPORTS + casteWiseSeats.PHG + casteWiseSeats.NCCG + casteWiseSeats.SPORTSG);

            casteWiseSeats.OC  = Round(GetSeats(seatsAvailableInBranch, 50), 0);
            casteWiseSeats.OCG = Round((casteWiseSeats.OC * 33.33) / 100, 0);
            casteWiseSeats.OC -= casteWiseSeats.OCG;

            casteWiseSeats.BCA  = Round(GetSeats(seatsAvailableInBranch, 7), 0);
            casteWiseSeats.BCAG = Round((casteWiseSeats.BCA * 33.33) / 100, 0);
            casteWiseSeats.BCA -= casteWiseSeats.BCAG;

            casteWiseSeats.BCB  = Round(GetSeats(seatsAvailableInBranch, 10), 0);
            casteWiseSeats.BCBG = Round((casteWiseSeats.BCB * 33.33) / 100, 0);
            casteWiseSeats.BCB -= casteWiseSeats.BCBG;

            casteWiseSeats.BCC  = Round(GetSeats(seatsAvailableInBranch, 1), 0);
            casteWiseSeats.BCCG = Round((casteWiseSeats.BCC * 33.33) / 100, 0);
            casteWiseSeats.BCC -= casteWiseSeats.BCCG;

            casteWiseSeats.BCD  = Round(GetSeats(seatsAvailableInBranch, 7), 0);
            casteWiseSeats.BCDG = Round((casteWiseSeats.BCD * 33.33) / 100, 0);
            casteWiseSeats.BCD -= casteWiseSeats.BCDG;

            casteWiseSeats.BCE  = Round(GetSeats(seatsAvailableInBranch, 4), 0);
            casteWiseSeats.BCEG = Round((casteWiseSeats.BCE * 33.33) / 100, 0);
            casteWiseSeats.BCE -= casteWiseSeats.BCEG;

            casteWiseSeats.SC  = Round(GetSeats(seatsAvailableInBranch, 15), 0);
            casteWiseSeats.SCG = Round((casteWiseSeats.SC * 33.33) / 100, 0);
            casteWiseSeats.SC -= casteWiseSeats.SCG;

            casteWiseSeats.ST  = Round(GetSeats(seatsAvailableInBranch, 6), 0);
            casteWiseSeats.STG = Round((casteWiseSeats.ST * 33.33) / 100, 0);
            casteWiseSeats.ST -= casteWiseSeats.STG;

            return(casteWiseSeats);
        }
 private void AdjustSpecialCategorySeats(AllocationOfSeatsAmongCategories availableSeats)
 {
     //Male
     if (availableSeats.CAP > 0)
     {
         availableSeats.OC += availableSeats.CAP;
     }
     if (availableSeats.PH > 0)
     {
         availableSeats.OC += availableSeats.PH;
     }
     if (availableSeats.NCC > 0)
     {
         availableSeats.OC += availableSeats.NCC;
     }
     if (availableSeats.SPORTS > 0)
     {
         availableSeats.OC += availableSeats.SPORTS;
     }
     //Female
     if (availableSeats.CAPG > 0)
     {
         availableSeats.OCG += availableSeats.CAPG;
     }
     if (availableSeats.PHG > 0)
     {
         availableSeats.OCG += availableSeats.PHG;
     }
     if (availableSeats.NCCG > 0)
     {
         availableSeats.OCG += availableSeats.NCCG;
     }
     if (availableSeats.SPORTSG > 0)
     {
         availableSeats.OCG += availableSeats.SPORTSG;
     }
 }
        private void AdjustAvailableSeatsAfterallotment(AllocationOfSeatsAmongCategories availableSeats)
        {
            //Male
            if (availableSeats.BCA > 0)
            {
                if (availableSeats.BCB > 0)
                {
                    if (availableSeats.BCC > 0)
                    {
                        if (availableSeats.BCD > 0)
                        {
                            if (availableSeats.BCE > 0)
                            {
                                availableSeats.BCA += availableSeats.BCE;
                            }
                            else
                            {
                                availableSeats.BCE += (availableSeats.BCA + availableSeats.BCB + availableSeats.BCC + availableSeats.BCE);
                            }
                        }
                        else
                        {
                            availableSeats.BCD += (availableSeats.BCA + availableSeats.BCB + availableSeats.BCC);
                        }
                    }
                    else
                    {
                        availableSeats.BCC += (availableSeats.BCA + availableSeats.BCB);
                    }
                }
                else
                {
                    availableSeats.BCB += availableSeats.BCA;
                }
            }
            if (availableSeats.SC > 0)
            {
                availableSeats.ST += availableSeats.SC;
            }
            else if (availableSeats.SC > 0)
            {
                availableSeats.SC += availableSeats.ST;
            }



            if (availableSeats.BCAG > 0)
            {
                if (availableSeats.BCBG > 0)
                {
                    if (availableSeats.BCCG > 0)
                    {
                        if (availableSeats.BCDG > 0)
                        {
                            if (availableSeats.BCEG > 0)
                            {
                                availableSeats.BCAG += availableSeats.BCEG;
                            }
                            else
                            {
                                availableSeats.BCEG += (availableSeats.BCAG + availableSeats.BCBG + availableSeats.BCCG + availableSeats.BCEG);
                            }
                        }
                        else
                        {
                            availableSeats.BCDG += (availableSeats.BCAG + availableSeats.BCBG + availableSeats.BCCG);
                        }
                    }
                    else
                    {
                        availableSeats.BCCG += (availableSeats.BCAG + availableSeats.BCBG);
                    }
                }
                else
                {
                    availableSeats.BCBG += availableSeats.BCAG;
                }
            }
            if (availableSeats.SCG > 0)
            {
                availableSeats.STG += availableSeats.SCG;
            }
            else if (availableSeats.SCG > 0)
            {
                availableSeats.SCG += availableSeats.STG;
            }
        }
        private void AllocateRemainingSeatsToOpenCategory(AllocationOfSeatsAmongCategories availableSeats)
        {
            //Male
            if (availableSeats.BCA > 0)
            {
                availableSeats.OC += availableSeats.BCA;
            }
            if (availableSeats.BCB > 0)
            {
                availableSeats.OC += availableSeats.BCB;
            }
            if (availableSeats.BCC > 0)
            {
                availableSeats.OC += availableSeats.BCC;
            }
            if (availableSeats.BCD > 0)
            {
                availableSeats.OC += availableSeats.BCD;
            }
            if (availableSeats.BCE > 0)
            {
                availableSeats.OC += availableSeats.BCE;
            }
            if (availableSeats.SC > 0)
            {
                availableSeats.OC += availableSeats.SC;
            }
            if (availableSeats.ST > 0)
            {
                availableSeats.OC += availableSeats.ST;
            }


            //Female

            if (availableSeats.BCAG > 0)
            {
                availableSeats.OCG += availableSeats.BCAG;
            }
            if (availableSeats.BCBG > 0)
            {
                availableSeats.OCG += availableSeats.BCBG;
            }
            if (availableSeats.BCCG > 0)
            {
                availableSeats.OCG += availableSeats.BCCG;
            }
            if (availableSeats.BCDG > 0)
            {
                availableSeats.OCG += availableSeats.BCDG;
            }
            if (availableSeats.BCEG > 0)
            {
                availableSeats.OCG += availableSeats.BCEG;
            }
            if (availableSeats.SCG > 0)
            {
                availableSeats.OCG += availableSeats.SCG;
            }
            if (availableSeats.SCG > 0)
            {
                availableSeats.OCG += availableSeats.STG;
            }
        }
 private void CheckAndAllocatebranchToSpecialCategoryStudent(StudentDetails student, AllocationOfSeatsAmongCategories availableSeats, ObservableCollection <EngineeringBranchAllocation.AllotmentResults> EceAllotmentResults, StudentDetails.Branches branches)
 {
     // CAP
     if (student.SpecialCategory.Equals(StudentDetails.Category.CAP))
     {
         if (availableSeats.CAP > 0)
         {
             EceAllotmentResults.Add(new AllotmentResults
             {
                 StudentId       = student.Id,
                 Name            = student.Name,
                 AllottedBranch  = branches,
                 CGPA            = student.CGPA.ToString(),
                 StudentCaste    = student.StudentCaste,
                 StudentCategory = student.SpecialCategory
             });
             availableSeats.CAP--;
             student.isBranchAllotted = true;
             return;
         }
     }
     if (student.SpecialCategory.Equals(StudentDetails.Category.CAP) && student.GenderType.Equals(StudentDetails.Gender.Female))
     {
         if (availableSeats.CAPG > 0)
         {
             EceAllotmentResults.Add(new AllotmentResults
             {
                 StudentId       = student.Id,
                 Name            = student.Name,
                 AllottedBranch  = branches,
                 CGPA            = student.CGPA.ToString(),
                 StudentCaste    = student.StudentCaste,
                 StudentCategory = student.SpecialCategory
             });
             availableSeats.CAPG--;
             student.isBranchAllotted = true;
             return;
         }
     }
     //PH
     if (student.SpecialCategory.Equals(StudentDetails.Category.PH) || student.SpecialCategory.Equals(StudentDetails.Category.PHHEARING) ||
         student.SpecialCategory.Equals(StudentDetails.Category.PHORTHO) ||
         student.SpecialCategory.Equals(StudentDetails.Category.PHVISUAL))
     {
         if (availableSeats.PH > 0)
         {
             EceAllotmentResults.Add(new AllotmentResults
             {
                 StudentId       = student.Id,
                 Name            = student.Name,
                 AllottedBranch  = branches,
                 CGPA            = student.CGPA.ToString(),
                 StudentCaste    = student.StudentCaste,
                 StudentCategory = student.SpecialCategory
             });
             availableSeats.PH--;
             student.isBranchAllotted = true;
             return;
         }
     }
     if (student.SpecialCategory.Equals(StudentDetails.Category.PH) || student.SpecialCategory.Equals(StudentDetails.Category.PHHEARING) ||
         student.SpecialCategory.Equals(StudentDetails.Category.PHORTHO) ||
         student.SpecialCategory.Equals(StudentDetails.Category.PHVISUAL) && student.GenderType.Equals(StudentDetails.Gender.Female))
     {
         if (availableSeats.PH > 0)
         {
             EceAllotmentResults.Add(new AllotmentResults
             {
                 StudentId       = student.Id,
                 Name            = student.Name,
                 AllottedBranch  = branches,
                 CGPA            = student.CGPA.ToString(),
                 StudentCaste    = student.StudentCaste,
                 StudentCategory = student.SpecialCategory
             });
             availableSeats.PH--;
             student.isBranchAllotted = true;
             return;
         }
     }
     //NCC
     if (student.SpecialCategory == StudentDetails.Category.NCC)
     {
         if (availableSeats.NCC > 0)
         {
             EceAllotmentResults.Add(new AllotmentResults
             {
                 StudentId       = student.Id,
                 Name            = student.Name,
                 AllottedBranch  = branches,
                 CGPA            = student.CGPA.ToString(),
                 StudentCaste    = student.StudentCaste,
                 StudentCategory = student.SpecialCategory
             });
             availableSeats.NCC--;
             student.isBranchAllotted = true;
             return;
         }
     }
     if (student.SpecialCategory == StudentDetails.Category.NCC && student.GenderType.Equals(StudentDetails.Gender.Female))
     {
         if (availableSeats.NCCG > 0)
         {
             EceAllotmentResults.Add(new AllotmentResults
             {
                 StudentId       = student.Id,
                 Name            = student.Name,
                 AllottedBranch  = branches,
                 CGPA            = student.CGPA.ToString(),
                 StudentCaste    = student.StudentCaste,
                 StudentCategory = student.SpecialCategory
             });
             availableSeats.NCCG--;
             student.isBranchAllotted = true;
             return;
         }
     }
     //Sports
     if (student.SpecialCategory == StudentDetails.Category.SPORTS)
     {
         if (availableSeats.SPORTS > 0)
         {
             EceAllotmentResults.Add(new AllotmentResults
             {
                 StudentId       = student.Id,
                 Name            = student.Name,
                 AllottedBranch  = branches,
                 CGPA            = student.CGPA.ToString(),
                 StudentCaste    = student.StudentCaste,
                 StudentCategory = student.SpecialCategory
             });
             availableSeats.SPORTS--;
             student.isBranchAllotted = true;
             return;
         }
     }
     if (student.SpecialCategory == StudentDetails.Category.SPORTS && student.GenderType.Equals(StudentDetails.Gender.Female))
     {
         if (availableSeats.SPORTSG > 0)
         {
             EceAllotmentResults.Add(new AllotmentResults
             {
                 StudentId       = student.Id,
                 Name            = student.Name,
                 AllottedBranch  = branches,
                 CGPA            = student.CGPA.ToString(),
                 StudentCaste    = student.StudentCaste,
                 StudentCategory = student.SpecialCategory
             });
             availableSeats.SPORTSG--;
             student.isBranchAllotted = true;
             return;
         }
     }
 }
        private void CheckAndAllocatebranchToStudent(StudentDetails student, AllocationOfSeatsAmongCategories availableSeats, ObservableCollection <AllotmentResults> EceAllotmentResults, StudentDetails.Branches branches)
        {
            //OC
            if (availableSeats.OC > 0)
            {
                EceAllotmentResults.Add(new AllotmentResults
                {
                    StudentId       = student.Id,
                    Name            = student.Name,
                    AllottedBranch  = branches,
                    CGPA            = student.CGPA.ToString(),
                    StudentCaste    = student.StudentCaste,
                    StudentCategory = student.SpecialCategory
                });
                availableSeats.OC--;
                student.isBranchAllotted = true;
                return;
            }


            if (student.GenderType.Equals(StudentDetails.Gender.Female) && availableSeats.OCG > 0)
            {
                EceAllotmentResults.Add(new AllotmentResults
                {
                    StudentId       = student.Id,
                    Name            = student.Name,
                    AllottedBranch  = branches,
                    CGPA            = student.CGPA.ToString(),
                    StudentCaste    = student.StudentCaste,
                    StudentCategory = student.SpecialCategory
                });
                availableSeats.OCG--;
                student.isBranchAllotted = true;
                return;
            }

            // BCA
            if (student.StudentCaste.Equals(StudentDetails.Cast.BCA))
            {
                if (availableSeats.BCA > 0)
                {
                    EceAllotmentResults.Add(new AllotmentResults
                    {
                        StudentId       = student.Id,
                        Name            = student.Name,
                        AllottedBranch  = branches,
                        CGPA            = student.CGPA.ToString(),
                        StudentCaste    = student.StudentCaste,
                        StudentCategory = student.SpecialCategory
                    });
                    availableSeats.BCA--;
                    student.isBranchAllotted = true;
                    return;
                }
            }
            if (student.StudentCaste.Equals(StudentDetails.Cast.BCA) && student.GenderType.Equals(StudentDetails.Gender.Female))
            {
                if (availableSeats.BCAG > 0)
                {
                    EceAllotmentResults.Add(new AllotmentResults
                    {
                        StudentId       = student.Id,
                        Name            = student.Name,
                        AllottedBranch  = branches,
                        CGPA            = student.CGPA.ToString(),
                        StudentCaste    = student.StudentCaste,
                        StudentCategory = student.SpecialCategory
                    });
                    availableSeats.BCAG--;
                    student.isBranchAllotted = true;
                    return;
                }
            }
            //BCB
            if (student.StudentCaste.Equals(StudentDetails.Cast.BCB))
            {
                if (availableSeats.BCB > 0)
                {
                    EceAllotmentResults.Add(new AllotmentResults
                    {
                        StudentId       = student.Id,
                        Name            = student.Name,
                        AllottedBranch  = branches,
                        CGPA            = student.CGPA.ToString(),
                        StudentCaste    = student.StudentCaste,
                        StudentCategory = student.SpecialCategory
                    });
                    availableSeats.BCB--;
                    student.isBranchAllotted = true;
                    return;
                }
            }
            if (student.StudentCaste.Equals(StudentDetails.Cast.BCB) && student.GenderType.Equals(StudentDetails.Gender.Female))
            {
                if (availableSeats.BCBG > 0)
                {
                    EceAllotmentResults.Add(new AllotmentResults
                    {
                        StudentId       = student.Id,
                        Name            = student.Name,
                        AllottedBranch  = branches,
                        CGPA            = student.CGPA.ToString(),
                        StudentCaste    = student.StudentCaste,
                        StudentCategory = student.SpecialCategory
                    });
                    availableSeats.BCBG--;
                    student.isBranchAllotted = true;
                    return;
                }
            }
            //BCC
            if (student.StudentCaste.Equals(StudentDetails.Cast.BCC))
            {
                if (availableSeats.BCC > 0)
                {
                    EceAllotmentResults.Add(new AllotmentResults
                    {
                        StudentId       = student.Id,
                        Name            = student.Name,
                        AllottedBranch  = branches,
                        CGPA            = student.CGPA.ToString(),
                        StudentCaste    = student.StudentCaste,
                        StudentCategory = student.SpecialCategory
                    });
                    availableSeats.BCC--;
                    student.isBranchAllotted = true;
                    return;
                }
            }
            if (student.StudentCaste.Equals(StudentDetails.Cast.BCC) && student.GenderType.Equals(StudentDetails.Gender.Female))
            {
                if (availableSeats.BCCG > 0)
                {
                    EceAllotmentResults.Add(new AllotmentResults
                    {
                        StudentId       = student.Id,
                        Name            = student.Name,
                        AllottedBranch  = branches,
                        CGPA            = student.CGPA.ToString(),
                        StudentCaste    = student.StudentCaste,
                        StudentCategory = student.SpecialCategory
                    });
                    availableSeats.BCCG--;
                    student.isBranchAllotted = true;
                    return;
                }
            }
            //BCD
            if (student.StudentCaste.Equals(StudentDetails.Cast.BCD))
            {
                if (availableSeats.BCD > 0)
                {
                    EceAllotmentResults.Add(new AllotmentResults
                    {
                        StudentId       = student.Id,
                        Name            = student.Name,
                        AllottedBranch  = branches,
                        CGPA            = student.CGPA.ToString(),
                        StudentCaste    = student.StudentCaste,
                        StudentCategory = student.SpecialCategory
                    });
                    availableSeats.BCD--;
                    student.isBranchAllotted = true;
                    return;
                }
            }
            if (student.StudentCaste.Equals(StudentDetails.Cast.BCD) && student.GenderType.Equals(StudentDetails.Gender.Female))
            {
                if (availableSeats.BCDG > 0)
                {
                    EceAllotmentResults.Add(new AllotmentResults
                    {
                        StudentId       = student.Id,
                        Name            = student.Name,
                        AllottedBranch  = branches,
                        CGPA            = student.CGPA.ToString(),
                        StudentCaste    = student.StudentCaste,
                        StudentCategory = student.SpecialCategory
                    });
                    availableSeats.BCDG--;
                    student.isBranchAllotted = true;
                    return;
                }
            }
            //BCE
            if (student.StudentCaste.Equals(StudentDetails.Cast.BCE))
            {
                if (availableSeats.BCE > 0)
                {
                    EceAllotmentResults.Add(new AllotmentResults
                    {
                        StudentId       = student.Id,
                        Name            = student.Name,
                        AllottedBranch  = branches,
                        CGPA            = student.CGPA.ToString(),
                        StudentCaste    = student.StudentCaste,
                        StudentCategory = student.SpecialCategory
                    });
                    availableSeats.BCE--;
                    student.isBranchAllotted = true;
                    return;
                }
            }
            if (student.StudentCaste.Equals(StudentDetails.Cast.BCE) && student.GenderType.Equals(StudentDetails.Gender.Female))
            {
                if (availableSeats.BCEG > 0)
                {
                    EceAllotmentResults.Add(new AllotmentResults
                    {
                        StudentId       = student.Id,
                        Name            = student.Name,
                        AllottedBranch  = branches,
                        CGPA            = student.CGPA.ToString(),
                        StudentCaste    = student.StudentCaste,
                        StudentCategory = student.SpecialCategory
                    });
                    availableSeats.BCEG--;
                    student.isBranchAllotted = true;
                    return;
                }
            }

            //SC
            if (student.StudentCaste.Equals(StudentDetails.Cast.SC))
            {
                if (availableSeats.SC > 0)
                {
                    EceAllotmentResults.Add(new AllotmentResults
                    {
                        StudentId       = student.Id,
                        Name            = student.Name,
                        AllottedBranch  = branches,
                        CGPA            = student.CGPA.ToString(),
                        StudentCaste    = student.StudentCaste,
                        StudentCategory = student.SpecialCategory
                    });
                    availableSeats.SC--;
                    student.isBranchAllotted = true;
                    return;
                }
            }
            if (student.StudentCaste.Equals(StudentDetails.Cast.SC) && student.GenderType.Equals(StudentDetails.Gender.Female))
            {
                if (availableSeats.SCG > 0)
                {
                    EceAllotmentResults.Add(new AllotmentResults
                    {
                        StudentId       = student.Id,
                        Name            = student.Name,
                        AllottedBranch  = branches,
                        CGPA            = student.CGPA.ToString(),
                        StudentCaste    = student.StudentCaste,
                        StudentCategory = student.SpecialCategory
                    });
                    availableSeats.SCG--;
                    student.isBranchAllotted = true;
                    return;
                }
            }
            //ST
            if (student.StudentCaste.Equals(StudentDetails.Cast.ST))
            {
                if (availableSeats.ST > 0)
                {
                    EceAllotmentResults.Add(new AllotmentResults
                    {
                        StudentId       = student.Id,
                        Name            = student.Name,
                        AllottedBranch  = branches,
                        CGPA            = student.CGPA.ToString(),
                        StudentCaste    = student.StudentCaste,
                        StudentCategory = student.SpecialCategory
                    });
                    availableSeats.ST--;
                    student.isBranchAllotted = true;
                    return;
                }
            }
            if (student.StudentCaste.Equals(StudentDetails.Cast.ST) && student.GenderType.Equals(StudentDetails.Gender.Female))
            {
                if (availableSeats.STG > 0)
                {
                    EceAllotmentResults.Add(new AllotmentResults
                    {
                        StudentId       = student.Id,
                        Name            = student.Name,
                        AllottedBranch  = branches,
                        CGPA            = student.CGPA.ToString(),
                        StudentCaste    = student.StudentCaste,
                        StudentCategory = student.SpecialCategory
                    });
                    availableSeats.STG--;
                    student.isBranchAllotted = true;
                    return;
                }
            }
        }