예제 #1
0
 public static void RoundInfo( UniversityInfo un )
 {
     un.MaximalTaitionFee = Math.Round( un.MaximalTaitionFee, 2 );
     un.MaximalResult = Math.Round( un.MaximalResult, 2 );
     un.MinimalTaitionFee = Math.Round( un.MinimalTaitionFee, 2 );
     un.MinimalResult = Math.Round( un.MinimalResult, 2 );
     un.RentsApartment = Math.Round( un.RentsApartment, 2 );
     un.RentsDormitory = Math.Round( un.RentsDormitory, 2 );
     un.ExpensesFood = Math.Round( un.ExpensesFood, 2 );
     un.ExpensesTravel = Math.Round( un.ExpensesTravel, 2 );
 }
예제 #2
0
 public ActionResult StudentPage( string UniversityID = null, int choose = 0, bool contract = false)
 {
     ViewBag.Title = "Відправка форми";
     UniversityInfo univ = new UniversityInfo();
     univ.IsContract = contract;
     univ.Choose = choose;
     univ.UniversityID = UniversityID;
     if (choose != 0)
         ViewBag.Model2 = univ;
     else
         ViewBag.Model2 = null;
     return View();
 }
예제 #3
0
        public static UniversityInfo GetInfo( string univers, bool contract, bool award, int choose )
        {
            UniversityInfo un = new UniversityInfo();

            var notes = NotesBusiness.GetListFromUniversity( univers );

            un.Award = 820;
            un.StateName = StateBusiness.GetStateNameFromUniversity( univers );
            un.UniversityName = GetName( univers );
            un.UniversityID = univers;
            un.IsContract = contract;
            un.Choose = choose;
            un.IsHaveAward = award;

            int ef = 0, et = 0, ra = 0, rd = 0;

            un.MinimalTaitionFee = double.MaxValue;

            foreach (var note in notes)
            {
                if (note.ExpensesFood > 0)
                {
                    un.ExpensesFood += note.ExpensesFood;
                    ef++;
                }

                if (note.ExpensesTravel > 0)
                {
                    un.ExpensesTravel += note.ExpensesTravel;
                    et++;
                }

                if (note.RentsApartment > 0 && choose == 2)
                {
                    un.RentsApartment += note.RentsApartment;
                    ra++;
                }

                if (note.RentsDormitory > 0 && choose == 3)
                {
                    un.RentsDormitory += note.RentsDormitory;
                    rd++;
                }

                if (contract)
                {
                    if (un.MaximalTaitionFee < note.MaximalTaitionFee)
                        un.MaximalTaitionFee = note.MaximalTaitionFee;

                    if (un.MinimalTaitionFee > note.MinimalTaitionFee)
                        un.MinimalTaitionFee = note.MinimalTaitionFee;
                }
            }

            if (!contract)
                un.MinimalTaitionFee = 0;

            if (ef > 0)
                un.ExpensesFood /= (double)ef;
            if (et > 0)
                un.ExpensesTravel /= (double)et;
            if (ra > 0 && choose == 2)
                un.RentsApartment /= (double)ra;
            if (rd > 0 && choose == 3)
                un.RentsDormitory /= (double)rd;

            un.MaximalResult = un.MinimalResult = un.RentsDormitory + un.RentsApartment + un.ExpensesTravel + un.ExpensesFood;

            if (contract)
            {
                un.MinimalResult += un.MinimalTaitionFee;
                un.MaximalResult += un.MaximalTaitionFee;
            }

            if (award)
            {
                un.MaximalResult -= un.Award;
                un.MinimalResult -= un.Award;
            }

            RoundInfo( un );

            if (Double.IsNaN( un.MaximalResult ) || Double.IsNaN( un.MinimalResult ))
                un.IsNaN = true;

            return un;
        }