Пример #1
0
        private void dtGrideRolamento_Initialized(object sender, EventArgs e)
        {
            RolamentoController rolamentoController = new RolamentoController();

            Rolamento rolamento = new Rolamento();

            dtGrideRolamento.ItemsSource = rolamentoController.ListarTodos();
        }
Пример #2
0
        private void dtGridRolamentos_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            rolTemp = (Rolamento)dtGridRolamentos.SelectedItem;

            if (rolTemp != null)
            {
                txtSku.Text   = rolTemp.Sku;
                txtDi.Text    = rolTemp.Di.ToString();
                txtDo.Text    = rolTemp.Do.ToString();
                txtW1.Text    = rolTemp.W1.ToString();
                cbMarca.Text  = rolTemp.MarcaVeiculo;
                cbModelo.Text = rolTemp.ModeloVeiculo;

                BtnDeletarRol.IsEnabled   = true;
                BtnAtualizarRol.IsEnabled = true;
                BtnCadastrarRol.IsEnabled = false;
            }
        }
Пример #3
0
        private void BtnCadastrarRol_Click(object sender, RoutedEventArgs e)
        {
            try

            {
                if (string.IsNullOrEmpty(txtSku.Text) || string.IsNullOrEmpty(txtDi.Text) ||
                    string.IsNullOrEmpty(txtDo.Text) || string.IsNullOrEmpty(txtW1.Text) ||
                    string.IsNullOrEmpty(cbMarca.Text) || string.IsNullOrEmpty(cbModelo.Text))
                {
                    throw new NullReferenceException("Cochilou o Cachimbo caí! ABRE O OLHO!! Todos os campos devem ser preenchidos, VERIFIQUE!");
                }



                Rolamento rolamento = new Rolamento();


                rolamento.Sku           = txtSku.Text;
                rolamento.Di            = Convert.ToInt32(txtDi.Text);
                rolamento.Do            = Convert.ToInt32(txtDo.Text);
                rolamento.W1            = Convert.ToInt32(txtW1.Text);
                rolamento.MarcaVeiculo  = cbMarca.Text;
                rolamento.ModeloVeiculo = cbModelo.Text;

                rolamentoController.Incluir(rolamento);
                MessageBox.Show("Rolamento Salvo com sucesso!");
                txtSku.Text   = "";
                txtDi.Text    = "";
                txtDo.Text    = "";
                txtW1.Text    = "";
                cbMarca.Text  = "";
                cbModelo.Text = "";
                dtGridRolamentos.ItemsSource = rolamentoController.ListarTodos();
            }

            catch (Exception ex)
            {
                MessageBox.Show("Cué cué cué cué! Erro ao salvar (" + ex.Message + ")");
            }
        }