Пример #1
0
        public static Pedido GetPedidoById(int PedidoID)
        {
            PedidoTableAdapter localAdapter = new PedidoTableAdapter();

            if (PedidoID <= 0)
            {
                return(null);
            }

            Pedido theUser = null;

            try
            {
                PedidoDS.PedidoDataTable table = localAdapter.GetPedidoById(PedidoID);

                if (table != null && table.Rows.Count > 0)
                {
                    PedidoDS.PedidoRow row = table[0];
                    theUser = FillPedidoRecord(row);
                }
            }
            catch (Exception q)
            {
                log.Error("An error was ocurred while geting Pedido data", q);
                return(null);
            }

            return(theUser);
        }
Пример #2
0
        private static Pedido FillPedidoRecord(PedidoDS.PedidoRow row)
        {
            Pedido theNewRecord = new Pedido(
                row.pedidoId,
                row.IsusuarioIdNull() ? 0 : row.usuarioId,
                row.departamentoId,
                row.IsdireccionNull() ? "" : row.direccion,
                row.IsnombreClienteNull() ? "" : row.nombreCliente,
                row.IsapellidoClienteNull() ? "" : row.apellidoCliente,
                row.nit,
                row.fechaPedido,
                row.IsfechaEntregaNull() ? DateTime.MinValue : row.fechaEntrega,
                row.IsobservacionEntregaNull() ? "" : row.observacionEntrega,
                row.carritoId,
                row.IstipoPagoIdNull() ? 0 : row.tipoPagoId,
                row.ventaId,
                row.IsmontoTotalNull() ? 0 : row.montoTotal,
                row.IslatitudNull() ? 0 : row.latitud,
                row.IslongitudNull() ? 0 : row.longitud);

            return(theNewRecord);
        }