Example #1
0
        //Eliminar

        public static string EliminarPedido(PedidoModel pedido)
        {
            OdbcConnection conn = Conexion.obtenerConexion();

            try
            {
                OdbcCommand command = new OdbcCommand();
                string      Sql     = "{call [sp_Eliminar_Pedido](?)}";

                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = Sql;
                command.Connection  = conn;

                command.Parameters.Add("@Id_Pedido", OdbcType.VarChar);
                command.Parameters["@Id_Pedido"].Value = pedido.Id_Pedido;

                command.ExecuteNonQuery();

                command.Dispose();

                return("true");
            }
            catch (Exception ax)
            {
                return("false");
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }
        }
Example #2
0
        //Por codigo

        public static List <PedidoModel> SeleccionarPedidosPorCodigo(string IdPedido)
        {
            OdbcConnection conn = Conexion.obtenerConexion();

            try
            {
                OdbcCommand command = new OdbcCommand();
                string      Sql     = "{call [dbo].[sp_Seleccionar_Producto_Por_Codigo](?)}";

                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = Sql;
                command.Connection  = conn;

                command.Parameters.Add("@Id_Producto", OdbcType.VarChar);
                command.Parameters["@Id_Producto"].Value = IdPedido;

                OdbcDataReader reader = command.ExecuteReader();

                List <PedidoModel> lista = new List <PedidoModel>();

                while (reader.Read())
                {
                    PedidoModel pedido = new PedidoModel();

                    pedido.Id_Pedido            = reader["Id_Pedido"].ToString();
                    pedido.Fecha                = Convert.ToDateTime(reader["Fecha"].ToString());
                    pedido.Cliente              = reader["Cliente"].ToString();
                    pedido.TotalPedido          = Convert.ToInt32(reader["Total"].ToString());
                    pedido.Estado               = Convert.ToInt32(reader["Estado"].ToString());
                    pedido.Usuario_Confirmacion = reader["Usuario_Confirmacion"].ToString();
                    pedido.Usuario_Creacion     = reader["Usuario_Creacion"].ToString();
                    lista.Add(pedido);
                }
                reader.Close();
                return(lista);
            }
            catch (OdbcException ax)
            {
                throw new ApplicationException("Error en Base de Datos..! \n" + ax.Message);
            }
            catch (Exception ex)
            {
                throw new ApplicationException("ERROR AL OBTENER LA CONSULTA. DETALLE: " + ex.Message);
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }
        }
Example #3
0
        //Modificar
        public static string ActualizarPedido(PedidoModel pedido)
        {
            OdbcConnection conn = Conexion.obtenerConexion();

            try
            {
                OdbcCommand command = new OdbcCommand();
                string      Sql     = "{call [dbo].[sp_Actualizar_Pedido](?,?,?,?,?,?)}";

                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = Sql;
                command.Connection  = conn;

                command.Parameters.Add("@Id_Pedido", OdbcType.VarChar);
                command.Parameters["@Id_Pedido"].Value = pedido.Id_Pedido;
                command.Parameters.Add("@Fecha", OdbcType.DateTime);
                command.Parameters["@Fecha"].Value = pedido.Fecha;
                command.Parameters.Add("@Cliente", OdbcType.Decimal);
                command.Parameters["@Cliente"].Value = pedido.Cliente;
                command.Parameters.Add("@Total", OdbcType.Decimal);
                command.Parameters["@Total"].Value = pedido.TotalPedido;//Usuario Logueado
                command.Parameters.Add("@Estado", OdbcType.Int);
                command.Parameters["@Estado"].Value = pedido.Estado;
                command.Parameters.Add("@Usuario_Confirmacion", OdbcType.VarChar);
                command.Parameters["@Usuario_Confirmacion"].Value = pedido.Usuario_Confirmacion;

                command.ExecuteNonQuery();

                command.Dispose();

                return("true");
            }
            catch (Exception ax)
            {
                return("false");
            }
            finally
            {
                conn.Close();
                conn.Dispose();
            }
        }