using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data.OracleClient; using System.Data; namespace DAL { class DBHelperOra : DalInterface { // Fields private string connectionString = ""; // Methods void DalInterface.CreateConnectionStringSql(string strConnectionString) { this.connectionString = strConnectionString; } int DalInterface.ExecuteSql(string SQLString) { int num2; using (OracleConnection connection = new OracleConnection(this.connectionString)) { OracleCommand command = new OracleCommand(SQLString, connection); try { connection.Open(); return command.ExecuteNonQuery(); } catch (OracleException exception) { connection.Close(); throw new Exception(exception.Message); } finally { if (command != null) { command.Dispose(); } } } return num2; } int DalInterface.ExecuteSql(string SQLString, params IDataParameter[] cmdParms) { int num2; using (OracleConnection connection = new OracleConnection(this.connectionString)) { OracleCommand command = new OracleCommand(); try { if (connection.State != ConnectionState.Open) { connection.Open(); } command.Connection = connection; command.CommandText = SQLString; command.CommandType = CommandType.Text; if (cmdParms != null) { foreach (OracleParameter parameter in cmdParms) { command.Parameters.Add(parameter); } } int num = command.ExecuteNonQuery(); command.Parameters.Clear(); return num; } catch (OracleException exception) { throw new Exception(exception.Message); } finally { if (command != null) { command.Dispose(); } } } return num2; } object DalInterface.GetSingle(string SQLString) { object obj3; using (OracleConnection connection = new OracleConnection(this.connectionString)) { OracleCommand command = new OracleCommand(SQLString, connection); try { connection.Open(); object objA = command.ExecuteScalar(); if (object.Equals(objA, null) || object.Equals(objA, DBNull.Value)) { return null; } return objA; } catch (OracleException exception) { connection.Close(); throw new Exception(exception.Message); } finally { if (command != null) { command.Dispose(); } } } return obj3; } DataSet DalInterface.Query(string SQLString) { using (OracleConnection connection = new OracleConnection(this.connectionString)) { DataSet dataSet = new DataSet(); try { connection.Open(); new OracleDataAdapter(SQLString, connection).Fill(dataSet, "ds"); } catch (OracleException exception) { throw new Exception(exception.Message); } return dataSet; } } } }