protected void btn_añadir_Click(object sender, EventArgs e) { if (lb_pedido.Text == "0") { return; } else { int idpedido = int.Parse(mesa_pendiente.SelectedValue); Session["id_pedido"] = idpedido; PedidoM P = new PedidoM(); P = (new DAOEmpleado().ObtenerPedidoE(int.Parse(Session["id_pedido"].ToString()))); int idFactura = P.Id; long total = P.Total; string pedido = P.Detalle; int pago = P.Id_pago; int cantidad = P.Cantidad; DetallePedidoM detalle = new DetallePedidoM(); detalle.Id_pedido = idpedido; detalle.Cantidad = cantidad; detalle.Total = total; detalle.Fecha = DateTime.Now; detalle.Id_mesero = int.Parse(Session["id_empleado"].ToString()); detalle.Detalle = pedido; detalle.Id_pago = pago; new DAOEmpleado().InsertarDetalleEmpleado(detalle); new DAOEmpleado().borrarPedidoPendiente(int.Parse(Session["id_pedido"].ToString())); Response.Redirect("FacturaCompraEmpleado.aspx"); } }
public List <PedidoM> obtenerPedidosxEmpleado(int empleadoid) { List <PedidoM> x = new List <PedidoM>(); PedidoM y = new PedidoM(); y.Id = 0; y.Nom_mesa = "--Seleccione--"; using (var db = new Mapeo()) { x = (from uu in db.pedidom join mes in db.mesa on uu.Id_mesa equals mes.Id where uu.Id_mesero == empleadoid select new { uu, mes }).ToList().Select(m => new PedidoM { Id = m.uu.Id, Nom_mesa = m.mes.Descripcion }).ToList(); } x.Add(y); return(x.OrderBy(z => z.Id).ToList()); }
public void InsertarPedidoEmpleado(PedidoM pedido) { using (var db = new Mapeo()) { db.pedidom.Add(pedido); db.SaveChanges(); } }
protected void btn_añadir_Click(object sender, EventArgs e) { ClientScriptManager cm = this.ClientScript; string seguridad = (new DAOEmpleado().obtenerProductosCarritoE(int.Parse(Session["id_empleado"].ToString())).Sum(x => x.Total).ToString()); long verificar = long.Parse(seguridad); if (verificar == 0) { return; } else { List <CarritoE> car = new DAOEmpleado().obtenerProductosCarritoE(int.Parse(Session["id_empleado"].ToString())); for (int i = 0; i <= car[i].Cantidad; i++) { Producto p = new DAOProducto().VerificarProducto(car[i].Producto_id); string nom = car[i].NombreProducto; if (car[i].Cantidad <= p.Cantidad) { string total = string.Format(new DAOEmpleado().obtenerProductosCarritoE(int.Parse(Session["id_empleado"].ToString())).Sum(x => x.Total).ToString()); PedidoM pedido = new PedidoM(); pedido.Id_mesero = int.Parse(Session["id_empleado"].ToString()); pedido.Id_mesa = int.Parse(tipo_mesa.SelectedValue); pedido.Total = long.Parse(total); pedido.Fecha = DateTime.Now; List <CarritoE> lista = new DAOEmpleado().obtenerProductosCarritoE(int.Parse(Session["id_empleado"].ToString())); pedido.Detalle = JsonConvert.SerializeObject(lista, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); pedido.Id_pago = int.Parse(tipo_pago.SelectedValue); pedido.Cantidad = int.Parse(new DAOEmpleado().obtenerCantidadProductoxEmpleado(int.Parse(Session["id_empleado"].ToString())).ToString()); ReporteGM reporte = new ReporteGM(); reporte.Id_mesero = int.Parse(Session["id_empleado"].ToString()); reporte.Total = long.Parse(total); reporte.Fecha = DateTime.Now; new DAOAdministrador().InsertarReporteMesero(reporte); new DAOEmpleado().InsertarPedidoEmpleado(pedido); new DAOEmpleado().ActulizarCantidad(int.Parse(Session["id_empleado"].ToString())); new DAOEmpleado().borrarCarroEmpleado(int.Parse(Session["id_empleado"].ToString())); Response.Redirect("CatalogoEmpleado.aspx"); } else if (car[0].Cantidad > p.Cantidad) { cm.RegisterClientScriptBlock(this.GetType(), "", "<script type='text/javascript'>alert('Cantidad No Disponible De:" + nom + ".Error:');</script>"); return; } else { cm.RegisterClientScriptBlock(this.GetType(), "", "<script type='text/javascript'>alert('Error No Identificado .Error:');</script>"); Session["id_empleado"] = null; Response.Redirect("Ingresar.aspx"); } } } // detallepedidoM(); }