private void PesquisaOcorrencia( ) { CreaterCursor Cr = new CreaterCursor(); this.Cursor = Cr.CreateCursor(Cr.btmap, 0, 0); try { RowRelatorio.Clear(); if (Convert.ToInt32(cbCliente.SelectedValue) > 0) { RowRelatorio.Add(new RowsFiltro("IDCLIENTE", "System.Int32", "=", cbCliente.SelectedValue.ToString())); } if (Convert.ToInt32(cbStatus.SelectedValue) > 0) { RowRelatorio.Add(new RowsFiltro("IDSTATUSTLMK", "System.Int32", "=", cbStatus.SelectedValue.ToString())); } if (Convert.ToInt32(cbVendedor.SelectedValue) > 0) { RowRelatorio.Add(new RowsFiltro("IDFUNCIONARIO", "System.Int32", "=", cbVendedor.SelectedValue.ToString())); } if ((msktDataInicial.Text != " / /") && (msktDataFinal.Text != " / /")) { string DataInicial = Util.ConverStringDateSearch(msktDataInicial.Text); string DataFinal = Util.ConverStringDateSearch(msktDataFinal.Text); RowRelatorio.Add(new RowsFiltro("DATAPROXCONTATO", "System.DateTime", ">=", DataInicial)); RowRelatorio.Add(new RowsFiltro("DATAPROXCONTATO", "System.DateTime", "<=", DataFinal)); } LIS_OCORRENCIATLMKColl = LIS_OCORRENCIATLMKP.ReadCollectionByParameter(RowRelatorio, "IDOCORRENCIATLMK DESC"); DataGriewDados.AutoGenerateColumns = false; DataGriewDados.DataSource = LIS_OCORRENCIATLMKColl; label13.Text = LIS_OCORRENCIATLMKColl.Count.ToString(); this.Cursor = Cursors.Default; } catch (Exception ex) { this.Cursor = Cursors.Default; 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("DATACONTATO", "System.DateTime", ">=", DataInicial)); RowRelatorio.Add(new RowsFiltro("DATACONTATO", "System.DateTime", "<=", DataFinal)); LIS_OCORRENCIATLMKColl = LIS_OCORRENCIATLMKP.ReadCollectionByParameter(RowRelatorio); //Remove ID repetido LIS_OCORRENCIATLMKCollection LIS_OCORRENCIATLMKColl2 = new LIS_OCORRENCIATLMKCollection(); foreach (LIS_OCORRENCIATLMKEntity item in LIS_OCORRENCIATLMKColl) { if (LIS_OCORRENCIATLMKColl2.Find(delegate(LIS_OCORRENCIATLMKEntity item2) { return (item2.IDFUNCIONARIO == item.IDFUNCIONARIO); }) == null) { LIS_OCORRENCIATLMKColl2.Add(item); } } LIS_OCORRENCIATLMKColl.Clear(); LIS_OCORRENCIATLMKColl = LIS_OCORRENCIATLMKColl2; 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 void PesquisaRapida() { CreaterCursor Cr = new CreaterCursor(); this.Cursor = Cr.CreateCursor(Cr.btmap, 0, 0); try { RowRelatorio.Clear(); RowRelatorio.Add(new RowsFiltro("NOMECLIENTE", "System.String", "collate pt_br like", "%" + txtPesquisaRapida.Text.Replace("'", "") + "%", "or")); RowRelatorio.Add(new RowsFiltro("CONVERSA", "System.String", "collate pt_br like", "%" + txtPesquisaRapida.Text.Replace("'", "") + "%", "or")); RowRelatorio.Add(new RowsFiltro("NOMECONTATO", "System.String", "collate pt_br like", "%" + txtPesquisaRapida.Text.Replace("'", "") + "%", "or")); //if (ValidacoesLibrary.ValidaTipoInt32(txtPesquisaRapida.Text)) //{ // RowRelatorio.Add(new RowsFiltro("IDORDEMSERVICO", "System.Int32", "like", txtPesquisaRapida.Text.Replace("'", ""), "or")); //} if (txtPesquisaRapida.Text.Trim() != string.Empty) { LIS_OCORRENCIATLMKColl = LIS_OCORRENCIATLMKP.ReadCollectionByParameter(RowRelatorio, "IDOCORRENCIATLMK DESC"); DataGriewDados.AutoGenerateColumns = false; DataGriewDados.DataSource = LIS_OCORRENCIATLMKColl; label13.Text = LIS_OCORRENCIATLMKColl.Count.ToString(); } this.Cursor = Cursors.Default; } catch (Exception ex) { this.Cursor = Cursors.Default; MessageBox.Show("Erro técnico: " + ex.Message, ConfigSistema1.Default.NomeEmpresa, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } }
private decimal QuantOcorrencias(int IDFUNCIOANRIO) { decimal result = 0; LIS_OCORRENCIATLMKCollection LIS_OCORRENCIATLMKColl2 = new LIS_OCORRENCIATLMKCollection(); string DataInicial = Util.ConverStringDateSearch(msktDataInicial.Text); string DataFinal = Util.ConverStringDateSearch(msktDataFinal.Text); RowRelatorio.Clear(); RowRelatorio.Add(new RowsFiltro("DATACONTATO", "System.DateTime", ">=", DataInicial)); RowRelatorio.Add(new RowsFiltro("DATACONTATO", "System.DateTime", "<=", DataFinal)); RowRelatorio.Add(new RowsFiltro("IDFUNCIONARIO", "System.Int32", "=", IDFUNCIOANRIO.ToString())); LIS_OCORRENCIATLMKColl2 = LIS_OCORRENCIATLMKP.ReadCollectionByParameter(RowRelatorio); foreach (var LIS_OCORRENCIATLMTy in LIS_OCORRENCIATLMKColl2) { result += 1; } return(result); }
private static LIS_OCORRENCIATLMKCollection ExecuteReader(ref LIS_OCORRENCIATLMKCollection collection, ref FbDataReader dataReader, FbCommand dbCommand) { using (dataReader = dbCommand.ExecuteReader()) { collection = new LIS_OCORRENCIATLMKCollection(); if (dataReader.HasRows) { while (dataReader.Read()) { collection.Add(FillEntityObject(ref dataReader)); } } if (!(dataReader.IsClosed)) { dataReader.Close(); } dataReader.Dispose(); } return(collection); }
public LIS_OCORRENCIATLMKCollection ReadCollectionByParameter(List <RowsFiltro> RowsFiltro, string FieldOrder) { FbDataReader dataReader = null; string strSqlCommand = String.Empty; LIS_OCORRENCIATLMKCollection collection = null; try { if (RowsFiltro != null) { if (RowsFiltro.Count > 0) { strSqlCommand = "SELECT * FROM LIS_OCORRENCIATLMK 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_OCORRENCIATLMK order by " + FieldOrder; } } else { strSqlCommand = "SELECT * FROM LIS_OCORRENCIATLMK 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_OCORRENCIATLMKCollection ReadCollection() { FbDataReader dataReader = null; try { LIS_OCORRENCIATLMKCollection 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_OCORRENCIATLMK", 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_OCORRENCIATLMK", 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; } }