Esempio n. 1
0
        private void btnHesap_Click(object sender, EventArgs e)
        {
            Bill bill;

            switch ((EBillKind)((Enum.Parse(typeof(EBillKind), (comboBox1.SelectedItem.ToString())))))
            {
            case EBillKind.Electricity:
                bill = new ElectricityBill();
                break;

            case EBillKind.Water:
                bill = new WaterBill();
                break;

            case EBillKind.Gas:
                bill = new GasBill();
                break;

            default:
                bill = new ElectricityBill();
                break;
            }
            Calculate calculator = new Calculate();

            bill.FirsIndex   = (float)numericUpDownilk.Value;
            bill.LastIndex   = (float)numericUpDownSon.Value;
            lblKullanım.Text = ((ICalculate)bill).TotalConsumption().ToString();
            lblTutar.Text    = (calculator.GetCalculation(bill).ToString());
        }
 public decimal GasDiscTotal(GasBill gasBill, Tariff tariff)
 {
     decimal totalValue = 0;
     List<decimal> tariffStr = tariff.ParseDiscString(tariff.GasDiscString);
     if (tariffStr.Count == 5)
     {
         if (gasBill.GasUsage >= tariffStr[0])
         {
             totalValue += tariffStr[0] * tariffStr[2];
             if (gasBill.GasUsage < tariffStr[1])
             {
                 totalValue += (gasBill.GasUsage - tariffStr[0]) * tariffStr[3];
             }
             else
             {
                 totalValue += ((tariffStr[1] - tariffStr[0]) * tariffStr[3]) + ((gasBill.GasUsage - tariffStr[1]) * tariffStr[4]);
             }
         }
         else
         {
             return gasBill.GasUsage * tariffStr[2];
         }
         return totalValue;
     }
     return totalValue;
 }
        public RedirectToRouteResult AddGasbillToCheckout(Checkout order, GasBill gasBill, string returnUrl)
        {
            if (gasBill != null)
            {
                if (order.chosenTariff == null)
                {
                    order.chosenTariff = tariffRepo.Tariffs
                        .FirstOrDefault(p => p.Id != null);

                }

                order.InitCalc(new ValueCalculator());
                order.SetGas(gasBill);
            }
            return RedirectToAction("Index", new { returnUrl });
        }
 public ViewResult AddGasbillToCheckout()
 {
     GasBill gasBill = new GasBill();
     return View(gasBill);
 }
 public decimal GasTotal(GasBill gasBill, Tariff tariff)
 {
     return gasBill.GasUsage * tariff.GasTariff;
 }