首次推送
This commit is contained in:
275
Mtxfw.DAL/user_Goods.cs
Normal file
275
Mtxfw.DAL/user_Goods.cs
Normal file
@@ -0,0 +1,275 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Text;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace Mtxfw.DAL
|
||||
{
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD>ݷ<EFBFBD><DDB7><EFBFBD><EFBFBD><EFBFBD>:user_Goods
|
||||
/// </summary>
|
||||
public partial class user_Goods : Mtxfw.Utility.Myabstract
|
||||
{
|
||||
public user_Goods()
|
||||
: base("user_Goods")
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
public int Add(Mtxfw.Model.user_Goods model)
|
||||
{
|
||||
StringBuilder strSql = new StringBuilder();
|
||||
strSql.Append("insert into user_Goods(");
|
||||
strSql.Append("GoodsName,GoodsPic,GoodsUrl,GoodsBody,GoodsPrices,GoodsPrices0,GoodsPrices1,GoodsPrices2,starttime,endtime,GoodsKC,GoodsNum,GoodsZT,AddTime,utype,gtype)");
|
||||
strSql.Append(" values (");
|
||||
strSql.Append("@GoodsName,@GoodsPic,@GoodsUrl,@GoodsBody,@GoodsPrices,@GoodsPrices0,@GoodsPrices1,@GoodsPrices2,@starttime,@endtime,@GoodsKC,@GoodsNum,@GoodsZT,@AddTime,@utype,@gtype)");
|
||||
strSql.Append(";select SCOPE_IDENTITY()");
|
||||
SqlParameter[] parameters = {
|
||||
new SqlParameter("@GoodsName", SqlDbType.VarChar,200),
|
||||
new SqlParameter("@GoodsPic", SqlDbType.VarChar,200),
|
||||
new SqlParameter("@GoodsUrl", SqlDbType.VarChar,200),
|
||||
new SqlParameter("@GoodsBody", SqlDbType.NText),
|
||||
new SqlParameter("@GoodsPrices", SqlDbType.Money),
|
||||
new SqlParameter("@GoodsPrices0", SqlDbType.Money),
|
||||
new SqlParameter("@GoodsPrices1", SqlDbType.Money),
|
||||
new SqlParameter("@GoodsPrices2", SqlDbType.Money),
|
||||
new SqlParameter("@starttime", SqlDbType.VarChar,50),
|
||||
new SqlParameter("@endtime", SqlDbType.VarChar,50),
|
||||
new SqlParameter("@GoodsKC", SqlDbType.Int),
|
||||
new SqlParameter("@GoodsNum", SqlDbType.Int),
|
||||
new SqlParameter("@GoodsZT", SqlDbType.Int),
|
||||
new SqlParameter("@AddTime", SqlDbType.DateTime),
|
||||
new SqlParameter("@utype", SqlDbType.Int),
|
||||
new SqlParameter("@gtype", SqlDbType.Int)};
|
||||
parameters[0].Value = model.GoodsName;
|
||||
parameters[1].Value = model.GoodsPic;
|
||||
parameters[2].Value = model.GoodsUrl;
|
||||
parameters[3].Value = model.GoodsBody;
|
||||
parameters[4].Value = model.GoodsPrices;
|
||||
parameters[5].Value = model.GoodsPrices0;
|
||||
parameters[6].Value = model.GoodsPrices1;
|
||||
parameters[7].Value = model.GoodsPrices2;
|
||||
parameters[8].Value = model.starttime;
|
||||
parameters[9].Value = model.endtime;
|
||||
parameters[10].Value = model.GoodsKC;
|
||||
parameters[11].Value = model.GoodsNum;
|
||||
parameters[12].Value = model.GoodsZT;
|
||||
parameters[13].Value = model.AddTime;
|
||||
parameters[14].Value = model.utype;
|
||||
parameters[15].Value = model.gtype;
|
||||
object obj = Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(strSql.ToString(), parameters);
|
||||
if (obj == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Convert.ToInt32(obj);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
public bool Update(Mtxfw.Model.user_Goods model)
|
||||
{
|
||||
StringBuilder strSql = new StringBuilder();
|
||||
strSql.Append("update user_Goods set ");
|
||||
strSql.Append("GoodsName=@GoodsName,");
|
||||
strSql.Append("GoodsPic=@GoodsPic,");
|
||||
strSql.Append("GoodsUrl=@GoodsUrl,");
|
||||
strSql.Append("GoodsBody=@GoodsBody,");
|
||||
strSql.Append("GoodsPrices=@GoodsPrices,");
|
||||
strSql.Append("GoodsPrices0=@GoodsPrices0,");
|
||||
strSql.Append("GoodsPrices1=@GoodsPrices1,");
|
||||
strSql.Append("GoodsPrices2=@GoodsPrices2,");
|
||||
strSql.Append("starttime=@starttime,");
|
||||
strSql.Append("endtime=@endtime,");
|
||||
strSql.Append("GoodsKC=@GoodsKC,");
|
||||
strSql.Append("GoodsNum=@GoodsNum,");
|
||||
strSql.Append("GoodsZT=@GoodsZT,");
|
||||
strSql.Append("utype=@utype");
|
||||
strSql.Append(" where ID=@ID");
|
||||
SqlParameter[] parameters = {
|
||||
new SqlParameter("@GoodsName", SqlDbType.VarChar,200),
|
||||
new SqlParameter("@GoodsPic", SqlDbType.VarChar,200),
|
||||
new SqlParameter("@GoodsUrl", SqlDbType.VarChar,200),
|
||||
new SqlParameter("@GoodsBody", SqlDbType.NText),
|
||||
new SqlParameter("@GoodsPrices", SqlDbType.Money),
|
||||
new SqlParameter("@GoodsPrices0", SqlDbType.Money),
|
||||
new SqlParameter("@GoodsPrices1", SqlDbType.Money),
|
||||
new SqlParameter("@GoodsPrices2", SqlDbType.Money),
|
||||
new SqlParameter("@starttime", SqlDbType.VarChar,50),
|
||||
new SqlParameter("@endtime", SqlDbType.VarChar,50),
|
||||
new SqlParameter("@GoodsKC", SqlDbType.Int),
|
||||
new SqlParameter("@GoodsNum", SqlDbType.Int),
|
||||
new SqlParameter("@GoodsZT", SqlDbType.Int),
|
||||
new SqlParameter("@utype", SqlDbType.Int),
|
||||
new SqlParameter("@ID", SqlDbType.Int)};
|
||||
parameters[0].Value = model.GoodsName;
|
||||
parameters[1].Value = model.GoodsPic;
|
||||
parameters[2].Value = model.GoodsUrl;
|
||||
parameters[3].Value = model.GoodsBody;
|
||||
parameters[4].Value = model.GoodsPrices;
|
||||
parameters[5].Value = model.GoodsPrices0;
|
||||
parameters[6].Value = model.GoodsPrices1;
|
||||
parameters[7].Value = model.GoodsPrices2;
|
||||
parameters[8].Value = model.starttime;
|
||||
parameters[9].Value = model.endtime;
|
||||
parameters[10].Value = model.GoodsKC;
|
||||
parameters[11].Value = model.GoodsNum;
|
||||
parameters[12].Value = model.GoodsZT;
|
||||
parameters[13].Value = model.utype;
|
||||
parameters[14].Value = model.Id;
|
||||
|
||||
int rows = Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(strSql.ToString(), parameters);
|
||||
if (rows > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// GoodsZT<5A><54><EFBFBD><EFBFBD>GoodsOrders
|
||||
/// </summary>
|
||||
public int UpdateSeef(string Sel, int SelValue, Int64 Id)
|
||||
{
|
||||
String sql = "update user_Goods set " + Sel + "=@SelValue where Id=@Id";
|
||||
SqlParameter[] para = { new SqlParameter("@SelValue", SqlDbType.Int),
|
||||
new SqlParameter("@Id", SqlDbType.Int, 4) };
|
||||
para[0].Value = SelValue;
|
||||
para[1].Value = Id;
|
||||
return Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(sql, para);
|
||||
}
|
||||
/// <summary>
|
||||
/// ɾ<><C9BE>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
public bool Delete(int Id)
|
||||
{
|
||||
|
||||
StringBuilder strSql = new StringBuilder();
|
||||
strSql.Append("delete from user_Goods ");
|
||||
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><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5>
|
||||
/// </summary>
|
||||
public Mtxfw.Model.user_Goods GetModel(int Id)
|
||||
{
|
||||
|
||||
StringBuilder strSql = new StringBuilder();
|
||||
strSql.Append("select top 1 * from user_Goods ");
|
||||
strSql.Append(" where Id=@Id");
|
||||
SqlParameter[] parameters = {
|
||||
new SqlParameter("@Id", SqlDbType.Int,4)
|
||||
};
|
||||
parameters[0].Value = Id;
|
||||
|
||||
Mtxfw.Model.user_Goods model = new Mtxfw.Model.user_Goods();
|
||||
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());
|
||||
}
|
||||
model.GoodsName = ds.Tables[0].Rows[0]["GoodsName"].ToString();
|
||||
model.GoodsPic = ds.Tables[0].Rows[0]["GoodsPic"].ToString();
|
||||
model.GoodsUrl = ds.Tables[0].Rows[0]["GoodsUrl"].ToString();
|
||||
model.GoodsBody = ds.Tables[0].Rows[0]["GoodsBody"].ToString();
|
||||
if (ds.Tables[0].Rows[0]["GoodsPrices"].ToString() != "")
|
||||
{
|
||||
model.GoodsPrices = Convert.ToDouble(ds.Tables[0].Rows[0]["GoodsPrices"].ToString());
|
||||
}
|
||||
model.GoodsPrices0 = Convert.ToDouble(ds.Tables[0].Rows[0]["GoodsPrices0"].ToString());
|
||||
if (ds.Tables[0].Rows[0]["GoodsPrices1"].ToString() != "")
|
||||
{
|
||||
model.GoodsPrices1 = Convert.ToDouble(ds.Tables[0].Rows[0]["GoodsPrices1"].ToString());
|
||||
}
|
||||
if (ds.Tables[0].Rows[0]["GoodsPrices2"].ToString() != "")
|
||||
{
|
||||
model.GoodsPrices2 = Convert.ToDouble(ds.Tables[0].Rows[0]["GoodsPrices2"].ToString());
|
||||
}
|
||||
model.starttime = ds.Tables[0].Rows[0]["starttime"].ToString();
|
||||
model.endtime = ds.Tables[0].Rows[0]["endtime"].ToString();
|
||||
model.GoodsKC = int.Parse(ds.Tables[0].Rows[0]["GoodsKC"].ToString());
|
||||
model.GoodsNum = int.Parse(ds.Tables[0].Rows[0]["GoodsNum"].ToString());
|
||||
model.GoodsZT = int.Parse(ds.Tables[0].Rows[0]["GoodsZT"].ToString());
|
||||
model.GoodsOrders = int.Parse(ds.Tables[0].Rows[0]["GoodsOrders"].ToString());
|
||||
if (ds.Tables[0].Rows[0]["AddTime"].ToString() != "")
|
||||
{
|
||||
model.AddTime = Convert.ToDateTime(ds.Tables[0].Rows[0]["AddTime"].ToString());
|
||||
}
|
||||
if (ds.Tables[0].Rows[0]["utype"].ToString() != "")
|
||||
{
|
||||
model.utype = int.Parse(ds.Tables[0].Rows[0]["utype"].ToString());
|
||||
}
|
||||
return model;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <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 user_Goods ");
|
||||
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 user_Goods ");
|
||||
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