Example #1
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            var senderGrid = (DataGridView)sender;

            if (e.ColumnIndex == 0 && senderGrid.Columns[e.ColumnIndex].Name == "eliminar")
            {
                string idVehiculo = senderGrid.Rows[e.RowIndex].Cells[5].Value.ToString();
                eliminarVehiculo(idVehiculo);
            }
            if (e.ColumnIndex == 1 && senderGrid.Columns[e.ColumnIndex].Name == "edit")
            {
                cars vh = new cars();
                vh.id = senderGrid.Rows[e.RowIndex].Cells["id"].Value.ToString();
                if (senderGrid.Rows[e.RowIndex].Cells["Type"].Value != null)
                {
                    vh.classType = senderGrid.Rows[e.RowIndex].Cells["Type"].Value.ToString();
                }
                vh.name         = senderGrid.Rows[e.RowIndex].Cells["name"].Value.ToString();
                vh.transmission = senderGrid.Rows[e.RowIndex].Cells["transmission"].Value.ToString();
                vh.hasAC        = (bool)senderGrid.Rows[e.RowIndex].Cells["hasAC"].Value;
                vh.doors        = (int)senderGrid.Rows[e.RowIndex].Cells["doors"].Value;
                vh.seats        = senderGrid.Rows[e.RowIndex].Cells["seats"].Value.ToString();
                vh.imageUrl     = senderGrid.Rows[e.RowIndex].Cells["imageUrl"].Value.ToString();
                vh.price        = (int)senderGrid.Rows[e.RowIndex].Cells["price"].Value;
                vh.luggage      = (int)senderGrid.Rows[e.RowIndex].Cells["luggage"].Value;
                actualizarVehiculo(vh);
            }
        }
Example #2
0
        private async void  cargarVehiculos()
        {
            FirebaseClient client = new FirebaseClient(GLOBAL.baseUrl, new FirebaseOptions
            {
                AuthTokenAsyncFactory = () => Task.FromResult(token)
            });
            var result = await client.Child("users/" + localId + "/cars").OnceAsync <cars>();

            List <cars> carlist = new List <cars>();

            foreach (var car in result)
            {
                cars caradd = new cars();
                caradd.classType    = car.Object.classType;
                caradd.doors        = car.Object.doors;
                caradd.hasAC        = car.Object.hasAC;
                caradd.id           = car.Key.ToString();
                caradd.name         = car.Object.name;
                caradd.transmission = car.Object.transmission;
                caradd.price        = car.Object.price;
                caradd.imageUrl     = car.Object.imageUrl;
                caradd.seats        = car.Object.seats;
                caradd.luggage      = car.Object.luggage;
                carlist.Add(caradd);
            }

            count = carlist.Count();
            dataGridView1.DataSource = carlist;
        }
Example #3
0
        private async void Guardar()
        {
            try
            {
                if (!string.IsNullOrEmpty(txtNombre.Text) && !string.IsNullOrEmpty(txtPuertas.Text) && !string.IsNullOrEmpty(txtPrecio.Text) && !string.IsNullOrEmpty(txtluggage.Text))
                {
                    vh = new cars();
                    setDatos();

                    FirebaseClient client = new FirebaseClient(GLOBAL.baseUrl, new FirebaseOptions
                    {
                        AuthTokenAsyncFactory = () => Task.FromResult(token)
                    });
                    var result = await client.Child("users/" + localId + "/cars").PostAsync(Newtonsoft.Json.JsonConvert.SerializeObject(vh));

                    MessageBox.Show("Guardado correctamente!", "Vehiculos", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Diligencie los datos solicitados.", "Vehiculos", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtNombre.Focus();
                }
            }
            catch (FirebaseAuthException e)
            {
                MessageBox.Show("Ocurrio un error al intentar registrar un vehiculo error: " + e.InnerException, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #4
0
        private void actualizarVehiculo(cars vh)
        {
            RegistrarVehiculo fr = new RegistrarVehiculo();

            fr.vh         = vh;
            fr.token      = token;
            fr.localId    = localId;
            fr.tipoAccion = RegistrarVehiculo.accion.actualizar;
            fr.cargarDatos();
            fr.Show();
        }