private List <ServicoSeparado> PegarDadosServicos(FbConnectionStringBuilder fbcs, FbConnection fbConn) { FbCommand fbCmd = new FbCommand(@"select nf.idnf, tiposerv.nome as tiposervico, serv.nome as servico, conta.nome as funcionario, serv_nf.tempo, serv_nf.valor, serv_nf.qtde, serv_nf.total from empresa_nf as nf inner join empresa_nf_servico serv_nf on serv_nf.idnf = nf.idnf inner join empresa_conta conta on conta.idconta = serv_nf.idfuncionario inner join vendas_servico serv on serv.idservico = serv_nf.idservico inner join vendas_tiposervico tiposerv on tiposerv.idtiposervico = serv.idtiposervico", fbConn); DataTable dtService = new DataTable(); try { FbDataAdapter fbDa = new FbDataAdapter(fbCmd); fbConn.Open(); fbDa.Fill(dtService); } catch (FbException fbex) { Console.WriteLine("Erro ao acessar o FireBird " + fbex.Message, "Erro"); } finally { fbConn.Close(); } List <ServicoSeparado> listServices = new List <ServicoSeparado>(); foreach (DataRow row in dtService.Rows) { ServicoSeparado servico = new ServicoSeparado(); servico.IDNF = Convert.ToInt32(row[0]); servico.TipoServico = row[1].ToString(); servico.NomeServico = row[2].ToString(); servico.Funcionario = row[3].ToString(); servico.Tempo = row[4].ToString(); servico.VlrUnit = Convert.ToDouble(row[5]); servico.QntItens = Convert.ToInt32(row[6]); servico.VlrTotal = Convert.ToDouble(row[7]); listServices.Add(servico); } return(listServices); }
private void PegarInfosServicos(Dictionary <long, ClienteSeparado> dicVendas, List <ServicoSeparado> servicos) { foreach (ClienteSeparado cliente in dicVendas.Values) { foreach (Venda venda in cliente.ListaVendas) { ServicoSeparado servico = servicos.Where(s => s.IDNF == venda.IDNF).FirstOrDefault(); if (servico != null) { venda.Servico = new ServicoSeparado { NomeServico = servico.NomeServico, Funcionario = servico.Funcionario, QntItens = servico.QntItens, Tempo = servico.Tempo, TipoServico = servico.TipoServico, VlrTotal = servico.VlrTotal, VlrUnit = servico.VlrUnit }; } } } }