Create procedure Sp_UpdateUpDown
(
@catId int,
@Action int
)
AS
BEGIN
Declare @orderNo int
Declare @NorderNo int
Declare @NeighbourId int
SET @NeighbourId=0
SELECT @orderNo=displayOrder FROM tblPartnerCategory WHERE catID=@catId
IF @Action =1
BEGIN
SET @NeighbourId = (SELECT TOP 1 catID FROM tblPartnerCategory WHERE displayOrder < @orderNo order by displayOrder DESC)
END
ELSE
BEGIN
SET @NeighbourId = (SELECT TOP 1 catID FROM tblPartnerCategory WHERE displayOrder > @orderNo order by displayOrder ASC)
END
SELECT @NorderNo=displayOrder FROM tblPartnerCategory WHERE catID=@NeighbourId
IF @NeighbourId > 0
BEGIN
UPDATE tblPartnerCategory SET displayOrder=@NorderNo WHERE catID=@catId
UPDATE tblPartnerCategory SET displayOrder=@orderNo WHERE catID=@NeighbourId
END
END
if (e.CommandName == "Up")
{
objAlbum.UpdateUpDown(Convert.ToInt32(e.CommandArgument), 1);
FillCategory();
}
else if (e.CommandName == "Down")
{
objAlbum.UpdateUpDown(Convert.ToInt32(e.CommandArgument), 0);
FillCategory();
}
public void UpdateUpDown(int catId, int action)
{
SqlParameter[] paramsToStore = new SqlParameter[3];
paramsToStore[0] = new SqlParameter("@catId", SqlDbType.Int);
paramsToStore[0].Value = catId;
paramsToStore[1] = new SqlParameter("@Action", SqlDbType.Int);
paramsToStore[1].Value = action;
SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, "Sp_UpdateUpDown", paramsToStore);
}
(
@catId int,
@Action int
)
AS
BEGIN
Declare @orderNo int
Declare @NorderNo int
Declare @NeighbourId int
SET @NeighbourId=0
SELECT @orderNo=displayOrder FROM tblPartnerCategory WHERE catID=@catId
IF @Action =1
BEGIN
SET @NeighbourId = (SELECT TOP 1 catID FROM tblPartnerCategory WHERE displayOrder < @orderNo order by displayOrder DESC)
END
ELSE
BEGIN
SET @NeighbourId = (SELECT TOP 1 catID FROM tblPartnerCategory WHERE displayOrder > @orderNo order by displayOrder ASC)
END
SELECT @NorderNo=displayOrder FROM tblPartnerCategory WHERE catID=@NeighbourId
IF @NeighbourId > 0
BEGIN
UPDATE tblPartnerCategory SET displayOrder=@NorderNo WHERE catID=@catId
UPDATE tblPartnerCategory SET displayOrder=@orderNo WHERE catID=@NeighbourId
END
END
if (e.CommandName == "Up")
{
objAlbum.UpdateUpDown(Convert.ToInt32(e.CommandArgument), 1);
FillCategory();
}
else if (e.CommandName == "Down")
{
objAlbum.UpdateUpDown(Convert.ToInt32(e.CommandArgument), 0);
FillCategory();
}
public void UpdateUpDown(int catId, int action)
{
SqlParameter[] paramsToStore = new SqlParameter[3];
paramsToStore[0] = new SqlParameter("@catId", SqlDbType.Int);
paramsToStore[0].Value = catId;
paramsToStore[1] = new SqlParameter("@Action", SqlDbType.Int);
paramsToStore[1].Value = action;
SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, "Sp_UpdateUpDown", paramsToStore);
}
No comments:
Post a Comment