private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            Category category;

            category = new Category()
            {
                Id = Database.GetInstance.redisClient.As<Category>().GetNextSequence(),
                Name = txtCategoria.Text,
                Description = txtDescricao.Text
            };

            if (_editing == null)
                category.Id = Database.GetInstance.redisClient.As<Category>().GetNextSequence();
            else
                category.Id = _editing.Id;

            if (category.Validate())
            {
                using (var trans = Database.GetInstance.redisClient.CreateTransaction())
                {
                    trans.QueueCommand(r => r.Store<Category>(category));
                    trans.Commit();
                }
                ListaCategorias();
                LimpaCampos();
            }
        }
        private void dataGrid1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var categoriaSelecionada = (Category)dataGrid1.SelectedItem;

            if (categoriaSelecionada != null)
            {
                txtCategoria.Text = categoriaSelecionada.Name;
                txtDescricao.Text = categoriaSelecionada.Description;

                _editing = new Category
                {
                    Id = categoriaSelecionada.Id,
                    Name = txtCategoria.Text,
                    Description = txtDescricao.Text
                };
            }
        }
Exemplo n.º 3
0
        private void dataGrid1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var fabricanteSelecionado = (Make)dataGrid1.SelectedItem;

            if (fabricanteSelecionado != null)
            {
                txtFabricante.Text = fabricanteSelecionado.Name;

                _editing = new Category
                {
                    Id = fabricanteSelecionado.Id,
                    Name = txtFabricante.Text,
                };
            }
        }
 private void LimpaCampos()
 {
     txtCategoria.Text = String.Empty;
     txtDescricao.Text = String.Empty;
     _editing = null;
 }
Exemplo n.º 5
0
 private void LimpaCampos()
 {
     txtFabricante.Text = String.Empty;
     _editing = null;
 }