📄 smartsoft.common.sql.dbfactory.cs
字号:
}
protected System.Data.IDbDataParameter 创建命令参数CommandParameter(string 参数名称String, string 参数值String, System.Data.ParameterDirection 参数方向ParameterDirection)
{
this.操作命令String = "设置数据库命令字串参数";
System.Data.IDbDataParameter 数据库命令参数CommandParameterX = null;
try
{
数据库命令参数CommandParameterX = SmartSoft.Common.SQL.DBFactory.数据库命令.创建命令参数CommandParameter(this.数据库类型名称, 参数名称String, 参数值String, 参数方向ParameterDirection);
this.操作成功();
}
catch (Exception e)
{
this.操作失败(e);
}
return 数据库命令参数CommandParameterX;
}
protected System.Data.IDbDataParameter 创建命令参数CommandParameter(string 参数名称String, float 参数值Float, System.Data.ParameterDirection 参数方向ParameterDirection)
{
this.操作命令String = "设置数据库命令单浮点参数";
System.Data.IDbDataParameter 数据库命令参数CommandParameterX = null;
try
{
数据库命令参数CommandParameterX = SmartSoft.Common.SQL.DBFactory.数据库命令.创建命令参数CommandParameter(this.数据库类型名称, 参数名称String, 参数值Float, 参数方向ParameterDirection);
this.操作成功();
}
catch (Exception e)
{
this.操作失败(e);
}
return 数据库命令参数CommandParameterX;
}
protected System.Data.IDbDataParameter 创建命令参数CommandParameter(string 参数名称String, int 参数值Int, System.Data.ParameterDirection 参数方向ParameterDirection)
{
this.操作命令String = "设置数据库命令整型参数";
System.Data.IDbDataParameter 数据库命令参数CommandParameterX = null;
try
{
数据库命令参数CommandParameterX = SmartSoft.Common.SQL.DBFactory.数据库命令.创建命令参数CommandParameter(this.数据库类型名称, 参数名称String, 参数值Int, 参数方向ParameterDirection);
this.操作成功();
}
catch (Exception e)
{
this.操作失败(e);
}
return 数据库命令参数CommandParameterX;
}
protected System.Data.IDbDataParameter 创建命令参数CommandParameter(string 参数名称String, Byte[] 参数值Byte, System.Data.ParameterDirection 参数方向ParameterDirection)
{
this.操作命令String = "设置数据库命令二进制参数";
System.Data.IDbDataParameter 数据库命令参数CommandParameterX = null;
try
{
数据库命令参数CommandParameterX = SmartSoft.Common.SQL.DBFactory.数据库命令.创建命令参数CommandParameter(this.数据库类型名称, 参数名称String, 参数值Byte, 参数方向ParameterDirection);
this.操作成功();
}
catch (Exception e)
{
this.操作失败(e);
}
return 数据库命令参数CommandParameterX;
}
#endregion 基础命令 设置数据库命令参数
}
public abstract class DBFactory数据库函数类 : DBFactory数据库基础类
{
#region 构造函数
public DBFactory数据库函数类(SmartSoft.Common.SQL.数据库类型 数据库类型enum, string 数据库链接字符串String)
: base(数据库类型enum, 数据库链接字符串String)
{
}
#endregion 构造函数
#region 扩展命令 数据库函数
protected string 获取文本数据库函数值(string 函数表达式)
{
string 别名值 = "";
string SQL语句 = SmartSoft.Common.SQL.SQLExpression.SQL语句.获取函数值(函数表达式, "别名");
if (SQL语句 != "")
{
别名值 = this.数据值查询String("别名",CommandType.Text,SQL语句);
}
return 别名值;
}
protected ulong 获取长整数据库函数值(string 函数表达式)
{
ulong 函数值 = 0;
string 函数值string = "";
函数值string = this.获取文本数据库函数值(函数表达式).Trim();
if (函数值string != "")
{
函数值 = Convert.ToUInt64(函数值string);
}
return 函数值;
}
protected decimal 获取浮点数据库函数值(string 函数表达式)
{
decimal 函数值 = 0.0M;
string 函数值string = "";
函数值string = this.获取文本数据库函数值(函数表达式).Trim();
if (函数值string != "")
{
函数值 = decimal.Parse(函数值string);
}
return 函数值;
}
protected int 获取整型数据库函数值(string 函数表达式)
{
int 函数值 = 0;
string 函数值string = "";
函数值string = this.获取文本数据库函数值(函数表达式).Trim();
if (函数值string != "")
{
函数值 = int.Parse(函数值string);
}
return 函数值;
}
protected bool 获取布尔数据库函数值(string 函数表达式)
{
bool 函数值 = false; ;
string 函数值string = "";
函数值string = this.获取文本数据库函数值(函数表达式).Trim();
if (函数值string != "")
{
函数值 = bool.Parse(函数值string);
}
return 函数值;
}
protected DateTime 获取时间数据库函数值(string 函数表达式)
{
DateTime 函数值 = DateTime.Now; ;
string 函数值string = "";
函数值string = this.获取文本数据库函数值(函数表达式).Trim();
if (函数值string != "")
{
函数值 = DateTime.Parse(函数值string);
}
return 函数值;
}
protected DateTime 数据库当前时间()
{
DateTime 函数值 = DateTime.Now;
函数值 = this.获取时间数据库函数值(SmartSoft.Common.SQL.SQLExpression.数据库函数.数据库当前时间());
return 函数值;
}
#endregion 扩展命令 数据库函数
}
public abstract class DBFactory数据库维护类 : DBFactory数据库基础类
{
#region 构造函数
public DBFactory数据库维护类(SmartSoft.Common.SQL.数据库类型 数据库类型enum, string 数据库链接字符串String)
: base(数据库类型enum, 数据库链接字符串String)
{
}
#endregion 构造函数
#region 扩展命令 数据库维护
protected bool 备份数据库(string 备份路径)
{
bool IsOk = false;
string SQL语句 = "";
if (string.Compare(备份路径, "") != 0)
{
SQL语句 = SmartSoft.Common.SQL.SQLExpression.SQL语句.备份数据库(this.数据库名称(), 备份路径);
if (SQL语句 != "")
{
this.数据库命令非查询(CommandType.Text,SQL语句);
IsOk = this.操作正确否;
}
}
return IsOk;
}
protected bool 截断事务日志()
{
bool IsOk = false;
string SQL语句 = "";
SQL语句 = SmartSoft.Common.SQL.SQLExpression.SQL语句.截断事务日志(this.数据库名称());
if (SQL语句 != "")
{
this.数据库命令非查询(CommandType.Text, SQL语句);
IsOk = this.操作正确否;
}
return IsOk;
}
#endregion 扩展命令 数据库维护
}
public abstract class DBFactory数据库存储命令类 : DBFactory数据库基础类
{
#region 构造函数
public DBFactory数据库存储命令类(SmartSoft.Common.SQL.数据库类型 数据库类型enum, string 数据库链接字符串String)
: base(数据库类型enum, 数据库链接字符串String)
{
}
//-------------
#endregion 构造函数
#region 扩展命令 数据值查询
//----------------------------------
protected string 数据值查询StringBY存储过程(string 数据值名称, string 存储过程名称String, params IDbDataParameter[] 数据库命令参数CommandParameters)
{
string 数据值String = "";
数据值String = this.数据值查询String(数据值名称, CommandType.StoredProcedure, 存储过程名称String, 数据库命令参数CommandParameters);
return 数据值String;
}
//-------------------------------
protected byte[] 数据值查询ByteBY存储过程(string 数据值名称, string 存储过程名称String, params IDbDataParameter[] 数据库命令参数CommandParameters)
{
byte[] 数据值Byte = null;
数据值Byte = this.数据值查询Byte(数据值名称, CommandType.StoredProcedure, 存储过程名称String, 数据库命令参数CommandParameters);
return 数据值Byte;
}
//-------------------------------
#endregion 扩展命令 数据值查询
#region 扩展命令 数据库命令标量查询
//----------------------------------
protected string 数据库命令标量查询StringBY存储过程(string 存储过程名称String, params IDbDataParameter[] 数据库命令参数CommandParameters)
{
string 数据值String = "";
数据值String = this.数据库命令标量查询String(CommandType.StoredProcedure, 存储过程名称String, 数据库命令参数CommandParameters);
return 数据值String;
}
//-------------------------------
protected byte[] 数据库命令标量查询ByteBY存储过程(string 存储过程名称String, params IDbDataParameter[] 数据库命令参数CommandParameters)
{
byte[] 数据值Byte = null;
数据值Byte = this.数据库命令标量查询Byte(CommandType.StoredProcedure, 存储过程名称String, 数据库命令参数CommandParameters);
return 数据值Byte;
}
//-------------------------------
#endregion 扩展命令 数据值查询
#region 扩展命令 非查询
//------------------------
protected int 数据库命令非查询BY存储过程(string 存储过程名称String, params IDbDataParameter[] 数据库命令参数CommandParameters)
{
int 非查询操作返回值Int = 0;
非查询操作返回值Int = this.数据库命令非查询(CommandType.StoredProcedure, 存储过程名称String, 数据库命令参数CommandParameters);
return 非查询操作返回值Int;
}
//-----------------------
#endregion 扩展命令 非查询
#region 扩展命令 通用DataSet查询
//------------------------
protected System.Data.DataSet 通用DataSet查询BY存储过程(string 数据表名称, string 存储过程名称String, params IDbDataParameter[] 数据库命令参数CommandParameters)
{
System.Data.DataSet 数据表DataSetX = new System.Data.DataSet();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -