using System; using System.Data; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class Admin_EditorPage_Update_Order : System.Web.UI.Page { DBAccess.DBAccess ClSqlCmd; public void Page_Load(object sender, EventArgs e) { ClSqlCmd = new DBAccess.DBAccess(System.Configuration.ConfigurationSettings.AppSettings["SE_ConnectionString"]); ////////////////////////////////////////////////////////////////////////// Update(); /////////////////////////////////////////////////////////////////// Response.Redirect(Server.UrlDecode(Request.Params["retP"])); } protected void Update() { string str_Parent_EditorPage_ID = ""; string str_EditorPage_Type_ID = ""; #region Get Data DataSet DS_Data=ClSqlCmd.DataSetSel(@" SELECT [Parent_EditorPage_ID], [EditorPage_Type_ID] FROM [dbo].[__StandardEngine_T_EditorPages] where [EditorPage_ID]=" + Request.Params["EPID"].Replace("'","") ); str_Parent_EditorPage_ID = DS_Data.Tables[0].Rows[0]["Parent_EditorPage_ID"].ToString(); str_EditorPage_Type_ID = DS_Data.Tables[0].Rows[0]["EditorPage_Type_ID"].ToString(); DataSet DS = ClSqlCmd.DataSetSel(@" SELECT [EditorPage_ID] ,[Order] FROM [dbo].[__StandardEngine_T_EditorPages] where [Parent_EditorPage_ID]="+str_Parent_EditorPage_ID+ @" and [EditorPage_Type_ID]=" + str_EditorPage_Type_ID + @" order by [Order] asc ,[EditorPage_ID] asc" ); #endregion if (Request.Params["Dir"] == "up") { if (Request.Params["i"] != "0") { //update current ClSqlCmd.CommandExc(@" update [dbo].[__StandardEngine_T_EditorPages] set [Order]=" + DS.Tables[0].Rows[Convert.ToInt32(Request.Params["i"].Replace("'", "")) - 1]["Order"].ToString() + @" where [EditorPage_ID]=" + DS.Tables[0].Rows[Convert.ToInt32(Request.Params["i"].Replace("'", ""))]["EditorPage_ID"].ToString() ); //update Prev ClSqlCmd.CommandExc(@" update [dbo].[__StandardEngine_T_EditorPages] set [Order]=" + DS.Tables[0].Rows[Convert.ToInt32(Request.Params["i"].Replace("'", ""))]["Order"].ToString() + @" where [EditorPage_ID]=" + DS.Tables[0].Rows[Convert.ToInt32(Request.Params["i"].Replace("'", "")) - 1]["EditorPage_ID"].ToString() ); } } else { if ((Convert.ToInt32(Request.Params["i"])+1) < DS.Tables[0].Rows.Count) { //update current ClSqlCmd.CommandExc(@" update [dbo].[__StandardEngine_T_EditorPages] set [Order]=" + DS.Tables[0].Rows[Convert.ToInt32(Request.Params["i"].Replace("'", "")) + 1]["Order"].ToString() + @" where [EditorPage_ID]=" + DS.Tables[0].Rows[Convert.ToInt32(Request.Params["i"].Replace("'", ""))]["EditorPage_ID"].ToString() ); //update Prev ClSqlCmd.CommandExc(@" update [dbo].[__StandardEngine_T_EditorPages] set [Order]=" + DS.Tables[0].Rows[Convert.ToInt32(Request.Params["i"].Replace("'", ""))]["Order"].ToString() + @" where [EditorPage_ID]=" + DS.Tables[0].Rows[Convert.ToInt32(Request.Params["i"].Replace("'", "")) + 1]["EditorPage_ID"].ToString() ); } } } }