private static void SpecialEquipment(List <object> data)
        {
            var name = data[0].ToString();

            var specialEquipment = new SpecialEquipment(name);

            Insert <SpecialEquipment> .InsertOriginal(specialEquipment, Select.SpecialEquipment());
        }
Exemplo n.º 2
0
        private void SpecialEquipmentSelector(object sender, EventArgs e)
        {
            var picker        = (Picker)sender;
            int selectedIndex = picker.SelectedIndex;

            if (selectedIndex >= 0)
            {
                SpecialEquipment selected = (SpecialEquipment)picker.SelectedItem;
                //SpecialEquipmentCode = selected.Code;
            }
        }
    private decimal ReturnPrice(SpecialEquipment equipment)
    {
        decimal reslut = decimal.Zero;

        VehcileSearchCondition vehcilesearchcondition = (VehcileSearchCondition)Utility.Transaction.CurrentSearchConditions;

        int days = ((TimeSpan)vehcilesearchcondition.DropoffTime.Subtract(vehcilesearchcondition.PickupTime)).Days;

        decimal decDay = decimal.Zero;
        decimal decWeek = decimal.Zero;
        decimal decMonth = decimal.Zero;
        decimal decMax = decimal.Zero;

        for (int count = 0; count < equipment.CalculationList.Count; count++)
        {
            if (equipment.CalculationList[count].UnitName == "RentalPeriod")
            {
                decMax = Convert.ToDecimal(equipment.CalculationList[count].UnitCharge);
            }
            else if (equipment.CalculationList[count].UnitName == "Week")
            {
                decWeek = Convert.ToDecimal(equipment.CalculationList[count].UnitCharge);
            }
            else if (equipment.CalculationList[count].UnitName == "Day")
            {
                decDay = Convert.ToDecimal(equipment.CalculationList[count].UnitCharge);
            }
            else if (equipment.CalculationList[count].UnitName == "Month")
            {
                decMonth = Convert.ToDecimal(equipment.CalculationList[count].UnitCharge);
            }
        }

        if (decDay == decimal.Zero && decWeek == decimal.Zero && decMonth == decimal.Zero && decMax != decimal.Zero)
        {
            int indexMonth = days / 30;

            int modMonth = days % 30;

            if (indexMonth <= 1 && modMonth == 0)
            {
                reslut = decMax;
            }
            else
            {
                reslut = (decMax * (indexMonth + 1));
            }
        }
        else
        {
            if (days < 7)
            {
                if (decWeek > 0)
                {
                    if (days * decDay > decWeek)
                    {
                        reslut = decWeek;
                    }
                    else
                    {
                        reslut = (days * decDay);
                    }
                }
                else
                {
                    if (days * decDay > decMax)
                    {
                        reslut = decMax;
                    }
                    else
                    {
                        reslut = (days * decDay);
                    }
                }
            }
            else if (days < 30)
            {
                if (decWeek > 0)
                {
                    int indexWeek = days / 7;

                    int modWeek = days % 7;

                    if ((decWeek * indexWeek + days * modWeek) > decMax)
                    {
                        reslut = decMax;
                    }
                    else
                    {
                        reslut = (decWeek * indexWeek + decDay * modWeek);
                    }
                }
                else
                {
                    if (days * decDay > decMax)
                    {
                        reslut = decMax;
                    }
                    else
                    {
                        reslut = (days * decDay);
                    }
                }
            }
            else
            {
                if (decMonth > 0)
                {
                    reslut = decMax;
                }
                else
                {
                    int indexMonth = days / 30;

                    int modMonth = days % 30;

                    int indexWeek = modMonth / 7;

                    int modWeek = modMonth % 7;

                    if (decDay * modMonth > decMax)
                    {
                        reslut= (decMax * indexMonth + decMax);
                    }
                    else
                    {
                        reslut= (decMax * indexMonth + decDay * modMonth);
                    }
                }
            }
        }

        return reslut;
    }