Professional Documents
Culture Documents
software
Proyecto: TPVXpress (sistema de punto de venta)
Revisión 2.0
Diciembre 2017
Ficha del documento
PredatorSoft
Contenido
Contenido
CONTENIDO ................................................................................................................................. 4
1 INTRODUCCIÓN .................................................................................................................. 6
5 APÉNDICES ....................................................................................................................... 25
1 Introducción
La presente especificación de requerimientos de software (SRS) del sistema a construir,
surge para ser un conjunto de información necesaria que ayuda a los desarrolladores del
software a analizar y entender todos los requisitos y requerimientos que el cliente desea.
Se describirá en forma detallada las interfaces de usuario de software, así como de los
requerimientos del cliente y atributos del sistema, entre otras cosas. Sirviendo como base
para futuras modificaciones.
1.1 Propósito
El propósito de este documento es proporcionar al administrador del sistema información
que le puede ser útil y necesaria, así como en un futuro poder ser la base para
modificaciones. Este programa se encarga de llevar un control de inventario y todo lo
relacionado a ventas. Así como proporcionarle al desarrollador la información del
sistema, como son los requisitos y las especificaciones.
1.2 Alcance
TPVExpress será un sistema que funcionará en un entorno web, que nos permitirá
administrar, consultar y controlar la información de los productos, clientes, empleados y
principalmente ventas, que se realizarán en un abarrote, así como la realización de
facturas.
Este sistema dará apoyo a estas actividades:
Minimizar el tiempo al momento de captura de información de ventas realizadas.
Gestión de usuarios del sistema.
Reportes de ventas al día.
1.5 Referencias
Referencia Titulo
R1 Documento IEEE
1.6 Resumen
Este documento muestra la información necesaria para el desarrollo del sistema punto
de ventas, se presentan pantallas de cómo el sistema será utilizado.
El SRS está compuesto de la siguiente manera:
Introducción: en esta sección se detallaran los objetivos que posee el SRS y del
sistema.
Descripción general: Se describe una representación general del sistema a
desarrollar, así como su funcionalidad, características de usuario y las
limitaciones que se podrá tener.
Requerimientos específicos: muestra a detalle todos los requerimientos que el
usuario desea en el producto final. Para el cuál se ha utilizado el formato de
documentación de requerimientos con el prototipo del estándar IEEE 830-1998.
2 Descripción general
2.1 Perspectiva del producto
El sistema TPVXpress es un software de punto de venta muy sencillo de utilizar
enfocado a pequeños y medianos negocios, que ayudará a reducir el tiempo en el que
se atiende a sus clientes, así como a manejar todos los productos de su negocio y
aumentar sus ventas, enfocado a que se dedique a vender mientras que el programa
lleva a cabo el control de sus productos y ventas.
2.4 Restricciones
La gestión de la base de datos será mediante SQL 2017, El sistema TPVXpress será
desarrollado en Microsoft Visual Studio 2017en la plataforma .NET, para el cual será
necesario contar con un sistema operativo ya instalado el cual se recomienda sea
Microsoft Windows XP o Windows 7, este sistema no emitirá facturas.
3 Requisitos específicos
Número de requisito RF10
Nombre de requisito Alta de usuarios.
Tipo Requisito Restricción
Fuente del requisito Funcionalidad básica sistema
Prioridad del requisito Alta/Esencial Media/Deseado Baja/
Opcional
Descripción El administrador podrá dar de alta a los nuevos usuarios.
eliminar.
4 Requisito funcional
4.1.2 Seguridad
Todos los usuarios deberán autenticarse y dependiendo su nivel podrán realizar
distintas operaciones dentro del sistema, las contraseñas estarán encriptadas
para brindar tanto al sistema, como a la información la seguridad que estos
necesitan tener.
4.1.3 Fiabilidad
Es uno de los factores que dará confianza al cliente, el sistema será confiable
para así poder brindarle lo que esté necesite al momento que lo ocupe, tendrá el
mínimo margen de error posible.
4.1.4 Disponibilidad
El sistema estará disponible para el usuario, tomando en cuenta las necesidades,
los requisitos, reglas y objetivos de este mismo. Por lo que se encontrará 100 %
disponible cada vez que el usuario desee utilizarlo, es decir las 24 horas del día.
4.1.5 Mantenibilidad
El TPVExpress cuenta con características adaptables, lo que permitirá futuros
mantenimientos. Es decir cada 6 meses se le realizará un mantenimiento
preventivo que se llevará a cabo por un técnico asignado.
4.1.6 Portabilidad
El sistema TPVXpress no podrá ser movido a alguna otra plataforma sin la
autorización de algún ingeniero en sistemas de la empresa Predators.
Será un sistema web 100% portable.
5 Apéndices
Se otorga el permiso para reproducir totalmente este documento en cualquier lugar que lo
desee, siempre y cuando los autores del mismo estén de acuerdo, por lo que cualquier
movimiento o edición a este documento tendrá que ser autorizado por los autores de este.
6 Esquema Relacional
7 Esquema Entidad-Relación
8 Codigo
MODELOS
USUARIO
using TPVE.Enum;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations.Schema;
namespace TPVE.Models
{
public class User
{
[Key]
public int UserId { get; set; }
[Display(Name = "NOMBRE")]
public string Name { get; set; }
[Display(Name = "APELLIDO")]
public string LastName { get; set; }
[Display(Name = "TIPO")]
public TypeUser TypeUser { get; set; }
[Display(Name = "DIRECCION")]
public string Address { get; set; }
[Display(Name = "TELEFONO")]
public string PhoneNumber { get; set; }
[Display(Name = "EMAIL")]
public string email { get; set; }
[Display(Name = "USUARIO")]
public string UserName { get; set; }
[NotMapped]
public string FullName { get { return string.Format("{0} {1}", Name,
LastName); } set { } }
}
}
PROVEEDOR
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
namespace TPVE.Models
{
public class Supplier
{
[Key]
public int SupplierId{ get; set; }
[Display(Name = "PROVEEDOR")]
public string CompanyName { get; set; }
[Display(Name = "DIRECCION")]
public string Addres { get; set; }
[DataType(DataType.PhoneNumber)]
[Required(ErrorMessage = "El campo {0} es requerido")]
[MaxLength(16)]
[Display(Name = "TELEFONO")]
[RegularExpression(@"^\(?([0-9]{3})\)?([ .-]?)([0-9]{3})\2([0-9]{4})$",
ErrorMessage = "Telefono no válido")]
///\(?([0-9]{3})\)?([ .-]?)([0-9]{3})\2([0-9]{4})/
public string PhoneNumber { get; set; }
[Display(Name = "EMAIL")]
[Required(ErrorMessage = "El campo no puede estar vacio")]
[DataType(DataType.EmailAddress, ErrorMessage = "Correo no valido")]
public string Email { get; set; }
}
}
DETALLE DE VENTA
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Web;
namespace TPVE.Models
{
public class SaleDetail
{
public int SaleDetailID { get; set; }
public int SaleId { get; set; }
public int ProductId { get; set; }
[NotMapped]
public decimal Amount
{
get
{
return UnitPrice * (decimal)Quantity;
}
}
VENTA
using TPVE.Enum;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace TPVE.Models
{
public class Sale
{
public int SaleId { get; set; }
public int ? UserId { get; set; }
public int ? CustomerId { get; set; }
public DateTime SaleDate { get; set; }
public PaymentType PaymentType { get; set; }
namespace TPVE.Models
{
public class Product
{
[Key]
public int ProductId { get; set; }
[Display(Name = "CODIGO")]
public string BarCode { get; set; }
[Display(Name = "PRODUCTO")]
public string ProductName { get; set; }
[Display(Name = "PROVEEDOR")]
public int ? SupplierId { get; set; }
[Display(Name = "CATEGORIA")]
public int? CategoryId { get; set; }
[Display(Name = "DISPONIBLES")]
public float Stock { get; set; }
CLIENTE
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Web;
namespace TPVE.Models
{
public class Customer
{
[Key]
public int CustomerId { get; set; }
[DataType(DataType.PhoneNumber)]
[Required(ErrorMessage = "El campo {0} es requerido")]
[MaxLength(16)]
[Display(Name = "TELEFONO")]
[RegularExpression(@"^\(?([0-9]{3})\)?([ .-]?)([0-9]{3})\2([0-9]{4})$",
ErrorMessage = "Telefono no válido")]
///\(?([0-9]{3})\)?([ .-]?)([0-9]{3})\2([0-9]{4})/
public string PhoneNumber { get; set; }
[Display(Name = "CREDITO")]
public float Credit { get; set; }
[NotMapped]
public string FullName { get { return "RFC: "+string.Format("{2} {1}
{0}", Name, LastName, RFC); } set { } }
}
}
CATEGORIA
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
namespace TPVE.Models
{
public class Category
{
[Key]
public int CategoryId { get; set; }
[Display(Name = "CATEGORIA")]
public string CategoryName { get; set; }
[Display(Name = "DESCRIPCION")]
public string Description { get; set; }
CONTROLADORES
USUARIO
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using TPVE.Context;
using TPVE.Models;
namespace TPVE.Controllers
{
public class UsersController : Controller
{
private TPVEContext db = new TPVEContext();
// GET: Users
public ActionResult Index()
{
return View(db.Users.ToList());
}
// GET: Users/Details/5
public ActionResult Details(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
User user = db.Users.Find(id);
if (user == null)
{
return HttpNotFound();
}
return View(user);
}
// GET: Users/Create
public ActionResult Create()
{
return View();
}
// POST: Users/Create
// Para protegerse de ataques de publicación excesiva, habilite las
propiedades específicas a las que desea enlazarse. Para obtener
// más información vea https://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create([Bind(Include =
"UserId,Name,LastName,TypeUser,Address,PhoneNumber,email,UserName,Password")]
User user)
{
if (ModelState.IsValid)
{
db.Users.Add(user);
db.SaveChanges();
return RedirectToAction("Index");
}
return View(user);
// GET: Users/Edit/5
public ActionResult Edit(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
User user = db.Users.Find(id);
if (user == null)
{
return HttpNotFound();
}
return View(user);
}
// POST: Users/Edit/5
// Para protegerse de ataques de publicación excesiva, habilite las
propiedades específicas a las que desea enlazarse. Para obtener
// más información vea https://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit([Bind(Include =
"UserId,Name,LastName,TypeUser,Address,PhoneNumber,email,UserName,Password")]
User user)
{
if (ModelState.IsValid)
{
db.Entry(user).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
return View(user);
}
// GET: Users/Delete/5
public ActionResult Delete(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
User user = db.Users.Find(id);
if (user == null)
{
return HttpNotFound();
}
return View(user);
}
// POST: Users/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public ActionResult DeleteConfirmed(int id)
{
User user = db.Users.Find(id);
db.Users.Remove(user);
try
{
db.SaveChanges();
}
catch {
}
return RedirectToAction("Index");
}
PROVEEDOR
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using TPVE.Context;
using TPVE.Models;
namespace TPVE.Controllers
{
public class SuppliersController : Controller
{
private TPVEContext db = new TPVEContext();
// GET: Suppliers
public ActionResult Index()
{
return View(db.Suppliers.ToList());
}
// GET: Suppliers/Details/5
public ActionResult Details(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Supplier supplier = db.Suppliers.Find(id);
if (supplier == null)
{
return HttpNotFound();
}
return View(supplier);
}
// GET: Suppliers/Create
public ActionResult Create()
{
return View();
}
// POST: Suppliers/Create
// Para protegerse de ataques de publicación excesiva, habilite las
propiedades específicas a las que desea enlazarse. Para obtener
// más información vea https://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create([Bind(Include =
"SupplierId,CompanyName,Addres,PhoneNumber,Email")] Supplier supplier)
{
if (ModelState.IsValid)
{
db.Suppliers.Add(supplier);
db.SaveChanges();
return RedirectToAction("Index");
}
return View(supplier);
}
// GET: Suppliers/Edit/5
public ActionResult Edit(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Supplier supplier = db.Suppliers.Find(id);
if (supplier == null)
{
return HttpNotFound();
}
return View(supplier);
}
// POST: Suppliers/Edit/5
// Para protegerse de ataques de publicación excesiva, habilite las
propiedades específicas a las que desea enlazarse. Para obtener
// más información vea https://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit([Bind(Include =
"SupplierId,CompanyName,Addres,PhoneNumber,Email")] Supplier supplier)
{
if (ModelState.IsValid)
{
db.Entry(supplier).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
return View(supplier);
}
// GET: Suppliers/Delete/5
public ActionResult Delete(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Supplier supplier = db.Suppliers.Find(id);
if (supplier == null)
{
return HttpNotFound();
}
return View(supplier);
}
// POST: Suppliers/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public ActionResult DeleteConfirmed(int id)
{
Supplier supplier = db.Suppliers.Find(id);
db.Suppliers.Remove(supplier);
db.SaveChanges();
return RedirectToAction("Index");
}
VENTA
using TPVE.Context;
using TPVE.Models;
using TPVE.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
using System.Web.Mvc;
namespace TPVE.Controllers
{
public class SaleController : Controller
{
// GET: Sale
public ActionResult NewSale() {
var SaleView = new SaleView();
SaleView.Customer = new Customer();
SaleView.Products = new List<ProductSale>();
Session["SaleView"] = SaleView;
var list = db.Customers.ToList();
// POST: Orders
[HttpPost]
public ActionResult NewSale(SaleView saleView)
{
saleView = Session["SaleView"] as SaleView;
int customerId = int.Parse(Request["CustomerVB"]);
int UserId = int.Parse(Session["LogedUserID"].ToString());
var listCustomer = db.Customers.ToList();
if (customerId == 0)
{
TempData["Error"] = "ESCOJA UN CLIENTE ";
}
var customer = db.Customers.Find(customerId);
if (customer == null)
{
TempData["Error"] = "ESCOJA UN CLIENTE";
listCustomer.Add(new Customer { CustomerId = 0, Name = "[Seleccione un cliente]"
});
listCustomer = listCustomer.OrderBy(x => x.FullName).ToList();
ViewBag.CustomerVB = new SelectList(listCustomer, "CustomerId", "FullName");
ViewBag.ProductId = new SelectList(listCustomer, "ProductId", "ProductName");
saleView.Products = new List<ProductSale>();
return View(saleView);
}
if (quantProduct < 1)
{
//ModelState.AddModelError("ProductId", "Seleccione cliente");
//mandar mensaje
TempData["Error"] = "AGREGUE PRODUCTOS PARA PODER REALIZAR UNA
COMPRA";
SaleDate = DateTime.Now,
PaymentType = Enum.PaymentType.Efectivo,
UserId = UserId
};
db.Sales.Add(Sale);
db.SaveChanges();
};
db.SaleDetails.Add(SaleDetail);
db.SaveChanges();
//Math.Sqrt(-25);
return RedirectToAction("NewSale");
}
var saleView=Session["SaleView"];
var listC = db.Customers.ToList();
listC.Add(new Customer { CustomerId = 0, Name = "[Seleccione un cliente]" });
listC = listC.OrderBy(x => x.FullName).ToList();
ViewBag.CustomerVB = new SelectList(listC, "CustomerID", "FullName");
[HttpPost]
public ActionResult AddProduct(ProductSale productOrder)
{
var saleView = Session["SaleView"] as SaleView;
if (productId == 0)
{
list.Add(new Product { ProductId = 0, ProductName = "[Seleccione un producto]" });
list = list.OrderBy(x => x.ProductName).ToList();
ViewBag.ProductId = new SelectList(list, "ProductId", "ProductName");
if (product == null)
{
list.Add(new Product { ProductId = 0, ProductName = "[Seleccione un producto]" });
list = list.OrderBy(x => x.ProductName).ToList();
ViewBag.ProductId = new SelectList(list, "ProductId", "ProductName");
bool juan=false;
foreach (var item in saleView.Products)
{
if (item.ProductId == productId) {
item.Quantity += productOrder.Quantity;
juan = true;
}
}
if (!juan) {
[HttpPost]
public ActionResult DetailSale(int id2)
{
int id = int.Parse(Request["Id"]);
var list = db.SaleDetails.Include(p => p.ProductName);
List<SaleDetail> list2 = new List<SaleDetail>();
PRODUCTO
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using TPVE.Context;
using TPVE.Models;
namespace TPVE.Controllers
{
public class ProductsController : Controller
{
private TPVEContext db = new TPVEContext();
[HttpPost]
public ActionResult Search()
{
products2.Add(item);
}
return View("Index",products2.ToList());
}
// GET: Products
public ActionResult Index()
{
if (Session["LogedUserID"] == null)
{
// GET: Products/Details/5
public ActionResult Details(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Product product = db.Products.Find(id);
if (product == null)
{
return HttpNotFound();
}
return View(product);
}
// GET: Products/Create
public ActionResult Create()
{
// POST: Products/Create
// Para protegerse de ataques de publicación excesiva, habilite las
propiedades específicas a las que desea enlazarse. Para obtener
// más información vea https://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create([Bind(Include =
"ProductId,BarCode,ProductName,SupplierId,CategoryId,UnitPrice,Stock")] Product
product)
{
if (ModelState.IsValid)
{
db.Products.Add(product);
db.SaveChanges();
return RedirectToAction("Index");
}
// GET: Products/Edit/5
public ActionResult Edit(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Product product = db.Products.Find(id);
if (product == null)
{
return HttpNotFound();
}
ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId",
"CategoryName", product.CategoryId);
ViewBag.SupplierId = new SelectList(db.Suppliers, "SupplierId",
"CompanyName", product.SupplierId);
return View(product);
}
// POST: Products/Edit/5
// Para protegerse de ataques de publicación excesiva, habilite las
propiedades específicas a las que desea enlazarse. Para obtener
// más información vea https://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit([Bind(Include =
"ProductId,BarCode,ProductName,SupplierId,CategoryId,UnitPrice,Stock")] Product
product)
{
if (ModelState.IsValid)
{
db.Entry(product).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId",
"CategoryName", product.CategoryId);
ViewBag.SupplierId = new SelectList(db.Suppliers, "SupplierId",
"CompanyName", product.SupplierId);
return View(product);
}
// GET: Products/Delete/5
public ActionResult Delete(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Product product = db.Products.Find(id);
if (product == null)
{
return HttpNotFound();
}
return View(product);
}
// POST: Products/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public ActionResult DeleteConfirmed(int id)
{
Product product = db.Products.Find(id);
db.Products.Remove(product);
db.SaveChanges();
return RedirectToAction("Index");
}
CLIENTE
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using TPVE.Context;
using TPVE.Models;
namespace TPVE.Controllers
{
// GET: Customers
public ActionResult Index()
{
if (Session["LogedUserID"]==null)
{
return RedirectToAction("Index", "Home");
}
return View(db.Customers.ToList());
}
// GET: Customers/Details/5
public ActionResult Details(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Customer customer = db.Customers.Find(id);
if (customer == null)
{
return HttpNotFound();
}
return View(customer);
}
// GET: Customers/Create
public ActionResult Create()
{
return View();
}
// POST: Customers/Create
// Para protegerse de ataques de publicación excesiva, habilite las
propiedades específicas a las que desea enlazarse. Para obtener
// más información vea https://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create([Bind(Include =
"CustomerId,Name,LastName,RFC,Address,PhoneNumber,Credit")] Customer customer)
{
if (ModelState.IsValid)
{
db.Customers.Add(customer);
db.SaveChanges();
return RedirectToAction("Index");
}
return View(customer);
}
// GET: Customers/Edit/5
public ActionResult Edit(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Customer customer = db.Customers.Find(id);
if (customer == null)
{
return HttpNotFound();
}
return View(customer);
}
// POST: Customers/Edit/5
// Para protegerse de ataques de publicación excesiva, habilite las
propiedades específicas a las que desea enlazarse. Para obtener
// más información vea https://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit([Bind(Include =
"CustomerId,Name,LastName,RFC,Address,PhoneNumber,Credit")] Customer customer)
{
if (ModelState.IsValid)
{
db.Entry(customer).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
return View(customer);
}
// GET: Customers/Delete/5
public ActionResult Delete(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Customer customer = db.Customers.Find(id);
if (customer == null)
{
return HttpNotFound();
}
return View(customer);
}
// POST: Customers/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public ActionResult DeleteConfirmed(int id)
{
Customer customer = db.Customers.Find(id);
db.Customers.Remove(customer);
db.SaveChanges();
return RedirectToAction("Index");
}
CATEGORIA
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using TPVE.Context;
using TPVE.Models;
namespace TPVE.Controllers
{
public class CategoriesController : Controller
{
private TPVEContext db = new TPVEContext();
// GET: Categories
public ActionResult Index()
{
return View(db.Categories.ToList());
}
// GET: Categories/Details/5
public ActionResult Details(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Category category = db.Categories.Find(id);
if (category == null)
{
return HttpNotFound();
}
return View(category);
}
// GET: Categories/Create
public ActionResult Create()
{
return View();
}
// POST: Categories/Create
// Para protegerse de ataques de publicación excesiva, habilite las
propiedades específicas a las que desea enlazarse. Para obtener
// más información vea https://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create([Bind(Include =
"CategoryId,CategoryName,Description")] Category category)
{
if (ModelState.IsValid)
{
db.Categories.Add(category);
db.SaveChanges();
return RedirectToAction("Index");
}
return View(category);
}
// GET: Categories/Edit/5
public ActionResult Edit(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Category category = db.Categories.Find(id);
if (category == null)
{
return HttpNotFound();
}
return View(category);
}
// POST: Categories/Edit/5
// Para protegerse de ataques de publicación excesiva, habilite las
propiedades específicas a las que desea enlazarse. Para obtener
// más información vea https://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit([Bind(Include =
"CategoryId,CategoryName,Description")] Category category)
{
if (ModelState.IsValid)
{
db.Entry(category).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
return View(category);
}
// GET: Categories/Delete/5
public ActionResult Delete(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Category category = db.Categories.Find(id);
if (category == null)
{
return HttpNotFound();
}
return View(category);
}
// POST: Categories/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public ActionResult DeleteConfirmed(int id)
{
Category category = db.Categories.Find(id);
db.Categories.Remove(category);
db.SaveChanges();
return RedirectToAction("Index");
}