You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

522 lines
25 KiB
C#

using System;
using System.Text;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Data.SqlClient;
using System.Collections.Generic;
using NetLibrary;
using NetLibrary.Data;
using NetLibrary.ReportPrint;
using TradeModel;
namespace TradeData
{
public class HY_MemberScore
{
#region 保存
public int SaveGift(HY_Gift Model)
{
string tsql = @"
if @GiftId>0
begin
Update [HY_Gift] set [GiftName]=@GiftName,[ImageUrl]=@ImageUrl,[ImageIds]=@ImageIds,[ChangeScore]=@ChangeScore,[Price]=@Price,[GiftDesc]=@GiftDesc,[Num]=@Num,[ShopId]=@ShopId,[State]=@State,[SDate]=@SDate,[EDate]=@EDate,[UseRule]=@UseRule where GiftId=@GiftId
end
else
begin
INSERT INTO [HY_Gift]([GiftName],[ImageUrl],[ImageIds],[ChangeScore],[Price],[GiftDesc],[Num],[LeftNum],[ShopId],[InDate],[InUserId],[State],[SDate],[EDate],[UseRule])values(@GiftName,@ImageUrl,@ImageIds,@ChangeScore,@Price,@GiftDesc,@Num,@LeftNum,@ShopId,@InDate,@InUserId,@State,@SDate,@EDate,@UseRule)
set @GiftId=SCOPE_IDENTITY()
end
select @GiftId";
Database db = DatabaseFactory.CreateDatabase();
DbCommand cmd = db.GetSqlStringCommand(tsql);
db.AddInParameter(cmd, "@GiftId", DbType.Int32, Model.GiftId);
db.AddInParameter(cmd, "@GiftName", DbType.String, Model.GiftName);
db.AddInParameter(cmd, "@ImageUrl", DbType.String, Model.ImageUrl);
db.AddInParameter(cmd, "@ImageIds", DbType.String, Model.ImageIds);
db.AddInParameter(cmd, "@ChangeScore", DbType.Int32, Model.ChangeScore);
db.AddInParameter(cmd, "@Price", DbType.Decimal, Model.Price);
db.AddInParameter(cmd, "@GiftDesc", DbType.String, Model.GiftDesc);
db.AddInParameter(cmd, "@Num", DbType.Int32, Model.Num);
db.AddInParameter(cmd, "@LeftNum", DbType.Int32, Model.LeftNum);
db.AddInParameter(cmd, "@ShopId", DbType.Int32, Model.ShopId);
db.AddInParameter(cmd, "@InDate", DbType.DateTime, Model.InDate);
db.AddInParameter(cmd, "@InUserId", DbType.Int32, Model.InUserId);
db.AddInParameter(cmd, "@State", DbType.Int32, Model.State);
db.AddInParameter(cmd, "@SDate", DbType.DateTime, Model.SDate);
db.AddInParameter(cmd, "@EDate", DbType.DateTime, Model.EDate);
db.AddInParameter(cmd, "@UseRule", DbType.String, Model.UseRule);
int a = Convert.ToInt32(db.ExecuteScalar(cmd));
return a;
}
#endregion
#region 删除礼物
public void DeleteGift(int GiftId)
{
string tsql = @"
delete from HY_Gift where GiftId=@GiftId
";
Database db = DatabaseFactory.CreateDatabase();
DbCommand cmd = db.GetSqlStringCommand(tsql);
db.AddInParameter(cmd, "@GiftId", DbType.Int32, GiftId);
db.ExecuteNonQuery(cmd);
}
#endregion
#region 返回Model
public HY_Gift GetGiftModel(int GiftId)
{
HY_Gift model = null;
string tsql = "select * from HY_Gift where GiftId=@GiftId";
Database db = DatabaseFactory.CreateDatabase();
DbCommand cmd = db.GetSqlStringCommand(tsql);
db.AddInParameter(cmd, "@GiftId", DbType.Int32, GiftId);
DataTable tb = db.ExecuteDataTable(cmd);
if (tb.Rows.Count > 0) model = tb.Rows[0].ToModel<HY_Gift>();
return model;
}
#endregion
#region 分页查询礼物
public List<HY_Gift> GetListHY_Gift(RefParameterCollection where, int PageIndex, int PageSize, string Sort, out int RowCount)
{
if (where == null) where = new RefParameterCollection();
QueryService ser = new QueryService();
ser.Fields = @"GiftId=cast(a.GiftId as int),a.GiftName,ImageUrl=case when a.ImageUrl is not null and a.ImageUrl<>'' then '../'+ a.ImageUrl else a.ImageUrl end,a.ImageIds,a.ChangeScore,a.Price,a.GiftDesc,a.Num,a.LeftNum,a.ShopId,a.InDate,a.InUserId,a.State,a.SDate,a.EDate,a.UseRule,StateName=case when a.State=1 then '上架' else '下架' end,b.ShopName";
ser.Tables = @"HY_Gift a inner join Jc_Shop b on a.ShopId=b.ShopId";
ser.Filter = where.GetWhere(System.Data.CommandType.Text);
ser.PageIndex = PageIndex;
ser.PageSize = PageSize;
ser.Sort = Sort;
ser.KeyName = "GiftId";
string tsql = ser.GetText();
where.AddOutParameter("RowCount", System.Data.DbType.Int32); ;
List<HY_Gift> ListModel = null;
Database db = DatabaseFactory.CreateDatabase();
DbCommand cmd = db.GetSqlStringCommand(tsql);
db.AddInParameter(cmd, where);
DataTable tb = db.ExecuteDataTable(cmd);
RowCount = Convert.ToInt32(cmd.Parameters["@RowCount"].Value);
ListModel = tb.ToList<HY_Gift>();
return ListModel;
}
#endregion
#region 保存会员
public int SaveMember(HY_Member Model)
{
string tsql = @"
if @MemberId>0
begin
Update [HY_Member] set [MemberNo]=@MemberNo,[MemberCode]=@MemberCode,[MemberName]=@MemberName,[MemberBirth]=@MemberBirth,[Sex]=@Sex,[CountryCode]=@CountryCode,[CountryName]=@CountryName,[Email]=@Email,[NowScore]=@NowScore,[LJScore]=@LJScore,[MemberGrade]=@MemberGrade,[WorkDesc]=@WorkDesc,[Remark]=@Remark,[LastChangeDate]=@LastChangeDate where MemberId=@MemberId
end
else
begin
INSERT INTO [HY_Member]([MemberNo],[MemberCode],[MemberName],[MemberBirth],[Sex],[CountryCode],[CountryName],[Email],[NowScore],[LJScore],[MemberGrade],[WorkDesc],[Remark],[LastChangeDate])values(@MemberNo,@MemberCode,@MemberName,@MemberBirth,@Sex,@CountryCode,@CountryName,@Email,@NowScore,@LJScore,@MemberGrade,@WorkDesc,@Remark,@LastChangeDate)
set @MemberId=SCOPE_IDENTITY()
end
select @MemberId";
Database db = DatabaseFactory.CreateDatabase();
DbCommand cmd = db.GetSqlStringCommand(tsql);
db.AddInParameter(cmd, "@MemberId", DbType.Int32, Model.MemberId);
db.AddInParameter(cmd, "@MemberNo", DbType.String, Model.MemberNo);
db.AddInParameter(cmd, "@MemberCode", DbType.String, Model.MemberCode);
db.AddInParameter(cmd, "@MemberName", DbType.String, Model.MemberName);
db.AddInParameter(cmd, "@MemberBirth", DbType.DateTime, Model.MemberBirth);
db.AddInParameter(cmd, "@Sex", DbType.String, Model.Sex);
db.AddInParameter(cmd, "@CountryCode", DbType.String, Model.CountryCode);
db.AddInParameter(cmd, "@CountryName", DbType.String, Model.CountryName);
db.AddInParameter(cmd, "@Email", DbType.String, Model.Email);
db.AddInParameter(cmd, "@NowScore", DbType.Int32, Model.NowScore);
db.AddInParameter(cmd, "@LJScore", DbType.Int32, Model.LJScore);
db.AddInParameter(cmd, "@MemberGrade", DbType.String, Model.MemberGrade);
db.AddInParameter(cmd, "@WorkDesc", DbType.String, Model.WorkDesc);
db.AddInParameter(cmd, "@Remark", DbType.String, Model.Remark);
db.AddInParameter(cmd, "@LastChangeDate", DbType.DateTime, Model.LastChangeDate);
int a = Convert.ToInt32(db.ExecuteScalar(cmd));
return a;
}
#endregion
#region 删除会员
public void DeleteMember(int MemberId)
{
string tsql = @"
delete from HY_Member where MemberId=@MemberId
";
Database db = DatabaseFactory.CreateDatabase();
DbCommand cmd = db.GetSqlStringCommand(tsql);
db.AddInParameter(cmd, "@MemberId", DbType.Int32, MemberId);
db.ExecuteNonQuery(cmd);
}
#endregion
#region 返回Model
public HY_Member GetMemberModel(int MemberId)
{
HY_Member model = null;
string tsql = "select * from HY_Member where MemberId=@MemberId";
Database db = DatabaseFactory.CreateDatabase();
DbCommand cmd = db.GetSqlStringCommand(tsql);
db.AddInParameter(cmd, "@MemberId", DbType.Int32, MemberId);
DataTable tb = db.ExecuteDataTable(cmd);
if (tb.Rows.Count > 0) model = tb.Rows[0].ToModel<HY_Member>();
return model;
}
#endregion
#region 分页查询会员
public List<HY_Member> GetListHY_Member(RefParameterCollection where, int PageIndex, int PageSize, string Sort, out int RowCount)
{
if (where == null) where = new RefParameterCollection();
QueryService ser = new QueryService();
ser.Fields = @"MemberId=cast(a.MemberId as int),a.MemberNo,a.MemberCode,a.MemberName,a.MemberBirth,a.Sex,a.CountryCode,a.CountryName,a.Email,a.NowScore,a.LJScore,a.MemberGrade,a.WorkDesc,a.Remark,a.LastChangeDate,b.ShopName";
ser.Tables = @"HY_Member a inner join Jc_Shop b on a.ShopId=b.ShopId";
ser.Filter = where.GetWhere(System.Data.CommandType.Text);
ser.PageIndex = PageIndex;
ser.PageSize = PageSize;
ser.Sort = Sort;
ser.KeyName = "MemberId";
string tsql = ser.GetText();
where.AddOutParameter("RowCount", System.Data.DbType.Int32); ;
List<HY_Member> ListModel = null;
Database db = DatabaseFactory.CreateDatabase();
DbCommand cmd = db.GetSqlStringCommand(tsql);
db.AddInParameter(cmd, where);
DataTable tb = db.ExecuteDataTable(cmd);
RowCount = Convert.ToInt32(cmd.Parameters["@RowCount"].Value);
ListModel = tb.ToList<HY_Member>();
return ListModel;
}
#endregion
#region 会员登陆
public HY_Member MemberLogin(string UserName,string Password)
{
HY_Member model = null;
string tsql = "select top 1 * from HY_Member where [MemberNo]=@UserName and MemberCode=@Password and state=1";
Database db = DatabaseFactory.CreateDatabase();
DbCommand cmd = db.GetSqlStringCommand(tsql);
db.AddInParameter(cmd, "@UserName", DbType.String, UserName);
db.AddInParameter(cmd, "@Password", DbType.String, Password);
DataTable tb = db.ExecuteDataTable(cmd);
if (tb.Rows.Count > 0) model = tb.Rows[0].ToModel<HY_Member>();
return model;
}
#endregion
#region 会员登陆
public HY_Addr GetMember(int memberId)
{
HY_Addr model = null;
string tsql = @"select top 1 a.MemberId,a.MemberName,a.Sex,a.Email,a.MemberBirth,b.Address,b.City,b.Phone,b.PostCode,b.Provice,a.CountryCode from HY_Member a
left join HY_Addr b on a.MemberId=b.MemberId and b.IsDefault=1
where a.MemberId=@memberId";
Database db = DatabaseFactory.CreateDatabase();
DbCommand cmd = db.GetSqlStringCommand(tsql);
db.AddInParameter(cmd, "@memberId", DbType.Int32, memberId);
DataTable tb = db.ExecuteDataTable(cmd);
if (tb.Rows.Count > 0) model = tb.Rows[0].ToModel<HY_Addr>();
return model;
}
#endregion
#region 置顶图片
public List<HY_Gift> GetHotGift()
{
List<HY_Gift> list = null;
string tsql = "select top 5 * from HY_Gift where istop=1 and State=1 order by indate desc";
Database db = DatabaseFactory.CreateDatabase();
DbCommand cmd = db.GetSqlStringCommand(tsql);
DataTable tb = db.ExecuteDataTable(cmd);
if (tb.Rows.Count > 0) list = tb.ToList<HY_Gift>();
return list;
}
#endregion
#region 置顶图片
public List<HY_Gift> GetHot()
{
List<HY_Gift> list = null;
string tsql = "select top 3 * from HY_Gift where State=1 order by Num-LeftNum desc";
Database db = DatabaseFactory.CreateDatabase();
DbCommand cmd = db.GetSqlStringCommand(tsql);
DataTable tb = db.ExecuteDataTable(cmd);
if (tb.Rows.Count > 0) list = tb.ToList<HY_Gift>();
return list;
}
#endregion
#region 置顶图片
public List<HY_Gift> GetHotGift2()
{
List<HY_Gift> list = null;
string tsql = "select top 2 * from HY_Gift where State=1 and giftid not in (select top 5 giftid from HY_Gift where istop=1 and State=1 order by indate desc) order by indate desc ";
Database db = DatabaseFactory.CreateDatabase();
DbCommand cmd = db.GetSqlStringCommand(tsql);
DataTable tb = db.ExecuteDataTable(cmd);
if (tb.Rows.Count > 0) list = tb.ToList<HY_Gift>();
return list;
}
#endregion
#region 置顶图片
public List<HY_Gift> GetHotGift3()
{
List<HY_Gift> list = null;
string tsql = "select top 6 * from HY_Gift where giftid not in (select top 7 giftid from HY_Gift where istop=1 and State=1 order by indate desc) and State=1 order by indate desc";
Database db = DatabaseFactory.CreateDatabase();
DbCommand cmd = db.GetSqlStringCommand(tsql);
DataTable tb = db.ExecuteDataTable(cmd);
if (tb.Rows.Count > 0) list = tb.ToList<HY_Gift>();
return list;
}
#endregion
#region 置顶图片
public List<HY_Gift> GetHotGift4()
{
List<HY_Gift> list = null;
string tsql = "select top 3 * from HY_Gift where giftid not in (select top 7 giftid from HY_Gift where istop=1 and State=1 order by indate desc) and State=1 order by indate desc";
Database db = DatabaseFactory.CreateDatabase();
DbCommand cmd = db.GetSqlStringCommand(tsql);
DataTable tb = db.ExecuteDataTable(cmd);
if (tb.Rows.Count > 0) list = tb.ToList<HY_Gift>();
return list;
}
#endregion
#region 置顶图片
public List<HY_Gift> GetHotGift5()
{
List<HY_Gift> list = null;
string tsql = "select * from HY_Gift where SortId= and State=1 order by indate desc";
Database db = DatabaseFactory.CreateDatabase();
DbCommand cmd = db.GetSqlStringCommand(tsql);
DataTable tb = db.ExecuteDataTable(cmd);
if (tb.Rows.Count > 0) list = tb.ToList<HY_Gift>();
return list;
}
#endregion
#region 保存购物车
public int SaveBuyCart(HY_BuyCart Model)
{
string tsql = @"
if @Id>0
begin
Update [HY_BuyCart] set [GiftId]=@GiftId,[MemberId]=@MemberId,[InDate]=@InDate,[Num]=@Num,[State]=@State,[Note]=@Note where Id=@Id
end
else
begin
INSERT INTO [HY_BuyCart]([GiftId],[MemberId],[InDate],[Num],[State],[Note])values(@GiftId,@MemberId,@InDate,@Num,@State,@Note)
set @Id=SCOPE_IDENTITY()
end
select @Id";
Database db = DatabaseFactory.CreateDatabase();
DbCommand cmd = db.GetSqlStringCommand(tsql);
db.AddInParameter(cmd, "@Id", DbType.Int32, Model.Id);
db.AddInParameter(cmd, "@GiftId", DbType.Int32, Model.GiftId);
db.AddInParameter(cmd, "@MemberId", DbType.Int32, Model.MemberId);
db.AddInParameter(cmd, "@InDate", DbType.DateTime, Model.InDate);
db.AddInParameter(cmd, "@Num", DbType.Int32, Model.Num);
db.AddInParameter(cmd, "@State", DbType.Int32, Model.State);
db.AddInParameter(cmd, "@Note", DbType.String, Model.Note);
int a = Convert.ToInt32(db.ExecuteScalar(cmd));
return a;
}
#endregion
#region 删除购物车
public void DeleteBuyCart(int Id,int State)
{
string tsql = @"
update HY_BuyCart set State=@State where Id=@Id
";
Database db = DatabaseFactory.CreateDatabase();
DbCommand cmd = db.GetSqlStringCommand(tsql);
db.AddInParameter(cmd, "@Id", DbType.Int32, Id);
db.AddInParameter(cmd, "@State", DbType.Int32, State);
db.ExecuteNonQuery(cmd);
}
#endregion
#region 修改剩余
public void UpdateGiftLeft(int GiftId, int Num)
{
string tsql = @"
update HY_Gift set LeftNum=LeftNum-@Num where GiftId=@GiftId
";
Database db = DatabaseFactory.CreateDatabase();
DbCommand cmd = db.GetSqlStringCommand(tsql);
db.AddInParameter(cmd, "@GiftId", DbType.Int32, GiftId);
db.AddInParameter(cmd, "@Num", DbType.Int32, Num);
db.ExecuteNonQuery(cmd);
}
#endregion
#region 修改用户积分
public void UpdateUserScore(int MemberId, int ScoreNum)
{
string tsql = @"
update HY_Member set NowScore=NowScore-@ScoreNum where MemberId=@MemberId
";
Database db = DatabaseFactory.CreateDatabase();
DbCommand cmd = db.GetSqlStringCommand(tsql);
db.AddInParameter(cmd, "@MemberId", DbType.Int32, MemberId);
db.AddInParameter(cmd, "@ScoreNum", DbType.Int32, ScoreNum);
db.ExecuteNonQuery(cmd);
}
#endregion
#region 查询购物车
public List<HY_BuyCart> GetBuyCartList(int MemberId)
{
List<HY_BuyCart> list = null;
string tsql = "select * from HY_BuyCart where MemberId=@MemberId and State=1";
Database db = DatabaseFactory.CreateDatabase();
DbCommand cmd = db.GetSqlStringCommand(tsql);
db.AddInParameter(cmd, "@MemberId", DbType.Int32, MemberId);
DataTable tb = db.ExecuteDataTable(cmd);
if (tb.Rows.Count > 0) list = tb.ToList<HY_BuyCart>();
return list;
}
#endregion
#region 查询购物车
public List<HY_BuyCart> GetBuyCartList2(int MemberId)
{
List<HY_BuyCart> list = null;
string tsql = @"select a.*,b.GiftName,b.ImageUrl,b.ChangeScore,TotalScore=b.ChangeScore*a.Num from HY_BuyCart a
inner join HY_Gift b on a.GiftId=b.GiftId
where a.MemberId=2 and a.State=1";
Database db = DatabaseFactory.CreateDatabase();
DbCommand cmd = db.GetSqlStringCommand(tsql);
db.AddInParameter(cmd, "@MemberId", DbType.Int32, MemberId);
DataTable tb = db.ExecuteDataTable(cmd);
if (tb.Rows.Count > 0) list = tb.ToList<HY_BuyCart>();
return list;
}
#endregion
#region 会员地址
public HY_Addr GetAddr(int MemberId)
{
HY_Addr model = null;
string tsql = "select top 1 * from HY_Addr where MemberId=@MemberId and IsDefault=1";
Database db = DatabaseFactory.CreateDatabase();
DbCommand cmd = db.GetSqlStringCommand(tsql);
db.AddInParameter(cmd, "@MemberId", DbType.Int32, MemberId);
DataTable tb = db.ExecuteDataTable(cmd);
if (tb.Rows.Count > 0) model = tb.Rows[0].ToModel<HY_Addr>();
return model;
}
#endregion
#region 保存兑换记录
public int SaveScoreChange(HY_ScoreChange Model)
{
string tsql = @"
if @Id>0
begin
Update [HY_ScoreChange] set [ChangeScore]=@ChangeScore,[GiftId]=@GiftId,[Num]=@Num,[AddrId]=@AddrId,[MemberId]=@MemberId,[InDate]=@InDate,[InUserId]=@InUserId,[State]=@State,[Note]=@Note where Id=@Id
end
else
begin
INSERT INTO [HY_ScoreChange]([ChangeScore],[GiftId],[Num],[AddrId],[MemberId],[InDate],[InUserId],[State],[Note])values(@ChangeScore,@GiftId,@Num,@AddrId,@MemberId,@InDate,@InUserId,@State,@Note)
set @Id=SCOPE_IDENTITY()
end
select @Id";
Database db = DatabaseFactory.CreateDatabase();
DbCommand cmd = db.GetSqlStringCommand(tsql);
db.AddInParameter(cmd, "@Id", DbType.Int32, Model.Id);
db.AddInParameter(cmd, "@ChangeScore", DbType.Int32, Model.ChangeScore);
db.AddInParameter(cmd, "@GiftId", DbType.Int32, Model.GiftId);
db.AddInParameter(cmd, "@Num", DbType.Int32, Model.Num);
db.AddInParameter(cmd, "@AddrId", DbType.Int32, Model.AddrId);
db.AddInParameter(cmd, "@MemberId", DbType.Int32, Model.MemberId);
db.AddInParameter(cmd, "@InDate", DbType.DateTime, Model.InDate);
db.AddInParameter(cmd, "@InUserId", DbType.Int32, Model.InUserId);
db.AddInParameter(cmd, "@State", DbType.Int32, Model.State);
db.AddInParameter(cmd, "@Note", DbType.String, Model.Note);
int a = Convert.ToInt32(db.ExecuteScalar(cmd));
return a;
}
#endregion
#region 保存地址
public int SaveAddr(HY_Addr Model)
{
string tsql = @"
if @AddrId>0
begin
Update [HY_Addr] set [MemberId]=@MemberId,[CountryCode]=@CountryCode,[Provice]=@Provice,[City]=@City,[Address]=@Address,[PostCode]=@PostCode,[IsDefault]=@IsDefault,[Phone]=@Phone where AddrId=@AddrId
end
else
begin
INSERT INTO [HY_Addr]([MemberId],[CountryCode],[Provice],[City],[Address],[PostCode],[IsDefault],[Phone])values(@MemberId,@CountryCode,@Provice,@City,@Address,@PostCode,@IsDefault,@Phone)
set @AddrId=SCOPE_IDENTITY()
end
select @AddrId";
Database db = DatabaseFactory.CreateDatabase();
DbCommand cmd = db.GetSqlStringCommand(tsql);
db.AddInParameter(cmd, "@AddrId", DbType.Int32, Model.AddrId);
db.AddInParameter(cmd, "@MemberId", DbType.Int32, Model.MemberId);
db.AddInParameter(cmd, "@CountryCode", DbType.String, Model.CountryCode);
db.AddInParameter(cmd, "@Provice", DbType.String, Model.Provice);
db.AddInParameter(cmd, "@City", DbType.String, Model.City);
db.AddInParameter(cmd, "@Address", DbType.String, Model.Address);
db.AddInParameter(cmd, "@PostCode", DbType.String, Model.PostCode);
db.AddInParameter(cmd, "@IsDefault", DbType.Int32, Model.IsDefault);
db.AddInParameter(cmd, "@Phone", DbType.String, Model.Phone);
int a = Convert.ToInt32(db.ExecuteScalar(cmd));
return a;
}
#endregion
#region 保存地址
public void SaveAddr2(HY_Addr Model)
{
string tsql = @"
Update [HY_Addr] set [CountryCode]=@CountryCode,[Provice]=@Provice,[City]=@City,[Address]=@Address,[PostCode]=@PostCode,[Phone]=@Phone where MemberId=@MemberId and IsDefault=1
update HY_Member set Sex=@Sex,MemberBirth=@MemberBirth,Email=@Email,MemberName=@MemberName where MemberId=@MemberId
";
Database db = DatabaseFactory.CreateDatabase();
DbCommand cmd = db.GetSqlStringCommand(tsql);
db.AddInParameter(cmd, "@AddrId", DbType.Int32, Model.AddrId);
db.AddInParameter(cmd, "@MemberId", DbType.Int32, Model.MemberId);
db.AddInParameter(cmd, "@CountryCode", DbType.String, Model.CountryCode);
db.AddInParameter(cmd, "@Provice", DbType.String, Model.Provice);
db.AddInParameter(cmd, "@City", DbType.String, Model.City);
db.AddInParameter(cmd, "@Address", DbType.String, Model.Address);
db.AddInParameter(cmd, "@PostCode", DbType.String, Model.PostCode);
db.AddInParameter(cmd, "@IsDefault", DbType.Int32, Model.IsDefault);
db.AddInParameter(cmd, "@Phone", DbType.String, Model.Phone);
db.AddInParameter(cmd, "@Email", DbType.String, Model.Email);
db.AddInParameter(cmd, "@MemberName", DbType.String, Model.MemberName);
db.AddInParameter(cmd, "@Sex", DbType.String, Model.Sex);
db.AddInParameter(cmd, "@MemberBirth", DbType.DateTime, Model.MemberBirth);
db.ExecuteNonQuery(cmd);
}
#endregion
#region 分页查询
public List<HY_Gift> GetListHY_Gift2(RefParameterCollection where, int PageIndex, int PageSize, string Sort, out int RowCount)
{
if (where == null) where = new RefParameterCollection();
QueryService ser = new QueryService();
ser.Fields = @"GiftId=cast(a.GiftId as int),a.GiftName,a.ImageUrl,a.ImageIds,a.ChangeScore,a.Price,a.GiftDesc,a.Num,a.LeftNum,a.ShopId,a.InDate,a.InUserId,a.State,a.SDate,a.EDate,a.UseRule,a.LinkUrl,a.IsTop,a.SortId";
ser.Tables = @"HY_Gift a";
ser.Filter = where.GetWhere(System.Data.CommandType.Text);
ser.PageIndex = PageIndex;
ser.PageSize = PageSize;
ser.Sort = Sort;
ser.KeyName = "GiftId";
string tsql = ser.GetText();
where.AddOutParameter("RowCount", System.Data.DbType.Int32); ;
List<HY_Gift> ListModel = null;
Database db = DatabaseFactory.CreateDatabase();
DbCommand cmd = db.GetSqlStringCommand(tsql);
db.AddInParameter(cmd, where);
DataTable tb = db.ExecuteDataTable(cmd);
RowCount = Convert.ToInt32(cmd.Parameters["@RowCount"].Value);
ListModel = tb.ToList<HY_Gift>();
return ListModel;
}
#endregion
}
}