代码修改后的版本,全部提交
This commit is contained in:
105
Mtxfw.DAL/host.cs
Normal file
105
Mtxfw.DAL/host.cs
Normal file
@@ -0,0 +1,105 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Text;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace Mtxfw.DAL
|
||||
{
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD>ݷ<EFBFBD><DDB7><EFBFBD><EFBFBD><EFBFBD>:host
|
||||
/// </summary>
|
||||
public partial class host : Mtxfw.Utility.Myabstract
|
||||
{
|
||||
public host()
|
||||
: base("host")
|
||||
{ }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <20>õ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5>
|
||||
/// </summary>
|
||||
public int GetId(string hostname)
|
||||
{
|
||||
|
||||
StringBuilder strSql = new StringBuilder();
|
||||
strSql.Append("select top 1 * from host ");
|
||||
strSql.Append(" where hostname=@hostname");
|
||||
SqlParameter[] parameters = {
|
||||
new SqlParameter("@hostname", SqlDbType.VarChar,50)};
|
||||
parameters[0].Value = hostname;
|
||||
int id = 0;
|
||||
DataSet ds = Mtxfw.Utility.SqlDbHelper_U.GetDataSet(strSql.ToString(), parameters);
|
||||
if (ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ɾ<><C9BE>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
public bool Delete(int Id)
|
||||
{
|
||||
|
||||
StringBuilder strSql = new StringBuilder();
|
||||
strSql.Append("delete from host ");
|
||||
strSql.Append(" where Id=@Id");
|
||||
SqlParameter[] parameters = {
|
||||
new SqlParameter("@Id", SqlDbType.Int,4)
|
||||
};
|
||||
parameters[0].Value = Id;
|
||||
|
||||
int rows = Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(strSql.ToString(), parameters);
|
||||
if (rows > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
|
||||
/// </summary>
|
||||
public DataSet GetList(string strWhere)
|
||||
{
|
||||
StringBuilder strSql = new StringBuilder();
|
||||
strSql.Append("select * ");
|
||||
strSql.Append(" FROM host ");
|
||||
if (strWhere.Trim() != "")
|
||||
{
|
||||
strSql.Append(" where " + strWhere);
|
||||
}
|
||||
return Mtxfw.Utility.SqlDbHelper_U.GetDataSet(strSql.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
public DataSet GetList(int Top, string strWhere, string filedOrder)
|
||||
{
|
||||
StringBuilder strSql = new StringBuilder();
|
||||
strSql.Append("select ");
|
||||
if (Top > 0)
|
||||
{
|
||||
strSql.Append(" top " + Top.ToString());
|
||||
}
|
||||
strSql.Append(" * ");
|
||||
strSql.Append(" FROM host ");
|
||||
if (strWhere.Trim() != "")
|
||||
{
|
||||
strSql.Append(" where " + strWhere);
|
||||
}
|
||||
strSql.Append(" order by " + filedOrder);
|
||||
return Mtxfw.Utility.SqlDbHelper_U.GetDataSet(strSql.ToString());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user