Example #1
0
        public static Select.Pedido_Sistema pedido_sistema_parse(DataRow r)
        {
            Select.Pedido_Sistema p = new Select.Pedido_Sistema();
            p.IdPedido = Int32.Parse(r["idPedido"].ToString());
            p.Documento = r["documento"].ToString();
            p.Cliente = r["cliente"].ToString();
            p.Direccion = r["direccion"].ToString();
            p.FechaEntrega = DateTime.ParseExact(r["fechaEntrega"].ToString(), "M/d/yyyy h:mm:ss ttt", null);
            p.FechaCreacion = DateTime.ParseExact(r["fechaCreacion"].ToString(), "M/d/yyyy h:mm:ss ttt", null);
            p.FechaPago = DateTime.ParseExact(r["fechaPago"].ToString(), "M/d/yyyy h:mm:ss ttt", null);
            p.Estado = r["estadoPedido"].ToString();
            p.Medio = r["medioPago"].ToString();
            p.Tarjeta = r["tipoTarjeta"].ToString();
            p.Moneda = r["moneda"].ToString();
            p.Total = Double.Parse(r["total"].ToString());
            p.CuantoPaga = Double.Parse(r["cuantoPaga"].ToString());
            p.Vuelto = Double.Parse(r["vuelto"].ToString());
            p.Motivo = r["motivoCancelacion"].ToString();
            p.Usuario = r["usuario"].ToString();
            p.Almacen = r["almacen"].ToString();
            p.Tienda = r["tienda"].ToString();

            return p;
        }
Example #2
0
        public Select.Pedido_Sistema selectById_Pedido(int id)
        {
            try
            {
                Select.Pedido_Sistema p = new Select.Pedido_Sistema();

                DataTable dt = new DataTable();
                SqlDataAdapter sda = new SqlDataAdapter();
                string ConnString = ConfigurationManager.ConnectionStrings["barabaresConnectionString"].ConnectionString;
                using (SqlConnection SqlConn = new SqlConnection(ConnString))
                {
                    try
                    {
                        SqlConn.Open();
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex.ToString());
                        return p;
                    }

                    SqlCommand sqlCmd = new SqlCommand("PEDIDO_SELECT_BY_ID_SISTEMA", SqlConn);
                    sqlCmd.CommandType = CommandType.StoredProcedure;

                    sqlCmd.Parameters.Add("@ipnIdPedido", SqlDbType.Int).Value = id;

                    sqlCmd.Parameters.Add("@ipsAccion", SqlDbType.VarChar).Value = Constantes.LOG_LISTAR;
                    sqlCmd.Parameters.Add("@ipsClase", SqlDbType.VarChar).Value = p.GetType().Name;
                    sqlCmd.Parameters.Add("@ipnIdUsuarioLog", SqlDbType.Int).Value = 1;

                    sda.SelectCommand = sqlCmd;
                    sda.Fill(dt);
                    SqlConn.Close();
                    sqlCmd.Dispose();
                    sda.Dispose();
                }

                DataRow[] rows = dt.Select();

                for (int i = 0; i < rows.Length; i++)
                {
                    p = Utils.pedido_sistema_parse(rows[i]);
                }

                return p;
            }
            catch (Exception ex)
            {
                Select.Pedido_Sistema p = new Select.Pedido_Sistema();

                LogBarabares b = new LogBarabares()
                {
                    Accion = Constantes.LOG_LISTAR,
                    Servicio = Constantes.SelectById_Pedido,
                    Input = JsonSerializer.selectById(id),
                    Descripcion = ex.ToString(),
                    Clase = p.GetType().Name,
                    Aplicacion = Constantes.ENTORNO_SERVICIOS,
                    Estado = Constantes.FALLA,
                    Ip = "",
                    IdUsuario = 1 //TODO: obtener usuario de la sesiĆ³n

                };

                Utils.add_LogBarabares(b);

                return new Select.Pedido_Sistema();
            }
        }