private void btnSalvar_Click(object sender, RoutedEventArgs e) { if (txtNome.Text.Length == 0 || txtId.Text.Length == 0 || txtDtInicio.Text.Length == 0 || txtDtFinal.Text.Length == 0) { Alerta alerta = new Alerta("Favor preencher todos os campos"); alerta.Show(); } else if (!Util.verificarStringNumero(txtId.Text)) { Alerta alerta = new Alerta("Preencha o campo Id com numero"); alerta.Show(); } else { Projeto p = new Projeto(Convert.ToInt32(txtCodigo.Text), txtNome.Text, Convert.ToInt32(txtId.Text), Convert.ToDateTime(txtDtInicio.Text), Convert.ToDateTime(txtDtFinal.Text)); ProjetoDAO pDAO = new ProjetoDAO(); if (p.Codigo == 0) { pDAO.incluir(p.encapsularLista()); } else { pDAO.atualizar(p.encapsularLista()); } Alerta alerta = new Alerta("Salvo com sucesso."); alerta.Show(); iniciarCampos(); preencherLista(); } }
public void Delete(long Id) { ProjetoDAO projeto = _context.Projetos.FirstOrDefault(x => x.Id_Projeto == Id); _context.Projetos.Remove(projeto); _context.SaveChanges(); }
public ProjetoController(ProjetoDAO projetoDAO, JobDAO jobDAO, StatusDAO statusDAO, IHostingEnvironment hosting) { _projetoDAO = projetoDAO; _jobDAO = jobDAO; _statusDAO = statusDAO; _hosting = hosting; }
public ProjetoController(ProjetoDAO projetoDAO, TarefaDAO tarefaDAO, UserManager <Usuario> userManager, UsuarioDAO usuarioDAO) { _projetoDAO = projetoDAO; _tarefaDAO = tarefaDAO; _usuarioDAO = usuarioDAO; _userManager = userManager; }
private void preencherComboProjeto() { ComboBoxItem itemTodos = new ComboBoxItem(); itemTodos.Content = "Todos"; itemTodos.Tag = 0; cmbFiltroProjeto.Items.Add(itemTodos); cmbFiltroProjeto.SelectedIndex = 0; ProjetoDAO pDAO = new ProjetoDAO(); List <Projeto> lista = pDAO.recuperar(); if (lista.Count > 0) { foreach (Projeto p in lista) { ComboBoxItem item = new ComboBoxItem(); item.Content = p.Nome; item.Tag = p.Codigo; cmbProjeto.Items.Add(item); ComboBoxItem itemFiltro = new ComboBoxItem(); itemFiltro.Content = p.Nome; itemFiltro.Tag = p.Codigo; cmbFiltroProjeto.Items.Add(itemFiltro); } cmbProjeto.SelectedIndex = 0; preencherComboSprint(lista[0].Codigo); } }
private void Form1_Load(object sender, EventArgs e) { //Seta as listas para os objetos correspondentes obtidos em banco objectListView1.SetObjects(ProfessorDAO.ObterProfessores()); objectListView2.SetObjects(AlunoDAO.ObterAlunos()); objectListView3.SetObjects(ProjetoDAO.ObterProjetos()); }
public List <ProjetoViewModel> PopulaProjetos([FromBody] OsViewModel OS) { ProjetoDAO projDAO = new ProjetoDAO(); var lista = projDAO.ProjetosDoCliente(OS.ClienteId); return(lista); }
private bool AtualizarMatriculasDoAluno(Aluno aluno, List <Projeto> projetosAtualizados) { List <Projeto> ProjetosAtuaisDoAluno = ProjetoDAO.ObterProjetosDoAluno(aluno.NumeroPece); bool exclusãoOK = true; bool inclusaoOK = true; //Exclui a matriculas que sairam foreach (Projeto projeto in ProjetosAtuaisDoAluno) { if (!projetoPertenceALista(projeto, projetosAtualizados)) { if (!alunodao.ExcluirMatricula(aluno, projeto)) { exclusãoOK = false; } } } //Inclui novas matriculas que sairam foreach (Projeto projeto in projetosAtualizados) { if (!projetoPertenceALista(projeto, ProjetosAtuaisDoAluno)) { if (!alunodao.InserirMatricula(aluno, projeto)) { inclusaoOK = false; } } } return(exclusãoOK && inclusaoOK); }
private void BtnInserir_Click(object sender, RoutedEventArgs e) { if (!txtNomeTarefa.Text.Equals("") && !txtTipo.Text.Equals("") && !cbRequisitante.SelectedValue.Equals("") ) { t = new Tarefa() { Titulo = txtNomeTarefa.Text, Tipo = txtTipo.Text, Status = txtStatus.Text, Prioridade = txtPrioridade.Text, Resolucao = txtResolucao.Text, Descricao = txtDesc.Text }; p = new Projeto() { Nome = cbProjetos.SelectedValue.ToString(), };//Validar aqui, cliente vazio estoura exceção //c = new Cliente() { // Nome = cbCliente.SelectedValue.ToString(), //}; assinatura = new Usuario() { Nickname = cbAssinatura.SelectedValue.ToString(), }; requisitante = new Usuario() { Nickname = cbRequisitante.SelectedValue.ToString(), }; p = ProjetoDAO.BuscarProjetoPorNome(p.Nome); t.Projeto = p; //c = ClienteDAO.BuscarClientePorNome(c.Nome); //t.Cliente = c; assinatura = UsuarioDAO.BuscarUsuarioPorNome(assinatura.Nickname); t.Assinatura = assinatura; requisitante = UsuarioDAO.BuscarUsuarioPorNome(requisitante.Nickname); t.Requisitante = requisitante; t.CriadoEm = DateTime.Now; TarefaDAO.CadastrarTarefa(t); lbMensagem.Foreground = new SolidColorBrush(Colors.DarkGreen); MensagemDeConfirmacaoOuErro("Tarefa criada !"); LimparCampos(); } else { lbMensagem.Foreground = new SolidColorBrush(Colors.DarkRed); MensagemDeConfirmacaoOuErro("Preencha os campos obrigatórios para criar uma tarefa !"); } }
//private int ProjetoId; public JobController(JobDAO jobDAO, TarefaDAO tarefaDAO, DepartamentoDAO departamentoDAO, ProjetoDAO projetoDAO, StatusDAO statusDAO, IHostingEnvironment hosting) { _projetoDAO = projetoDAO; _jobDAO = jobDAO; _tarefaDAO = tarefaDAO; _departamentoDAO = departamentoDAO; _statusDAO = statusDAO; _hosting = hosting; }
//private int JobId; public TarefaController(ProjetoDAO projetoDAO, JobDAO jobDAO, TarefaDAO tarefaDAO, FuncionarioDAO funcionarioDAO, StatusDAO statusDAO, IHostingEnvironment hosting) { _projetoDAO = projetoDAO; _jobDAO = jobDAO; _tarefaDAO = tarefaDAO; _funcionarioDAO = funcionarioDAO; _statusDAO = statusDAO; _hosting = hosting; }
private void Window_Loaded(object sender, RoutedEventArgs e) { cbProjetos.ItemsSource = ProjetoDAO.ListarProjetos(); //cbCliente.ItemsSource = ClienteDAO.ListarClientes(); cbAssinatura.ItemsSource = UsuarioDAO.ListarUsuarios(); cbRequisitante.ItemsSource = UsuarioDAO.ListarUsuarios(); dtCriadoEm.Text = DateTime.Now.ToString(); cbAssinatura.IsEnabled = ValidaLogin.GerenteLogado; }
private Projeto recuperarProjeto() { ProjetoDAO pDAO = new ProjetoDAO(); int codigo = Convert.ToInt32(((ComboBoxItem)cmbProjeto.SelectedItem).Tag); List <Projeto> lista = pDAO.recuperar(Projeto.criarListaParametros(codigo)); if (lista.Count > 0) { return(lista[0]); } return(null); }
public void Update(Projeto item) { ProjetoDAO projeto = _context.Projetos.FirstOrDefault(x => x.Id_Projeto == item.Id_Projeto); projeto.Razao_Social = item.Razao_Social; projeto.CNPJ = item.CNPJ; projeto.Horas_Projeto = item.Horas_Projeto; projeto.Data_Inicial_Contrato = item.Data_Inicial_Contrato; projeto.Observacoes = item.Observacoes; _context.SaveChanges(); }
private void preencherCombos() { ProjetoDAO pDAO = new ProjetoDAO(); List <Projeto> lista = pDAO.recuperar(); if (lista.Count > 0) { preencherComboProjeto(lista); cmbProjeto.SelectedIndex = 0; preencherComboSprint(lista[0].Codigo); } }
public void Add(Projeto item) { var projeto = new ProjetoDAO { Razao_Social = item.Razao_Social, CNPJ = item.CNPJ, Horas_Projeto = item.Horas_Projeto, Data_Inicial_Contrato = item.Data_Inicial_Contrato, Observacoes = item.Observacoes }; _context.Projetos.Add(projeto); _context.SaveChanges(); }
private void button9_Click(object sender, EventArgs e) { if (objectListView3.SelectedObject != null) { DialogResult dr = MessageBox.Show("Deseja realmente excluir esse registro?", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dr == DialogResult.Yes) { //Outro cast, igual ao de cima //A lista não sabe o que ela recebe, nem sabe o que é model, então ela guarda só como objeto ProjetoDAO.Excluir((Projeto)objectListView3.SelectedObject); atualizar(); } } }
private void Window_Loaded(object sender, RoutedEventArgs e) { lbUserLogado.Foreground = new SolidColorBrush(Colors.White); lbUserLogado.Content = ValidaLogin.user; btnConfigurações.IsEnabled = ValidaLogin.adminLogado; int users = UsuarioDAO.ListarUsuarios().Count; int projetos = ProjetoDAO.ListarProjetos().Count; int tarefas = TarefaDAO.ListarTarefas().Count; GraficoUsuarios.Value = users; GraficoProjetos.Value = projetos; GraficoTarefas.Value = tarefas; }
public Projeto GetProjeto(long Id) { ProjetoDAO colaborador = _context.Projetos.Find(Id); return(colaborador != null ? new Projeto { Id_Projeto = colaborador.Id_Projeto, Razao_Social = colaborador.Razao_Social, CNPJ = colaborador.CNPJ, Horas_Projeto = colaborador.Horas_Projeto, Data_Inicial_Contrato = colaborador.Data_Inicial_Contrato, Observacoes = colaborador.Observacoes } : null); }
private void preencherLista() { try { ProjetoDAO pDAO = new ProjetoDAO(); tblProjeto.ItemsSource = pDAO.recuperar(); } catch (Exception ex) { Alerta alerta = new Alerta(); alerta.preencherMensagem("Problema ao tentar acessar o banco de dados: \n" + ex.Message); alerta.Show(); this.Close(); } }
private void btnExcluir_Click(object sender, RoutedEventArgs e) { Projeto p = new Projeto(Convert.ToInt32(txtCodigo.Text), txtNome.Text, Convert.ToInt32(txtId.Text), Convert.ToDateTime(txtDtInicio.Text), Convert.ToDateTime(txtDtFinal.Text)); if (p.Codigo > 0) { ProjetoDAO pDAO = new ProjetoDAO(); pDAO.excluir(p.encapsularLista()); Alerta alerta = new Alerta("Excluido com sucesso."); alerta.Show(); } iniciarCampos(); preencherLista(); }
public Projeto recuperarProjetoInCache(List <Projeto> listaProjeto, int idProjeto, int codProjeto, string nomeProjeto) { foreach (Projeto p in listaProjeto) { if (p.Id.Equals(idProjeto)) { return(p); } } ProjetoDAO pDAO = new ProjetoDAO(); List <Projeto> lista = pDAO.recuperar(Projeto.criarListaParametrosId(idProjeto)); if (lista.Count > 0) { listaProjeto.Add(lista[0]); return(lista[0]); } return(new Projeto(codProjeto, nomeProjeto, idProjeto, DateTime.Now, DateTime.Now)); }
public void preencherComboProjeto(ComboBox cmb, bool todos) { ProjetoDAO pDAO = new ProjetoDAO(); List <Projeto> lista = pDAO.recuperar(); if (lista.Count > 0) { if (todos) { cmb.Items.Add(preencherComboItem(0, "Todos")); } foreach (Projeto p in lista) { cmb.Items.Add(preencherComboItem(p.Codigo, p.Nome)); } // cmb.SelectedIndex = 0; } }
private void btnPesquisar_Click(object sender, RoutedEventArgs e) { Dictionary <string, string> param = new Dictionary <string, string>(); if (txtFiltroNome.Text.Length > 0) { param.Add(Projeto.NOME, txtFiltroNome.Text); } if (txtFiltroId.Text.Length > 0) { param.Add(Projeto.ID, txtFiltroId.Text); } if (txtFiltroDtInicio.Text.Length > 0) { param.Add(Projeto.DTINICIO, txtFiltroDtInicio.Text); } if (txtFiltroDtFinal.Text.Length > 0) { param.Add(Projeto.DTFINAL, txtFiltroDtFinal.Text); } if (param.Count > 0) { try { ProjetoDAO pDAO = new ProjetoDAO(); tblProjeto.ItemsSource = pDAO.recuperar(param); } catch (Exception ex) { Alerta alerta = new Alerta(); alerta.preencherMensagem("Problema ao tentar acessar o banco de dados: \n" + ex.Message); alerta.Show(); this.Close(); } } else { preencherLista(); } }
private Projeto recuperarProjeto(List <Projeto> listaProjeto, int idProjeto) { foreach (Projeto p in listaProjeto) { if (p.Id.Equals(idProjeto)) { return(p); } } ProjetoDAO pDAO = new ProjetoDAO(); List <Projeto> lista = pDAO.recuperar(Projeto.criarListaParametrosId(idProjeto)); if (lista.Count > 0) { listaProjeto.Add(lista[0]); return(lista[0]); } else { int codigo = Convert.ToInt32(((ComboBoxItem)cmbProjeto.SelectedItem).Tag); return(new Projeto(codigo, "Unssigned", 0, DateTime.Now, DateTime.Now)); } }
private void button2_Click(object sender, EventArgs e) { if (aluno != null && professor != null && dateTimePicker1.Value != null && textBox1.Text != "" && textBox2.Text != "") { projeto.data = dateTimePicker1.Value; projeto.descricaodoprojeto = textBox2.Text; projeto.nomepro = textBox1.Text; projeto.professor = professor; projeto.aluno = aluno; projeto.Aluno = aluno.Id; projeto.Professor = professor.Id; if (modoEdicao) { if (ProjetoDAO.Alterar(projeto)) { MessageBox.Show("Projeto editado com sucesso.", "Informação", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Erro ao tentar editar o projeto.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { if (ProjetoDAO.Incluir(projeto)) { MessageBox.Show("Projeto cadastrado com sucesso.", "Informação", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Erro ao tentar incluir o projeto.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } } Program.atualizarListas(); } }
private void preencherComboProjeto() { ComboBoxItem itemTodos = new ComboBoxItem(); itemTodos.Content = "Todos"; itemTodos.Tag = 0; cmbFiltroProjeto.Items.Add(itemTodos); ProjetoDAO pDAO = new ProjetoDAO(); List <Projeto> lista = pDAO.recuperar(); foreach (Projeto p in lista) { ComboBoxItem item = new ComboBoxItem(); item.Content = p.Nome; item.Tag = p.Codigo; cmbProjeto.Items.Add(item); ComboBoxItem itemFiltro = new ComboBoxItem(); itemFiltro.Content = p.Nome; itemFiltro.Tag = p.Codigo; cmbFiltroProjeto.Items.Add(itemFiltro); } }
public void preencherListBoxProjeto(ListBox lst, string sistema) { lst.Items.Clear(); ProjetoDAO pDAO = new ProjetoDAO(); List <Projeto> lista = new List <Projeto>(); if (sistema.Length == 0 || sistema.Equals("Todos")) { lista = pDAO.recuperar(); } else { Dictionary <string, string> param = new Dictionary <string, string>(); param.Add(Projeto.SISTEMA, sistema); lista = pDAO.recuperar(param); } if (lista.Count > 0) { foreach (Projeto p in lista) { lst.Items.Add(preencherListItem(p.Id, p.Nome)); } } }
//Atulaiza as coisas do banco public void atualizar() { objectListView1.SetObjects(ProfessorDAO.ObterProfessores()); objectListView2.SetObjects(AlunoDAO.ObterAlunos()); objectListView3.SetObjects(ProjetoDAO.ObterProjetos()); }
public ProjetoAPIController(ProjetoDAO projetoDAO) { _projetoDAO = projetoDAO; }