194 lines
6.4 KiB
C#
194 lines
6.4 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Text;
|
|
using System.Data.SqlClient;
|
|
|
|
namespace Mtxfw.DAL
|
|
{
|
|
/// <summary>
|
|
/// 数据访问类:user_Results
|
|
/// </summary>
|
|
public partial class user_Results_jl3 : Mtxfw.Utility.Myabstract
|
|
{
|
|
public user_Results_jl3()
|
|
: base("user_Results_jl3")
|
|
{ }
|
|
|
|
/// <summary>
|
|
/// 增加一条数据
|
|
/// </summary>
|
|
public int Add(Mtxfw.Model.user_Results_jl3 model)
|
|
{
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("insert into user_Results_jl3(");
|
|
strSql.Append("utype,blmoney,fs,addtime,gtype)");
|
|
strSql.Append(" values (");
|
|
strSql.Append("@utype,@blmoney,@fs,@addtime,@gtype)");
|
|
strSql.Append(";select SCOPE_IDENTITY()");
|
|
SqlParameter[] parameters = {
|
|
new SqlParameter("@utype", SqlDbType.VarChar,50),
|
|
new SqlParameter("@blmoney", SqlDbType.Money),
|
|
new SqlParameter("@fs", SqlDbType.Int),
|
|
new SqlParameter("@addtime", SqlDbType.DateTime),
|
|
new SqlParameter("@gtype", SqlDbType.Int)};
|
|
parameters[0].Value = model.utype;
|
|
parameters[1].Value = model.blmoney;
|
|
parameters[2].Value = model.fs;
|
|
parameters[3].Value = model.addtime;
|
|
parameters[4].Value = model.gtype;
|
|
string obj = Mtxfw.Utility.SqlDbHelper_U.GetObject(strSql.ToString(), parameters).ToString();
|
|
if (obj == "")
|
|
{
|
|
return 0;
|
|
}
|
|
else
|
|
{
|
|
return Convert.ToInt32(obj);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 更新数据
|
|
/// </summary>
|
|
public bool Update(int fs, Double blmoney, Int64 Id)
|
|
{
|
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("update user_Results_jl3 set fs=@fs,blmoney=@blmoney");
|
|
strSql.Append(" where Id=@Id");
|
|
SqlParameter[] parameters = {
|
|
new SqlParameter("@fs", SqlDbType.Int),
|
|
new SqlParameter("@blmoney", SqlDbType.Money),
|
|
new SqlParameter("@Id", SqlDbType.BigInt)
|
|
};
|
|
parameters[0].Value = fs;
|
|
parameters[1].Value = blmoney;
|
|
parameters[2].Value = Id;
|
|
int rows = Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(strSql.ToString(), parameters);
|
|
if (rows > 0)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 删除一条数据
|
|
/// </summary>
|
|
public bool Delete(Int64 Id)
|
|
{
|
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("delete from user_Results_jl3");
|
|
strSql.Append(" where Id=@Id");
|
|
SqlParameter[] parameters = {
|
|
new SqlParameter("@Id", SqlDbType.BigInt)
|
|
};
|
|
parameters[0].Value = Id;
|
|
|
|
int rows = Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(strSql.ToString(), parameters);
|
|
if (rows > 0)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 得到一个对象实体
|
|
/// </summary>
|
|
public Mtxfw.Model.user_Results_jl3 GetModel(Int64 Id)
|
|
{
|
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("select top 1 * from user_Results_jl3");
|
|
strSql.Append(" where Id=@Id");
|
|
SqlParameter[] parameters = {
|
|
new SqlParameter("@Id", SqlDbType.BigInt)
|
|
};
|
|
parameters[0].Value = Id;
|
|
|
|
Mtxfw.Model.user_Results_jl3 model = new Mtxfw.Model.user_Results_jl3();
|
|
DataSet ds = Mtxfw.Utility.SqlDbHelper_U.GetDataSet(strSql.ToString(), parameters);
|
|
if (ds.Tables[0].Rows.Count > 0)
|
|
{
|
|
if (ds.Tables[0].Rows[0]["Id"].ToString() != "")
|
|
{
|
|
model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
|
|
}
|
|
if (ds.Tables[0].Rows[0]["blmoney"].ToString() != "")
|
|
{
|
|
model.blmoney = Double.Parse(ds.Tables[0].Rows[0]["blmoney"].ToString());
|
|
}
|
|
else
|
|
{
|
|
model.blmoney = 0.00;
|
|
}
|
|
if (ds.Tables[0].Rows[0]["fs"].ToString() != "")
|
|
{
|
|
model.fs = int.Parse(ds.Tables[0].Rows[0]["fs"].ToString());
|
|
}
|
|
else
|
|
{
|
|
model.fs = 0;
|
|
}
|
|
model.utype = ds.Tables[0].Rows[0]["utype"].ToString();
|
|
if (ds.Tables[0].Rows[0]["addtime"].ToString() != "")
|
|
{
|
|
model.addtime = DateTime.Parse(ds.Tables[0].Rows[0]["addtime"].ToString());
|
|
}
|
|
model.gtype = int.Parse(ds.Tables[0].Rows[0]["gtype"].ToString());
|
|
return model;
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 获得数据列表
|
|
/// </summary>
|
|
public DataSet GetList(string strWhere)
|
|
{
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("select * ");
|
|
strSql.Append(" FROM user_Results_jl3 ");
|
|
if (strWhere.Trim() != "")
|
|
{
|
|
strSql.Append(" where " + strWhere);
|
|
}
|
|
return Mtxfw.Utility.SqlDbHelper_U.GetDataSet(strSql.ToString());
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获得前几行数据
|
|
/// </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 user_Results_jl3 ");
|
|
if (strWhere.Trim() != "")
|
|
{
|
|
strSql.Append(" where " + strWhere);
|
|
}
|
|
strSql.Append(" order by " + filedOrder);
|
|
return Mtxfw.Utility.SqlDbHelper_U.GetDataSet(strSql.ToString());
|
|
}
|
|
|
|
}
|
|
}
|
|
|