Ejemplo n.º 1
0
        private async void BtnAdd_Clicked(object sender, EventArgs e)
        {
            try
            {
                if (String.IsNullOrWhiteSpace(txtPnombre.SelectedItem.ToString()))
                {
                    await this.DisplayAlert("Advertencia", "El campo del nombre es obligatorio.", "OK");
                }
                else if (String.IsNullOrWhiteSpace(txtCategoria.SelectedItem.ToString()))
                {
                    await this.DisplayAlert("Advertencia", "El campo del categoria es obligatorio.", "OK");
                }
                else if (String.IsNullOrWhiteSpace(txtProvedor.SelectedItem.ToString()))
                {
                    await this.DisplayAlert("Advertencia", "El campo del provedor es obligatorio.", "OK");
                }
                else if (String.IsNullOrWhiteSpace(txtPrecio.SelectedItem.ToString()))
                {
                    await this.DisplayAlert("Advertencia", "El campo del precio es obligatorio.", "OK");
                }
                else
                {
                    var allUsuarios = await firebaseHelper.GetAllProductos();

                    string Pids = "asse-PRO-" + allUsuarios.Count().ToString();

                    await firebaseHelper.AddProducto(Pids, txtCategoria.SelectedItem.ToString(), txtPnombre.SelectedItem.ToString(), Convert.ToDouble(txtPrecio.SelectedItem.ToString()), txtProvedor.SelectedItem.ToString(), PickStokid.SelectedItem.ToString());

                    await firebaseHelper.UpdateStock(PickStokid.SelectedItem.ToString());

                    txtPid.Text = string.Empty;



                    await DisplayAlert("Success", "Producto agregado", "OK");

                    var allUsuarios1 = await firebaseHelper.GetAllProductos();

                    lstProduct.ItemsSource = allUsuarios1;
                }
            }
            catch (Exception)
            {
                await this.DisplayAlert("Advertencia", "no deve haver campos vacios.", "OK");
            }
        }