Professional Documents
Culture Documents
namespace WebAppPOO_01.Models
{
public class Venta
{//atributos
public string _numero { get; set; }
public DateTime _fecha { get; set; }
public string _cliente { get; set; }
public string _mueble { get; set; }
public double _precio { get; set; }
Venta públi
_numero = "";
_fecha = DateTime.Today;
_cliente = string.Empty;
_mueble = string.Empty;
_precio = 0;
}
//métodos descuento
if
0.02 * _precio;
else return 0.05 * _precio;
}
//método para el neto
public double Neto()
{
return _precio - Descuento();
}
-----------------------------------------------------------en la carpeta controller
crear un controlador en blanco llamado VentasController
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WebAppPOO_01.Models;
namespace WebAppPOO_01.Controllers
{
public class VentasController : Controller
{
// GET: Ventas
public ActionResult ActionVenta()
{
return View(new Venta());
}
//POST
[HttpPost] public ActionResult ActionVenta(Venta reg)
{
ViewBag.descuento = reg.Descuento();
ViewBag.neto=reg.Neto();
return View(reg);
//ViewBag.Nombre="Daniel ";
//en la vista en el html
//<p> Hola ,@ViewBag.Nombre </p>
}
}
}
------------------------------------------------------------
Crear Vista Basado en Controlador ActionVenta()
------------------------------------------
@model WebAppPOO_01.Models.Venta
@{
ViewBag.Title = "ActionVenta";
}
<h2>Registro de Ventas</h2>
</div>
<div class=" form-group">
@Html.Label("Cliente", htmlAttributes: new { @class = "control-label
col-md-2" })
@Html.TextBoxFor(model => model._cliente, htmlAttributes: new { @class
= "form-control col-md-10" })
</div>
<div class=" form-group">
@Html.Label("Mueble", htmlAttributes: new { @class = "control-label
col-md-2" })
@Html.TextBoxFor(model => model._mueble, htmlAttributes: new { @class =
"form-control col-md-10" })
</div>
<div class=" form-group">
@Html.Label("Precio", htmlAttributes: new { @class = "control-label
col-md-2" })
@Html.TextBox("_precio", 0, htmlAttributes: new { @class = "form-
control col-md-10" })
</div>
<div class=" form-group">
@Html.Label("Descuento", htmlAttributes: new { @class = "control-label
col-md-2" })
@Html.TextBox("descuento", @ViewBag.descuento as String,
htmlAttributes: new { @class = "form-control col-md-10" })
</div>
</div>
</div>
</div>