Ejemplo n.º 1
0
        public double GetRate(string town, string date)
        {
            DateTime dt;

            DateTime.TryParseExact(date,
                                   "yyyy.MM.dd",
                                   CultureInfo.InvariantCulture,
                                   DateTimeStyles.None,
                                   out dt);
            if (dt != null)
            {
                TaxClassesDataContext dc     = new TaxClassesDataContext();
                List <Tax>            result = dc.Taxes.Where(t => t.Town.Equals(town) && dt >= t.DateBegin && dt <= t.DateEnd).OrderBy(t => t.TimeSpan).ToList();
                if (result.Count > 0)
                {
                    return(result.Last().Rate);
                }
                else
                {
                    return(0.0);
                }
            }
            else
            {
                return(0.0);
            }
        }
Ejemplo n.º 2
0
        public void DeleteTaxes(string town)
        {
            TaxClassesDataContext dc           = new TaxClassesDataContext();
            List <Tax>            matchedTaxes = dc.Taxes.Where(t => t.Town.Equals(town)).ToList();

            dc.Taxes.DeleteAllOnSubmit(matchedTaxes);
            dc.SubmitChanges();
        }
Ejemplo n.º 3
0
        public Tax CreateTax(Tax createTax)
        {
            Table <Tax> taxes = new TaxClassesDataContext().Taxes;

            try
            {
                taxes.InsertOnSubmit(createTax);
            }
            catch (Exception)
            {
                return(null);
            }
            taxes.Context.SubmitChanges();
            return(createTax);
        }
Ejemplo n.º 4
0
        public List <Tax> CreateTaxes(List <Tax> createTaxes)
        {
            var dc = new TaxClassesDataContext();

            dc.ExecuteCommand("TRUNCATE TABLE Tax");
            Table <Tax> taxes = dc.Taxes;

            foreach (Tax t in createTaxes)
            {
                try
                {
                    taxes.InsertOnSubmit(t);
                }
                catch (Exception)
                {
                    return(null);
                }
            }
            taxes.Context.SubmitChanges();
            return(createTaxes);
        }
Ejemplo n.º 5
0
        public List <Tax> GetAllTaxesOfTown(string town)
        {
            TaxClassesDataContext dc = new TaxClassesDataContext();

            return(dc.Taxes.Where(t => t.Town.Equals(town)).ToList());
        }
Ejemplo n.º 6
0
        public List <Tax> GetAllTaxes()
        {
            TaxClassesDataContext dc = new TaxClassesDataContext();

            return(dc.Taxes.ToList());
        }