Beispiel #1
0
 private void btnExcluir_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Tem certeza que deseja excluir?", "Confirmação", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         if (Convert.ToInt32(lblid.Text) != -1)
         {
             Camadas.Model.servico servico    = new Camadas.Model.servico();
             Camadas.BLL.servico   bllServico = new Camadas.BLL.servico();
             servico.idServico     = Convert.ToInt32(lblid.Text);
             servico.idCliente     = Convert.ToInt32(comboCliente.SelectedValue);
             servico.idVeiculo     = Convert.ToInt32(comboVeiculo.SelectedValue);
             servico.idProduto     = Convert.ToInt32(comboProduto.SelectedValue);
             servico.idFuncionario = Convert.ToInt32(comboFuncionario.SelectedValue);
             //servico.idTipo_prod = Convert.ToInt32(comboTipo.SelectedValue);
             servico.tipo         = comboTipo.Text;
             servico.serv_lateral = comboServ_lateral.Text;
             servico.serv_frontal = comboServ_frontal.Text;
             servico.valor        = Convert.ToDouble(textValor.Text);
             servico.status       = "";
             bllServico.Delete(servico);
             dgvServico.DataSource = (from p in bllServico.Select()
                                      select new
             {
                 Serviço = p.idServico,
                 Cliente = new Camadas.BLL.cliente().Select().FirstOrDefault(t => t.idCliente == p.idCliente)?.nome ?? "Não encontrado",
                 Veiculo = new Camadas.BLL.veiculo().Select().FirstOrDefault(t => t.idVeiculo == p.idVeiculo)?.nome ?? "Não encontrado",
                 Produto = new Camadas.BLL.produto().Select().FirstOrDefault(t => t.idProduto == p.idProduto)?.tonalidade ?? "Não encontrado",
                 Funcionario = new Camadas.BLL.funcionario().Select().FirstOrDefault(t => t.idFuncionario == p.idFuncionario)?.nome ?? "Não encontrado",
                 //TipoProduto = new Camadas.BLL.tipo_prod().Select().FirstOrDefault(t => t.idTipo_prod == p.idTipo_prod)?.tipo ?? "Não encontrado",
                 //TipoServiço = new Camadas.BLL.tipo_serv().Select().FirstOrDefault(t => t.idTipo_serv == p.idTipo_serv)?.idTipo_serv.ToString() ?? "Não encontrado",
                 Tipo = p.tipo,
                 ServiçoLateral = p.serv_lateral,
                 ServiçoFrontal = p.serv_frontal,
                 Valor = p.valor,
                 Status = p.status
             }).ToList();
         }
         else
         {
             MessageBox.Show("Não há nenhum cadastro para ser excluído!", "Confirmação", MessageBoxButtons.OK, MessageBoxIcon.Hand);
         }
     }
     btnPreServico.Enabled = false;
     LimpaCampos();
 }
Beispiel #2
0
 private void btnPesquisar_Click(object sender, EventArgs e)
 {
     Camadas.BLL.servico bllServico = new Camadas.BLL.servico();
     dgvServico.DataSource = (from p in bllServico.Select()
                              select new
     {
         Serviço = p.idServico,
         Cliente = new Camadas.BLL.cliente().Select().FirstOrDefault(t => t.idCliente == p.idCliente)?.nome ?? "Não encontrado",
         Veiculo = new Camadas.BLL.veiculo().Select().FirstOrDefault(t => t.idVeiculo == p.idVeiculo)?.nome ?? "Não encontrado",
         Produto = new Camadas.BLL.produto().Select().FirstOrDefault(t => t.idProduto == p.idProduto)?.tonalidade ?? "Não encontrado",
         Funcionario = new Camadas.BLL.funcionario().Select().FirstOrDefault(t => t.idFuncionario == p.idFuncionario)?.nome ?? "Não encontrado",
         //TipoProduto = new Camadas.BLL.tipo_prod().Select().FirstOrDefault(t => t.idTipo_prod == p.idTipo_prod)?.tipo ?? "Não encontrado",
         //TipoServiço = new Camadas.BLL.tipo_serv().Select().FirstOrDefault(t => t.idTipo_serv == p.idTipo_serv)?.idTipo_serv.ToString() ?? "Não encontrado",
         Tipo = p.tipo,
         ServiçoLateral = p.serv_lateral,
         ServiçoFrontal = p.serv_frontal,
         Valor = p.valor,
         Status = p.status
     }).ToList();
     btnGravar.Enabled     = true;
     btnPreServico.Enabled = true;
 }