Esempio n. 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            AspNetFinanceMonth aspNetFinanceMonth = db.AspNetFinanceMonths.Find(id);

            db.AspNetFinanceMonths.Remove(aspNetFinanceMonth);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
 public ActionResult Edit([Bind(Include = "Id,Month,StartData,EndDate,Name,PeriodId")] AspNetFinanceMonth aspNetFinanceMonth)
 {
     if (ModelState.IsValid)
     {
         db.Entry(aspNetFinanceMonth).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.PeriodId = new SelectList(db.AspNetFinancePeriods, "Id", "Year", aspNetFinanceMonth.PeriodId);
     return(View(aspNetFinanceMonth));
 }
Esempio n. 3
0
        // GET: AspNetFinanceMonths/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AspNetFinanceMonth aspNetFinanceMonth = db.AspNetFinanceMonths.Find(id);

            if (aspNetFinanceMonth == null)
            {
                return(HttpNotFound());
            }
            return(View(aspNetFinanceMonth));
        }
Esempio n. 4
0
        // GET: AspNetFinanceMonths/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AspNetFinanceMonth aspNetFinanceMonth = db.AspNetFinanceMonths.Find(id);

            if (aspNetFinanceMonth == null)
            {
                return(HttpNotFound());
            }
            ViewBag.PeriodId = new SelectList(db.AspNetFinancePeriods, "Id", "Year", aspNetFinanceMonth.PeriodId);
            return(View(aspNetFinanceMonth));
        }
Esempio n. 5
0
        public ActionResult Create([Bind(Include = "Id,Year")] AspNetFinancePeriod aspNetFinancePeriod)
        {
            if (ModelState.IsValid)
            {
                db.AspNetFinancePeriods.Add(aspNetFinancePeriod);
                db.SaveChanges();
                string[] Months = new string[] { "July", "August", "September", "October", "November", "December", "January", "Febuary", "March", "April", "May", "June" };

                for (int i = 1; i <= 12; i++)
                {
                    AspNetFinanceMonth month = new AspNetFinanceMonth();
                    month.Month = Months[i - 1];
                    string start = "01";
                    string end   = "";
                    if (i != 4 && i != 5 && i != 6)
                    {
                        if (i < 10)
                        {
                            month.Name = aspNetFinancePeriod.Year + "-00" + i;
                        }
                        else
                        {
                            month.Name = aspNetFinancePeriod.Year + "-0" + i;
                        }
                        if (i <= 6)
                        {
                            start = start + "/0" + (i + 6) + "/" + aspNetFinancePeriod.Year;
                        }
                        else
                        {
                            start = start + "/0" + (i - 6) + "/" + aspNetFinancePeriod.Year;
                        }
                    }
                    else
                    {
                        if (i < 10)
                        {
                            month.Name = aspNetFinancePeriod.Year + "-00" + i;
                        }
                        else
                        {
                            month.Name = aspNetFinancePeriod.Year + "-0" + i;
                        }
                        if (i <= 6)
                        {
                            start = start + "/" + (i + 6) + "/" + aspNetFinancePeriod.Year;
                        }
                        else
                        {
                            start = start + "/" + (i - 6) + "/" + aspNetFinancePeriod.Year;
                        }
                    }

                    if (i == 1 || i == 2 || i == 4 || i == 6 || i == 7 || i == 9 || i == 11)
                    {
                        end = "31";
                        if (i != 4 && i != 5 && i != 6)
                        {
                            if (i <= 6)
                            {
                                end = end + "/0" + (i + 6) + "/" + aspNetFinancePeriod.Year;
                            }
                            else
                            {
                                end = end + "/0" + (i - 6) + "/" + aspNetFinancePeriod.Year;
                            }
                        }
                        else
                        {
                            if (i <= 6)
                            {
                                end = end + "/" + (i + 6) + "/" + aspNetFinancePeriod.Year;
                            }
                            else
                            {
                                end = end + "/" + (i - 6) + "/" + aspNetFinancePeriod.Year;
                            }
                        }
                    }
                    else if (i == 3 || i == 5 || i == 10 || i == 12)
                    {
                        end = "30";
                        if (i != 4 && i != 5 && i != 6)
                        {
                            if (i <= 6)
                            {
                                end = end + "/0" + (i + 6) + "/" + aspNetFinancePeriod.Year;
                            }
                            else
                            {
                                end = end + "/0" + (i - 6) + "/" + aspNetFinancePeriod.Year;
                            }
                        }
                        else
                        {
                            if (i <= 6)
                            {
                                end = end + "/" + (i + 6) + "/" + aspNetFinancePeriod.Year;
                            }
                            else
                            {
                                end = end + "/" + (i - 6) + "/" + aspNetFinancePeriod.Year;
                            }
                        }
                    }
                    else if (i == 8)
                    {
                        var remainder = Convert.ToInt32(aspNetFinancePeriod.Year) % 4;
                        if (remainder == 0)
                        {
                            end = "29";
                        }
                        else
                        {
                            end = "28";
                        }

                        end = end + "/0" + (i - 6) + "/" + aspNetFinancePeriod.Year;
                    }

                    month.StartData = DateTime.ParseExact(start, "dd/MM/yyyy", CultureInfo.InvariantCulture);;
                    month.EndDate   = DateTime.ParseExact(end, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                    month.PeriodId  = db.AspNetFinancePeriods.Select(x => x.Id).Max();
                    db.AspNetFinanceMonths.Add(month);
                }
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(aspNetFinancePeriod));
        }