using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public partial class Admin_Groups_Update : 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"]); /////////////////////////////////////////////////////////////////////////// if (!Page.IsPostBack) { GetData(); } } void GetData() { DataSet DS = ClSqlCmd.DataSetSel(@" SELECT dbo.__StandardEngine_T_Groups.Group_ID, dbo.__StandardEngine_T_Groups.GroupName, dbo.__StandardEngine_T_Groups.Module_ID, dbo.__StandardEngine_T_Groups.[Order], dbo.__StandardEngine_T_Groups.UpperMenu_Name, dbo.__StandardEngine_T_Groups.FooterMenu_Name, dbo.__StandardEngine_T_Groups.Active, dbo.__StandardEngine_T_EditorPages.EditorPage_ID, dbo.__StandardEngine_T_EditorPages.EditorPage_Type_ID, dbo.__StandardEngine_T_EditorPages.Parent_EditorPage_ID FROM dbo.__StandardEngine_T_Groups INNER JOIN dbo.__StandardEngine_T_EditorPages ON dbo.__StandardEngine_T_Groups.Group_ID = dbo.__StandardEngine_T_EditorPages.Group_ID where dbo.__StandardEngine_T_EditorPages.EditorPage_Type_ID=9 and dbo.__StandardEngine_T_Groups.Group_ID=" + Request.Params["ID"].Replace("'", "").Trim()+@" Order by dbo.__StandardEngine_T_EditorPages.Parent_EditorPage_ID asc"); if (DS.Tables.Count > 0 && DS.Tables[0].Rows.Count > 0) { if (DS.Tables[0].Rows[0]["GroupName"] != Convert.DBNull) txt_GroupName.Text = DS.Tables[0].Rows[0]["GroupName"].ToString(); cb_UpperMenu_Name.Checked = DS.Tables[0].Rows[0]["UpperMenu_Name"] != Convert.DBNull ? true : false; if (DS.Tables[0].Rows.Count >= 1) { hdn_UpperMenu_Name.Value = DS.Tables[0].Rows[0]["EditorPage_ID"].ToString(); lnk_UpperMenu_EditorPage.NavigateUrl = "EditorPage.aspx?EPID=" + DS.Tables[0].Rows[0]["EditorPage_ID"].ToString() + "&ND=1&Type=9&Title=تعديل%20محتوى&retP=" + Request.Params["retP"]; } cb_FooterMenu_Name.Checked = DS.Tables[0].Rows[0]["FooterMenu_Name"] != Convert.DBNull ? true : false; if (DS.Tables[0].Rows.Count >= 2) { hdn_FooterMenu_Name.Value = DS.Tables[0].Rows[1]["EditorPage_ID"].ToString(); lnk_FooterMenu_EditorPage.NavigateUrl = "EditorPage.aspx?EPID=" + DS.Tables[0].Rows[1]["EditorPage_ID"].ToString() + "&ND=1&Type=9&Title=تعديل%20محتوى&retP=" + Request.Params["retP"]; } if (DS.Tables[0].Rows[0]["Active"] != Convert.DBNull) rbl_Active.SelectedValue = DS.Tables[0].Rows[0]["Active"].ToString(); } } protected void Button1_Click(object sender, EventArgs e) { #region Validation bool bool_Valid = true; if (!cb_UpperMenu_Name.Checked && !cb_FooterMenu_Name.Checked) { bool_Valid = false; td_Meg_Error.Visible = true; } if (!bool_Valid) return; #endregion #region Variables string str_Group_ID; string str_GroupName; string str_Module_ID; string str_Order; string str_UpperMenu_Name; string str_FooterMenu_Name; string str_Active; string str_EditorPage_ID_Main; string str_EditorPage_ID; string str_LinkHref_ID; string str_LinkHref_Href; string str_LinkHref_Target; string str_Link_ID; string str_Text; #endregion #region Update str_GroupName = txt_GroupName.Text != "" ? ("N'" + txt_GroupName.Text + "'") : "NULL"; str_UpperMenu_Name = cb_UpperMenu_Name.Checked ? ("N'" + txt_GroupName.Text + "'") : "NULL"; str_FooterMenu_Name = cb_FooterMenu_Name.Checked ? ("N'" + txt_GroupName.Text + "'") : "NULL"; str_Active = rbl_Active.SelectedValue; ClSqlCmd.CommandExc(@" update [dbo].[__StandardEngine_T_Groups] set [GroupName]="+str_GroupName+@" ,[UpperMenu_Name]="+str_UpperMenu_Name+@" ,[FooterMenu_Name]="+str_FooterMenu_Name+@" ,[Active]="+str_Active+@" where [Group_ID]="+Request.Params["ID"].Replace("'","").Trim()); #endregion /////////////////////////////////////////////////////////////////////// if (Request.Params["retP"] != null && Request.Params["retP"] != "") { Response.Redirect(Server.UrlDecode(Request.Params["retP"])); } /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// str_EditorPage_ID_Main = ClSqlCmd.DataSetSel(@"select [dbo].[__StandardEngine_F_Group_FirstPage](" + Request.Params["ID"].Replace("'", "") + ")").Tables[0].Rows[0][0].ToString(); if (cb_UpperMenu_Name.Checked && hdn_UpperMenu_Name.Value.Trim() == "") { #region Insert Upper Menu #region Insert Editorpage //insert editor page for group str_EditorPage_ID = ClSqlCmd.DataSetSel("select dbo.__StandardEngine_F_MaxID_EditorPages()+1").Tables[0].Rows[0][0].ToString(); ClSqlCmd.CommandExc(@" INSERT INTO [dbo].[__StandardEngine_T_EditorPages] ([EditorPage_ID] ,[Module_ID] ,[Parent_EditorPage_ID] ,[EditorPage_Type_ID] ,[Group_ID]) VALUES (" + str_EditorPage_ID + @" , " + System.Configuration.ConfigurationSettings.AppSettings["SE_ModuleID"] + @", [dbo].[__StandardEngine_F_EditorPage__Type](1001," + System.Configuration.ConfigurationSettings.AppSettings["SE_ModuleID"] + @"), 9, " + Request.Params["ID"].Replace("'", "") + @" )" ); #endregion #region Insert LinkHref_ID str_LinkHref_ID = ClSqlCmd.DataSetSel("select dbo.__StandardEngine_F_MaxID_LinkHref()+1").Tables[0].Rows[0][0].ToString(); str_LinkHref_Href = "N'Page.aspx?ID=" + str_EditorPage_ID_Main + "'"; str_LinkHref_Target = "N'_self'"; ClSqlCmd.CommandExc(@" INSERT INTO [dbo].[__StandardEngine_T_LinkHref] ([LinkHref_ID] ,[LinkHref_Href] ,[LinkHref_Target]) VALUES ( " + str_LinkHref_ID + @", " + str_LinkHref_Href + @", " + str_LinkHref_Target + @" )"); #endregion #region Insert Link str_Link_ID = ClSqlCmd.DataSetSel("select dbo.__StandardEngine_F_MaxID_Link()+1").Tables[0].Rows[0][0].ToString(); str_Text = "N'" + txt_GroupName.Text.Replace("'", "''") + "'"; ClSqlCmd.CommandExc(@" INSERT INTO [dbo].[__StandardEngine_T_Link] ([Link_ID] ,[Text] ,[Class] ,[LinkHref_ID] ,[EditorPage_ID] ,[Order]) VALUES (" + str_Link_ID + @" ," + str_Text + @" ," + "N'UpperMenu_Menu'" + @" ," + str_LinkHref_ID + @" ," + str_EditorPage_ID + @" ,1)" ); #endregion #endregion hdn_UpperMenu_Name.Value = txt_GroupName.Text; } if (cb_FooterMenu_Name.Checked && hdn_FooterMenu_Name.Value.Trim() == "") { #region Insert Footer Menu #region Insert Editorpage //insert editor page for group str_EditorPage_ID = ClSqlCmd.DataSetSel("select dbo.__StandardEngine_F_MaxID_EditorPages()+1").Tables[0].Rows[0][0].ToString(); ClSqlCmd.CommandExc(@" INSERT INTO [dbo].[__StandardEngine_T_EditorPages] ([EditorPage_ID] ,[Module_ID] ,[Parent_EditorPage_ID] ,[EditorPage_Type_ID] ,[Group_ID]) VALUES (" + str_EditorPage_ID + @" , " + System.Configuration.ConfigurationSettings.AppSettings["SE_ModuleID"] + @", [dbo].[__StandardEngine_F_EditorPage__Type](2001," + System.Configuration.ConfigurationSettings.AppSettings["SE_ModuleID"] + @"), 9, " + Request.Params["ID"].Replace("'", "") + @" )" ); #endregion #region Insert LinkHref_ID str_LinkHref_ID = ClSqlCmd.DataSetSel("select dbo.__StandardEngine_F_MaxID_LinkHref()+1").Tables[0].Rows[0][0].ToString(); str_LinkHref_Href = "N'Page.aspx?ID=" + str_EditorPage_ID_Main + "'"; str_LinkHref_Target = "N'_self'"; ClSqlCmd.CommandExc(@" INSERT INTO [dbo].[__StandardEngine_T_LinkHref] ([LinkHref_ID] ,[LinkHref_Href] ,[LinkHref_Target]) VALUES ( " + str_LinkHref_ID + @", " + str_LinkHref_Href + @", " + str_LinkHref_Target + @" )"); #endregion #region Insert Link str_Link_ID = ClSqlCmd.DataSetSel("select dbo.__StandardEngine_F_MaxID_Link()+1").Tables[0].Rows[0][0].ToString(); str_Text = "N'" + txt_GroupName.Text.Replace("'", "''") + "'"; ClSqlCmd.CommandExc(@" INSERT INTO [dbo].[__StandardEngine_T_Link] ([Link_ID] ,[Text] ,[Class] ,[LinkHref_ID] ,[EditorPage_ID] ,[Order]) VALUES (" + str_Link_ID + @" ," + str_Text + @" ," + "N'FooterMenu_Menu'" + @" ," + str_LinkHref_ID + @" ," + str_EditorPage_ID + @" ,1)" ); #endregion #endregion hdn_FooterMenu_Name.Value = txt_GroupName.Text; } } }