/*
*本代码由代码生成器自动生成,请不要更改此文件的任何代码,如需要添加方法,请创建同名类,并在该类中添加新的方法。
*生成时间:2010-11-2 9:44:44
*生成者:Kuibono
*/
using
System;
using
System.Text;
using
System.Data;
using
System.Linq;
using
System.Data.SqlClient;
using
System.Collections.Generic;
using
WanerSoft;
using
WanerSoft.Model;
using
WanerSoft.Config;
using
WanerSoft.Data.SqlClient;
using
WanerSoft.Setting;
namespace
WanerSoft.DAL
{
///
<summary>
///
表Ws_Setting的数据操作类
///
</summary>
public
partial
class
Ws_SettingView
{
#region
将数据插入表
///
<summary>
///
将数据插入表
///
</summary>
///
<param name="M">
赋值后的实体
</param>
///
<returns></returns>
public
static
void
Insert(Ws_Setting M)
{
SqlHelper Sql
=
new
SqlHelper(ConnStr.SystemConnStr);
Sql.Add(
"
@K
"
,SqlDbType.NVarChar,M.K,
50
);
Sql.Add(
"
@V
"
,SqlDbType.NText,M.V);
Sql.ExecuteNonQuery(
"
Ws_Setting_Insert
"
).ToString();
}
///
<summary>
///
将数据插入表
///
</summary>
///
<param name="M">
赋值后的实体
</param>
///
<returns>
返回ID
</returns>
public
static
int
InsertAndReturnPK(Ws_Setting M)
{
SqlHelper Sql
=
new
SqlHelper(ConnStr.SystemConnStr);
Sql.Add(
"
@K
"
,SqlDbType.NVarChar,M.K,
50
);
Sql.Add(
"
@V
"
,SqlDbType.NText,M.V);
return
Convert.ToInt32(Sql.ExecuteScalar(
"
Ws_Setting_Insert
"
).ToString());
}
#endregion
#region
Update将修改过的实体修改到数据库
///
<summary>
///
将修改过的实体修改到数据库
///
</summary>
///
<param name="M">
赋值后的实体
</param>
///
<returns></returns>
public
static
void
Update(Ws_Setting M)
{
SqlHelper Sql
=
new
SqlHelper(ConnStr.SystemConnStr);
Sql.Add(
"
@id
"
,M.Id);
Sql.Add(
"
@K
"
,SqlDbType.NVarChar,M.K,
50
);
Sql.Add(
"
@V
"
,SqlDbType.NText,M.V);
Sql.ExecuteNonQuery(
"
Ws_Setting_Update
"
);
}
#endregion
#region
根据ID取得实体
///
<summary>
///
根据ID取得实体
///
</summary>
///
<param name="id">
id,即编号主键
</param>
///
<returns></returns>
public
static
Ws_Setting GetModelByID(
int
id)
{
SqlHelper Sql
=
new
SqlHelper(ConnStr.SystemConnStr);
Ws_Setting M
=
new
Ws_Setting();
SqlDataReader Rs
=
Sql.ExecuteReader(CommandType.Text,
"
select id,K,V from Ws_Setting where Id=
"
+
id.ToString(), SqlHelper.ConnClose.Yes);
if
(
!
Rs.Read())
{
M.Id
=
int
.MinValue;
}
else
{
M.Id
=
Rs[
"
id
"
].ToInt32();
M.K
=
Rs[
"
K
"
].ToString();
M.V
=
Rs[
"
V
"
].ToString();
}
Rs.Close();
Rs
=
null
;
return
M;
}
#endregion
#region
根据条件语句取得第一个实体
///
<summary>
///
根据条件语句取得第一个实体
///
</summary>
///
<param name="m_where">
条件语句,不包含“where”
</param>
///
<returns></returns>
public
static
Ws_Setting Find(
string
m_where)
{
SqlHelper Sql
=
new
SqlHelper(ConnStr.SystemConnStr);
Ws_Setting M
=
new
Ws_Setting();
SqlDataReader Rs
=
Sql.ExecuteReader(CommandType.Text,
"
select id,K,V from Ws_Setting where
"
+
m_where, SqlHelper.ConnClose.Yes);
if
(
!
Rs.Read())
{
M.Id
=
int
.MinValue;
}
else
{
M.Id
=
Rs[
"
id
"
].ToInt32();
M.K
=
Rs[
"
K
"
].ToString();
M.V
=
Rs[
"
V
"
].ToString();
}
Rs.Close();
Rs
=
null
;
return
M;
}
#endregion
#region
根据条件语句取得符合条件的数据表
///
<summary>
///
根据条件语句取得符合条件的数据表,慎用!!!!
///
</summary>
///
<param name="m_where">
条件语句,不包含“where”
</param>
///
<returns></returns>
public
static
DataTable getTable(
string
m_where)
{
SqlHelper Sql
=
new
SqlHelper(ConnStr.SystemConnStr);
return
Sql.ExecuteDataTable(CommandType.Text,
"
select id,K,V from Ws_Setting where
"
+
m_where);
}
///
<summary>
///
根据条件语句取得符合条件的数据表,慎用!!!!
///
</summary>
///
<returns></returns>
public
static
DataTable getTable()
{
SqlHelper Sql
=
new
SqlHelper(ConnStr.SystemConnStr);
DataTable dt
=
Sql.ExecuteDataTable(CommandType.Text,
"
select id,K,V from Ws_Setting
"
);
return
dt;
}
///
<summary>
///
根据条件语句取得符合条件的数据表,慎用!!!!
///
</summary>
///
<param name="top">
前多少条数据
</param>
///
<param name="m_where">
条件语句,不包含“where”
</param>
///
<returns></returns>
public
static
DataTable getTable(
string
m_where,
int
top)
{
SqlHelper Sql
=
new
SqlHelper(ConnStr.SystemConnStr);
DataTable dt
=
Sql.ExecuteDataTable(CommandType.Text,
"
select top
"
+
top.ToString()
+
"
id,K,V from Ws_Setting where
"
+
m_where);
return
dt;
}
#endregion
#region
根据条件语句取得符合条件的数据集数据集
///
<summary>
///
根据条件语句取得符合条件的数据集数据集,慎用!!!!
///
</summary>
///
<param name="m_where">
条件语句,不包含“where”
</param>
///
<returns></returns>
public
static
DataSet getDs(
string
m_where)
{
SqlHelper Sql
=
new
SqlHelper(ConnStr.SystemConnStr);
return
Sql.ExecuteDataSet(CommandType.Text,
"
select id,K,V from Ws_Setting where
"
+
m_where);
}
///
<summary>
///
根据条件语句取得符合条件的数据集数据集,慎用!!!!
///
</summary>
///
<param name="m_where">
条件语句,不包含“where”
</param>
///
<returns></returns>
public
static
DataSet getDs()
{
SqlHelper Sql
=
new
SqlHelper(ConnStr.SystemConnStr);
return
Sql.ExecuteDataSet(CommandType.Text,
"
select id,K,V from Ws_Setting
"
);
}
#endregion
#region
获取符合条件记录的条数
///
<summary>
///
获取符合条件记录的条数
///
</summary>
///
<param name="m_where">
条件语句,不包含“where”
</param>
///
<returns></returns>
public
static
int
Count(
string
m_where)
{
SqlHelper Sql
=
new
SqlHelper(ConnStr.SystemConnStr);
return
Convert.ToInt32(Sql.ExecuteScalar(CommandType.Text,
"
select count(0) from Ws_Setting where
"
+
m_where));
}
#endregion
#region
验证符合条件的记录是否存在
///
<summary>
///
验证符合条件的记录是否存在
///
</summary>
///
<param name="m_where">
条件语句,不包含“where”
</param>
///
<returns></returns>
public
static
bool
Exist(
string
m_where)
{
bool
returnValue
=
false
;
SqlHelper Sql
=
new
SqlHelper(ConnStr.SystemConnStr);
SqlDataReader sd
=
null
;
sd
=
Sql.ExecuteReader(CommandType.Text,
"
select max(Id) from Ws_Setting where
"
+
m_where, SqlHelper.ConnClose.Yes);
if
(sd.Read())
{
returnValue
=
true
;
}
sd.Close();
sd.Dispose();
return
returnValue;
}
#endregion
#region
List<Ws_Setting>获取符合条件记录的实体列表,慎用!!!!
///
<summary>
///
List
<Ws_Setting>
获取符合条件记录的实体列表,慎用!!!!
///
</summary>
///
<param name="m_where">
条件语句,不包含“where”
</param>
///
<returns></returns>
public
static
List
<
Ws_Setting
>
GetModelList(
string
m_where)
{
List
<
Ws_Setting
>
Ms
=
new
List
<
Ws_Setting
>
();
SqlHelper Sql
=
new
SqlHelper(ConnStr.SystemConnStr);
DataTable dt
=
Sql.ExecuteDataTable(CommandType.Text,
"
select id,K,V from Ws_Setting where
"
+
m_where);
for
(
int
i
=
0
;i
<
dt.Rows.Count;i
++
)
{
Ws_Setting M
=
new
Ws_Setting();
M.Id
=
dt.Rows[i][
"
id
"
].ToInt32();
M.K
=
dt.Rows[i][
"
K
"
].ToString();
M.V
=
dt.Rows[i][
"
V
"
].ToString();
Ms.Add(M);
}
return
Ms;
}
public
static
List
<
Ws_Setting
>
GetModelList(
string
m_where,
int
top)
{
List
<
Ws_Setting
>
Ms
=
new
List
<
Ws_Setting
>
();
SqlHelper Sql
=
new
SqlHelper(ConnStr.SystemConnStr);
DataTable dt
=
Sql.ExecuteDataTable(CommandType.Text,
"
select top
"
+
top.ToString()
+
"
id,K,V from Ws_Setting where
"
+
m_where);
for
(
int
i
=
0
;i
<
dt.Rows.Count;i
++
)
{
Ws_Setting M
=
new
Ws_Setting();
M.Id
=
dt.Rows[i][
"
id
"
].ToInt32();
M.K
=
dt.Rows[i][
"
K
"
].ToString();
M.V
=
dt.Rows[i][
"
V
"
].ToString();
Ms.Add(M);
}
return
Ms;
}
public
static
List
<
Ws_Setting
>
GetModelList()
{
List
<
Ws_Setting
>
Ms
=
new
List
<
Ws_Setting
>
();
SqlHelper Sql
=
new
SqlHelper(ConnStr.SystemConnStr);
DataTable dt
=
Sql.ExecuteDataTable(CommandType.Text,
"
select id,K,V from Ws_Setting
"
);
for
(
int
i
=
0
; i
<
dt.Rows.Count; i
++
)
{
Ws_Setting M
=
new
Ws_Setting();
M.Id
=
dt.Rows[i][
"
id
"
].ToInt32();
M.K
=
dt.Rows[i][
"
K
"
].ToString();
M.V
=
dt.Rows[i][
"
V
"
].ToString();
Ms.Add(M);
}
return
Ms;
}
#endregion
#region
删除符合条件记录
///
<summary>
///
删除符合条件记录
///
</summary>
///
<param name="m_where">
条件语句,不包含“where”
</param>
///
<returns></returns>
public
static
bool
Del(
string
m_where)
{
SqlHelper Sql
=
new
SqlHelper(ConnStr.SystemConnStr);
try
{
Sql.ExecuteNonQuery(CommandType.Text,
"
delete from Ws_Setting where
"
+
m_where);
return
true
;
}
catch
{
return
false
;
}
}
#endregion
#region
删除符合条件记录
///
<summary>
///
删除符合条件记录
///
</summary>
///
<param name="ID">
ID
</param>
///
<returns></returns>
public
static
bool
DelByID(
int
ID)
{
return
Del(
"
Id=
"
+
ID.ToString());
}
#endregion
}
}