📄 operation.cs
字号:
using System;
using System.Collections;
namespace _36Hang.Data
{
/// <summary>
/// Operation 的摘要说明。
/// </summary>
public class Operation : Connection
{
public Operation(string Server,string Database,string Username,string Password) : base(Server,Database,Username,Password) {}
/// <summary>
/// 检测符合条件的记录是否存在
/// </summary>
/// <param name="Sql">检测条件</param>
public bool Check(string Sql)
{
try
{
_36Hang.Xml.Operation objOperation = new _36Hang.Xml.Operation(Records(Sql));
if(objOperation.Count("Root") == 0) return false;
return true;
}
catch
{
throw(new Exception(Sql));
}
}
/// <summary>
/// 添加记录
/// </summary>
/// <param name="Table">数据表名称</param>
/// <param name="Fields">数据表字段名称集合</param>
/// <param name="Values">数据表字段值集合</param>
public void Insert(string Table,ArrayList Fields,ArrayList Values)
{
string strSql = "";
try
{
strSql = "insert into [" + Table + "](";
for(int i=0; i<Fields.Count; i++)
{
strSql = strSql + "[" + Fields[i].ToString() + "]" + (i == Fields.Count - 1 ? "" : ",");
}
strSql = strSql + ") values(";
for(int i=0; i<Values.Count; i++)
{
strSql = strSql + "'" + Values[i].ToString() + "'" + (i == Values.Count - 1 ? "" : ",");
}
strSql = strSql + ")";
Execute(strSql);
}
catch
{
throw(new Exception(strSql));
}
}
/// <summary>
/// 修改记录
/// </summary>
/// <param name="Table">数据表名称</param>
/// <param name="Fields">数据表字段名称集合</param>
/// <param name="Values">数据表字段值集合</param>
/// <param name="ID">数据表记录标志</param>
public void Update(string Table,ArrayList Fields,ArrayList Values,long ID)
{
string strSql = "";
try
{
strSql = "update [" + Table + "] set";
for(int i=0; i<Fields.Count; i++)
{
strSql = strSql + " [" + Fields[i] + "] = '" + Values[i].ToString() + "'" + (i == Fields.Count - 1 ? "" : ",");
}
strSql = strSql + " where [ID] = '" + ID + "'";
Execute(strSql);
}
catch
{
throw(new Exception(strSql));
}
}
/// <summary>
/// 删除记录
/// </summary>
/// <param name="Table">数据表名称</param>
/// <param name="ID">数据表记录标志</param>
public void Delete(string Table,long ID)
{
string strSql = "";
try
{
strSql = "delete from [" + Table + "]";
strSql = strSql + " where [ID] = '" + ID + "'";
Execute(strSql);
}
catch
{
throw(new Exception(strSql));
}
}
public long Max(string Sql)
{
try
{
string strXml = Records(Sql);
_36Hang.Xml.Operation objOperation = new _36Hang.Xml.Operation(strXml);
if(objOperation.Value("Root",0,"Max") == "") return 0;
return Convert.ToInt64(objOperation.Value("Root",0,"Max"));
}
catch
{
throw(new Exception(Sql));
}
}
public long Count(string Sql)
{
try
{
string strXml = Records(Sql);
_36Hang.Xml.Operation objOperation = new _36Hang.Xml.Operation(strXml);
return Convert.ToInt64(objOperation.Value("Root",0,"Count"));
}
catch
{
throw(new Exception(Sql));
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -