private void ListaServico() { try { RowRelatorio.Clear(); RowRelatorio.Add(new RowsFiltro("DATAEMISSAO", "System.DateTime", ">=", Util.ConverStringDateSearch(maskedtxtData.Text))); RowRelatorio.Add(new RowsFiltro("DATAEMISSAO", "System.DateTime", "<=", Util.ConverStringDateSearch(mdkDataFinal.Text))); if (Convert.ToInt32(cbFuncionario2.SelectedValue) > 0) { RowRelatorio.Add(new RowsFiltro("IDFUNCIONARIO", "System.Int32", "=", cbFuncionario2.SelectedValue.ToString())); } if (Convert.ToInt32(cbCliente.SelectedValue) > 0) { RowRelatorio.Add(new RowsFiltro("IDCLIENTE", "System.Int32", "=", cbCliente.SelectedValue.ToString())); } LIS_ORDEMSERVICOSFECHColl = LIS_ORDEMSERVICOSFECHP.ReadCollectionByParameter(RowRelatorio); PreencheGrid(); } catch (Exception EX) { MessageBox.Show("Erro técnico: " + EX.Message); } }
private void PesquisaPedido() { try { CreaterCursor Cr = new CreaterCursor(); this.Cursor = Cr.CreateCursor(Cr.btmap, 0, 0); LIS_ORDEMSERVICOSFECHProvider LIS_ORDEMSERVICOSFECHP = new LIS_ORDEMSERVICOSFECHProvider(); RowsFiltroCollection RowRelatorio = new RowsFiltroCollection(); if (txtNomePesquisa.Text.Trim().Length > 0) { RowRelatorio.Add(new RowsFiltro("IDORDEMSERVICO", "System.Int32", "=", txtNomePesquisa.Text)); } LIS_ORDEMSERVICOSFECHColl = LIS_ORDEMSERVICOSFECHP.ReadCollectionByParameter(RowRelatorio, "IDORDEMSERVICO , DATAEMISSAO desc"); DataGriewSearch.AutoGenerateColumns = false; DataGriewSearch.DataSource = LIS_ORDEMSERVICOSFECHColl; txtNomePesquisa.Focus(); this.Cursor = Cursors.Default; } catch (Exception) { this.Cursor = Cursors.Default; MessageBox.Show(ConfigMessage.Default.searchFieldType, ConfigSistema1.Default.NomeEmpresa, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } }
private void btnConsultar_Click_1(object sender, EventArgs e) { if (Validacoes()) { 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 (rbOrcamento.Checked) { RowRelatorio.Add(new RowsFiltro("FLAGORCAMENTO", "System.String", "=", "S")); } else if (rbVenda.Checked) { RowRelatorio.Add(new RowsFiltro("FLAGORCAMENTO", "System.String", "=", "N")); } if (Convert.ToInt32(cbFuncionario.SelectedValue) > 0) { RowRelatorio.Add(new RowsFiltro("IDFUNCIONARIO", "System.Int32", "=", cbFuncionario.SelectedValue.ToString())); } if (Convert.ToInt32(cbCliente.SelectedValue) > 0) { RowRelatorio.Add(new RowsFiltro("IDCLIENTE", "System.Int32", "=", cbCliente.SelectedValue.ToString())); } if (Convert.ToInt32(cbVeiculo.SelectedValue) > 0) { RowRelatorio.Add(new RowsFiltro("PLACA", "System.String", "=", cbVeiculo.Text)); } LIS_ORDEMSERVICOSFECHColl = LIS_ORDEMSERVICOSFECHP.ReadCollectionByParameter(RowRelatorio, "IDORDEMSERVICO DESC"); PreencheGrid(); } catch (Exception EX) { MessageBox.Show("Erro na pesquisa!"); MessageBox.Show("Erro técnico: " + EX.Message); } } }
private void AddGridFormaPagto() { try { //Remove ID repetido LIS_ORDEMSERVICOSFECHCollection LIS_ORDEMSERVICOSFECH2Coll = new LIS_ORDEMSERVICOSFECHCollection(); foreach (LIS_ORDEMSERVICOSFECHEntity item in LIS_ORDEMSERVICOSFECHColl) { if (LIS_ORDEMSERVICOSFECH2Coll.Find(delegate(LIS_ORDEMSERVICOSFECHEntity item2) { return (item2.IDFORMAPAGAMENTO == item.IDFORMAPAGAMENTO); }) == null) { LIS_ORDEMSERVICOSFECH2Coll.Add(item); } } decimal ValorTotal = 0; decimal TotalGeral = 0; dtgFormPagto.Rows.Clear(); foreach (var LIS_ORDEMSERVICOSFECH2Ty in LIS_ORDEMSERVICOSFECH2Coll) { ValorTotal = 0; ValorTotal = QuantFormaPagto(Convert.ToInt32(LIS_ORDEMSERVICOSFECH2Ty.IDFORMAPAGAMENTO)); TotalGeral += ValorTotal; DataGridViewRow row2 = new DataGridViewRow(); row2.CreateCells(dtgFormPagto, LIS_ORDEMSERVICOSFECH2Ty.NOMEFORMAPAGTO, ValorTotal.ToString("n2")); row2.DefaultCellStyle.Font = new Font("Arial", 8); dtgFormPagto.Rows.Add(row2); } //Total Geral DataGridViewRow row3 = new DataGridViewRow(); row3.CreateCells(dtgFormPagto, "Total: ", TotalGeral.ToString("n2")); row3.DefaultCellStyle.Font = new Font("Arial", 8); dtgFormPagto.Rows.Add(row3); } catch (Exception ex) { MessageBox.Show("Erro técnico: " + ex.Message); } }
private void btnConsultar_Click(object sender, EventArgs e) { try { RowRelatorio.Clear(); RowRelatorio.Add(new RowsFiltro("DATAEMISSAO", "System.DateTime", ">=", Util.ConverStringDateSearch(mkDtInicial.Text))); RowRelatorio.Add(new RowsFiltro("DATAEMISSAO", "System.DateTime", "<=", Util.ConverStringDateSearch(mkdatafinal.Text))); if (rdOrcamento.Checked) { RowRelatorio.Add(new RowsFiltro("FLAGORCAMENTO", "System.String", "=", "S")); } else if (rdVenda.Checked) { RowRelatorio.Add(new RowsFiltro("FLAGORCAMENTO", "System.String", "=", "N")); } LIS_ORDEMSERVICOSFECHColl.Clear(); LIS_ORDEMSERVICOSFECHColl = LIS_ORDEMSERVICOSFECHP.ReadCollectionByParameter(RowRelatorio, "DATAEMISSAO DESC"); //Colocando somatorio no final da lista LIS_ORDEMSERVICOSFECHEntity LIS_ORDEMSERVICOSFECHTy = new LIS_ORDEMSERVICOSFECHEntity(); LIS_ORDEMSERVICOSFECHTy.TOTALFECHOS = SumTotalPesquisa("TOTALFECHOS"); LIS_ORDEMSERVICOSFECHColl.Add(LIS_ORDEMSERVICOSFECHTy); lblTotalRegistros.Text = "Total de Registros: " + (LIS_ORDEMSERVICOSFECHColl.Count - 1).ToString(); DataGridRelaPedido.AutoGenerateColumns = false; DataGridRelaPedido.DataSource = LIS_ORDEMSERVICOSFECHColl; AddGridFormaPagto(); } catch (Exception ex) { MessageBox.Show("Erro técnico: " + ex.Message); } }
private decimal QuantFormaPagto(int IDFORMAPAGAMENTO) { decimal result = 0; try { RowRelatorio.Clear(); RowRelatorio.Add(new RowsFiltro("IDFORMAPAGAMENTO", "System.Int32", "=", IDFORMAPAGAMENTO.ToString())); RowRelatorio.Add(new RowsFiltro("DATAEMISSAO", "System.DateTime", ">=", Util.ConverStringDateSearch(mkDtInicial.Text))); RowRelatorio.Add(new RowsFiltro("DATAEMISSAO", "System.DateTime", "<=", Util.ConverStringDateSearch(mkdatafinal.Text))); if (rdOrcamento.Checked) { RowRelatorio.Add(new RowsFiltro("FLAGORCAMENTO", "System.String", "=", "S")); } else if (rdVenda.Checked) { RowRelatorio.Add(new RowsFiltro("FLAGORCAMENTO", "System.String", "=", "N")); } LIS_ORDEMSERVICOSFECHCollection LIS_ORDEMSERVICOSFECH3Coll = new LIS_ORDEMSERVICOSFECHCollection(); LIS_ORDEMSERVICOSFECH3Coll = LIS_ORDEMSERVICOSFECHP.ReadCollectionByParameter(RowRelatorio); foreach (var LIS_ORDEMSERVICOSFECH3Ty in LIS_ORDEMSERVICOSFECH3Coll) { result += Convert.ToDecimal(LIS_ORDEMSERVICOSFECH3Ty.TOTALFECHOS); } return(result); } catch (Exception ex) { return(result); MessageBox.Show("Erro técnico: " + ex.Message); } }
private static LIS_ORDEMSERVICOSFECHCollection ExecuteReader(ref LIS_ORDEMSERVICOSFECHCollection collection, ref FbDataReader dataReader, FbCommand dbCommand) { using (dataReader = dbCommand.ExecuteReader()) { collection = new LIS_ORDEMSERVICOSFECHCollection(); 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; }
public LIS_ORDEMSERVICOSFECHCollection ReadCollectionByParameter(List <RowsFiltro> RowsFiltro, string FieldOrder) { FbDataReader dataReader = null; string strSqlCommand = String.Empty; LIS_ORDEMSERVICOSFECHCollection collection = null; try { if (RowsFiltro != null) { if (RowsFiltro.Count > 0) { strSqlCommand = "SELECT * FROM LIS_ORDEMSERVICOSFECH 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_ORDEMSERVICOSFECH order by " + FieldOrder; } } else { strSqlCommand = "SELECT * FROM LIS_ORDEMSERVICOSFECH 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_ORDEMSERVICOSFECHCollection ReadCollection() { FbDataReader dataReader = null; try { LIS_ORDEMSERVICOSFECHCollection 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_ORDEMSERVICOSFECH", 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_ORDEMSERVICOSFECH", 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; } }