
/*2011-5-22*/

/*表*/
alter table mymember add  constraint  allow_status_default  default ('1')  for  allowed

alter table [siteconfig] add [bgColor] varchar(50)
alter table [siteconfig] add [bgImage] varchar(50)
alter table [siteconfig] add [PhoneNumStyle] varchar(1)
alter table [siteconfig] add [regPassDefault] varchar(1)

update siteconfig set bgColor='#3B85C3',bgImage='',PhoneNumStyle='2',regPassDefault='1'



/*存储过程*/

create  procedure ListDeliverType
(
@startIndex int,
@endIndex int,
@condition varchar(8000),
@orderCMD varchar(1000),
@doCount int
)
AS
SET NOCOUNT ON
declare @t varchar(8000) 
set @t=
'
 select DeliverTypeID,DeliverTypeName,Charge,NeedTime,Memo into #temp 
 from DeliverType  
 '
+@condition 
+'
 If '+cast(@doCount as varchar)+'=1
   Begin
     select count(*) from #temp
   End
 Else
   Begin
 declare @indextable table(id int identity(1,1),nid int) 
 insert into @indextable(nid) select DeliverTypeID from #temp '+@orderCMD+'
 select * from #temp p inner join @indextable t on p.DeliverTypeID=t.nid 
   where t.id between '+cast(@startIndex as varchar)+' and '+cast(@endIndex as varchar)+' order by t.id 
   End
'
exec (@t)
SET NOCOUNT OFF
GO


CREATE  procedure ListPayway
(
@startIndex int,
@endIndex int,
@condition varchar(8000),
@orderCMD varchar(1000),
@doCount int
)
AS
SET NOCOUNT ON
declare @t varchar(8000) 
set @t=
'
 select PayWayID,PayWayName,MemoTitle,Tips into #temp 
 from PayWay  
 '
+@condition 
+'
 If '+cast(@doCount as varchar)+'=1
   Begin
     select count(*) from #temp
   End
 Else
   Begin
 declare @indextable table(id int identity(1,1),nid int) 
 insert into @indextable(nid) select PayWayID from #temp '+@orderCMD+'
 select * from #temp p inner join @indextable t on p.PayWayID=t.nid 
   where t.id between '+cast(@startIndex as varchar)+' and '+cast(@endIndex as varchar)+' order by t.id 
   End
'
exec (@t)
SET NOCOUNT OFF
GO

ALTER  procedure ListScheme
(
@startIndex int,
@endIndex int,
@condition varchar(8000),
@orderCMD varchar(1000),
@doCount int
)
AS
SET NOCOUNT ON
declare @t varchar(8000) 
set @t=
'
 select ID,name,companyname=c.categoryname,brandname=b.categoryname,brandid,areaname into #temp 
 from pro_scheme s 
 inner join category b on s.brandID=b.categoryID 
 inner join category c on b.parentID=c.categoryID
 inner join Area a on s.cityid=a.areaid
 '
+@condition 
+@orderCMD 
+'
 If '+cast(@doCount as varchar)+'=1
   Begin
     select count(*) from #temp
   End
 Else
   Begin
 declare @indextable table(id int identity(1,1),nid int) 
 insert into @indextable(nid) select ID from #temp 
 select * from #temp p inner join @indextable t on p.ID=t.nid 
   where t.id between '+cast(@startIndex as varchar)+' and '+cast(@endIndex as varchar)+' order by t.id 
   End
'
exec (@t)
SET NOCOUNT OFF
GO


create  procedure NewProduct
AS
SET NOCOUNT ON

 select top 24 ProductID,ProductName,Property1,Price,CityName,ProvinceName,
CategoryName=catName,p.AddTime,p.Recommend,
SellOut=case SellOut when '1' then '<font color=gray>已售</font>' else '<font color=green>有货</font>' end 
 from Product p 
 where m_Allowed='1' and m_grade='3'
 order by p.AddTime desc

SET NOCOUNT OFF

GO



ALTER procedure RecommendProduct
AS
SET NOCOUNT ON

 select top 24 ProductID,ProductName,Property1,Price,CityName,ProvinceName,
CategoryName=catName,p.AddTime,p.Recommend,
SellOut=case SellOut when '1' then '<font color=gray>已售</font>' else '<font color=green>有货</font>' end
 from Product p 
 where m_Allowed='1' and m_grade='3' and p.Recommend='1'
 order by p.AddTime desc

SET NOCOUNT OFF
GO


ALTER procedure free_NewProduct
AS
SET NOCOUNT ON

 select top 6 ProductID,ProductName,Property1,Price,CityName,ProvinceName,
CategoryName=catName,p.AddTime,p.Recommend,
SellOut=case SellOut when '1' then '<font color=gray>已售</font>' else '<font color=green>有货</font>' end 
 from Product p 
 where m_Allowed='1' and m_grade<>'3'
 order by p.AddTime desc

SET NOCOUNT OFF
GO


/*数据*/


update info set title='广告编号：D-001 (位置：会员主页左侧)' where infoid=31
update info set title='广告编号：C-001 (位置：会员中心左侧)' where infoid=35
update info set title='广告编号：B-001 (位置：内页右侧)' where infoid=34
update info set title='广告编号：A-001 (位置：首页左侧1)' where infoid=37
update info set title='广告编号：A-008 (位置：首页右侧6)' where infoid=33
insert into info(title,sortid) values('广告编号：A-002 (位置：首页左侧2)',2)
insert into info(title,sortid) values('广告编号：A-003 (位置：首页右侧1)',2)
insert into info(title,sortid) values('广告编号：A-004 (位置：首页右侧2)',2)
insert into info(title,sortid) values('广告编号：A-005 (位置：首页右侧3)',2)
insert into info(title,sortid) values('广告编号：A-006 (位置：首页右侧4)',2)
insert into info(title,sortid) values('广告编号：A-007 (位置：首页右侧5)',2)