private void FrmTipoRegiao_Load(object sender, EventArgs e) { CreaterCursor Cr = new CreaterCursor(); this.Cursor = Cr.CreateCursor(Cr.btmap, 0, 0); this.MinimizeBox = false; this.FormBorderStyle = FormBorderStyle.FixedDialog; PreencheDropCamposPesquisa(); PreencheDropTipoPesquisa(); GetToolStripButtonCadastro(); GetDropProdutos(); GetDropStatus(); GetDropStatus2(); GetDropCliente(); btnCadCliente.Image = Util.GetAddressImage(6); btnCadProduto.Image = Util.GetAddressImage(6); btnStatus.Image = Util.GetAddressImage(6); if (_IDRESERVA != -1) { Entity = RESERVAP.Read(_IDRESERVA); } else if (DataConsultaSelec != string.Empty) { tabControlMarca.SelectTab(1); RowRelatorio.Clear(); RowRelatorio.Add(new RowsFiltro("DATARETIRADA", "System.DateTime", "=", Util.ConverStringDateSearch(DataConsultaSelec))); LIS_RESERVAColl = LIS_RESERVAP.ReadCollectionByParameter(RowRelatorio, "IDRESERVA DESC"); DataGriewDados.AutoGenerateColumns = false; DataGriewDados.DataSource = LIS_RESERVAColl; } this.Cursor = Cursors.Default; if (!Util.Acessa_Tela(this.Name, FrmLogin._IdNivel)) { MessageBox.Show(ConfigMessage.Default.MsgPerm); this.Close(); } }
private string RetornaNomeCliente(int IDRESERVA) { string result = string.Empty; RowRelatorio.Clear(); RowRelatorio.Add(new RowsFiltro("IDRESERVA", "System.Int32", "=", IDRESERVA.ToString())); LIS_RESERVAProvider LIS_RESERVAP = new LIS_RESERVAProvider(); LIS_RESERVACollection LIS_RESERVAColl = new LIS_RESERVACollection(); LIS_RESERVAColl = LIS_RESERVAP.ReadCollectionByParameter(RowRelatorio); if (LIS_RESERVAColl.Count > 0) { result = LIS_RESERVAColl[0].NOMECLIENTE; } return(result); }
private void btnPesquisa_Click(object sender, EventArgs e) { CreaterCursor Cr = new CreaterCursor(); this.Cursor = Cr.CreateCursor(Cr.btmap, 0, 0); if (cbTipoPesquisa.Text == "Todos") { Filtro.Clear(); if (!chkpesquisaperiodo.Checked) { if (dateTimePickerEntradaFiltro.Text != " / /" && dateTimePickerSaidaFiltro.Text != " / /" && ValidacoesLibrary.ValidaTipoDateTime(dateTimePickerEntradaFiltro.Text) && ValidacoesLibrary.ValidaTipoDateTime(dateTimePickerSaidaFiltro.Text)) { filtroProfile = new RowsFiltro("DATARETIRADA", "System.DateTime", ">=", Util.ConverStringDateSearch(dateTimePickerEntradaFiltro.Text)); Filtro.Insert(Filtro.Count, filtroProfile); filtroProfile = new RowsFiltro("DATAENTREGA", "System.DateTime", "<=", Util.ConverStringDateSearch(dateTimePickerSaidaFiltro.Text)); Filtro.Insert(Filtro.Count, filtroProfile); } } if (Convert.ToInt32(cbStatus2.SelectedValue) > 0) { filtroProfile = new RowsFiltro("IDSTATUS", "System.Int32", "=", cbStatus2.SelectedValue.ToString()); Filtro.Insert(Filtro.Count, filtroProfile); } LIS_RESERVAColl = LIS_RESERVAP.ReadCollectionByParameter(Filtro, "IDRESERVA DESC"); DataGriewDados.AutoGenerateColumns = false; DataGriewDados.DataSource = LIS_RESERVAColl; lblTotalPesquisa.Text = LIS_RESERVAColl.Count.ToString(); } else { PesquisaFiltro(); } this.Cursor = Cursors.Default; }
private void PesquisaReserva() { try { RowsFiltroCollection RowRelatorio = new RowsFiltroCollection(); RowRelatorio.Add(new RowsFiltro(cbCamposPesquisa.SelectedValue.ToString(), "System.String", "like ", "%" + txtNomePesquisa.Text.ToUpper() + "%")); LIS_RESERVAColl = LIS_RESERVAP.ReadCollectionByParameter(RowRelatorio, "IDRESERVA desc"); DataGriewSearch.AutoGenerateColumns = false; DataGriewSearch.DataSource = LIS_RESERVAColl; txtNomePesquisa.Focus(); lblObsField.Text = "Total da pesquisa: " + LIS_RESERVAColl.Count.ToString(); } catch (Exception) { MessageBox.Show(ConfigMessage.Default.searchFieldType, ConfigSistema1.Default.NomeEmpresa, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } }
private static LIS_RESERVACollection ExecuteReader(ref LIS_RESERVACollection collection, ref FbDataReader dataReader, FbCommand dbCommand) { using (dataReader = dbCommand.ExecuteReader()) { collection = new LIS_RESERVACollection(); if (dataReader.HasRows) { while (dataReader.Read()) { collection.Add(FillEntityObject(ref dataReader)); } } if (!(dataReader.IsClosed)) { dataReader.Close(); } dataReader.Dispose(); } return(collection); }
private void FilterList() { /// referente ao tipo de campo string campo = cbCamposPesquisa.SelectedValue.ToString(); //Necessario passar a coleção vazia para o grid, para pegar o tipo da coluna if (LIS_RESERVAColl.Count == 0) { DataGriewDados.AutoGenerateColumns = false; DataGriewDados.DataSource = LIS_RESERVAColl; } // Retorna o tipo de campo para pesquisa Ex.: String, Integer, Date... string Tipo = DataGriewDados.Columns[cbCamposPesquisa.SelectedValue.ToString()].ValueType.FullName; if (Tipo.Length > 20) { Tipo = Util.GetTypeCell(Tipo);//Retorna o texto resumido do tipo } string Valor = txtCriterioPesquisa.Text; //Verifica se o valor digitado e compativel com // o tipo de pesquisa if (ValidacoesLibrary.ValidaTipoPesquisa(Tipo, Valor)) { if (Tipo == "System.DateTime")//formata data para pesquisa. { Valor = Util.ConverStringDateSearch(txtCriterioPesquisa.Text); } else if (Tipo == "System.Decimal")//formata Numeric para pesquisa. { Valor = Util.ConverStringDecimalSearch(txtCriterioPesquisa.Text); } filtroProfile = new RowsFiltro(campo, Tipo, cbTipoPesquisa.SelectedValue.ToString(), Valor); if (!chkBoxAcumulaPesquisa.Checked)//Acumular pesquisa { Filtro.Clear(); } Filtro.Insert(Filtro.Count, filtroProfile); if (!chkpesquisaperiodo.Checked) { if (dateTimePickerEntradaFiltro.Text != " / /" && dateTimePickerSaidaFiltro.Text != " / /" && ValidacoesLibrary.ValidaTipoDateTime(dateTimePickerEntradaFiltro.Text) && ValidacoesLibrary.ValidaTipoDateTime(dateTimePickerSaidaFiltro.Text)) { filtroProfile = new RowsFiltro("DATARETIRADA", "System.DateTime", ">=", Util.ConverStringDateSearch(dateTimePickerEntradaFiltro.Text)); Filtro.Insert(Filtro.Count, filtroProfile); filtroProfile = new RowsFiltro("DATAENTREGA", "System.DateTime", "<=", Util.ConverStringDateSearch(dateTimePickerSaidaFiltro.Text)); Filtro.Insert(Filtro.Count, filtroProfile); } } if (Convert.ToInt32(cbStatus2.SelectedValue) > 0) { filtroProfile = new RowsFiltro("IDSTATUS", "System.Int32", "=", cbStatus2.SelectedValue.ToString()); Filtro.Insert(Filtro.Count, filtroProfile); } LIS_RESERVAColl = LIS_RESERVAP.ReadCollectionByParameter(Filtro, "IDRESERVA DESC"); DataGriewDados.AutoGenerateColumns = false; DataGriewDados.DataSource = LIS_RESERVAColl; lblTotalPesquisa.Text = LIS_RESERVAColl.Count.ToString(); } else { MessageBox.Show(ConfigMessage.Default.searchFieldType); errorProvider1.SetError(txtCriterioPesquisa, ConfigMessage.Default.searchFieldType); txtCriterioPesquisa.Focus(); } }
private void FrmRelaReserva_2_Load(object sender, EventArgs e) { 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; } } nomeempresa = EMPRESAColl[0].NOMEFANTASIA; //Dados do Cliente RowRelatorio.Clear(); RowRelatorio.Add(new RowsFiltro("IDCLIENTE", "System.Int32", "=", codclienteSelec.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 Reserva RowRelatorio.Clear(); RowRelatorio.Add(new RowsFiltro("IDRESERVA", "System.Int32", "=", IDRESERVASELEC.ToString())); LIS_RESERVAProvider LIS_RESERVAP = new LIS_RESERVAProvider(); LIS_RESERVAColl = LIS_RESERVAP.ReadCollectionByParameter(RowRelatorio); //Dados do Produto Reserva RowRelatorio.Clear(); RowRelatorio.Add(new RowsFiltro("IDRESERVA", "System.Int32", "=", IDRESERVASELEC.ToString())); LIS_PRODUTORESERVAProvider LIS_PRODUTORESERVAP = new LIS_PRODUTORESERVAProvider(); LIS_PRODUTORESERVAColl = LIS_PRODUTORESERVAP.ReadCollectionByParameter(RowRelatorio); Microsoft.Reporting.WinForms.ReportParameter[] p = new Microsoft.Reporting.WinForms.ReportParameter[5]; p[0] = new Microsoft.Reporting.WinForms.ReportParameter("cpfcnpj", cpfcnpjPar); p[1] = new Microsoft.Reporting.WinForms.ReportParameter("controle", controleSelec); p[2] = new Microsoft.Reporting.WinForms.ReportParameter("vlpago", vlpagoSelec); p[3] = new Microsoft.Reporting.WinForms.ReportParameter("nomeempresa", nomeempresa); p[4] = new Microsoft.Reporting.WinForms.ReportParameter("titulo", IDRESERVASELEC.ToString().PadLeft(6, '0')); reportViewer1.LocalReport.SetParameters(p); this.EMPRESACollectionBindingSource.DataSource = EMPRESAColl; this.LIS_CLIENTECollectionBindingSource.DataSource = LIS_CLIENTEColl; this.LIS_RESERVAEntityBindingSource.DataSource = LIS_RESERVAColl; this.LIS_PRODUTORESERVACollectionBindingSource.DataSource = LIS_PRODUTORESERVAColl; this.reportViewer1.SetDisplayMode(DisplayMode.PrintLayout); this.reportViewer1.ZoomMode = ZoomMode.Percent; this.reportViewer1.RefreshReport(); }
public LIS_RESERVACollection ReadCollectionByParameter(List <RowsFiltro> RowsFiltro, string FieldOrder) { FbDataReader dataReader = null; string strSqlCommand = String.Empty; LIS_RESERVACollection collection = null; try { if (RowsFiltro != null) { if (RowsFiltro.Count > 0) { strSqlCommand = "SELECT * FROM LIS_RESERVA 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_RESERVA order by " + FieldOrder; } } else { strSqlCommand = "SELECT * FROM LIS_RESERVA 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_RESERVACollection ReadCollection() { FbDataReader dataReader = null; try { LIS_RESERVACollection 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_RESERVA", 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_RESERVA", 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; } }