Exemplo n.º 1
0
        public LastTaxPayedViewModel GetLastTax(int motorcycleId)
        {
            LastTaxPayedViewModel lastTaxIdAndContCount = null;

            try
            {
                string query = $"select first 1 t.id ,t.contributioncount, t.payday, t.price from tax t where t.motorcycledata_id = {motorcycleId} order by t.payday desc";

                com.CommandText = query;

                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }

                using (var reader = com.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        int      taxId     = int.Parse(reader["id"].ToString());
                        short    contCount = short.Parse(reader["contributioncount"].ToString());
                        DateTime payDate   = DateTime.Parse(reader["payday"].ToString());
                        double   price     = double.Parse(reader["price"].ToString());

                        lastTaxIdAndContCount = new LastTaxPayedViewModel
                        {
                            ContCount = contCount,
                            PayDate   = payDate,
                            Price     = price,
                            TaxId     = taxId,
                        };
                    }
                }
            }
            catch (Exception ex)
            {
                logger.LogExceptionText(ex.ToString());
            }
            finally
            {
                con.Close();
            }

            return(lastTaxIdAndContCount);
        }
Exemplo n.º 2
0
        private void GenerateTaxTabData()
        {
            int currentBikeId = GlobalVariables.CurrentBikeId;

            if (!taxService.HasTax(currentBikeId))
            {
                TaxInformationLabel.Text      = "Данъка не е платен";
                TaxInformationLabel.ForeColor = Color.Red;
                return;
            }

            LastTaxPayedViewModel model = taxService.GetLastTax(currentBikeId);
            int      contCount          = taxService.GeTaxContCount(model.TaxId);
            DateTime taxValidDay        = model.PayDate.AddYears(1);

            if (taxValidDay >= DateTime.Now)
            {
                if (contCount == 2)
                {
                    TaxInformationLabel.Text      = $"Данъка е платен до {taxValidDay:dd.MM.yyyy}";
                    TaxInformationLabel.ForeColor = Color.Green;
                    return;
                }
                else if (contCount == 1)
                {
                    TaxInformationLabel.Text      = $"Остава да направите 1 вноска";
                    TaxInformationLabel.ForeColor = Color.Orange;
                    double priceLeft = model.Price / 2;
                    priceLeft             = Math.Round(priceLeft, 2);
                    TaxContPriceText.Text = priceLeft.ToString();
                    return;
                }
            }

            TaxInformationLabel.Text      = "Данъка не е платен";
            TaxInformationLabel.ForeColor = Color.Red;
        }