namespace MDMLayerStyle
{
using System;
using System.Data;
using System.Data.OleDb;
public class MSMSDATALAYER
{
private OleDbConnection CN;
private string ConnStr;
public MSMSDATALAYER(string ConnectionString)
{
this.ConnStr = ConnectionString;
}
public bool ChickExist(string SqlStatment)
{
OleDbConnection connection = this.Information_OpenedConn();
OleDbDataReader reader = new OleDbCommand(SqlStatment, connection).ExecuteReader();
if (reader.Read())
{
reader.Close();
this.Information_CloseConn();
return true;
}
reader.Close();
this.Information_CloseConn();
return false;
}
public OleDbDataAdapter DA_Info_Needed(OleDbCommand SelectCommand)
{
OleDbDataAdapter adapter = new OleDbDataAdapter();
SelectCommand.Connection = this.Information_Conn();
adapter.SelectCommand = SelectCommand;
return adapter;
}
public OleDbDataAdapter DA_Info_Needed(string SQLStatment)
{
return new OleDbDataAdapter(SQLStatment, this.Information_Conn());
}
public OleDbDataAdapter DA_Info_Needed(OleDbCommand SelectCommand, OleDbCommand InsertCommand)
{
OleDbDataAdapter adapter = new OleDbDataAdapter();
OleDbConnection connection = this.Information_Conn();
SelectCommand.Connection = connection;
InsertCommand.Connection = connection;
adapter.SelectCommand = SelectCommand;
adapter.InsertCommand = InsertCommand;
return adapter;
}
public OleDbDataAdapter DA_Info_Needed(OleDbCommand Command, string Type)
{
OleDbDataAdapter adapter = new OleDbDataAdapter();
OleDbConnection connection = this.Information_Conn();
if (Type == "UPDATE")
{
Command.Connection = connection;
adapter.UpdateCommand = Command;
}
return adapter;
}
public OleDbDataAdapter DA_Info_Needed(OleDbCommand SelectCommand, OleDbCommand InsertCommand, OleDbCommand UpdateCommand)
{
OleDbDataAdapter adapter = new OleDbDataAdapter();
OleDbConnection connection = this.Information_Conn();
SelectCommand.Connection = connection;
InsertCommand.Connection = connection;
UpdateCommand.Connection = connection;
adapter.SelectCommand = SelectCommand;
adapter.InsertCommand = InsertCommand;
adapter.UpdateCommand = UpdateCommand;
return adapter;
}
public OleDbDataAdapter DA_Info_Needed(OleDbCommand SelectCommand, OleDbCommand InsertCommand, OleDbCommand UpdateCommand, OleDbCommand DeletCommand)
{
OleDbDataAdapter adapter = new OleDbDataAdapter();
OleDbConnection connection = this.Information_Conn();
SelectCommand.Connection = connection;
InsertCommand.Connection = connection;
UpdateCommand.Connection = connection;
DeletCommand.Connection = connection;
adapter.SelectCommand = SelectCommand;
adapter.InsertCommand = InsertCommand;
adapter.UpdateCommand = UpdateCommand;
adapter.DeleteCommand = DeletCommand;
return adapter;
}
public OleDbDataAdapter DA_Info_Needed_Select_Delete(OleDbCommand SelectCommand, OleDbCommand DeleteCommand)
{
OleDbDataAdapter adapter = new OleDbDataAdapter();
OleDbConnection connection = this.Information_Conn();
SelectCommand.Connection = connection;
DeleteCommand.Connection = connection;
adapter.SelectCommand = SelectCommand;
adapter.DeleteCommand = DeleteCommand;
return adapter;
}
public DataSet DS_Info_Needed(OleDbCommand SelectCommand, string TableName)
{
OleDbConnection connection = this.Information_Conn();
OleDbDataAdapter adapter = this.DA_Info_Needed(SelectCommand);
adapter.SelectCommand = SelectCommand;
SelectCommand.Connection = connection;
DataSet dataSet = new DataSet();
adapter.Fill(dataSet, TableName);
return dataSet;
}
public DataSet DS_Info_Needed(string SQLStatment, string TableName)
{
try
{
OleDbConnection connection = this.Information_Conn();
OleDbCommand selectCommand = new OleDbCommand(SQLStatment);
OleDbDataAdapter adapter = this.DA_Info_Needed(selectCommand);
adapter.SelectCommand = selectCommand;
selectCommand.Connection = connection;
DataSet dataSet = new DataSet();
adapter.Fill(dataSet, TableName);
return dataSet;
}
catch
{
return null;
}
}
public DataSet DS_Info_Needed(OleDbCommand SelectCommand, OleDbCommand InsertCommand, string TableName)
{
OleDbConnection connection = this.Information_Conn();
OleDbDataAdapter adapter = this.DA_Info_Needed(SelectCommand, InsertCommand);
adapter.SelectCommand = SelectCommand;
adapter.InsertCommand = InsertCommand;
SelectCommand.Connection = connection;
InsertCommand.Connection = connection;
DataSet dataSet = new DataSet();
adapter.Fill(dataSet, TableName);
return dataSet;
}
public DataSet DS_Info_Needed(OleDbCommand SelectCommand, OleDbCommand InsertCommand, OleDbCommand UpdateCommand, string TableName)
{
OleDbConnection connection = this.Information_Conn();
OleDbDataAdapter adapter = this.DA_Info_Needed(SelectCommand, InsertCommand, UpdateCommand);
adapter.SelectCommand = SelectCommand;
adapter.InsertCommand = InsertCommand;
adapter.UpdateCommand = UpdateCommand;
SelectCommand.Connection = connection;
InsertCommand.Connection = connection;
UpdateCommand.Connection = connection;
DataSet dataSet = new DataSet();
adapter.Fill(dataSet, TableName);
return dataSet;
}
public DataSet DS_Info_Needed(OleDbCommand SelectCommand, OleDbCommand InsertCommand, OleDbCommand UpdateCommand, OleDbCommand DeleteCommand, string TableName)
{
OleDbConnection connection = this.Information_Conn();
OleDbDataAdapter adapter = this.DA_Info_Needed(SelectCommand, InsertCommand, UpdateCommand, DeleteCommand);
adapter.SelectCommand = SelectCommand;
adapter.InsertCommand = InsertCommand;
adapter.UpdateCommand = UpdateCommand;
adapter.DeleteCommand = DeleteCommand;
SelectCommand.Connection = connection;
InsertCommand.Connection = connection;
UpdateCommand.Connection = connection;
DeleteCommand.Connection = connection;
DataSet dataSet = new DataSet();
adapter.Fill(dataSet, TableName);
return dataSet;
}
public DataTable DT_Info_Needed(OleDbCommand SelectCommand)
{
OleDbConnection connection = this.Information_Conn();
OleDbDataAdapter adapter = this.DA_Info_Needed(SelectCommand);
adapter.SelectCommand = SelectCommand;
SelectCommand.Connection = connection;
DataTable dataTable = new DataTable();
adapter.Fill(dataTable);
return dataTable;
}
public DataView DV_Info_Needed(OleDbCommand SelectCommand)
{
OleDbConnection connection = this.Information_Conn();
OleDbDataAdapter adapter = this.DA_Info_Needed(SelectCommand);
adapter.SelectCommand = SelectCommand;
SelectCommand.Connection = connection;
DataSet dataSet = new DataSet();
adapter.Fill(dataSet);
return dataSet.Tables[0].DefaultView;
}
public DataView DV_Info_Needed(string SQLStatment)
{
try
{
OleDbConnection connection = this.Information_Conn();
OleDbCommand selectCommand = new OleDbCommand(SQLStatment);
OleDbDataAdapter adapter = this.DA_Info_Needed(selectCommand);
adapter.SelectCommand = selectCommand;
selectCommand.Connection = connection;
DataSet dataSet = new DataSet();
adapter.Fill(dataSet);
return dataSet.Tables[0].DefaultView;
}
catch
{
return null;
}
}
public string ExecutCommand(OleDbCommand CommandToExec)
{
try
{
OleDbConnection connection = this.Information_OpenedConn();
CommandToExec.Connection = connection;
int num = CommandToExec.ExecuteNonQuery();
this.Information_CloseConn();
return "Executed";
}
catch (OleDbException exception)
{
return exception.ToString();
}
}
public int ExecutCommandRowsEf(OleDbCommand CommandToExec)
{
try
{
OleDbConnection connection = this.Information_OpenedConn();
CommandToExec.Connection = connection;
int num = CommandToExec.ExecuteNonQuery();
this.Information_CloseConn();
return num;
}
catch (OleDbException)
{
return 0;
}
}
public string ExecutCommandRowsEf(OleDbCommand CommandToExec, string exep)
{
try
{
OleDbConnection connection = this.Information_OpenedConn();
CommandToExec.Connection = connection;
int num = CommandToExec.ExecuteNonQuery();
this.Information_CloseConn();
return num.ToString();
}
catch (OleDbException exception)
{
return exception.ToString();
}
}
public string ExecutCommandScalar(OleDbCommand CommandToExec)
{
try
{
OleDbConnection connection = this.Information_OpenedConn();
CommandToExec.Connection = connection;
string str = CommandToExec.ExecuteScalar().ToString();
this.Information_CloseConn();
return str;
}
catch (OleDbException exception)
{
return exception.ToString();
}
}
public string ExecutScalar(OleDbCommand CommandToExec)
{
try
{
OleDbConnection connection = this.Information_OpenedConn();
CommandToExec.Connection = connection;
string str = CommandToExec.ExecuteScalar().ToString();
this.Information_CloseConn();
return str;
}
catch (OleDbException)
{
return null;
}
}
public void Information_CloseConn()
{
this.CN.Close();
}
public OleDbConnection Information_Conn()
{
this.CN = new OleDbConnection(this.ConnStr);
return this.CN;
}
public OleDbConnection Information_OpenedConn()
{
this.CN = new OleDbConnection(this.ConnStr);
try
{
this.CN.Open();
return this.CN;
}
catch
{
return this.CN;
}
}
}
}