/// <summary> /// Verifica a liberação de Apaga de registro /// </summary> public Boolean Apaga_RegistroSenha(string NomeFormulario, int IDNIVEL) { Boolean result = true; RowsFiltroCollection RowFiltroAcess = new RowsFiltroCollection(); RowFiltroAcess.Add(new RowsFiltro("IDNIVEL", "System.Int32", "=", IDNIVEL.ToString(), "and")); RowFiltroAcess.Add(new RowsFiltro("NOMEFORMULARIO", "System.String", "=", NomeFormulario)); LIS_CONTROLEACESSOCollection LIS_CONTROLEACESSOColl = new LIS_CONTROLEACESSOCollection(); LIS_CONTROLEACESSOProvider LIS_CONTROLEACESSOP = new LIS_CONTROLEACESSOProvider(); LIS_CONTROLEACESSOColl = LIS_CONTROLEACESSOP.ReadCollectionByParameter(RowFiltroAcess); if (LIS_CONTROLEACESSOColl.Count > 0) { if (LIS_CONTROLEACESSOColl[0].FLAGAPAGA == "S") { result = true; } else { result = false; } } return(result); }
/// <summary> /// Verifica a liberação de Apaga de registro /// </summary> public Boolean Apaga_Registro(string NomeFormulario, int IDNIVEL) { Boolean result = true; RowsFiltroCollection RowFiltroAcess = new RowsFiltroCollection(); RowFiltroAcess.Add(new RowsFiltro("IDNIVEL", "System.Int32", "=", IDNIVEL.ToString(), "and")); RowFiltroAcess.Add(new RowsFiltro("NOMEFORMULARIO", "System.String", "=", NomeFormulario)); LIS_CONTROLEACESSOCollection LIS_CONTROLEACESSOColl = new LIS_CONTROLEACESSOCollection(); LIS_CONTROLEACESSOProvider LIS_CONTROLEACESSOP = new LIS_CONTROLEACESSOProvider(); LIS_CONTROLEACESSOColl = LIS_CONTROLEACESSOP.ReadCollectionByParameter(RowFiltroAcess); if (LIS_CONTROLEACESSOColl.Count > 0) { if (LIS_CONTROLEACESSOColl[0].FLAGAPAGA == "S") { result = true; } else { result = false; MessageBox.Show(ConfigMessage.Default.MsgPerm, ConfigSistema1.Default.NomeEmpresa, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } } return(result); }
private void OpenTelas() { RowRelatorio.Clear(); if (Convert.ToInt32(cbnivel2.SelectedValue) > 0) { RowRelatorio.Add(new RowsFiltro("IDNIVEL", "System.Int32", "=", Convert.ToInt32(cbnivel2.SelectedValue).ToString())); } LIS_CONTROLEACESSOColl2 = LIS_CONTROLEACESSOP.ReadCollectionByParameter(RowRelatorio, "NOMETELA"); LimpaGrid(); foreach (LIS_CONTROLEACESSOEntity item in LIS_CONTROLEACESSOColl2) { foreach (DataGridViewRow dg in dgvTelas.Rows) { if (item.IDFORMULARIO == Convert.ToInt32(dg.Cells[0].Value)) { dg.Cells[2].Value = item.FLAGACESSA; dg.Cells[3].Value = item.FLAGALTERA; dg.Cells[4].Value = item.FLAGAPAGA; } } } }
private static LIS_CONTROLEACESSOCollection ExecuteReader(ref LIS_CONTROLEACESSOCollection collection, ref FbDataReader dataReader, FbCommand dbCommand) { using (dataReader = dbCommand.ExecuteReader()) { collection = new LIS_CONTROLEACESSOCollection(); if (dataReader.HasRows) { while (dataReader.Read()) { collection.Add(FillEntityObject(ref dataReader)); } } if (!(dataReader.IsClosed)) { dataReader.Close(); } dataReader.Dispose(); } return(collection); }
public LIS_CONTROLEACESSOCollection ReadCollectionByParameter(List <RowsFiltro> RowsFiltro, string FieldOrder) { FbDataReader dataReader = null; string strSqlCommand = String.Empty; LIS_CONTROLEACESSOCollection collection = null; try { if (RowsFiltro != null) { if (RowsFiltro.Count > 0) { strSqlCommand = "SELECT * FROM LIS_CONTROLEACESSO 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_CONTROLEACESSO order by " + FieldOrder; } } else { strSqlCommand = "SELECT * FROM LIS_CONTROLEACESSO 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_CONTROLEACESSOCollection ReadCollection() { FbDataReader dataReader = null; try { LIS_CONTROLEACESSOCollection 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_CONTROLEACESSO", 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_CONTROLEACESSO", 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; } }