public IndexModel(IRepository repository)
 {
     DateFrom = DateTime.Now;
     DateTo   = DateFrom.AddYears(1);
     //repo = FakeEventRepository.Instance;// Der skal kun være et objekt af FakeEventRepository
     repo = repository;
 }
示例#2
0
        private void Forward(object sender, RoutedEventArgs e)
        {
            switch (Interval)
            {
            case "Day":
                DateFrom = DateFrom.AddDays(1);
                break;

            case "Week":
                DateFrom = DateFrom.AddDays(7);
                break;

            case "Month":
                DateFrom = DateFrom.AddMonths(1);
                break;

            case "Year":
                DateFrom = DateFrom.AddYears(1);
                break;
            }
        }
示例#3
0
        public string AddSchedule(string Municipality, string TaxType, string Date)
        {
            string   MunID, TaxID;
            DateTime DateFrom, DateTo;

            if (!DateTime.TryParse(Date, out DateFrom))
            {
                return("Date value invalid");
            }

            switch (TaxType.ToLower())
            {
            case "yearly":
                DateTo = DateFrom.AddYears(1);
                break;

            case "monthly":
                DateTo = DateFrom.AddMonths(1);
                break;

            case "weekly":
                DateTo = DateFrom.AddDays(7);
                break;

            case "daily":
                DateTo = DateFrom.AddDays(1);
                break;

            default:
                return("Tax Type parameter invalid");
            }


            SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["Connectas"].ConnectionString);

            try
            {
                conn.Open();
                DataSet        ds       = new DataSet();
                SqlDataAdapter konektas = new SqlDataAdapter("Select ID from Municipality where [Municipality] = '" + Municipality + "'", conn);
                konektas.Fill(ds);
                konektas.Dispose();
                if (ds.Tables[0].Rows.Count == 0)
                {
                    return("Municipality not defined");
                }
                MunID = ds.Tables[0].Rows[0]["ID"].ToString();

                ds       = new DataSet();
                konektas = new SqlDataAdapter("Select ID from TaxesConfig where [TaxTypeString] = '" + TaxType + "'", conn);
                konektas.Fill(ds);
                konektas.Dispose();
                if (ds.Tables[0].Rows.Count == 0)
                {
                    return("TaxesConfig not defined");
                }
                TaxID = ds.Tables[0].Rows[0]["ID"].ToString();

                SqlCommand cmd = new SqlCommand("INSERT INTO [Taxes] values (" + MunID + "," + TaxID + ",'" + DateFrom.ToString("yyyy-MM-dd") + "','" + DateTo.ToString("yyyy-MM-dd") + "')", conn);
                cmd.ExecuteNonQuery();

                conn.Close();

                return("OK");
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
 public IndexModel(IRepository repository)
 {
     DateFrom = DateTime.Now;
     DateTo   = DateFrom.AddYears(1);
     repo     = repository;
 }