public string devolverTodo(int userId)
        {
            HistoricoVentas hv = new HistoricoVentas();
            hv.ListaVentas = new List<Venta>();
            Venta v;
            MySqlConnection conn = new MySqlConnection(connString);
            MySqlCommand command = conn.CreateCommand();
            command.CommandText = "Select * from ventas where vendedor=" + "'" + userId + "' and finalizada=1";
            conn.Open();

            MySqlDataReader reader = command.ExecuteReader();
            while (reader.Read())
            {
                v = new Venta();
                v.id = int.Parse(reader["id"].ToString());
                v.tipo = reader["tipo"].ToString();
                v.estado = reader["estado"].ToString();
                v.precio = int.Parse(reader["precio"].ToString());
                v.finalizada = int.Parse(reader["finalizada"].ToString());
                hv.ListaVentas.Add(v);
            }

            conn.Close();

            var javaScriptSerializer = new JavaScriptSerializer();

            return javaScriptSerializer.Serialize(hv);
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["Id"] != null)
     {
         Auxiliar aux = new Auxiliar();
         HistoricoVentas hv = new HistoricoVentas();
         string jsonVentas = "";
         Historico serv = new Historico();
         serv.Url = new Juddi().getServiceUrl("Historico");
         jsonVentas = serv.devolverTodo((int)Session["Id"]);
         var javaScriptSerializer = new JavaScriptSerializer();
         hv = javaScriptSerializer.Deserialize<HistoricoVentas>(jsonVentas);
         DataTable dt = new DataTable();
         dt.Columns.AddRange(new DataColumn[4] {
                 new DataColumn("id", typeof(int)),
                                 new DataColumn("tipo", typeof(string)),
                                 new DataColumn("estado",typeof(string)),
                                 new DataColumn("precioventa",typeof(int))
             });
         for (int i = 0; i < hv.ListaVentas.Count; i++)
         {
             dt.Rows.Add(hv.ListaVentas[i].id, hv.ListaVentas[i].tipo, hv.ListaVentas[i].estado, hv.ListaVentas[i].precio);
         }
         GridView1.DataSource = dt;
         GridView1.DataBind();
     }
     else
     {
         Response.Redirect("/");
     }
 }
        public string getVentasActivas(int userId)
        {
            HistoricoVentas hv = new HistoricoVentas();
            hv.ListaVentas = new List<Venta>();
            Venta v;
            MySqlConnection conn = new MySqlConnection(connString);
            MySqlCommand command = conn.CreateCommand();
            command.CommandText = "Select * from ventas where vendedor=" + "'" + userId + "'" + "and (finalizada=0 or finalizada=3)";
            conn.Open();

            MySqlDataReader reader = command.ExecuteReader();
            while (reader.Read())
            {
                v = new Venta();
                v.id = int.Parse(reader["id"].ToString());
                v.tipo = reader["tipo"].ToString();
                v.precio = int.Parse(reader["precio"].ToString());
                v.fecha_I = reader["fecha_I"].ToString();
                v.fecha_F = reader["fecha_F"].ToString();
                v.negociado = int.Parse(reader["negociado"].ToString());
                hv.ListaVentas.Add(v);
            }

            conn.Close();

            var javaScriptSerializer = new JavaScriptSerializer();

            return javaScriptSerializer.Serialize(hv.ListaVentas);
        }