Permalink
Browse files

Layout, usability, style, etc..

  • Loading branch information...
1 parent d423998 commit 985107a94aafee7a64475567535bef4337a87258 @iloire committed Oct 6, 2011
Showing with 1,036 additions and 217 deletions.
  1. +2 −1 .gitignore
  2. +10 −0 README.md
  3. +6 −0 iloire Facturacion.sln
  4. BIN iloire Facturacion/App_Data/ASPNETDB.MDF
  5. BIN iloire Facturacion/App_Data/aspnetdb_log.ldf
  6. +14 −2 iloire Facturacion/Content/Site.css
  7. +2 −3 iloire Facturacion/Content/bootstrap.extra.css
  8. +2 −1 iloire Facturacion/Controllers/CustomerController.cs
  9. +1 −2 iloire Facturacion/Controllers/HomeController.cs
  10. +14 −7 iloire Facturacion/Controllers/InvoiceController.cs
  11. +41 −22 iloire Facturacion/Controllers/InvoiceDetailsController.cs
  12. +8 −1 iloire Facturacion/Controllers/PurchaseController.cs
  13. +2 −4 iloire Facturacion/Models/EntitiesContextDBInitializer.cs
  14. +2 −0 iloire Facturacion/Models/POCO/InvoiceDetails.cs
  15. +626 −0 iloire Facturacion/Scripts/jquery-calendar.js
  16. +7 −0 iloire Facturacion/Views/Customer/Details.cshtml
  17. +12 −9 iloire Facturacion/Views/Home/Index.cshtml
  18. +0 −19 iloire Facturacion/Views/Invoice/Details.cshtml
  19. +147 −4 iloire Facturacion/Views/Invoice/Edit.cshtml
  20. +22 −8 iloire Facturacion/Views/Invoice/Index.cshtml
  21. +0 −32 iloire Facturacion/Views/Invoice/InvoiceDetailsPartial.cshtml
  22. +15 −3 iloire Facturacion/Views/Invoice/InvoicesListPartial.cshtml
  23. +5 −6 iloire Facturacion/Views/InvoiceDetails/Create.cshtml
  24. +2 −9 iloire Facturacion/Views/InvoiceDetails/Delete.cshtml
  25. +5 −7 iloire Facturacion/Views/InvoiceDetails/Edit.cshtml
  26. +8 −9 iloire Facturacion/Views/InvoiceDetails/EditOrAddInvoiceDetailsPartial.cshtml
  27. +24 −35 iloire Facturacion/Views/InvoiceDetails/Index.cshtml
  28. +7 −1 iloire Facturacion/Views/Provider/Details.cshtml
  29. +40 −30 iloire Facturacion/Web.config
  30. +10 −2 iloire Facturacion/iloire Facturacion.csproj
  31. +2 −0 iloire Facturacion/packages.config
View
@@ -2,4 +2,5 @@ bin/
obj/
*.dll
*.pdb
-*.suo
+*.suo
+iloire Facturacion/App_Error/*
View
@@ -23,6 +23,16 @@ This is a sample invoicing application used for ASP.NET MVC3 training purposes.
## TAGS (change log):
+**0.12
+
+ * Added pagination functionality using https://github.com/martijnboland/MvcPaging library to some entities (pending the other ones)
+ * Added NUnit testing project as example of how to include it.
+ * Make "new", "edit" and delete invoice details work in new modal window, using AJAX and the twitter bootstrap css library.
+ * Layout changes
+ * Basic print view for invoices, with a custom layout for printing.
+ * Added error handling by including Elmah from NuGet repository (try it by accessing http://localhost:xxxx/elmah.axd)
+ * Added a custom functionality to HandleErrorAttribute so it logs to Elmah.
+
**0.11**
* Added search functionality in Customer list.
@@ -3,6 +3,8 @@ Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Web Developer Express 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "iloire Facturacion", "iloire Facturacion\iloire Facturacion.csproj", "{1895D1C8-FDCE-4BB7-839F-ADB779ED1EC6}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "iloire Facturacion Tests", "iloire Facturacion Tests\iloire Facturacion Tests.csproj", "{F54F4D12-10BE-4084-8470-5690D7831A44}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -13,6 +15,10 @@ Global
{1895D1C8-FDCE-4BB7-839F-ADB779ED1EC6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1895D1C8-FDCE-4BB7-839F-ADB779ED1EC6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1895D1C8-FDCE-4BB7-839F-ADB779ED1EC6}.Release|Any CPU.Build.0 = Release|Any CPU
+ {F54F4D12-10BE-4084-8470-5690D7831A44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F54F4D12-10BE-4084-8470-5690D7831A44}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F54F4D12-10BE-4084-8470-5690D7831A44}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F54F4D12-10BE-4084-8470-5690D7831A44}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Binary file not shown.
Binary file not shown.
@@ -3,12 +3,24 @@
color:White;
}
-ul.filtroAlfab{ list-style-type:none; margin:0px;}
+ul.filtroAlfab
+{
+ list-style-type:none;
+ margin:0px;
+ float:left;
+}
+
ul.filtroAlfab li
{
float:left;
- margin:4px;
+}
+
+ul.filtroAlfab li a
+{
+ margin:2px;
font-size:120%;
+ border: 1px solid #f5f5f5;
+ padding:4px 6px;
}
div.pagingContainer
@@ -7,13 +7,12 @@ body {
tfoot
{
- background-color:#222;
+ background-color:#666666;
}
tfoot *
{
font-weight:bold;
- color:White;
- font-size:110%;
+ color:white;
}
@@ -9,7 +9,7 @@
namespace iloire_Facturacion.Controllers
{
- [Authorize]
+ [Authorize]
public class CustomerController : Controller
{
private const int defaultPageSize = 10;
@@ -56,6 +56,7 @@ where c.Name.StartsWith(q)
public ViewResult Index(int? page)
{
+ //throw new Exception("ops, error");
int currentPageIndex = page.HasValue ? page.Value - 1 : 0;
return View(db.Customers.ToList().ToPagedList(currentPageIndex, defaultPageSize));
}
@@ -11,8 +11,7 @@ public class HomeController : Controller
{
public ActionResult Index()
{
- ViewBag.Message = "ASP.NET MVC";
-
+ throw new Exception("");
return View();
}
@@ -5,13 +5,15 @@
using System.Linq;
using System.Web;
using System.Web.Mvc;
+using MvcPaging;
namespace iloire_Facturacion.Controllers
{
[Authorize]
public class InvoiceController : Controller
{
private DBContext db = new DBContext();
+ private const int defaultPageSize=10;
/*CUSTOM*/
public PartialViewResult UnPaidInvoices()
@@ -20,28 +22,30 @@ public PartialViewResult UnPaidInvoices()
return PartialView("InvoicesListPartial", invoices.ToList());
}
- public PartialViewResult DetailsPartial(int id)
+ public PartialViewResult LastInvoicesByCustomer(int id)
{
- Invoice invoice = db.Invoices.Find(id);
- return PartialView("InvoiceDetailsPartial", invoice);
+ var invoices = db.Invoices.Include(i => i.Customer).Where(i => i.CustomerID == id);
+ return PartialView("InvoicesListPartial", invoices.ToList());
}
/*END CUSTOM*/
//
// GET: /Invoice/
- public ViewResult Index()
+ public ViewResult Index(int? page)
{
+ int currentPageIndex = page.HasValue ? page.Value - 1 : 0;
var invoices = db.Invoices.Include(i => i.Customer);
- return View(invoices.ToList());
+ return View(invoices.ToList().ToPagedList(currentPageIndex, defaultPageSize));
}
//
// GET: /Invoice/Details/5
- public ViewResult Details(int id)
+ public ViewResult Print(int id)
{
+ ViewBag.Print = true;
Invoice invoice = db.Invoices.Find(id);
return View(invoice);
}
@@ -51,8 +55,11 @@ public ViewResult Details(int id)
public ActionResult Create()
{
+ Invoice i = new Invoice();
+ i.TimeStamp = DateTime.Now;
+ i.DueDate = DateTime.Now.AddDays(30); //30 days after today
ViewBag.CustomerID = new SelectList(db.Customers, "CustomerID", "Name");
- return View();
+ return View(i);
}
//
@@ -20,6 +20,8 @@ public PartialViewResult IndexByInvoice(int id)
var invoicedetails = db.InvoiceDetails.Include(i => i.Invoice).Where(i=>i.InvoiceID==id);
return PartialView("Index", invoicedetails.ToList());
}
+
+
/*END CUSTOM*/
//
@@ -46,27 +48,35 @@ public ViewResult Details(int id)
public ActionResult Create(int? id)
{
ViewBag.InvoiceID = new SelectList(db.Invoices, "InvoiceID", "Notes");
+ Invoice invoice = null;
+ InvoiceDetails i = null;
if (id.HasValue) {
- var invoice = (from i in db.Invoices
- where i.InvoiceID == id
- select i).FirstOrDefault();
-
- if (invoice != null) {
- InvoiceDetails i = new InvoiceDetails();
+ invoice = (from ii in db.Invoices
+ where ii.InvoiceID == id
+ select ii).FirstOrDefault();
+
+ if (invoice != null)
+ {
+ i = new InvoiceDetails();
i.InvoiceID = id.Value;
i.Invoice = invoice;
+ i.Qty = 1;
+ i.VAT = 18;
i.TimeStamp = DateTime.Now;
ViewBag.InvoiceID = new SelectList(db.Invoices, "InvoiceID", "Notes", id.Value);
- return View(i);
}
- else
- return View();
}
- else
- return View();
+
+ if (Request.IsAjaxRequest())
+ {
+ return PartialView("Create", i);
+ }
+ else {
+ return View("Create", i);
+ }
}
//
@@ -79,21 +89,22 @@ public ActionResult Create(InvoiceDetails invoicedetails)
{
db.InvoiceDetails.Add(invoicedetails);
db.SaveChanges();
- return RedirectToAction("Details", "Invoice", new { id = invoicedetails.InvoiceID });
+ return PartialView("Index", db.InvoiceDetails.Where(i => i.InvoiceID == invoicedetails.InvoiceID));
}
ViewBag.InvoiceID = new SelectList(db.Invoices, "InvoiceID", "Notes", invoicedetails.InvoiceID);
- return View(invoicedetails);
+ this.Response.StatusCode = 400;
+ return PartialView("Create", invoicedetails);
}
//
// GET: /InvoiceDetails/Edit/5
-
+
public ActionResult Edit(int id)
{
InvoiceDetails invoicedetails = db.InvoiceDetails.Find(id);
ViewBag.InvoiceID = new SelectList(db.Invoices, "InvoiceID", "Notes", invoicedetails.InvoiceID);
- return View(invoicedetails);
+ return PartialView(invoicedetails);
}
//
@@ -106,10 +117,11 @@ public ActionResult Edit(InvoiceDetails invoicedetails)
{
db.Entry(invoicedetails).State = EntityState.Modified;
db.SaveChanges();
- return RedirectToAction("Details", "Invoice", new { id = invoicedetails.InvoiceID });
- }
+ return RedirectToAction("IndexByInvoice", "InvoiceDetails", new { id = invoicedetails.InvoiceID });
+ }
ViewBag.InvoiceID = new SelectList(db.Invoices, "InvoiceID", "Notes", invoicedetails.InvoiceID);
- return View(invoicedetails);
+ this.Response.StatusCode = 400;
+ return PartialView("Edit", invoicedetails);
}
//
@@ -118,7 +130,7 @@ public ActionResult Edit(InvoiceDetails invoicedetails)
public ActionResult Delete(int id)
{
InvoiceDetails invoicedetails = db.InvoiceDetails.Find(id);
- return View(invoicedetails);
+ return PartialView(invoicedetails);
}
//
@@ -128,9 +140,16 @@ public ActionResult Delete(int id)
public ActionResult DeleteConfirmed(int id)
{
InvoiceDetails invoicedetails = db.InvoiceDetails.Find(id);
- db.InvoiceDetails.Remove(invoicedetails);
- db.SaveChanges();
- return RedirectToAction("Details", "Invoice", new { id = invoicedetails.InvoiceID });
+ if (invoicedetails != null)
+ {
+ db.InvoiceDetails.Remove(invoicedetails);
+ db.SaveChanges();
+ return RedirectToAction("IndexByInvoice", "InvoiceDetails", new { id = invoicedetails.InvoiceID });
+ }
+ else {
+ this.Response.StatusCode = 400;
+ return Content("Record not found");
+ }
}
protected override void Dispose(bool disposing)
@@ -20,6 +20,11 @@ public PartialViewResult RecentPurchases()
return PartialView("PurchasesListPartial", invoices.ToList());
}
+ public PartialViewResult RecentPurchasesByCustomer(int? providerID)
+ {
+ var invoices = db.Purchases.Include(i => i.Provider).Where(p=>p.ProviderID==providerID).OrderByDescending(t => t.TimeStamp).Take(10);
+ return PartialView("PurchasesListPartial", invoices.ToList());
+ }
/*END CUSTOM*/
//
@@ -45,8 +50,10 @@ public ViewResult Details(int id)
public ActionResult Create()
{
+ Purchase p = new Purchase();
+ p.TimeStamp = DateTime.Now;
ViewBag.ProviderID = new SelectList(db.Providers, "ProviderID", "Name");
- return View();
+ return View(p);
}
//
@@ -5,7 +5,6 @@ public class EntitiesContextInitializer : DropCreateDatabaseIfModelChanges<DBCon
{
protected override void Seed(DBContext context)
{
-
//users
List<User> users = new List<User>{
new User { Name="Usuario dummy", Login="user", Password="pass", Email="hello2@user.com", Enabled=true}
@@ -15,12 +14,11 @@ protected override void Seed(DBContext context)
context.Users.Add(u);
}
-
//let's add some dummy customer data:
List<Customer> customers = new List<Customer>
{
- new Customer {Name="ACME Internation LS", Address="12 Stree NY", CP= "232323", CompanyNumber="3424324342", City="New York", Phone1="223-23232323", Fax="233-333333", Email="hello@hello.com"},
- new Customer {Name="Apple Inc.", Address="1233 Street NY", CP= "232323", CompanyNumber="23232323", City="NN CA", Phone1="343-23232323", Fax="233-333333", Email="apple@hello.com"}
+ new Customer {Name="ACME Internation LS", Address="12 Stree NY", CP="232323", CompanyNumber="3424324342", City="New York", Phone1="223-23232323", Fax="233-333333", Email="hello@hello.com"},
+ new Customer {Name="Apple Inc.", Address="1233 Street NY", CP="232323", CompanyNumber="23232323", City="NN CA", Phone1="343-23232323", Fax="233-333333", Email="apple@hello.com"}
};
for (int i = 0; i < 100; i++)
{
@@ -1,5 +1,6 @@
using System;
using System.ComponentModel.DataAnnotations;
+using System.ComponentModel;
public class InvoiceDetails
{
@@ -20,6 +21,7 @@ public class InvoiceDetails
[Range(1, 100, ErrorMessage = "VAT must be between 1 and 100")]
public decimal VAT { get; set; }
+ [DisplayName("Created")]
public DateTime TimeStamp { get; set; }
public decimal Total {
Oops, something went wrong.

0 comments on commit 985107a

Please sign in to comment.