public void insertarListaPedido(String codigoPlato, String identificadorOrden, int cantidad) { try { TOListaPedidos toListaPedidos = new TOListaPedidos(identificadorOrden, codigoPlato, cantidad); daoLista.insertarListaProducto(toListaPedidos); } catch (Exception e) { throw new Exception(e.Message); } }
public List <TOListaPedidos> obtenerListaPedidosPorPlato(String identificador_plato) { try { TOListaPedidos toListaPedidos = new TOListaPedidos(); toListaPedidos.Codigo_Plato = identificador_plato; return(daoLista.obtenerPedidosPorPlato(toListaPedidos)); } catch (Exception e) { throw new Exception(e.Message); } }
public void eliminarPlatoListaPedidos(String codigoPlato, String identificadorOrden) { try { TOListaPedidos toListaPedido = new TOListaPedidos(); toListaPedido.Codigo_Plato = codigoPlato; toListaPedido.Identificador_Orden = identificadorOrden; daoLista.eliminarPlato(toListaPedido); } catch (Exception e) { throw new Exception(e.Message); } }
public List <TOListaPedidos> obtenerPedidosPorPlato(TOListaPedidos toListaPedidos) { try { comando.Connection = conexion; consulta = "SELECT * FROM LISTA_PEDIDO WHERE Codigo_Plato=@plato"; comando.CommandText = consulta; comando.Parameters.AddWithValue("@plato", toListaPedidos.Codigo_Plato); if (conexion.State != ConnectionState.Open) { conexion.Open(); } SqlDataReader lector = comando.ExecuteReader(); List <TOListaPedidos> listaPedidos = new List <TOListaPedidos>(); if (lector.HasRows) { while (lector.Read()) { listaPedidos.Add( new TOListaPedidos(lector["Nombre_Usuario"].ToString(), lector["Identificador_Plato"].ToString(), int.Parse(lector["Cantidad"].ToString()))); } } return(listaPedidos); } catch (SqlException) { throw new Exception("¡Error en la base de datos!"); } catch (Exception) { throw; } finally { if (conexion.State != ConnectionState.Closed) { conexion.Close(); } } }
public void insertarListaProducto(TOListaPedidos toListaPedidos) { try { consulta = "INSERT INTO LISTA_PEDIDO VALUES(@plato, @identificador, @cant)"; comando.CommandText = consulta; comando.Parameters.AddWithValue("@plato", toListaPedidos.Codigo_Plato); comando.Parameters.AddWithValue("@identificador", toListaPedidos.Identificador_Orden); comando.Parameters.AddWithValue("@cant", toListaPedidos.Cantidad_Plato); if (conexion.State != ConnectionState.Open) { conexion.Open(); } comando.Connection = conexion; comando.ExecuteNonQuery(); comando.Parameters.RemoveAt("@plato"); comando.Parameters.RemoveAt("@identificador"); comando.Parameters.RemoveAt("@cant"); } catch (SqlException) { throw new Exception("¡Error en la base de datos!"); } catch (Exception) { throw; } finally { if (conexion.State != ConnectionState.Closed) { conexion.Close(); } } }
public void eliminarPlato(TOListaPedidos toListaPedidos) { try { consulta = "DELETE FROM LISTA_PEDIDO WHERE Nombre_Usuario=@nombre and Identificador_=@plato"; comando.CommandText = consulta; comando.Parameters.AddWithValue("@nombre", toListaPedidos.Identificador_Orden); comando.Parameters.AddWithValue("@plato", toListaPedidos.Codigo_Plato); if (conexion.State != ConnectionState.Open) { conexion.Open(); } comando.Connection = conexion; comando.ExecuteNonQuery(); if (conexion.State != ConnectionState.Closed) { conexion.Close(); } } catch (SqlException) { throw new Exception("¡Error en la base de datos!"); } catch (Exception) { throw; } finally { if (conexion.State != ConnectionState.Closed) { conexion.Close(); } } }