private void BtnBuscarHistoricoServicoCliente_Click(object sender, EventArgs e)
        {
            FrmConsultaServico consultaHistorico = FormResolve.Resolve <FrmConsultaServico>();

            consultaHistorico.ShowDialog();
            consultaHistorico.Dispose();
        }
        private void BtnBuscarHistoricoCliente_Click(object sender, EventArgs e)
        {
            FrmConsultaServico consultaServico = FormResolve.Resolve <FrmConsultaServico>();

            consultaServico.servicoId = Convert.ToInt32(txtClienteId.Text);
            consultaServico.ShowDialog();
            consultaServico.Dispose();
            consultaServico.Close();
        }
Пример #3
0
        private void BtnLocalizar_Click(object sender, EventArgs e)
        {
            FrmConsultaServico consultaServico = FormResolve.Resolve <FrmConsultaServico>();

            consultaServico.ShowDialog();

            DialogResult res = MessageBox.Show("Deseja efetuar alguma alteração no Serviço?", "Ordem de Serviço", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (res.ToString() == "Yes")
            {
                if (consultaServico.servicoId != 0)
                {
                    var servico        = _servicoApplication.GetServicoByServicoId(consultaServico.servicoId);
                    var clienteVeiculo = _clienteVeiculoApplication.GetVeiculoClienteByClienteVeiculoId(servico.ClienteVeiculoId);
                    var cliente        = _clienteApplication.GetClienteById(clienteVeiculo.ClienteId);

                    txtServicoId.Text           = Convert.ToString(servico.ServicoId);
                    txtClienteId.Text           = servico.ClienteVeiculoId.ToString();
                    txtClienteVeiculoId.Text    = servico.ClienteVeiculoId.ToString();
                    txtValorTotalMaodeObra.Text = servico.ValorMaodeObra.ToString("C");
                    txtValorTotalPecas.Text     = servico.ValorPeca.ToString("C");
                    txtValorAdicional.Text      = servico.ValorAdicional.ToString("C");
                    txtPercentualDesconto.Text  = servico.PercentualDesconto.ToString("P");
                    txtValorDesconto.Text       = servico.ValorDesconto.ToString("C");
                    txtValorTotal.Text          = servico.ValorTotal.ToString("C");
                    txtClienteSelecionado.Text  = cliente.NomeCliente;
                    txtDescricao.Text           = servico.Descricao.ToString();

                    var servicoMaodeObraSalvo = _servicoApplication.GetServicoMaodeObraByServicoId(servico.ServicoId);

                    IList <PesquisaMaodeObraServicoDataSource> maoDeObra = new List <PesquisaMaodeObraServicoDataSource>();

                    foreach (var item in servicoMaodeObraSalvo)
                    {
                        var mao = _maoDeObraApplication.GetMaodeObraById(item.MaodeObraId);

                        maoDeObra.Add(new PesquisaMaodeObraServicoDataSource
                        {
                            MaodeObraId        = mao.MaodeObraId,
                            MaodeObra          = mao.Descricao,
                            Valor              = mao.Valor,
                            ServicoMaodeObraId = item.Id
                        });
                    }

                    dgvMaodeObra.DataSource            = maoDeObra;
                    dgvMaodeObra.Columns[0].HeaderText = "Código";
                    dgvMaodeObra.Columns[0].Width      = 50;
                    dgvMaodeObra.Columns[1].HeaderText = "Mão de Obra";
                    dgvMaodeObra.Columns[1].Width      = 300;
                    dgvMaodeObra.Columns[2].HeaderText = "Valor";
                    dgvMaodeObra.Columns[2].Width      = 70;
                    dgvMaodeObra.Columns[2].DefaultCellStyle.Format    = "C2";
                    dgvMaodeObra.Columns[2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                    dgvMaodeObra.Columns[3].HeaderText = "ServicoMaoDeObraId";
                    dgvMaodeObra.Columns[3].Width      = 20;
                    dgvMaodeObra.Columns[3].Visible    = false;

                    var servicoPecaSalvo = _servicoApplication.GetServicoPecaByServicoId(servico.ServicoId);

                    IList <PesquisaPecaServicoDataSource> peca = new List <PesquisaPecaServicoDataSource>();

                    foreach (var item in servicoPecaSalvo)
                    {
                        var mao = _pecaApplication.GetPecaByPecaId(item.PecaId);
                        peca.Add(new PesquisaPecaServicoDataSource
                        {
                            PecaId        = mao.PecaId,
                            Peca          = mao.Descricao,
                            Valor         = mao.Valor,
                            ServicoPecaId = item.Id
                        });
                    }

                    dgvPeca.DataSource            = peca;
                    dgvPeca.Columns[0].HeaderText = "Código";
                    dgvPeca.Columns[0].Width      = 50;
                    dgvPeca.Columns[1].HeaderText = "Peça";
                    dgvPeca.Columns[1].Width      = 330;
                    dgvPeca.Columns[2].HeaderText = "Valor Integral";
                    dgvPeca.Columns[2].Width      = 70;
                    dgvPeca.Columns[2].DefaultCellStyle.Format    = "C2";
                    dgvPeca.Columns[2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;



                    DisponibilizarBotoesTela(EnumControleTelas.AlterarExcluirCancelar);
                }
                else
                {
                    this.LimpaTela();
                    this.DisponibilizarBotoesTela(EnumControleTelas.InserirLocalizar);
                }
            }
            else
            {
                this.LimpaTela();
                this.DisponibilizarBotoesTela(EnumControleTelas.InserirLocalizar);
            }

            consultaServico.Dispose();
        }