private LIS_SERVICOOSFECHCollection ServicoRel(int IDFUNCIONARIO) { LIS_SERVICOOSFECHCollection LIS_SERVICOOSFECHColl = new LIS_SERVICOOSFECHCollection(); LIS_SERVICOOSFECHProvider LIS_SERVICOOSFECHP = new LIS_SERVICOOSFECHProvider(); string DataInicial = Util.ConverStringDateSearch(msktDataInicial.Text); string DataFinal = Util.ConverStringDateSearch(msktDataFinal.Text); RowRelatorio.Clear(); RowRelatorio.Add(new RowsFiltro("IDFUNCIONARIO", "System.Int32", "=", IDFUNCIONARIO.ToString())); RowRelatorio.Add(new RowsFiltro("DATAEMISSAO", "System.DateTime", ">=", DataInicial)); RowRelatorio.Add(new RowsFiltro("DATAEMISSAO", "System.DateTime", "<=", DataFinal)); if (rdOrcamento.Checked) { RowRelatorio.Add(new RowsFiltro("FLAGORCAMENTO", "System.String", "=", "S")); } else if (rdVenda.Checked) { RowRelatorio.Add(new RowsFiltro("FLAGORCAMENTO", "System.String", "=", "N")); } if (Convert.ToInt32(cbStatus.SelectedValue) > 0) { RowRelatorio.Add(new RowsFiltro("IDSTATUS", "System.Int32", "=", Convert.ToInt32(cbStatus.SelectedValue).ToString())); } LIS_SERVICOOSFECHColl = LIS_SERVICOOSFECHP.ReadCollectionByParameter(RowRelatorio); return(LIS_SERVICOOSFECHColl); }
private LIS_SERVICOOSFECHCollection ServicoRel(int IDORDEMSERVICO) { LIS_SERVICOOSFECHCollection LIS_SERVICOOSFECHColl = new LIS_SERVICOOSFECHCollection(); LIS_SERVICOOSFECHProvider LIS_SERVICOOSFECHP = new LIS_SERVICOOSFECHProvider(); try { RowRelatorio.Clear(); if (Convert.ToInt32(cbFuncionario.SelectedValue) > 0) { RowRelatorio.Add(new RowsFiltro("IDFUNCIONARIO", "System.Int32", "=", Convert.ToInt32(cbFuncionario.SelectedValue).ToString())); } RowRelatorio.Add(new RowsFiltro("IDORDEMSERVICO", "System.Int32", "=", IDORDEMSERVICO.ToString())); LIS_SERVICOOSFECHColl = LIS_SERVICOOSFECHP.ReadCollectionByParameter(RowRelatorio); return(LIS_SERVICOOSFECHColl); } catch (Exception ex) { MessageBox.Show("Erro técnico: " + ex.Message); return(LIS_SERVICOOSFECHColl); } }
private void btnPesquisa_Click(object sender, EventArgs e) { if (Validacoes()) { try { RowRelatorio.Clear(); string DataInicial = Util.ConverStringDateSearch(msktDataInicial.Text); string DataFinal = Util.ConverStringDateSearch(msktDataFinal.Text); if (Convert.ToInt32(cbFuncionario.SelectedValue) > 0) { RowRelatorio.Add(new RowsFiltro("IDFUNCIONARIO", "System.Int32", "=", Convert.ToInt32(cbFuncionario.SelectedValue).ToString())); } RowRelatorio.Add(new RowsFiltro("DATAEMISSAO", "System.DateTime", ">=", DataInicial)); RowRelatorio.Add(new RowsFiltro("DATAEMISSAO", "System.DateTime", "<=", DataFinal)); if (rdOrcamento.Checked) { RowRelatorio.Add(new RowsFiltro("FLAGORCAMENTO", "System.String", "=", "S")); } else if (rdVenda.Checked) { RowRelatorio.Add(new RowsFiltro("FLAGORCAMENTO", "System.String", "=", "N")); } if (Convert.ToInt32(cbStatus.SelectedValue) > 0) { RowRelatorio.Add(new RowsFiltro("IDSTATUS", "System.Int32", "=", Convert.ToInt32(cbStatus.SelectedValue).ToString())); } LIS_SERVICOOSFECHColl = LIS_SERVICOOSFECHP.ReadCollectionByParameter(RowRelatorio, "DATAEMISSAO DESC"); LIS_PRODUTOOSFECHColl = LIS_PRODUTOOSFECHP.ReadCollectionByParameter(RowRelatorio, "DATAEMISSAO DESC"); PreencheGrid2(); PreencheGrid3(); } catch (Exception EX) { MessageBox.Show("Erro na pesquisa!"); MessageBox.Show("Erro técnico: " + EX.Message); } } }
private void btnPesquisa_Click(object sender, EventArgs e) { if (Validacoes()) { CreaterCursor Cr = new CreaterCursor(); this.Cursor = Cr.CreateCursor(Cr.btmap, 0, 0); try { RowRelatorio.Clear(); string DataInicial = Util.ConverStringDateSearch(msktDataInicial.Text); string DataFinal = Util.ConverStringDateSearch(msktDataFinal.Text); RowRelatorio.Add(new RowsFiltro("DATAEMISSAO", "System.DateTime", ">=", DataInicial)); RowRelatorio.Add(new RowsFiltro("DATAEMISSAO", "System.DateTime", "<=", DataFinal)); if (Convert.ToInt32(cbServico.SelectedValue) > 0) { RowRelatorio.Add(new RowsFiltro("IDSERVICO", "System.Int32", "=", Convert.ToInt32(cbServico.SelectedValue).ToString())); } if (rbOrcamentoPesquisa.Checked) { RowRelatorio.Add(new RowsFiltro("FLAGORCAMENTO", "System.String", "=", "S")); } if (rbVendasPesquisa.Checked) { RowRelatorio.Add(new RowsFiltro("FLAGORCAMENTO", "System.String", "=", "N")); } LIS_SERVICOOSFECHColl = LIS_SERVICOOSFECHP.ReadCollectionByParameter(RowRelatorio, "IDORDEMSERVICO DESC"); PreencheGrid(); this.Cursor = Cursors.Default; } catch (Exception EX) { this.Cursor = Cursors.Default; MessageBox.Show("Erro na pesquisa!"); MessageBox.Show("Erro técnico: " + EX.Message); } } }
private static LIS_SERVICOOSFECHCollection ExecuteReader(ref LIS_SERVICOOSFECHCollection collection, ref FbDataReader dataReader, FbCommand dbCommand) { using (dataReader = dbCommand.ExecuteReader()) { collection = new LIS_SERVICOOSFECHCollection(); if (dataReader.HasRows) { while (dataReader.Read()) { collection.Add(FillEntityObject(ref dataReader)); } } if (!(dataReader.IsClosed)) { dataReader.Close(); } dataReader.Dispose(); } return(collection); }
private void FrmRelatPedidoVendas_Load(object sender, EventArgs e) { CreaterCursor Cr = new CreaterCursor(); this.Cursor = Cr.CreateCursor(Cr.btmap, 0, 0); EMPRESAProvider EMPRESAP = new EMPRESAProvider(); EMPRESACollection EMPRESAColl = new EMPRESACollection(); EMPRESAColl = EMPRESAP.ReadCollectionByParameter(null); //Logomarca CONFISISTEMAProvider CONFISISTEMAP = new CONFISISTEMAProvider(); CONFISISTEMAEntity CONFISISTEMAty = CONFISISTEMAP.Read(1); if (CONFISISTEMAty.FLAGLOGORELATORIO == "S") { if (CONFISISTEMAty.IDARQUIVOBINARIO1 != null) { ARQUIVOBINARIOProvider ARQUIVOBINARIOP = new ARQUIVOBINARIOProvider(); ARQUIVOBINARIOCollection ARQUIVOBINARIOColl = new ARQUIVOBINARIOCollection(); RowRelatorio.Clear(); RowRelatorio.Add(new RowsFiltro("IDARQUIVOBINARIO", "System.Int32", "=", CONFISISTEMAty.IDARQUIVOBINARIO1.ToString())); ARQUIVOBINARIOColl = ARQUIVOBINARIOP.ReadCollectionByParameter(RowRelatorio); this.ARQUIVOBINARIOCollectionBindingSource.DataSource = ARQUIVOBINARIOColl; } } //Dados do Cliente RowRelatorio.Clear(); RowRelatorio.Add(new RowsFiltro("IDCLIENTE", "System.Int32", "=", idcliente.ToString())); LIS_CLIENTEProvider LIS_CLIENTEP = new LIS_CLIENTEProvider(); LIS_CLIENTEColl = LIS_CLIENTEP.ReadCollectionByParameter(RowRelatorio); string cpfcnpjPar = (LIS_CLIENTEColl[0].CNPJ == " . . / -" || LIS_CLIENTEColl[0].CNPJ == string.Empty) ? LIS_CLIENTEColl[0].CPF : LIS_CLIENTEColl[0].CNPJ; //Dados do Pedido RowRelatorio.Clear(); RowRelatorio.Add(new RowsFiltro("IDORDEMSERVICO", "System.Int32", "=", IDORDEMSERVICO.ToString())); LIS_ORDEMSERVICOSFECHProvider LIS_ORDEMSERVICOSFECHP = new LIS_ORDEMSERVICOSFECHProvider(); LIS_ORDEMSERVICOSFECHColl = LIS_ORDEMSERVICOSFECHP.ReadCollectionByParameter(RowRelatorio); //Dados do Produto RowRelatorio.Clear(); RowRelatorio.Add(new RowsFiltro("IDORDEMSERVICO", "System.Int32", "=", IDORDEMSERVICO.ToString())); LIS_PRODUTOOSFECHProvider LIS_PRODUTOOSFECHP = new LIS_PRODUTOOSFECHProvider(); LIS_PRODUTOOSFECHColl = LIS_PRODUTOOSFECHP.ReadCollectionByParameter(RowRelatorio); //Dados do Produto MTQ RowRelatorio.Clear(); RowRelatorio.Add(new RowsFiltro("IDORDEMSERVICO", "System.Int32", "=", IDORDEMSERVICO.ToString())); LIS_PRODUTOSPEDIDOMTQOSProvider LIS_PRODUTOSPEDIDOMTQOSP = new LIS_PRODUTOSPEDIDOMTQOSProvider(); LIS_PRODUTOSPEDIDOMTQOSColl = LIS_PRODUTOSPEDIDOMTQOSP.ReadCollectionByParameter(RowRelatorio); //Dados Servicos RowRelatorio.Clear(); RowRelatorio.Add(new RowsFiltro("IDORDEMSERVICO", "System.Int32", "=", IDORDEMSERVICO.ToString())); LIS_SERVICOOSFECHProvider LIS_SERVICOOSFECHP = new LIS_SERVICOOSFECHProvider(); LIS_SERVICOOSFECHColl = LIS_SERVICOOSFECHP.ReadCollectionByParameter(RowRelatorio); //Dados Equipamento RowRelatorio.Clear(); RowRelatorio.Add(new RowsFiltro("IDORDEMSERVICO", "System.Int32", "=", IDORDEMSERVICO.ToString())); LIS_EQUIPAMENTOOSFECHProvider LIS_EQUIPAMENTOOSFECHP = new LIS_EQUIPAMENTOOSFECHProvider(); LIS_EQUIPAMENTOOSFECHCollection LIS_EQUIPAMENTOOSFECHColl = new LIS_EQUIPAMENTOOSFECHCollection(); LIS_EQUIPAMENTOOSFECHColl = LIS_EQUIPAMENTOOSFECHP.ReadCollectionByParameter(RowRelatorio); if (LIS_SERVICOOSFECHColl.Count > 0) { listaservicoSelec = "true"; } string titulo = "Nº O.S " + IDORDEMSERVICO.ToString().PadLeft(6, '0'); if (LIS_ORDEMSERVICOSFECHColl[0].FLAGORCAMENTO.TrimEnd() == "S") { titulo = "Nº ORÇAMENTO " + IDORDEMSERVICO.ToString().PadLeft(6, '0'); } decimal totalproduto = 0; foreach (LIS_PRODUTOOSFECHEntity item in LIS_PRODUTOOSFECHColl) { totalproduto += Convert.ToDecimal(item.VALORTOTAL); listaproduto1Selec = "true"; } foreach (LIS_PRODUTOSPEDIDOMTQOSEntity item in LIS_PRODUTOSPEDIDOMTQOSColl) { totalproduto += Convert.ToDecimal(item.VALORTOTAL); listaproduto2Selec = "true"; } if (LIS_EQUIPAMENTOOSFECHColl.Count > 0) { ListaEquipamento = "true"; } //setando os parametro Microsoft.Reporting.WinForms.ReportParameter[] p = new Microsoft.Reporting.WinForms.ReportParameter[6]; p[0] = new Microsoft.Reporting.WinForms.ReportParameter("CPFCNPJ", cpfcnpjPar); p[1] = new Microsoft.Reporting.WinForms.ReportParameter("titulo", titulo.ToString().PadLeft(6, '0')); p[2] = new Microsoft.Reporting.WinForms.ReportParameter("totalproduto", totalproduto.ToString("N2")); p[3] = new Microsoft.Reporting.WinForms.ReportParameter("listaproduto1", listaproduto1Selec); p[4] = new Microsoft.Reporting.WinForms.ReportParameter("listaproduto2", listaproduto2Selec); p[5] = new Microsoft.Reporting.WinForms.ReportParameter("listaservico", listaservicoSelec); reportViewer1.LocalReport.SetParameters(p); this.LIS_CLIENTECollectionBindingSource.DataSource = LIS_CLIENTEColl; this.EMPRESACollectionBindingSource.DataSource = EMPRESAColl; this.LIS_ORDEMSERVICOSFECHCollectionBindingSource.DataSource = LIS_ORDEMSERVICOSFECHColl; this.LIS_PRODUTOOSFECHCollectionBindingSource.DataSource = LIS_PRODUTOOSFECHColl; this.LIS_PRODUTOSPEDIDOMTQOSCollectionBindingSource.DataSource = LIS_PRODUTOSPEDIDOMTQOSColl; this.LIS_SERVICOOSFECHCollectionBindingSource.DataSource = LIS_SERVICOOSFECHColl; LIS_EQUIPAMENTOOSFECHCollectionBindingSource.DataSource = LIS_EQUIPAMENTOOSFECHColl; this.reportViewer1.SetDisplayMode(DisplayMode.PrintLayout); this.reportViewer1.ZoomMode = ZoomMode.Percent; this.reportViewer1.RefreshReport(); this.Cursor = Cursors.Default; }
private void PreencheGrid2() { //Remove Vendedor Repetido LIS_SERVICOOSFECHCollection LIS_SERVICOOSFECHColl2 = new LIS_SERVICOOSFECHCollection(); foreach (LIS_SERVICOOSFECHEntity item in LIS_SERVICOOSFECHColl) { if (LIS_SERVICOOSFECHColl2.Find(delegate(LIS_SERVICOOSFECHEntity item2) { return(item2.IDFUNCIONARIO == item.IDFUNCIONARIO && item.IDFUNCIONARIO != null && item.IDFUNCIONARIO > 0); }) == null) { LIS_SERVICOOSFECHColl2.Add(item); } } LIS_SERVICOOSFECHColl.Clear(); LIS_SERVICOOSFECHColl = LIS_SERVICOOSFECHColl2; TotalGeralPedido = 0; CreaterCursor Cr = new CreaterCursor(); this.Cursor = Cr.CreateCursor(Cr.btmap, 0, 0); DataGriewDados.Rows.Clear(); foreach (var LIS_PEDIDOTy in LIS_SERVICOOSFECHColl) { LIS_SERVICOOSFECHCollection LIS_SERVICOOSFECH2Coll = new LIS_SERVICOOSFECHCollection(); if (LIS_PEDIDOTy.IDFUNCIONARIO != null && LIS_PEDIDOTy.IDFUNCIONARIO > 0) { //Cabeçalho - Nome do Vendedor DataGridViewRow rowCabec = new DataGridViewRow(); rowCabec.CreateCells(DataGriewDados, LIS_PEDIDOTy.NOMEFUNCIONARIO); rowCabec.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold); DataGriewDados.Rows.Add(rowCabec); DataGridViewRow row4_2 = new DataGridViewRow(); row4_2.CreateCells(DataGriewDados, "Serviço", "Quant.", "Total"); row4_2.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold); DataGriewDados.Rows.Add(row4_2); LIS_SERVICOOSFECH2Coll = ServicoRel(Convert.ToInt32(LIS_PEDIDOTy.IDFUNCIONARIO)); foreach (LIS_SERVICOOSFECHEntity item in LIS_SERVICOOSFECH2Coll) { DataGridViewRow row5 = new DataGridViewRow(); row5.CreateCells(DataGriewDados, item.NOMESERVICO, Convert.ToDecimal(item.QUANTIDADE).ToString(), Convert.ToDecimal(item.VALORTOTAL).ToString("n2")); row5.DefaultCellStyle.Font = new Font("Arial", 8); DataGriewDados.Rows.Add(row5); SubGeralPedido += Convert.ToDecimal(item.VALORTOTAL); } TotalGeralPedido += Convert.ToDecimal(SubGeralPedido); DataGridViewRow rowLinhaSubTotal = new DataGridViewRow(); rowLinhaSubTotal.CreateCells(DataGriewDados, "", "Sub-Total", SubGeralPedido.ToString("n2")); rowLinhaSubTotal.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold); DataGriewDados.Rows.Add(rowLinhaSubTotal); DataGridViewRow rowLinha1 = new DataGridViewRow(); rowLinha1.CreateCells(DataGriewDados, "______________________________________", "_________", "_________"); rowLinha1.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold); DataGriewDados.Rows.Add(rowLinha1); } } //Total Geral DataGridViewRow rowTotalGeral = new DataGridViewRow(); rowTotalGeral.CreateCells(DataGriewDados, "______________________________________", "_________", TotalGeralPedido.ToString("n2")); rowTotalGeral.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold); DataGriewDados.Rows.Add(rowTotalGeral); this.Cursor = Cursors.Default; }
private void PreencheGrid() { CreaterCursor Cr = new CreaterCursor(); this.Cursor = Cr.CreateCursor(Cr.btmap, 0, 0); DataGriewDados.Rows.Clear(); totalGeralOS = 0; totalQuant = 0; DataGridViewRow rowTop = new DataGridViewRow(); // rowTop.CreateCells(DataGriewDados, "_________", "__________", "____________________________________________", "_________", ____________________________", "__________"); rowTop.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold); DataGriewDados.Rows.Add(rowTop); DataGridViewRow row1 = new DataGridViewRow(); row1.CreateCells(DataGriewDados, "O.SERVIÇO", "EMISSÃO", "SERVIÇO", "QUANT.", "CLIENTE", "TOTAL O.S", "FUNCIONÁRIO"); row1.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold); DataGriewDados.Rows.Add(row1); foreach (var LIS_ORDEMSERVICOSFECHTy in LIS_ORDEMSERVICOSFECHColl) { LIS_SERVICOOSFECHCollection LIS_SERVICOOSFECHColl = new LIS_SERVICOOSFECHCollection(); LIS_SERVICOOSFECHProvider LIS_SERVICOOSFECHP = new LIS_SERVICOOSFECHProvider(); RowRelatorio.Clear(); RowRelatorio.Add(new RowsFiltro("IDORDEMSERVICO", "System.Int32", "=", LIS_ORDEMSERVICOSFECHTy.IDORDEMSERVICO.ToString())); LIS_SERVICOOSFECHColl = LIS_SERVICOOSFECHP.ReadCollectionByParameter(RowRelatorio); foreach (var LIS_SERVICOOSFECHTy in LIS_SERVICOOSFECHColl) { string DataEmissao = string.Empty; if (LIS_ORDEMSERVICOSFECHTy.IDORDEMSERVICO != null) { DataEmissao = Convert.ToDateTime(LIS_ORDEMSERVICOSFECHTy.DATAEMISSAO).ToString("dd/MM/yyyy"); } string TotalOS = Convert.ToDecimal(LIS_SERVICOOSFECHTy.VALORTOTAL).ToString("n2"); DataGridViewRow row2 = new DataGridViewRow(); string OSNumero = LIS_ORDEMSERVICOSFECHTy.IDORDEMSERVICO.ToString().PadLeft(6, '0'); row2.CreateCells(DataGriewDados, OSNumero, DataEmissao, LIS_SERVICOOSFECHTy.NOMESERVICO, LIS_SERVICOOSFECHTy.QUANTIDADE, LIS_ORDEMSERVICOSFECHTy.NOMECLIENTE, TotalOS, LIS_ORDEMSERVICOSFECHTy.NOMEFUNCIONARIO); row2.DefaultCellStyle.Font = new Font("Arial", 8); DataGriewDados.Rows.Add(row2); totalQuant += Convert.ToInt32(LIS_SERVICOOSFECHTy.QUANTIDADE); } totalGeralOS += Convert.ToDecimal(LIS_ORDEMSERVICOSFECHTy.TOTALFECHOS); } DataGridViewRow rowLinha = new DataGridViewRow(); // rowLinha.CreateCells(DataGriewDados, "_________", "__________", "____________________________________________", "_________", "_________" "____________________________", "__________"); rowLinha.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold); DataGriewDados.Rows.Add(rowLinha); DataGridViewRow rowRodape = new DataGridViewRow(); rowRodape.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold); rowRodape.CreateCells(DataGriewDados, string.Empty, string.Empty, "TOTAL GERAL ", totalQuant, string.Empty, totalGeralOS.ToString("n2"), string.Empty); rowRodape.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold); DataGriewDados.Rows.Add(rowRodape); this.Cursor = Cursors.Default; }
private void PreencheGrid() { CreaterCursor Cr = new CreaterCursor(); this.Cursor = Cr.CreateCursor(Cr.btmap, 0, 0); try { TotalGeralPedido = 0; TotalGeralComissao = 0; SubTotalComissaoFuncionario = 0; DataGriewDados.Rows.Clear(); DataGridViewRow rowTop = new DataGridViewRow(); rowTop.CreateCells(DataGriewDados, "_________", "__________", "____________________________________________", "____________________________", "____________________________", "__________", "__________"); rowTop.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold); DataGriewDados.Rows.Add(rowTop); DataGridViewRow row1 = new DataGridViewRow(); row1.CreateCells(DataGriewDados, "O.S", "EMISSÃO", "CLIENTE", "STATUS", "FUNCIONÁRIO", "TOTAL O.S", "COMISSÃO"); row1.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold); DataGriewDados.Rows.Add(row1); FUNCIONARIOProvider FUNCIONARIOP = new FUNCIONARIOProvider(); string ComissaoporOS = "0"; foreach (var LIS_PEDIDOTy in LIS_ORDEMSERVICOSFECHColl) { decimal?ComissaoFuncionario = 0; string DataEmissao = string.Empty; if (LIS_PEDIDOTy.IDORDEMSERVICO != null) { DataEmissao = Convert.ToDateTime(LIS_PEDIDOTy.DATAEMISSAO).ToString("dd/MM/yyyy"); } string TotalPedido = Convert.ToDecimal(LIS_PEDIDOTy.TOTALFECHOS).ToString("n2"); string TotalComissao = "0"; //Convert.ToDecimal(LIS_PEDIDOTy.VLCOMISSAO).ToString("n2"); if (!chkExibirProdutos.Checked) { ComissaoFuncionario = 0; FUNCIONARIOEntity FUNCIONARIOTy = new FUNCIONARIOEntity(); FUNCIONARIOTy = FUNCIONARIOP.Read(Convert.ToInt32(LIS_PEDIDOTy.IDFUNCIONARIO)); if (FUNCIONARIOTy != null) { ComissaoFuncionario = FUNCIONARIOTy.COMISSAO; } ComissaoporOS = (Convert.ToDecimal(LIS_PEDIDOTy.TOTALFECHOS * Convert.ToDecimal(ComissaoFuncionario)) / 100).ToString("n2"); SubTotalComissaoFuncionario += Convert.ToDecimal(ComissaoporOS); } DataGridViewRow row2 = new DataGridViewRow(); row2.CreateCells(DataGriewDados, LIS_PEDIDOTy.IDORDEMSERVICO, DataEmissao, LIS_PEDIDOTy.NOMECLIENTE, LIS_PEDIDOTy.NOMESTATUS, LIS_PEDIDOTy.NOMEFUNCIONARIO, TotalPedido, ComissaoporOS); row2.DefaultCellStyle.Font = new Font("Arial", 8); DataGriewDados.Rows.Add(row2); TotalGeralPedido += Convert.ToDecimal(TotalPedido); if (chkExibirProdutos.Checked) { //Produtos DataGridViewRow row3 = new DataGridViewRow(); row3.CreateCells(DataGriewDados, "PRODUTOS"); row3.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold); DataGriewDados.Rows.Add(row3); //Cabeçalho do produto DataGridViewRow row4 = new DataGridViewRow(); row4.CreateCells(DataGriewDados, "Quant.", "Total", "Produtos"); row4.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold); DataGriewDados.Rows.Add(row4); LIS_PRODUTOOSFECHCollection LIS_PRODUTOOSFECHColl = new LIS_PRODUTOOSFECHCollection(); LIS_PRODUTOOSFECHColl = ProdutoRel(Convert.ToInt32(LIS_PEDIDOTy.IDORDEMSERVICO)); foreach (LIS_PRODUTOOSFECHEntity item in LIS_PRODUTOOSFECHColl) { ComissaoFuncionario = 0; FUNCIONARIOEntity FUNCIONARIOTy = new FUNCIONARIOEntity(); FUNCIONARIOTy = FUNCIONARIOP.Read(Convert.ToInt32(item.IDFUNCIONARIO)); if (FUNCIONARIOTy != null) { ComissaoFuncionario = FUNCIONARIOTy.COMISSAO; } SubTotalComissaoFuncionario = Convert.ToDecimal(item.VALORTOTAL * ComissaoFuncionario) / 100; DataGridViewRow row5 = new DataGridViewRow(); row5.CreateCells(DataGriewDados, Convert.ToDecimal(item.QUANTIDADE).ToString("n2"), Convert.ToDecimal(item.VALORTOTAL).ToString("n2"), item.NOMEPRODUTO, " ", item.NOMEFUNCIONARIO, " ", SubTotalComissaoFuncionario); row5.DefaultCellStyle.Font = new Font("Arial", 8); DataGriewDados.Rows.Add(row5); TotalGeralComissao += Convert.ToDecimal(SubTotalComissaoFuncionario); } //Produto MT2 LIS_PRODUTOSPEDIDOMTQOSCollection LIS_PRODUTOSPEDIDOMTQOSColl = new LIS_PRODUTOSPEDIDOMTQOSCollection(); LIS_PRODUTOSPEDIDOMTQOSColl = ProdutoRelMTQ(Convert.ToInt32(LIS_PEDIDOTy.IDORDEMSERVICO)); foreach (LIS_PRODUTOSPEDIDOMTQOSEntity item in LIS_PRODUTOSPEDIDOMTQOSColl) { ComissaoFuncionario = 0; FUNCIONARIOEntity FUNCIONARIOTy = new FUNCIONARIOEntity(); FUNCIONARIOTy = FUNCIONARIOP.Read(Convert.ToInt32(item.IDFUNCIONARIO)); if (FUNCIONARIOTy != null) { ComissaoFuncionario = FUNCIONARIOTy.COMISSAO; } SubTotalComissaoFuncionario = Convert.ToDecimal(item.VALORTOTAL * ComissaoFuncionario) / 100; decimal QuantMTQ = Convert.ToDecimal(item.QUANTIDADE * item.MT2); DataGridViewRow row5 = new DataGridViewRow(); row5.CreateCells(DataGriewDados, QuantMTQ.ToString("n2"), Convert.ToDecimal(item.VALORTOTAL).ToString("n2"), item.NOMEPRODUTO, " ", item.NOMEFUNCIONARIO, " ", SubTotalComissaoFuncionario); row5.DefaultCellStyle.Font = new Font("Arial", 8); DataGriewDados.Rows.Add(row5); TotalGeralComissao += Convert.ToDecimal(SubTotalComissaoFuncionario); } //Servicos DataGridViewRow row3_2 = new DataGridViewRow(); row3_2.CreateCells(DataGriewDados, "SERVIÇOS"); row3_2.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold); DataGriewDados.Rows.Add(row3_2); ///Produto MT2 DataGridViewRow row4_2 = new DataGridViewRow(); row4_2.CreateCells(DataGriewDados, "Quant.", "Total", "Serviço"); row4_2.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold); DataGriewDados.Rows.Add(row4_2); LIS_SERVICOOSFECHCollection LIS_SERVICOOSFECHColl = new LIS_SERVICOOSFECHCollection(); LIS_SERVICOOSFECHColl = ServicoRel(Convert.ToInt32(LIS_PEDIDOTy.IDORDEMSERVICO)); foreach (LIS_SERVICOOSFECHEntity item in LIS_SERVICOOSFECHColl) { ComissaoFuncionario = 0; FUNCIONARIOEntity FUNCIONARIOTy = new FUNCIONARIOEntity(); FUNCIONARIOTy = FUNCIONARIOP.Read(Convert.ToInt32(item.IDFUNCIONARIO)); if (FUNCIONARIOTy != null) { ComissaoFuncionario = FUNCIONARIOTy.COMISSAO; } SubTotalComissaoFuncionario = Convert.ToDecimal(item.VALORTOTAL * ComissaoFuncionario) / 100; DataGridViewRow row5 = new DataGridViewRow(); row5.CreateCells(DataGriewDados, Convert.ToDecimal(item.QUANTIDADE).ToString("n2"), Convert.ToDecimal(item.VALORTOTAL).ToString("n2"), item.NOMESERVICO, " ", item.NOMEFUNCIONARIO, " ", SubTotalComissaoFuncionario); row5.DefaultCellStyle.Font = new Font("Arial", 8); DataGriewDados.Rows.Add(row5); TotalGeralComissao += Convert.ToDecimal(SubTotalComissaoFuncionario); } DataGridViewRow rowLinha_2 = new DataGridViewRow(); rowLinha_2.CreateCells(DataGriewDados, "_________", "__________", "____________________________________________", "____________________________", "____________________________", "__________", "__________"); rowLinha_2.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold); DataGriewDados.Rows.Add(rowLinha_2); } } if (!chkExibirProdutos.Checked) { TotalGeralComissao = Convert.ToDecimal(SubTotalComissaoFuncionario); } DataGridViewRow rowLinha = new DataGridViewRow(); rowLinha.CreateCells(DataGriewDados, "_________", "__________", "____________________________________________", "____________________________", "TOTAL GERAL:", TotalGeralPedido, TotalGeralComissao); rowLinha.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold); DataGriewDados.Rows.Add(rowLinha); this.Cursor = Cursors.Default; } catch (Exception ex) { MessageBox.Show("Erro técnico: " + ex.Message); this.Cursor = Cursors.Default; } }
private void PreencheGrid() { CreaterCursor Cr = new CreaterCursor(); this.Cursor = Cr.CreateCursor(Cr.btmap, 0, 0); try { DataGriewDados.Rows.Clear(); DataGridViewRow rowTop = new DataGridViewRow(); rowTop.CreateCells(DataGriewDados, "_________", "__________", "____________________________________________", "____________________________", "____________________________", "__________"); rowTop.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold); DataGriewDados.Rows.Add(rowTop); decimal TotalGeralOS = 0; Decimal TotalGeralServico = 0; Decimal TotalGeralProduto = 0; foreach (var LIS_ORDEMSERVICOSFECHTy in LIS_ORDEMSERVICOSFECHColl) { string DataEmissao = string.Empty; if (LIS_ORDEMSERVICOSFECHTy.IDORDEMSERVICO != null) { DataEmissao = Convert.ToDateTime(LIS_ORDEMSERVICOSFECHTy.DATAEMISSAO).ToString("dd/MM/yyyy"); } string TotalOS = Convert.ToDecimal(LIS_ORDEMSERVICOSFECHTy.TOTALFECHOS).ToString("n2"); TotalGeralOS += Convert.ToDecimal(LIS_ORDEMSERVICOSFECHTy.TOTALFECHOS); //Cabeçalho principal if (LIS_ORDEMSERVICOSFECHTy.IDORDEMSERVICO != null) { DataGridViewRow row1 = new DataGridViewRow(); row1.CreateCells(DataGriewDados, "O.SERVIÇO", "EMISSÃO", "CLIENTE", "STATUS", "FUNCIONÁRIO", "TOTAL O.S"); row1.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold); DataGriewDados.Rows.Add(row1); } DataGridViewRow row2 = new DataGridViewRow(); row2.CreateCells(DataGriewDados, LIS_ORDEMSERVICOSFECHTy.IDORDEMSERVICO.ToString().PadLeft(6, '0'), DataEmissao, LIS_ORDEMSERVICOSFECHTy.NOMECLIENTE, LIS_ORDEMSERVICOSFECHTy.NOMESTATUS, LIS_ORDEMSERVICOSFECHTy.NOMEFUNCIONARIO, TotalOS); row2.DefaultCellStyle.Font = new Font("Arial", 8); DataGriewDados.Rows.Add(row2); if (LIS_ORDEMSERVICOSFECHTy.IDORDEMSERVICO != null) { //Dados do produto LIS_PRODUTOOSFECHCollection LIS_PRODUTOOSFECHPrintColl = new LIS_PRODUTOOSFECHCollection(); LIS_PRODUTOOSFECHPrintColl = ProdutoRel(Convert.ToInt32(LIS_ORDEMSERVICOSFECHTy.IDORDEMSERVICO)); if (LIS_PRODUTOOSFECHPrintColl.Count > 0 && chkExibirProdutos.Checked) { DataGridViewRow row3 = new DataGridViewRow(); row3.CreateCells(DataGriewDados, "PRODUTOS"); row3.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold); DataGriewDados.Rows.Add(row3); //Cabeçalho do produto DataGridViewRow row4 = new DataGridViewRow(); row4.CreateCells(DataGriewDados, "Quant.", "Total", "Produtos"); row4.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold); DataGriewDados.Rows.Add(row4); Decimal TotalProduto = 0; foreach (LIS_PRODUTOOSFECHEntity item in LIS_PRODUTOOSFECHPrintColl) { DataGridViewRow row5 = new DataGridViewRow(); row5.CreateCells(DataGriewDados, Convert.ToDecimal(item.QUANTIDADE).ToString("n2"), Convert.ToDecimal(item.VALORTOTAL).ToString("n2"), item.NOMEPRODUTO); row5.DefaultCellStyle.Font = new Font("Arial", 8); DataGriewDados.Rows.Add(row5); TotalProduto += Convert.ToDecimal(item.VALORTOTAL); } TotalGeralProduto += TotalProduto; //Total de Produto DataGridViewRow row5_2 = new DataGridViewRow(); row5_2.CreateCells(DataGriewDados, "Total: ", TotalProduto.ToString("n2"), string.Empty); row5_2.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold); DataGriewDados.Rows.Add(row5_2); } //Dados do Serviço LIS_SERVICOOSFECHCollection LIS_SERVICOOSFECHPrintColl = new LIS_SERVICOOSFECHCollection(); LIS_SERVICOOSFECHPrintColl = ServicoRel(Convert.ToInt32(LIS_ORDEMSERVICOSFECHTy.IDORDEMSERVICO)); if (LIS_SERVICOOSFECHPrintColl.Count > 0 && chkExibirServico.Checked) { DataGridViewRow row6 = new DataGridViewRow(); row6.CreateCells(DataGriewDados, "SERVIÇOS"); row6.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold); DataGriewDados.Rows.Add(row6); Decimal TotalServico = 0; //Cabeçalho do Serviço DataGridViewRow row7 = new DataGridViewRow(); row7.CreateCells(DataGriewDados, "Quant.", "Total", "Serviço"); row7.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold); DataGriewDados.Rows.Add(row7); foreach (LIS_SERVICOOSFECHEntity item in LIS_SERVICOOSFECHPrintColl) { DataGridViewRow row8 = new DataGridViewRow(); row8.CreateCells(DataGriewDados, Convert.ToDecimal(item.QUANTIDADE).ToString("n2"), Convert.ToDecimal(item.VALORTOTAL).ToString("n2"), item.NOMESERVICO); row8.DefaultCellStyle.Font = new Font("Arial", 8); DataGriewDados.Rows.Add(row8); TotalServico += Convert.ToDecimal(item.VALORTOTAL); } TotalGeralServico += TotalServico; //Total de Serviço DataGridViewRow row8_2 = new DataGridViewRow(); row8_2.CreateCells(DataGriewDados, "Total: ", TotalServico.ToString("n2"), string.Empty); row8_2.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold); DataGriewDados.Rows.Add(row8_2); } } DataGridViewRow rowLinha = new DataGridViewRow(); rowLinha.CreateCells(DataGriewDados, "_________", "__________", "____________________________________________", "____________________________", "____________________________", "__________"); rowLinha.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold); DataGriewDados.Rows.Add(rowLinha); this.Cursor = Cursors.Default; } if (chkExibirServico.Checked) { //Total Geral de Servico DataGridViewRow rowTotalGeralServico = new DataGridViewRow(); rowTotalGeralServico.CreateCells(DataGriewDados, "", "", "Total Geral de Serviço: " + TotalGeralServico.ToString("n2")); rowTotalGeralServico.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold); DataGriewDados.Rows.Add(rowTotalGeralServico); } if (chkExibirProdutos.Checked) { //Total Geral de Produto DataGridViewRow rowTotalGeralProduto = new DataGridViewRow(); rowTotalGeralProduto.CreateCells(DataGriewDados, "", "", "Total Geral de Produtos: " + TotalGeralProduto.ToString("n2")); rowTotalGeralProduto.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold); DataGriewDados.Rows.Add(rowTotalGeralProduto); } //Total Geral de OS DataGridViewRow rowTotalOS = new DataGridViewRow(); rowTotalOS.CreateCells(DataGriewDados, "_________", "__________", "____________________________________________", "____________________________", "Total Geral da O.S...:", TotalGeralOS.ToString("n2")); rowTotalOS.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold); DataGriewDados.Rows.Add(rowTotalOS); this.Cursor = Cursors.Default; } catch (Exception ex) { this.Cursor = Cursors.Default; MessageBox.Show("Erro técnico: " + ex.Message); } }
public LIS_SERVICOOSFECHCollection ReadCollectionByParameter(List <RowsFiltro> RowsFiltro, string FieldOrder) { FbDataReader dataReader = null; string strSqlCommand = String.Empty; LIS_SERVICOOSFECHCollection collection = null; try { if (RowsFiltro != null) { if (RowsFiltro.Count > 0) { strSqlCommand = "SELECT * FROM LIS_SERVICOOSFECH WHERE ("; ArrayList _rowsFiltro = new ArrayList(); RowsFiltro.ForEach(delegate(RowsFiltro i) { string[] item = { i.Condicao.ToString(), i.Campo.ToString(), i.Tipo.ToString(), i.Operador.ToString(), i.Valor.ToString() }; _rowsFiltro.Add(item); }); int _count = 1; foreach (string[] item in _rowsFiltro) { strSqlCommand += "(" + item[1] + " " + item[3]; switch (item[2]) { case ("System.String"): if (item[3].ToUpper() != "LIKE") { strSqlCommand += " '" + item[4] + "')"; } else { strSqlCommand += " '%" + item[4] + "%')"; } break; case ("System.Int16"): if (item[3].ToUpper() != "LIKE") { strSqlCommand += " " + item[4] + ")"; } else { strSqlCommand += " '%" + item[4] + "%')"; } break; case ("System.Int32"): if (item[3].ToUpper() != "LIKE") { strSqlCommand += " " + item[4] + ")"; } else { strSqlCommand += " '%" + item[4] + "%')"; } break; case ("System.Int64"): if (item[3].ToUpper() != "LIKE") { strSqlCommand += " " + item[4] + ")"; } else { strSqlCommand += " '%" + item[4] + "%')"; } break; case ("System.Double"): if (item[3].ToUpper() != "LIKE") { strSqlCommand += " " + item[4] + ")"; } else { strSqlCommand += " '%" + item[4] + "%')"; } break; case ("System.Decimal"): if (item[3].ToUpper() != "LIKE") { strSqlCommand += " " + item[4] + ")"; } else { strSqlCommand += " '%" + item[4] + "%')"; } break; case ("System.Float"): if (item[3].ToUpper() != "LIKE") { strSqlCommand += " " + item[4] + ")"; } else { strSqlCommand += " '%" + item[4] + "%')"; } break; case ("System.Byte"): strSqlCommand += " " + item[4] + ")"; break; case ("System.SByte"): strSqlCommand += " " + item[4] + ")"; break; case ("System.Char"): if (item[3].ToUpper() != "LIKE") { strSqlCommand += " '" + item[4] + "')"; } else { strSqlCommand += " '%" + item[4] + "%')"; } break; case ("System.DateTime"): if (item[3].ToUpper() != "LIKE") { strSqlCommand += " '" + item[4] + "')"; } else { strSqlCommand += " '%" + item[4] + "%')"; } break; case ("System.Guid"): if (item[3].ToUpper() != "LIKE") { strSqlCommand += " '" + item[4] + "')"; } else { strSqlCommand += " '%" + item[4] + "%')"; } break; case ("System.Boolean"): strSqlCommand += " " + item[4] + ")"; break; } if (_rowsFiltro.Count > 1) { if (_count < _rowsFiltro.Count) { strSqlCommand += " " + item[0] + " "; } _count++; } } strSqlCommand += ") order by " + FieldOrder; } else { strSqlCommand = "SELECT * FROM LIS_SERVICOOSFECH order by " + FieldOrder; } } else { strSqlCommand = "SELECT * FROM LIS_SERVICOOSFECH order by " + FieldOrder; } //Verificando a existência de um transação aberta if (dbTransaction != null) { if (dbCnn.State == ConnectionState.Closed) { dbCnn.Open(); } dbCommand = new FbCommand(strSqlCommand, dbCnn); dbCommand.CommandType = CommandType.Text; dbCommand.Transaction = ((FbTransaction)(dbTransaction)); } else { if (dbCnn == null) { dbCnn = new FbConnection(connectionString); } if (dbCnn.State == ConnectionState.Closed) { dbCnn.Open(); } dbCommand = new FbCommand(strSqlCommand, dbCnn); dbCommand.CommandType = CommandType.Text; dbCommand.Transaction = dbCnn.BeginTransaction(IsolationLevel.ReadCommitted); } collection = ExecuteReader(ref collection, ref dataReader, dbCommand); if (dataReader != null) { dataReader.Close(); dataReader.Dispose(); } if (dbTransaction == null) { dbCommand.Transaction.Commit(); dbCnn.Close(); } return(collection); } catch (Exception ex) { // Deleta reader if (dataReader != null) { dataReader.Close(); dataReader.Dispose(); } if (dbTransaction != null) { this.RollbackTransaction(); } else { if (dbCommand.Transaction != null) { dbCommand.Transaction.Rollback(); } if (dbCnn.State == ConnectionState.Open) { dbCnn.Close(); } } throw ex; } }
public LIS_SERVICOOSFECHCollection ReadCollection() { FbDataReader dataReader = null; try { LIS_SERVICOOSFECHCollection collection = null; //Verificando a existência de um transação aberta if (dbTransaction != null) { if (dbCnn.State == ConnectionState.Closed) { dbCnn.Open(); } dbCommand = new FbCommand("SELECT * FROM LIS_SERVICOOSFECH", dbCnn); dbCommand.Transaction = ((FbTransaction)(dbTransaction)); } else { if (dbCnn == null) { dbCnn = ((FbConnection)GetConnectionDB()); } if (dbCnn.State == ConnectionState.Closed) { dbCnn.Open(); } dbCommand = new FbCommand("SELECT * FROM LIS_SERVICOOSFECH", dbCnn); dbCommand.Transaction = dbCnn.BeginTransaction(IsolationLevel.ReadCommitted); } // Tipo do comando de banco Procedure ou SQL dbCommand.CommandType = CommandType.Text; collection = ExecuteReader(ref collection, ref dataReader, dbCommand); if (dataReader != null) { dataReader.Close(); dataReader.Dispose(); } if (dbTransaction == null) { dbCommand.Transaction.Commit(); dbCnn.Close(); } return(collection); } catch (Exception ex) { // Deleta reader if (dataReader != null) { dataReader.Close(); dataReader.Dispose(); } if (dbTransaction != null) { this.RollbackTransaction(); } else { if (dbCommand.Transaction != null) { dbCommand.Transaction.Rollback(); } if (dbCnn.State == ConnectionState.Open) { dbCnn.Close(); } } throw ex; } }
private void btnPesquisa_Click(object sender, EventArgs e) { if (Validacoes()) { CreaterCursor Cr = new CreaterCursor(); this.Cursor = Cr.CreateCursor(Cr.btmap, 0, 0); try { RowRelatorio.Clear(); string DataInicial = Util.ConverStringDateSearch(msktDataInicial.Text); string DataFinal = Util.ConverStringDateSearch(msktDataFinal.Text); RowRelatorio.Add(new RowsFiltro("DATAEMISSAO", "System.DateTime", ">=", DataInicial, "and")); RowRelatorio.Add(new RowsFiltro("DATAEMISSAO", "System.DateTime", "<=", DataFinal, "and")); if (rbOrcamentoPesquisa.Checked) { RowRelatorio.Add(new RowsFiltro("FLAGORCAMENTO", "System.String", "=", "S", "and")); } if (rbVendasPesquisa.Checked) { RowRelatorio.Add(new RowsFiltro("FLAGORCAMENTO", "System.String", "=", "N", "and")); } RowRelatorio.Add(new RowsFiltro("IDFUNCIONARIO", "System.Int32", "=", Convert.ToInt32(cbFuncionario.SelectedValue).ToString(), "and")); DataGriewDados.Rows.Clear(); TotalGeral = 0; TotalGeralComissao = 0; LIS_PRODUTOOSFECHColl.Clear(); LIS_SERVICOOSFECHColl.Clear(); if (chkProduto.Checked) { LIS_PRODUTOOSFECHColl = LIS_PRODUTOOSFECHP.ReadCollectionByParameter(RowRelatorio, "IDORDEMSERVICO DESC"); lblTotalRegistros.Text = "Total de Registros: " + LIS_PRODUTOOSFECHColl.Count.ToString(); PreencheGridProduto(); } if (ChkServiço.Checked) { LIS_SERVICOOSFECHColl = LIS_SERVICOOSFECHP.ReadCollectionByParameter(RowRelatorio, "IDORDEMSERVICO DESC"); lblTotalRegistros.Text = "Total de Registros: " + (LIS_SERVICOOSFECHColl.Count + LIS_PRODUTOOSFECHColl.Count).ToString(); PreencheGridServico(); } DataGriewDados.Sort(DataGriewDados.Columns["ordemservico"], ListSortDirection.Descending); DataGridViewRow row3 = new DataGridViewRow(); row3.CreateCells(DataGriewDados, "", "", "Total Geral:", TotalGeral.ToString("n2"), TotalGeralComissao.ToString("n2")); row3.DefaultCellStyle.Font = new Font("Arial", 8, FontStyle.Bold); DataGriewDados.Rows.Add(row3); this.Cursor = Cursors.Default; } catch (Exception EX) { this.Cursor = Cursors.Default; MessageBox.Show("Erro na pesquisa!"); MessageBox.Show("Erro técnico: " + EX.Message); } } }