예제 #1
0
        private void BtnBuscar_Click(object sender, RoutedEventArgs e)
        {
            if (!txtNumero.Text.Equals(""))
            {
                Projeto projeto = new Projeto
                {
                    NumeroProjeto = txtNumero.Text
                };

                projeto = ProjetoDao.BuscarProjetoPorNumero(projeto);

                Orcamento orcamento = ProjetoDao.BuscaOrcamentoProjeto(projeto);

                if (projeto != null)
                {
                    txtProjeto.Text = projeto.NomeProjeto;

                    dtaListaServicos.ItemsSource = orcamento.servico;

                    dtaListaMateriais.ItemsSource = orcamento.material;

                    //double valorTotal = orcamento.servico.Sum();
                }
                else
                {
                    MessageBox.Show("Projeto Inexistente", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else
            {
                MessageBox.Show("Insira o código do Projeto", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
 public frmCadastroOrcamento(string projeto)
 {
     projetoAtivo = ProjetoDao.BuscarProjetoPorNumeroString(projeto);
     InitializeComponent();
     txtNumero.Text  = projetoAtivo.NumeroProjeto;
     txtProjeto.Text = projetoAtivo.NomeProjeto;
 }
예제 #3
0
        private void BtnNovo_Click(object sender, RoutedEventArgs e)
        {
            //Adicionar Numeração Automática
            cboStatus.SelectedIndex = 0;
            cboStatus.IsEnabled     = false;
            txtNumero.IsEnabled     = false;
            txtProjeto.IsEnabled    = true;
            cboCliente.IsEnabled    = true;
            btnSalvar.IsEnabled     = true;
            btnSalvar.Visibility    = Visibility.Visible;
            btnCancelar.Visibility  = Visibility.Visible;
            btnNovo.IsEnabled       = false;
            txtProjeto.Focus();

            txtNomeServico.IsEnabled       = true;
            btnBuscarServico.IsEnabled     = true;
            txtQuantidadeServico.IsEnabled = true;
            btnAdicionarServico.IsEnabled  = true;

            txtNomeMaterial.IsEnabled   = false;
            txtCodigoMaterial.IsEnabled = true;

            txtCodigoMaterial.Focus();
            txtQuantidadeMaterial.IsEnabled = true;
            txtDescricao.IsEnabled          = true;
            txtfabricante.IsEnabled         = true;
            btnBuscarMaterial.IsEnabled     = true;
            btnAdicionarMaterial.IsEnabled  = true;

            txtNumero.Text = ProjetoDao.GerarNumeroProjeto(projetoNovo);
        }
예제 #4
0
        private void BtnEditar_Click(object sender, RoutedEventArgs e)
        {
            if (!txtNumero.Text.Equals("") && !txtProjeto.Text.Equals(""))
            {
                Projeto projeto = new Projeto
                {
                    NumeroProjeto = txtNumero.Text
                };

                projeto = ProjetoDao.BuscarProjetoPorNumero(projeto);

                if (projeto != null)
                {
                    projeto.NomeProjeto = txtProjeto.Text;
                    projeto.Status      = cboStatus.SelectedIndex.ToString();

                    int idCliente = Convert.ToInt32(cboCliente.SelectedValue);
                    projeto.Cliente = ClienteDao.BuscarClientePorId(idCliente);

                    if (ProjetoDao.AlterarProjeto(projeto))
                    {
                        MessageBox.Show("Cadastro Alterado!",
                                        "Sistema de Orcamento", MessageBoxButton.OK, MessageBoxImage.Information);

                        txtNumero.Text           = "";
                        txtProjeto.Text          = "";
                        cboCliente.SelectedIndex = -1;
                        cboStatus.SelectedIndex  = -1;

                        txtNumero.IsEnabled = true;
                        txtProjeto.Focus();
                        txtProjeto.IsEnabled  = false;
                        btnEditar.IsEnabled   = false;
                        btnCancelar.IsEnabled = false;
                        cboStatus.IsEnabled   = false;
                        cboCliente.IsEnabled  = false;
                        btnBuscar.IsEnabled   = true;
                    }
                    else
                    {
                        MessageBox.Show("Projeto Não pode ser alterado",
                                        "Sistema Orcamento", MessageBoxButton.OK,
                                        MessageBoxImage.Error);
                    }
                }
                else
                {
                    MessageBox.Show("Projeto Inexistente", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else
            {
                MessageBox.Show("Insira o código do Projeto", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
예제 #5
0
        private void BtnSalvar_Click(object sender, RoutedEventArgs e)
        {
            if (txtNumero.Text != null && cboStatus.Text != null && txtProjeto.Text != "" && cboCliente.Text != null)
            {
                orcamento.servico  = listaItensServicos;
                orcamento.material = listaItensMateriais;
                itensOrcamento io = new itensOrcamento
                {
                    orcamento = orcamento
                };
                listaItensOrcamentos.Add(io);

                int idCliente = Convert.ToInt32(cboCliente.SelectedValue);
                projetoNovo.NumeroProjeto  = txtNumero.Text;
                projetoNovo.NomeProjeto    = txtProjeto.Text.ToUpper();
                projetoNovo.Status         = cboStatus.SelectedIndex.ToString();
                projetoNovo.Cliente        = ClienteDao.BuscarClientePorId(idCliente);
                projetoNovo.listaOrcamento = listaItensOrcamentos;


                if (ProjetoDao.CadastrarProjeto(projetoNovo))
                {
                    MessageBox.Show("Projeto Cadastrado!",
                                    "Sistema Orcamento", MessageBoxButton.OK,
                                    MessageBoxImage.Information);

                    btnSalvar.Visibility   = Visibility.Hidden;
                    btnCancelar.Visibility = Visibility.Hidden;
                    btnNovo.IsEnabled      = true;
                    txtNumero.Text         = "";
                    txtNumero.IsEnabled    = true;
                    txtNumero.Focus();
                    txtProjeto.Text          = "";
                    txtProjeto.IsEnabled     = false;
                    cboStatus.SelectedIndex  = -1;
                    cboStatus.IsEnabled      = false;
                    cboCliente.SelectedIndex = -1;
                    cboCliente.IsEnabled     = false;
                }
                else
                {
                    MessageBox.Show("Já Exite um Projeto com Este Número",
                                    "Sistema Orcamento", MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                }
            }
            else
            {
                MessageBox.Show("Por favor Preencha todos os campos!");
            }
        }
예제 #6
0
        private void BtnBuscar_Click(object sender, RoutedEventArgs e)
        {
            if (!txtNumero.Text.Equals(""))
            {
                Projeto projeto = new Projeto
                {
                    NumeroProjeto = txtNumero.Text
                };

                projeto = ProjetoDao.BuscarProjetoPorNumero(projeto);

                if (projeto != null)
                {
                    txtNumero.IsEnabled   = false;
                    txtProjeto.IsEnabled  = true;
                    btnEditar.IsEnabled   = true;
                    btnCancelar.IsEnabled = true;
                    cboStatus.IsEnabled   = true;
                    cboCliente.IsEnabled  = true;

                    txtProjeto.Text         = projeto.NomeProjeto;
                    cboStatus.SelectedIndex = Convert.ToInt32(projeto.Status);

                    int     idCliente = projeto.Cliente.ClienteId;
                    Cliente cliente   = ClienteDao.BuscarClientePorId(idCliente);

                    cboCliente.SelectedIndex = cliente.ClienteId;

                    btnBuscar.IsEnabled = false;
                }
                else
                {
                    MessageBox.Show("Projeto Inexistente", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else
            {
                MessageBox.Show("Insira o código do Projeto", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
예제 #7
0
 private void DtaProjeto_Loaded(object sender, RoutedEventArgs e)
 {
     dtaProjeto.ItemsSource = ProjetoDao.ListarTodosProjetos();
     dtaProjeto.Items.Refresh();
 }