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_Groups_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(); } protected void Update() { #region Get Data DataSet DS = ClSqlCmd.DataSetSel(@" SELECT [Group_ID] ,[GroupName] ,[Module_ID] ,[Order] ,[UpperMenu_Name] ,[FooterMenu_Name] ,[Active] FROM [dbo].[__StandardEngine_T_Groups] where ["+Request.Params["Location"].Replace("'","")+@"_Name] is not NULL and [Active]=1 and [Module_ID]=" + System.Configuration.ConfigurationSettings.AppSettings["SE_ModuleID"]+ @" Order by [Order] asc, [Group_ID] asc" ); #endregion #region Validation bool bool_Valid = true; if (!bool_Valid) return; #endregion if (Request.Params["Dir"] == "up") { if (Request.Params["i"] != "0") { //update current ClSqlCmd.CommandExc(@" update [dbo].[__StandardEngine_T_Groups] set [Order]=" + DS.Tables[0].Rows[Convert.ToInt32(Request.Params["i"].Replace("'","")) - 1]["Order"].ToString() + @" where [Group_ID]=" + DS.Tables[0].Rows[Convert.ToInt32(Request.Params["i"].Replace("'", ""))]["Group_ID"].ToString() ); //update Prev ClSqlCmd.CommandExc(@" update [dbo].[__StandardEngine_T_Groups] set [Order]=" + DS.Tables[0].Rows[Convert.ToInt32(Request.Params["i"].Replace("'", ""))]["Order"].ToString() + @" where [Group_ID]=" + DS.Tables[0].Rows[Convert.ToInt32(Request.Params["i"].Replace("'", "")) - 1]["Group_ID"].ToString() ); } } else { if (Convert.ToInt32( Request.Params["i"] ) < DS.Tables[0].Rows.Count) { //update current ClSqlCmd.CommandExc(@" update [dbo].[__StandardEngine_T_Groups] set [Order]=" + DS.Tables[0].Rows[Convert.ToInt32(Request.Params["i"].Replace("'", ""))+1]["Order"].ToString() + @" where [Group_ID]=" + DS.Tables[0].Rows[Convert.ToInt32(Request.Params["i"].Replace("'", ""))]["Group_ID"].ToString() ); //update Prev ClSqlCmd.CommandExc(@" update [dbo].[__StandardEngine_T_Groups] set [Order]=" + DS.Tables[0].Rows[Convert.ToInt32(Request.Params["i"].Replace("'", ""))]["Order"].ToString() + @" where [Group_ID]=" + DS.Tables[0].Rows[Convert.ToInt32(Request.Params["i"].Replace("'", ""))+1]["Group_ID"].ToString() ); } } /////////////////////////////////////////////////////////////////// Response.Redirect(Server.UrlDecode(Request.Params["retP"])); } }