protected void btnAceptar_Click(object sender, EventArgs e) { DetallePedidoEntidad detalle = new DetallePedidoEntidad(); detalle.idEncabezadoPedido = encabezado; detalle.idDetallePedido = deta; Boolean esta = false; if (this.ddlEstado.SelectedIndex == 1) { esta = true; } detalle.estado = esta; detalle.cantidad = Convert.ToInt16(this.txtCantidad.Text); detalle.comentario = this.txtComentario.Text; detalle.precio = Convert.ToDecimal(this.txtPrecio.Text); detalle.producto.idProducto = idProduc; DetallePedidoLN.Modificar(detalle); EncabezadoPedidoEntidad enca = new EncabezadoPedidoEntidad(); enca = EncabezadoPedidoLN.obtenerEncabezadoPedidoXID(encabezado); Response.Redirect("accionMesa.aspx?idMesa=" + enca.mesa.idMesa); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DetallePedidoEntidad detalle = new DetallePedidoEntidad(); int idDetalle = Convert.ToInt16(Request.QueryString["idDetallePedido"].ToString()); deta = idDetalle; int idEncabezado = Convert.ToInt16(Request.QueryString["idEncabezadoPedido"].ToString()); encabezado = idEncabezado; detalle = DetallePedidoLN.ObtenerDetalle(idDetalle, idEncabezado); this.txtNombreProducto.Text = detalle.producto.nombre; idProduc = detalle.producto.idProducto; this.txtComentario.Text = detalle.comentario; this.txtCantidad.Text = detalle.cantidad.ToString(); this.imagenProducto.ImageUrl = "img/productos/" + detalle.producto.imagen; this.txtPrecio.Text = (detalle.producto.precio * detalle.cantidad).ToString(); valor = detalle.producto.precio; ListItemCollection items = new ListItemCollection { new ListItem("Desactivo", "0"), new ListItem("Activo", "1"), }; this.ddlEstado.DataSource = items; this.ddlEstado.DataBind(); int vEstado = 0; if (detalle.estado == true) { vEstado = 1; } this.ddlEstado.SelectedIndex = vEstado; } }
public static void Modificar(DetallePedidoEntidad detalle) { SqlCommand comando = new SqlCommand("[PA_ModificarDetallesPedido]"); comando.CommandType = CommandType.StoredProcedure; comando.Parameters.AddWithValue("@id", detalle.idDetallePedido); comando.Parameters.AddWithValue("@idEncabezadoPedido", detalle.idEncabezadoPedido); comando.Parameters.AddWithValue("@idProducto", detalle.producto.idProducto); comando.Parameters.AddWithValue("@cantidad", detalle.cantidad); comando.Parameters.AddWithValue("@precio", detalle.precio); comando.Parameters.AddWithValue("@comentario", detalle.comentario); int estado = 0; if (detalle.estado == true) { estado = 1; } comando.Parameters.AddWithValue("@estado", estado); using (Database db = DatabaseFactory.CreateDatabase("Default")) { db.ExecuteNonQuery(comando); } }
public static List <DetallePedidoEntidad> ObtenerTodos(int id) { /*public int idDetallePedido { get; set; } * public int idEncabezadoPedido { get; set; } * public ProductoEntidad producto { get; set; } * public int cantidad { get; set; } * public Decimal precio { get; set; } * public String comentario { get; set; } * public int estado { get; set; } */ List <DetallePedidoEntidad> lista = new List <DetallePedidoEntidad>(); DataSet ds = DetallePedidoDatos.SeleccionarTodosporID(id); foreach (DataRow fila in ds.Tables[0].Rows) { DetallePedidoEntidad elemento = new DetallePedidoEntidad(); elemento.idDetallePedido = Convert.ToInt16(fila["id"].ToString()); elemento.idEncabezadoPedido = Convert.ToInt16(fila["idEncabezadoPedido"].ToString()); elemento.producto.idProducto = Convert.ToInt16(fila["idProducto"].ToString()); elemento.producto.nombre = fila["nombre"].ToString(); elemento.producto.imagen = fila["imagen"].ToString(); elemento.cantidad = Convert.ToInt16(fila["cantidad"].ToString()); elemento.precio = Convert.ToDecimal(fila["precio"].ToString()); elemento.producto.precio = Convert.ToDecimal(fila["precioProducto"].ToString()); elemento.comentario = fila["comentario"].ToString(); if (Convert.ToInt16(fila["estado"].ToString()) == 1) { elemento.estado = true; } else { elemento.estado = false; } if (Convert.ToInt16(fila["estadoProducto"].ToString()) == 1) { elemento.producto.estado = true; } else { elemento.producto.estado = false; } lista.Add(elemento); } return(lista); }
protected void grvPedido_RowCommand(object sender, GridViewCommandEventArgs e) { DetallePedidoEntidad detalle = new DetallePedidoEntidad(); int num = Convert.ToInt32(e.CommandArgument); List <DetallePedidoEntidad> lista = new List <DetallePedidoEntidad>(); lista = EncabezadoPedidoLN.obtenerEncabezadoPedido(mesaPedido).listaDetalles; int id = Convert.ToInt16(this.grvPedido.DataKeys[num].Values[0]); detalle = lista[num]; Response.Redirect("EditarPedido.aspx?idDetallePedido=" + detalle.idDetallePedido + "&idEncabezadoPedido=" + detalle.idEncabezadoPedido); }
public List <DetallePedidoEntidad> ObtenerDetallePedido() { string rutaCola = @".\private$\compraproductos"; if (!MessageQueue.Exists(rutaCola)) { MessageQueue.Create(rutaCola); } MessageQueue cola = new MessageQueue(rutaCola); cola.Formatter = new XmlMessageFormatter(new Type[] { typeof(ProductoEntidad) }); var mensajes = cola.GetAllMessages(); //cola.Purge(); List <ProductoEntidad> ListaProductos = new List <ProductoEntidad>(); if (mensajes != null && mensajes.Length > 0) { foreach (var mensaje in mensajes) { ProductoEntidad oProductoEntidad = new ProductoEntidad(); oProductoEntidad = (ProductoEntidad)mensaje.Body; ListaProductos.Add(oProductoEntidad); } } List <DetallePedidoEntidad> ListaDetallePedido = new List <DetallePedidoEntidad>(); foreach (var item in ListaProductos) { var producto = oProductoDominio.ObtenerxCodigo(item.Cod_Producto.ToString()); DetallePedidoEntidad oDetallePedidoEntidad = new DetallePedidoEntidad(); producto.Cantidad = item.Cantidad; oDetallePedidoEntidad.Producto = producto; oDetallePedidoEntidad.Cantidad = producto.Cantidad; oDetallePedidoEntidad.SubTotal = (item.Cantidad * producto.Precio); ListaDetallePedido.Add(oDetallePedidoEntidad); } return(ListaDetallePedido); }
protected void btnAgregarProducto_Click(object sender, EventArgs e) { if (Convert.ToInt16(this.txtCantidad.Text) >= 1 && Convert.ToInt16(this.txtCantidad.Text) <= 10) { ProductoEntidad producto = ProductoLN.ObtenerProducto(Convert.ToInt16(hdfIdProducto.Value)); EncabezadoPedidoEntidad pedido = (EncabezadoPedidoEntidad)Session["pedido"]; DetallePedidoEntidad detallePedido = new DetallePedidoEntidad(); detallePedido.idEncabezadoPedido = pedido.idEncabezadoPedido; detallePedido.producto = producto; detallePedido.cantidad = Convert.ToInt16(txtCantidad.Text); detallePedido.comentario = txtComentario.Text; detallePedido.precio = detallePedido.cantidad * producto.precio; detallePedido.estado = true; DetallePedidoLN.Nuevo(detallePedido); Session.Remove("pedido"); Response.Redirect("accionMesa.aspx?idMesa=" + pedido.mesa.idMesa); } else { this.lblMensaje.Text = "La cantidad debe ser mayor a 0 y menor o igual a 10"; } }
public static void Modificar(DetallePedidoEntidad detalle) { DetallePedidoDatos.Modificar(detalle); }
public static void Nuevo(DetallePedidoEntidad detalle) { DetallePedidoDatos.Insertar(detalle); }