private void ListaProdutoFesta(int IDITENSFESTAS) { RowsFiltroCollection RowpProdPedido = new RowsFiltroCollection(); RowpProdPedido.Add(new RowsFiltro("IDITENSFESTAS", "System.Int32", "=", IDITENSFESTAS.ToString())); LIS_PRODUTOSFESTASColl = LIS_PRODUTOSFESTASP.ReadCollectionByParameter(RowpProdPedido); dataGridProdutos.AutoGenerateColumns = false; dataGridProdutos.DataSource = LIS_PRODUTOSFESTASColl; SumTotalProdutos(); }
private LIS_PRODUTOSFESTASCollection ProdutoRel(int IDITENSFESTAS) { LIS_PRODUTOSFESTASCollection LIS_PRODUTOSFESTASColl = new LIS_PRODUTOSFESTASCollection(); RowsFiltroCollection RowRelatorio = new RowsFiltroCollection(); RowRelatorio.Add(new RowsFiltro("IDITENSFESTAS", "System.Int32", "=", IDITENSFESTAS.ToString())); LIS_PRODUTOSFESTASColl = LIS_PRODUTOSFESTASP.ReadCollectionByParameter(RowRelatorio); return(LIS_PRODUTOSFESTASColl); }
private void RelatItensProdutoFesta_Load(object sender, EventArgs e) { this.MinimizeBox = false; this.FormBorderStyle = FormBorderStyle.FixedDialog; this.reportViewer1.RefreshReport(); 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; } } RowRelatorio.Clear(); RowRelatorio.Add(new RowsFiltro("IDITENSFESTAS", "System.Int32", "=", IDITENSFESTAS.ToString())); LIS_ITENSFESTASProvider LIS_ITENSFESTASP = new LIS_ITENSFESTASProvider(); LIS_ITENSFESTASCollection LIS_ITENSFESTASColl = new LIS_ITENSFESTASCollection(); LIS_ITENSFESTASColl = LIS_ITENSFESTASP.ReadCollectionByParameter(RowRelatorio); RowRelatorio.Clear(); RowRelatorio.Add(new RowsFiltro("IDITENSFESTAS", "System.Int32", "=", IDITENSFESTAS.ToString())); LIS_PRODUTOSFESTASProvider LIS_PRODUTOSFESTASP = new LIS_PRODUTOSFESTASProvider(); LIS_PRODUTOSFESTASCollection LIS_PRODUTOSFESTASColl = new LIS_PRODUTOSFESTASCollection(); LIS_PRODUTOSFESTASColl = LIS_PRODUTOSFESTASP.ReadCollectionByParameter(RowRelatorio); this.EMPRESACollectionBindingSource.DataSource = EMPRESAColl; LIS_PRODUTOSFESTASCollectionBindingSource.DataSource = LIS_PRODUTOSFESTASColl; LIS_ITENSFESTASCollectionBindingSource.DataSource = LIS_ITENSFESTASColl; this.reportViewer1.SetDisplayMode(DisplayMode.PrintLayout); this.reportViewer1.ZoomMode = ZoomMode.Percent; this.reportViewer1.RefreshReport(); }
private static LIS_PRODUTOSFESTASCollection ExecuteReader(ref LIS_PRODUTOSFESTASCollection collection, ref FbDataReader dataReader, FbCommand dbCommand) { using (dataReader = dbCommand.ExecuteReader()) { collection = new LIS_PRODUTOSFESTASCollection(); if (dataReader.HasRows) { while (dataReader.Read()) { collection.Add(FillEntityObject(ref dataReader)); } } if (!(dataReader.IsClosed)) { dataReader.Close(); } dataReader.Dispose(); } return(collection); }
public LIS_PRODUTOSFESTASCollection ReadCollectionByParameter(List <RowsFiltro> RowsFiltro, string FieldOrder) { FbDataReader dataReader = null; string strSqlCommand = String.Empty; LIS_PRODUTOSFESTASCollection collection = null; try { if (RowsFiltro != null) { if (RowsFiltro.Count > 0) { strSqlCommand = "SELECT * FROM LIS_PRODUTOSFESTAS 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_PRODUTOSFESTAS order by " + FieldOrder; } } else { strSqlCommand = "SELECT * FROM LIS_PRODUTOSFESTAS 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_PRODUTOSFESTASCollection ReadCollection() { FbDataReader dataReader = null; try { LIS_PRODUTOSFESTASCollection 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_PRODUTOSFESTAS", 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_PRODUTOSFESTAS", 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 printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { try { ConfigReportStandard config = new ConfigReportStandard(); //'Cabecalho e.Graphics.DrawLine(config.CanetaDaImpressora, config.MargemEsquerda, 60, config.MargemDireita, 60); e.Graphics.DrawLine(config.CanetaDaImpressora, config.MargemEsquerda, 160, config.MargemDireita, 160); CONFISISTEMAProvider CONFISISTEMAP = new CONFISISTEMAProvider(); CONFISISTEMAEntity CONFISISTEMAty = CONFISISTEMAP.Read(1); if (CONFISISTEMAty.FLAGLOGORELATORIO == "S") { if (CONFISISTEMAty.IDARQUIVOBINARIO1 != null) { ARQUIVOBINARIOProvider ARQUIVOBINARIOP = new ARQUIVOBINARIOProvider(); ARQUIVOBINARIOEntity ARQUIVOBINARIOEtY = ARQUIVOBINARIOP.Read(Convert.ToInt32(CONFISISTEMAty.IDARQUIVOBINARIO1)); MemoryStream stream = new MemoryStream(ARQUIVOBINARIOEtY.FOTO); //'Imagem e.Graphics.DrawImage(Image.FromStream(stream), config.MargemEsquerda + 600, 68); } } //'nome da empresa EMPRESAProvider EMPRESAP = new EMPRESAProvider(); EMPRESAEntity EMPRESATy = EMPRESAP.Read(1); config.NomeEmpresa = EMPRESATy.NOMECLIENTE + " - " + EMPRESATy.CNPJCPF; e.Graphics.DrawString(config.NomeEmpresa, config.FonteNegrito, Brushes.Black, config.MargemEsquerda, 68); //Titulo e.Graphics.DrawString(RelatorioTitulo, config.FonteNegrito, Brushes.Black, config.MargemEsquerda, 140); //campos a serem impressos e.Graphics.DrawString("Código", config.FonteNegrito, Brushes.Black, config.MargemEsquerda, 170); e.Graphics.DrawString("Nome Festa", config.FonteNegrito, Brushes.Black, config.MargemEsquerda + 50, 170); e.Graphics.DrawLine(config.CanetaDaImpressora, config.MargemEsquerda, 190, config.MargemDireita, 190); config.LinhasPorPagina = Convert.ToInt32(e.MarginBounds.Height / config.FonteNormal.GetHeight(e.Graphics) - 9); int NumerorRegistros = LIS_ITENSFESTASColl.Count; //Alinhamento dos valores StringFormat stringFormat = new StringFormat(); stringFormat.Alignment = StringAlignment.Far; stringFormat.LineAlignment = StringAlignment.Far; while (IndexRegistro < LIS_ITENSFESTASColl.Count) { if (LIS_ITENSFESTASColl[IndexRegistro].IDITENSFESTAS != null) { config.PosicaoDaLinha = config.MargemSuperior + (config.LinhaAtual * config.FonteNormal.GetHeight(e.Graphics)); e.Graphics.DrawString(LIS_ITENSFESTASColl[IndexRegistro].IDITENSFESTAS.ToString(), config.FonteConteudo, Brushes.Black, config.MargemEsquerda, config.PosicaoDaLinha); e.Graphics.DrawString(Util.LimiterText(LIS_ITENSFESTASColl[IndexRegistro].NOMEFESTA, 40), config.FonteConteudo, Brushes.Black, config.MargemEsquerda + 50, config.PosicaoDaLinha); string TotalFOS = Convert.ToDecimal(LIS_ITENSFESTASColl[IndexRegistro].TOTALITENS).ToString("n2"); e.Graphics.DrawString("Total dos Itens: " + TotalFOS, config.FonteNegrito, Brushes.Black, config.MargemEsquerda + 700, config.PosicaoDaLinha + 17, stringFormat); config.LinhaAtual++; config.PosicaoDaLinha = config.MargemSuperior + (config.LinhaAtual * config.FonteNormal.GetHeight(e.Graphics)); //Listar os produtos LIS_PRODUTOSFESTASCollection LIS_PRODUTOSFESTASPrintColl = new LIS_PRODUTOSFESTASCollection(); LIS_PRODUTOSFESTASPrintColl = ProdutoRel(Convert.ToInt32(LIS_ITENSFESTASColl[IndexRegistro].IDITENSFESTAS)); e.Graphics.DrawString("Cod.Produto", config.FonteNegrito, Brushes.Black, config.MargemEsquerda, config.PosicaoDaLinha + 1); e.Graphics.DrawString("Produtos/Itens", config.FonteNegrito, Brushes.Black, config.MargemEsquerda + 100, config.PosicaoDaLinha + 1); e.Graphics.DrawString("Quant.", config.FonteNegrito, Brushes.Black, config.MargemEsquerda + 300, config.PosicaoDaLinha + 1); e.Graphics.DrawString("Vl.Unitário.", config.FonteNegrito, Brushes.Black, config.MargemEsquerda + 400, config.PosicaoDaLinha + 1); e.Graphics.DrawString("Vl.Total.", config.FonteNegrito, Brushes.Black, config.MargemEsquerda + 500, config.PosicaoDaLinha + 1); foreach (LIS_PRODUTOSFESTASEntity item in LIS_PRODUTOSFESTASPrintColl) { config.LinhaAtual++; config.PosicaoDaLinha = config.MargemSuperior + (config.LinhaAtual * config.FonteNormal.GetHeight(e.Graphics)); e.Graphics.DrawString(Util.LimiterText(item.IDPRODUTO.ToString(), 10), config.FonteConteudo, Brushes.Black, config.MargemEsquerda, config.PosicaoDaLinha); e.Graphics.DrawString(Util.LimiterText(item.NOMEPRODUTOS, 25), config.FonteConteudo, Brushes.Black, config.MargemEsquerda + 100, config.PosicaoDaLinha); e.Graphics.DrawString(Util.LimiterText(item.QUANTIDADE.ToString(), 10), config.FonteConteudo, Brushes.Black, config.MargemEsquerda + 300, config.PosicaoDaLinha); e.Graphics.DrawString(Util.LimiterText(Convert.ToDecimal(item.VALOR).ToString("n2"), 20), config.FonteConteudo, Brushes.Black, config.MargemEsquerda + 400, config.PosicaoDaLinha); e.Graphics.DrawString(Util.LimiterText(Convert.ToDecimal(item.VALORTOTAL).ToString("n2"), 20), config.FonteConteudo, Brushes.Black, config.MargemEsquerda + 500, config.PosicaoDaLinha); } config.LinhaAtual++; config.PosicaoDaLinha = config.MargemSuperior + (config.LinhaAtual * config.FonteNormal.GetHeight(e.Graphics)); config.LinhaAtual++; string linhasepar = "------------------------------------------------------------------------------------------"; string linhasepar2 = "------------------------------------------------------------------------------------------"; e.Graphics.DrawString(linhasepar + linhasepar2, config.FonteConteudo, Brushes.Black, config.MargemEsquerda, config.PosicaoDaLinha + 10); IndexRegistro++; config.LinhaAtual++; } if (config.LinhaAtual > config.LinhasPorPagina) { break; } } //'Incrementa o n£mero da pagina paginaAtual += 1; //'verifica se continua imprimindo if (IndexRegistro < LIS_ITENSFESTASColl.Count) { e.HasMorePages = true; } else { //Soma e.Graphics.DrawString("Total Geral: " + SomaTotal().ToString("n2"), config.FonteNegrito, Brushes.Black, config.MargemEsquerda + 700, config.PosicaoDaLinha + 60, stringFormat); e.Graphics.DrawString("", config.FonteConteudo, Brushes.Black, config.MargemEsquerda, config.PosicaoDaLinha + 50); e.Graphics.DrawString("Total da pesquisa: " + LIS_ITENSFESTASColl.Count, config.FonteConteudo, Brushes.Black, config.MargemEsquerda, config.PosicaoDaLinha + 50); //Rodape e.Graphics.DrawLine(config.CanetaDaImpressora, config.MargemEsquerda, config.MargemInferior, config.MargemDireita, config.MargemInferior); e.Graphics.DrawString(System.DateTime.Now.ToString(), config.FonteRodape, Brushes.Black, config.MargemEsquerda, config.MargemInferior); config.LinhaAtual += Convert.ToInt32(config.FonteNormal.GetHeight(e.Graphics)); config.LinhaAtual++; e.Graphics.DrawString("Pagina : " + paginaAtual, config.FonteRodape, Brushes.Black, config.MargemDireita - 70, config.MargemInferior); } } catch (Exception) { MessageBox.Show(ConfigMessage.Default.MsgErroPrint); } }