public string generatePageAlias(string strPageName) { string strAlias = ""; if (strPageName != "") { if (ddlParent.SelectedIndex > 0) { objMenuItem = new tblMenuItem(); DataTable dtMenuItems = objMenuItem.GetSiteMapDT(Convert.ToInt32(ddlParent.SelectedValue)); if (dtMenuItems.Rows.Count > 0) { for (int i = 0; i <= dtMenuItems.Rows.Count - 1; i++) { if (dtMenuItems.Rows[i][tblPage.ColumnNames.AppAlias].ToString() != "") { strAlias += dtMenuItems.Rows[i][tblPage.ColumnNames.AppAlias].ToString() + "/"; } } } } strAlias += strPageName.Replace(" ", "-"); strAlias = strAlias.Replace("_", "-"); } else { DInfo.ShowMessage("Please enter page name to generate alias", Enums.MessageType.Warning); } return(strAlias); }
public static int Delete(Guid id) { try { using (FoodOrderSystemEntities dc = new FoodOrderSystemEntities()) { tblMenuItem deletedrow = dc.tblMenuItems.FirstOrDefault(a => a.Id == id); if (deletedrow != null) { dc.tblMenuItems.Remove(deletedrow); return(dc.SaveChanges()); } else { return(0); } } } catch (Exception ex) { throw ex; } }
public static int Update(MenuItem menuItem) { try { using (FoodOrderSystemEntities dc = new FoodOrderSystemEntities()) { tblMenuItem updatedrow = dc.tblMenuItems.FirstOrDefault(a => a.Id == menuItem.Id); if (updatedrow != null) { updatedrow.ItemName = menuItem.ItemName; updatedrow.Price = menuItem.Price; return(dc.SaveChanges()); } else { return(0); } } } catch (Exception ex) { throw ex; } }
public static MenuItem LoadById(Guid id) { try { using (FoodOrderSystemEntities dc = new FoodOrderSystemEntities()) { tblMenuItem MenuItemRow = dc.tblMenuItems.FirstOrDefault(a => a.Id == id); if (MenuItemRow != null) { return(new MenuItem { Id = MenuItemRow.Id, ItemName = MenuItemRow.ItemName, Price = (float)MenuItemRow.Price, }); } else { throw new Exception("Row not found..."); } } } catch (Exception ex) { throw ex; } }
public static bool Insert(string itemName, float price) { try { using (FoodOrderSystemEntities dc = new FoodOrderSystemEntities()) { // Make a new row tblMenuItem newrow = new tblMenuItem(); // Set the properties newrow.Id = Guid.NewGuid(); newrow.ItemName = itemName; newrow.Price = price; // Do the Insert dc.tblMenuItems.Add(newrow); // Commit the insert dc.SaveChanges(); return(true); } } catch (Exception ex) { throw ex; } }
private void LoadDataGrid(bool IsResetPageIndex, bool IsSort, string strFieldName = "", string strFieldValue = "") { objMenuItem = new tblMenuItem(); string strWhereCondition = ""; if (hdnPKID.Value != "" && hdnType.Value == "") { strWhereCondition = "appParentID = " + hdnPKID.Value.ToString(); } else if (hdnPKID.Value != "" && hdnType.Value != "") { strWhereCondition = "appMenuTypeID = " + hdnPKID.Value.ToString() + " and appParentID = 0"; } else { strWhereCondition = "appParentID = 0"; } objDataTable = objMenuItem.LoadGridData(ddlFields.SelectedValue, txtSearch.Text.Trim(), strWhereCondition); //'Reset PageIndex of gridviews if (IsResetPageIndex) { if (dgvGridView.PageCount > 0) { dgvGridView.PageIndex = 0; } } dgvGridView.DataSource = null; dgvGridView.DataBind(); lblCount.Text = 0.ToString(); hdnSelectedIDs.Value = ""; //'Check for data into datatable if (objDataTable.Rows.Count <= 0) { DInfo.ShowMessage("No data found", Enums.MessageType.Information); return; } else { if (ddlPerPage.SelectedItem.Text.ToLower() == "all") { dgvGridView.AllowPaging = false; } else { dgvGridView.AllowPaging = true; dgvGridView.PageSize = Convert.ToInt32(ddlPerPage.SelectedItem.Text); } lblCount.Text = objDataTable.Rows.Count.ToString(); objDataTable = SortDatatable(objDataTable, ViewState["SortColumn"].ToString(), (appFunctions.Enum_SortOrderBy)ViewState["SortOrder"], IsSort); dgvGridView.DataSource = objDataTable; dgvGridView.DataBind(); } objMenuItem = null; }
private void SetValuesToControls() { if (!string.IsNullOrEmpty(hdnPKID.Value) && hdnPKID.Value != "") { objMenuItem = new tblMenuItem(); if (objMenuItem.LoadByPrimaryKey(Convert.ToInt32(hdnPKID.Value))) { txtMenuItemName.Text = objMenuItem.AppMenuItem; ddlMenuType.SelectedValue = objMenuItem.s_AppMenuTypeId; ddlMenuType_SelectedIndexChanged(null, null); ddlParent.SelectedValue = objMenuItem.s_AppParentId; ddlMenuItemType.SelectedValue = objMenuItem.s_AppMenuItemTypeID; ChkIsActive.Checked = objMenuItem.AppIsActive; if (objMenuItem.AppPageId != 0) { hdnPageId.Value = objMenuItem.s_AppPageId; rdbEditExisting.Checked = true; rdbEditExisting.Visible = true; trPageAliasOptions.Visible = false; chkCreatePage.Checked = true; SetPageObjValues(); } else { chkCreatePage.Checked = false; trPageOptions.Visible = false; divSubtitle.Visible = false; trPageDetails.Visible = false; } } objMenuItem = null; } }
protected void ddlMenuType_SelectedIndexChanged(object sender, EventArgs e) { if (ddlMenuType.SelectedIndex != 0) { DataTable dt = new DataTable(); DataRow dr; tblMenuItem objSetMenuItem = new tblMenuItem(); objMenuType = new tblMenuType(); objMenuType.Where.AppMenuTypeId.Value = ddlMenuType.SelectedValue; objMenuType.Query.AddResultColumn(tblMenuType.ColumnNames.AppNoOfLevel); objMenuType.Query.Load(); dt = objSetMenuItem.getMenuItem(Convert.ToInt32(ddlMenuType.SelectedValue), Convert.ToInt32(objMenuType.AppNoOfLevel)); dr = dt.NewRow(); dr["appMenuItemId"] = 0; dr["appMenuItem"] = "-- Select Parent --"; dt.Rows.InsertAt(dr, 0); ddlParent.DataSource = dt; ddlParent.DataValueField = tblMenuItem.ColumnNames.AppMenuItemId; ddlParent.DataTextField = tblMenuItem.ColumnNames.AppMenuItem; ddlParent.DataBind(); objMenuType = null; objSetMenuItem = null; } }
protected void dgvGridView_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e) { if (!string.IsNullOrEmpty(e.CommandArgument.ToString())) { objCommon = new clsCommon(); if (e.CommandName == "IsActive") { objMenuItem = new tblMenuItem(); if (objMenuItem.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString()))) { if (objMenuItem.AppIsActive == true) { objMenuItem.AppIsActive = false; } else if (objMenuItem.AppIsActive == false) { objMenuItem.AppIsActive = true; } objMenuItem.Save(); } objMenuItem = null; } else if (e.CommandName == "Up") { LinkButton inkButton = (LinkButton)e.CommandSource; GridViewRow drCurrent = (GridViewRow)inkButton.Parent.Parent; if (drCurrent.RowIndex > 0) { GridViewRow drUp = dgvGridView.Rows[drCurrent.RowIndex - 1]; objCommon.SetDisplayOrder("tblMenuItem", tblMenuItem.ColumnNames.AppMenuItemId, tblMenuItem.ColumnNames.AppDisplayOrder, (int)dgvGridView.DataKeys[drCurrent.RowIndex].Values[0], (int)dgvGridView.DataKeys[drCurrent.RowIndex].Values[1], (int)dgvGridView.DataKeys[drUp.RowIndex].Values[0], (int)dgvGridView.DataKeys[drUp.RowIndex].Values[1]); LoadDataGrid(false, false); objCommon = null; } } else if (e.CommandName == "Down") { LinkButton lnkButton = (LinkButton)e.CommandSource; GridViewRow drCurrent = (GridViewRow)lnkButton.Parent.Parent; if (drCurrent.RowIndex < dgvGridView.Rows.Count - 1) { GridViewRow drUp = dgvGridView.Rows[drCurrent.RowIndex + 1]; objCommon.SetDisplayOrder("tblMenuItem", tblMenuItem.ColumnNames.AppMenuItemId, tblMenuItem.ColumnNames.AppDisplayOrder, (int)dgvGridView.DataKeys[drCurrent.RowIndex].Values[0], (int)dgvGridView.DataKeys[drCurrent.RowIndex].Values[1], (int)dgvGridView.DataKeys[drUp.RowIndex].Values[0], (int)dgvGridView.DataKeys[drUp.RowIndex].Values[1]); LoadDataGrid(false, false); objCommon = null; } } LoadDataGrid(false, false, "", ""); } }
private bool Delete(int intPKID) { bool retval = false; objMenuItem = new tblMenuItem(); if (objMenuItem.LoadByPrimaryKey(intPKID)) { objMenuItem.MarkAsDeleted(); objMenuItem.Save(); } retval = true; objMenuItem = null; return(retval); }
public void DeleteTest() { using (FoodOrderSystemEntities dc = new FoodOrderSystemEntities()) { tblMenuItem deletedrow = dc.tblMenuItems.Where(mi => mi.ItemName == "Spaghetti") .FirstOrDefault(); if (deletedrow != null) { dc.tblMenuItems.Remove(deletedrow); int results = dc.SaveChanges(); Assert.IsTrue(results != 0); } } }
public void InsertTest() { using (FoodOrderSystemEntities dc = new FoodOrderSystemEntities()) { tblMenuItem newrow = new tblMenuItem(); newrow.Id = Guid.NewGuid(); newrow.ItemName = "Spaghetti"; newrow.Price = 15.99; dc.tblMenuItems.Add(newrow); int results = dc.SaveChanges(); Assert.IsTrue(results != 0); } }
public void UpdateTest() { using (FoodOrderSystemEntities dc = new FoodOrderSystemEntities()) { tblMenuItem updatedrow = dc.tblMenuItems.Where(mi => mi.ItemName == "Spaghetti") .FirstOrDefault(); if (updatedrow != null) { updatedrow.Price = 19.99; int results = dc.SaveChanges(); Assert.IsTrue(results != 0); } } }
protected void btnDelete_Click(object sender, System.EventArgs e) { string[] arIDs = hdnSelectedIDs.Value.ToString().TrimEnd(',').Split(','); bool IsDelete = false; bool HasChild = false; for (int i = 0; i <= arIDs.Length - 1; i++) { if (!string.IsNullOrEmpty(arIDs.GetValue(i).ToString())) { tblMenuItem objMenuItem = new tblMenuItem(); objMenuItem.Query.AddResultColumn(tblMenuItem.ColumnNames.AppMenuItem); objMenuItem.Where.AppPageId.Value = arIDs.GetValue(i); objMenuItem.Query.Load(); if (objMenuItem.RowCount == 0) { if (Delete(Convert.ToInt32(arIDs.GetValue(i)))) { IsDelete = true; } } else { HasChild = true; } } } if (HasChild) { DInfo.ShowMessage("Some Item May Not Deleted As It Is Linked With Some Menu Item . . .", Enums.MessageType.Warning); } else { DInfo.ShowMessage("Page Formate has been deleted successfully", Enums.MessageType.Successfull); } if (IsDelete || HasChild) { LoadDataGrid(false, false); } hdnSelectedIDs.Value = ""; }
protected void btnDelete_Click(object sender, System.EventArgs e) { string[] arIDs = hdnSelectedIDs.Value.ToString().TrimEnd(',').Split(','); bool IsDelete = false; bool IsAnyRecordPresent = false; tblMenuItem objMenuItem = new tblMenuItem(); for (int i = 0; i <= arIDs.Length - 1; i++) { objMenuType = new tblMenuType(); if (!string.IsNullOrEmpty(arIDs.GetValue(i).ToString())) { if (objMenuType.GetChildCount(Convert.ToInt32(arIDs.GetValue(i))) > 0) { IsAnyRecordPresent = true; } else { if (Delete(Convert.ToInt32(arIDs.GetValue(i)))) { IsDelete = true; } } objMenuItem.Where.WhereClauseReset(); } objMenuType = null; } if (IsAnyRecordPresent) { LoadDataGrid(false, false); DInfo.ShowMessage("Some Items Cannot Be Deleted As Dependencies exist", Enums.MessageType.Error); } else if (IsDelete) { LoadDataGrid(false, false); DInfo.ShowMessage("MenuType has been deleted successfully", Enums.MessageType.Successfull); } hdnSelectedIDs.Value = ""; }
protected void Page_Load(object sender, System.EventArgs e) { if (!IsPostBack) { ifError = false; ViewState["SortOrder"] = appFunctions.Enum_SortOrderBy.Asc; ViewState["SortColumn"] = ""; btnAdd.Visible = HasAdd; btnDelete.Visible = HasDelete; dgvGridView.Columns[0].Visible = HasDelete; dgvGridView.Columns[1].Visible = HasEdit; dgvGridView.Columns[5].Visible = HasEdit; if ((Session[appFunctions.Session.ShowMessage.ToString()] != null)) { if (!string.IsNullOrEmpty(Session[appFunctions.Session.ShowMessage.ToString()].ToString())) { DInfo.ShowMessage(Session[appFunctions.Session.ShowMessage.ToString()].ToString(), (Enums.MessageType)Session[appFunctions.Session.ShowMessageType.ToString()]); Session[appFunctions.Session.ShowMessage.ToString()] = ""; Session[appFunctions.Session.ShowMessageType.ToString()] = ""; } } objCommon = new clsCommon(); objCommon.FillRecordPerPage(ref ddlPerPage); if ((Request.QueryString.Get("ID") != null)) { objEncrypt = new clsEncryption(); try { hdnPKID.Value = objEncrypt.Decrypt(Request.QueryString.Get("ID"), appFunctions.strKey); intSiteMapId = Convert.ToInt32(hdnPKID.Value); } catch (Exception ex) { // noIdFoundRedirect("Employee.aspx"); } objEncrypt = null; if ((Request.QueryString.Get("type") != null)) { if ((Request.QueryString.Get("type") == "mtype")) { hdnType.Value = "mtype"; } else { hdnType.Value = ""; } } else { hdnType.Value = ""; } } if (intSiteMapId != -1) { DataTable dt = new DataTable(); objEncrypt = new clsEncryption(); dynamic objTempMenuItem = new tblMenuItem(); if (hdnType.Value == "") { dt = objTempMenuItem.GetSiteMap(intSiteMapId); strSiteMapData = dt.Rows[0][0].ToString(); dt = objTempMenuItem.GetMenuType(intSiteMapId, false); } else { dt = objTempMenuItem.GetMenuType(intSiteMapId, true); } String[] SplitSiteMapString = strSiteMapData.Split('/'); strSiteMap = "<a href='MasterMenus.aspx'>Menu Items</a>"; if (SplitSiteMapString.Length > 1) { strSiteMap += " > <a href=MenuItems.aspx?Id=" + objEncrypt.Encrypt(dt.Rows[0]["appMenuTypeId"].ToString(), appFunctions.strKey) + "&type=mtype>" + dt.Rows[0]["appMenuTypeName"].ToString() + "</a>"; //strSiteMap = "<a href='MenuItems.aspx'>Parent Tabs </a>"; } else { strSiteMap += " > " + dt.Rows[0]["appMenuTypeName"].ToString(); } for (int i = 0; i <= SplitSiteMapString.Length - 2; i += 1) { String[] SplittedItems = SplitSiteMapString.GetValue(i).ToString().Split(','); if (i == SplitSiteMapString.Length - 2) { strSiteMap += " > " + SplittedItems.GetValue(0); } else { strSiteMap += " > <a href='MenuItems.aspx?Id=" + objEncrypt.Encrypt(SplittedItems.GetValue(1).ToString(), appFunctions.strKey) + "'> " + SplittedItems.GetValue(0) + "</a>"; } } litSiteMap.Text = strSiteMap; } LoadDataGrid(true, false); txtSearch.Focus(); objCommon = null; } }
public void SetUpBlocks() { tblBlock objBlock = new tblBlock(); StringBuilder blockContent = new StringBuilder(); objBlockDt = objBlock.GetBlockByControlId(); if (Cache["SiteName"] == null) { tblSettings objSettings = new tblSettings(); objSettings.Query.AddResultColumn(tblSettings.ColumnNames.AppSiteName); objSettings.Query.AddResultColumn(tblSettings.ColumnNames.AppSiteTagLine); objSettings.Query.AddResultColumn(tblSettings.ColumnNames.AppSiteFavicon); objSettings.LoadAll(); if (objSettings.RowCount > 0) { Cache["SiteName"] = objSettings.AppSiteName; } } for (int i = 0; i <= objBlockDt.Rows.Count - 1; i++) { blockContent = new StringBuilder(); DataRow dr = objBlockDt.Rows[i]; if (dr["appMenuTypeId"].ToString() != DBNull.Value.ToString() & (bool)dr["appIsShowContent"] == false) { objMenuItem = new tblMenuItem(); objMenuDt = new DataTable(); objMenuDt = objMenuItem.GetChildMenus((int)dr["appMenuTypeId"]); if (string.Compare(dr["appControlId"].ToString(), "divTopMenu") == 0) { blockContent.Append(" <div style=\"background-color: #ED258F;\">"); blockContent.Append(" <div class=\"wrap\">"); blockContent.Append(" <div class=\"menu\">"); blockContent.Append("<ul class=\"megamenu skyblue\">"); LoadTopMenu(ref blockContent, 0); blockContent.Append("</ul></div></div></div>"); } else if (string.Compare(dr["appControlId"].ToString(), "divFooterBlock1") == 0) { objMenuType = new tblMenuType(); if (objMenuType.LoadByPrimaryKey((int)dr["appMenuTypeId"])) { LoadFooterMenu(ref blockContent, 0, objMenuType.AppMenuTypeName); } objMenuType = null; } else if (string.Compare(dr["appControlId"].ToString(), "divFooterBlock2") == 0) { objMenuType = new tblMenuType(); if (objMenuType.LoadByPrimaryKey((int)dr["appMenuTypeId"])) { LoadCategory(ref blockContent); } objMenuType = null; } else if (string.Compare(dr["appControlId"].ToString(), "divCategoryFooter") == 0) { LoadCategoryFooter(ref blockContent); } else if (dr["appMenuTypeId"].ToString() != DBNull.Value.ToString()) { blockContent.Append("<ul>"); SetUpMenu(ref blockContent, 0); blockContent.Append("</ul>"); } } else if ((bool)dr["appIsShowContent"] == true) { blockContent.Append(dr["appContent"]); } StringBuilder strContent = new StringBuilder(); strContent.Append(blockContent); blockContent = new StringBuilder(); blockContent.Append(strContent.ToString().Replace("~GetServerURL()~", PageBase.GetServerURL() + "/")); if ((this.Master.FindControl("ContentPlaceHolder1").FindControl(dr["appControlId"].ToString()) != null)) { ((HtmlContainerControl)this.Master.FindControl("ContentPlaceHolder1").FindControl(dr["appControlId"].ToString())).InnerHtml = blockContent.ToString(); } else if ((this.Master.FindControl(dr["appControlId"].ToString()) != null)) { ((HtmlContainerControl)this.Master.FindControl(dr["appControlId"].ToString())).InnerHtml = blockContent.ToString(); } } }
public void SetUpPageContent(ref HtmlGenericControl PageContentControl, ref HtmlGenericControl PageHeadingControl, ref string metaDescription, ref string metaKeywords, ref HtmlGenericControl objSiteMapControl) { string pageName = ""; pageName = GetPageAliasFromURL(); tblPage objPage = new tblPage(); DataTable dtPageDetail = objPage.GetPageDetailByAlias(); DataRow[] arDataRow = dtPageDetail.Select("appAlias='" + pageName + "'"); if (!(arDataRow.Length > 0)) { arDataRow = dtPageDetail.Select("appAlias='" + pageName.Split('/')[0] + "/{*name}" + "'"); } //objPage.Where.AppPageName.Value = pageName //'objPage.Where.AppAlias.Value = pageName //'objPage.Query.AddResultColumn(tblPage.ColumnNames.AppPageId) //'objPage.Query.AddResultColumn(tblPage.ColumnNames.AppPageTitle) //'objPage.Query.AddResultColumn(tblPage.ColumnNames.AppPageContent) //'objPage.Query.AddResultColumn(tblPage.ColumnNames.AppPageHeading) //'objPage.Query.AddResultColumn(tblPage.ColumnNames.AppSEOWord) //'objPage.Query.AddResultColumn(tblPage.ColumnNames.AppSEODescription) //'objPage.Query.Load() if (arDataRow.Length > 0) { Page.Title = arDataRow[0][tblPage.ColumnNames.AppPageTitle].ToString(); ViewState["CurrentPageTitle"] = arDataRow[0][tblPage.ColumnNames.AppPageTitle]; if ((PageContentControl != null)) { PageContentControl.InnerHtml = arDataRow[0][tblPage.ColumnNames.AppPageContent].ToString().Replace("<pre ", "<p ").Replace("</pre>", "</p>"); PageContentControl.InnerHtml = PageContentControl.InnerHtml.Replace("~GetServerURL()~", PageBase.GetServerURL() + "/"); } if ((PageHeadingControl != null)) { PageHeadingControl.InnerText = arDataRow[0][tblPage.ColumnNames.AppPageHeading].ToString(); } metaDescription = arDataRow[0][tblPage.ColumnNames.AppSEODescription].ToString(); metaKeywords = arDataRow[0][tblPage.ColumnNames.AppSEOWord].ToString(); ViewState["CurrentPageMetaDesc"] = arDataRow[0][tblPage.ColumnNames.AppSEODescription]; ViewState["CurrentPageMetaKeyWords"] = arDataRow[0][tblPage.ColumnNames.AppSEOWord]; if ((objSiteMapControl != null)) { tblMenuItem objMenuItem = new tblMenuItem(); DataTable dtSiteMap = objMenuItem.GetSiteMapDT((int)arDataRow[0][tblMenuItem.ColumnNames.AppMenuItemId]); objSiteMapControl.InnerHtml = "<div class=\"itemnode\"><a href='" + strServerURL + "'>Home</a></div>"; for (int i = 0; i <= dtSiteMap.Rows.Count - 2; i++) { objSiteMapControl.InnerHtml += "<div class=\"itemseparator\"> </div>"; if (!string.IsNullOrEmpty(dtSiteMap.Rows[i]["appAlias"].ToString())) { objSiteMapControl.InnerHtml += "<div class='itemnode'><a href='" + strServerURL + dtSiteMap.Rows[i]["appAlias"] + "'>" + dtSiteMap.Rows[i]["appMenuItem"] + "</a></div>"; } else { objSiteMapControl.InnerHtml += "<div class='itemnode'>" + dtSiteMap.Rows[i]["appMenuItem"] + "</div>"; } } objSiteMapControl.InnerHtml += "<div class=\"itemseparator\"> </div>"; objSiteMapControl.InnerHtml += "<div class='currentitem itemnode'>" + dtSiteMap.Rows[dtSiteMap.Rows.Count - 1]["appMenuItem"] + "</div>"; } } }
private bool SaveData() { objMenuItem = new tblMenuItem(); objCommon = new clsCommon(); if (!string.IsNullOrEmpty(hdnPKID.Value) && hdnPKID.Value != "") { objMenuItem.LoadByPrimaryKey(Convert.ToInt32(hdnPKID.Value)); } else { objMenuItem.AddNew(); objMenuItem.AppCreatedDate = System.DateTime.Now; objMenuItem.AppCreatedBy = Convert.ToInt32(Session[appFunctions.Session.UserID.ToString()]); } if (chkCreatePage.Checked) { string strPageAlias = ""; int intPageID = 0; objPage = new tblPage(); if (rdbEditExisting.Checked) { objPage.LoadByPrimaryKey(Convert.ToInt32(hdnPageId.Value)); strPageAlias = txtNewPageAlias.Text; intPageID = Convert.ToInt32(hdnPageId.Value); } else if (rdbUseExistingPage.Checked && txtMenuPageAlias.Text != "") { objPage.LoadByPrimaryKey(Convert.ToInt32(ddlPages.SelectedValue)); strPageAlias = txtMenuPageAlias.Text; intPageID = Convert.ToInt32(ddlPages.SelectedValue); } else if (rdbUseExistingPage.Checked && txtMenuPageAlias.Text == "") { objMenuItem.s_AppPageId = ddlPages.SelectedValue; goto saveMenuItem; } else if (rdbCreateNewPage.Checked) { objPage.AddNew(); objPage.s_AppCreatedBy = Session[appFunctions.Session.UserID.ToString()].ToString(); strPageAlias = txtNewPageAlias.Text; objPage.AppCreatedDate = DateTime.Now; } ; if (rdbCreateNewPage.Checked || rdbEditExisting.Checked) { if (checkPage(txtPageName.Text, false, intPageID) != true) { DInfo.ShowMessage("The Page name already exists!!", Enums.MessageType.Error); return(false); } } if (checkPage(strPageAlias, true, intPageID) != true) { DInfo.ShowMessage("The Page alias already exists!!", Enums.MessageType.Error); return(false); } if (rdbCreateNewPage.Checked || rdbEditExisting.Checked) { if (chkIsDefault.Checked) { tblPage objPageTemp = new tblPage(); objPageTemp.ResetDefaultPage(); objPageTemp = null; objPage.AppIsDefault = chkIsDefault.Checked; } else { objPage.AppIsDefault = false; } objPage.AppIsLink = chkIsLink.Checked; if (chkIsLink.Checked) { objPage.AppLinkURL = txtLinkURL.Text; objPage.AppIsOpenInNewTab = chkIsOpenInNewTab.Checked; objPage.AppPageFormatId = 0; } else { objPage.s_AppPageFormatId = ddlPageFormats.SelectedValue; objPage.AppLinkURL = ""; objPage.AppIsOpenInNewTab = false; } objPage.AppPageContent = txtDescription.Text; objPage.AppPageHeading = txtPageHeader.Text; objPage.AppPageName = txtPageName.Text; objPage.AppPageTitle = txtPageTitle.Text; objPage.AppSEODescription = txtSEODescription.Text; objPage.AppSEOWord = txtSEOWord.Text; objPage.s_AppDynamicParameters = CkEditorDynParameters.Text; } strPageAlias = strPageAlias.Replace(" ", "-"); if (chkIsStatic.Checked) { objPage.AppAlias = strPageAlias; } else { objPage.AppAlias = strPageAlias + "/{*name}"; } objPage.Save(); objMenuItem.AppPageId = objPage.AppPageId; } else { objMenuItem.AppPageId = 0; } saveMenuItem: if (ChkIsActive.Checked) { objMenuItem.AppIsActive = true; } else { objMenuItem.AppIsActive = false; } objMenuItem.s_AppMenuItemTypeID = ddlMenuItemType.SelectedValue; objMenuItem.s_AppMenuItem = txtMenuItemName.Text; objMenuItem.s_AppParentId = ddlParent.SelectedValue; objMenuItem.s_AppMenuTypeId = ddlMenuType.SelectedValue; if (hdnPKID.Value == "") { objMenuItem.AppDisplayOrder = objCommon.GetNextDisplayOrder("tblMenuItem", tblMenuItem.ColumnNames.AppDisplayOrder, "appMenuTypeId = " + objMenuItem.AppMenuTypeId.ToString() + " and appParentID = " + objMenuItem.AppParentId.ToString()); } objMenuItem.Save(); iMenuItemid = objMenuItem.AppMenuItemId; objMenuItem = null; objCommon = null; return(true); }
public void GenerateAlias(int intId) { DataTable dt; tblMenuType objMenuType = new tblMenuType(); objMenuItem = new tblMenuItem(); objEncrypt = new clsEncryption(); dt = objMenuItem.GetSiteMap(intId); strSiteMap = dt.Rows[0][0].ToString().Trim('/'); if (hdnMenuTypeId.Value == "") { dt = objMenuItem.GetMenuType(intId, false); } else { dt = objMenuItem.GetMenuType(Convert.ToInt32(hdnMenuTypeId.Value), true); } string[] SplitSiteMapString = strSiteMap.Split('/'); objMenuType.Where.AppMenuTypeId.Value = ddlMenuType.SelectedValue; objMenuType.Query.Load(); strSiteMap = "<a href='MasterMenus.aspx'>Menu Items</a>"; if (objMenuType.RowCount > 0) { strSiteMap += " > <a href=MenuItems.aspx?Id=" + objEncrypt.Encrypt(dt.Rows[0]["appMenuTypeId"].ToString(), appFunctions.strKey) + "&type=mtype>" + dt.Rows[0]["appMenuTypeName"].ToString() + "</a>"; } if (objMenuType.AppNoOfLevel > SplitSiteMapString.Length - 1) { for (int i = 0; i <= SplitSiteMapString.Length - 1; i++) { string[] SplittedItems = SplitSiteMapString[i].Split(','); aliasPrefix += SplittedItems[0] + "/"; if (i == SplitSiteMapString.Length - 1) { strSiteMap += " > " + SplittedItems[0]; } else { strSiteMap += "> <a href='MenuItems.aspx?Id=" + objEncrypt.Encrypt(SplittedItems[1].ToString(), appFunctions.strKey) + "'>" + SplittedItems[0].ToString() + "</a>"; } } siteMapLiteral.Text = strSiteMap.ToString(); if (aliasPrefix.Length > 0) { aliasPrefix = aliasPrefix.Substring(0, aliasPrefix.Length - 1); aliasPrefix = aliasPrefix.Substring(0, aliasPrefix.LastIndexOf("/") + 1); } hdnAliasPrefix.Value = aliasPrefix.Replace(" ", "-"); } else { Session[appFunctions.Session.ShowMessage.ToString()] = "You Can't Add Menu Item For This Level As Maximum No. Of Level Is " + objMenuType.AppNoOfLevel.ToString(); Session[appFunctions.Session.ShowMessageType.ToString()] = Enums.MessageType.Error; if (Request.QueryString.Get("PID") != null) { Response.Redirect("MenuItems.aspx?Id=" + Request.QueryString.Get("PID"), true); } else if (Request.QueryString.Get("TID") != null) { Response.Redirect("MenuItems.aspx?Id=" + Request.QueryString.Get("TID") + "&type=mtype", true); } else if (hdnPKID.Value == "") { Response.Redirect("Dashboard.aspx"); } } objMenuItem = null; objMenuType = null; }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { lnkSaveAndAddnew.Visible = HasAdd; if (!((bool)Session[appFunctions.Session.IsSuperAdmin.ToString()])) { trDefaultPage.Visible = false; trIsStatic.Visible = false; trdynParameters.Visible = false; } hdnAliasPrefix.Value = ""; objCommon = new clsCommon(); objCommon.FillDropDownList(ddlMenuType, "tblMenuType", tblMenuType.ColumnNames.AppMenuTypeName, tblMenuType.ColumnNames.AppMenuTypeId, "-- Select Menu --", tblMenuType.ColumnNames.AppMenuTypeName, appFunctions.Enum_SortOrderBy.Asc); objCommon.FillDropDownList(ddlPages, "tblPage", tblPage.ColumnNames.AppPageName, tblPage.ColumnNames.AppPageId, "-- Select Page --", tblPage.ColumnNames.AppPageName, appFunctions.Enum_SortOrderBy.Asc); objCommon.FillDropDownList(ddlPageFormats, "tblPageFormat", tblPageFormat.ColumnNames.AppPageFormatName, tblPageFormat.ColumnNames.AppPageFormatId, "-- Select Page Format --", tblPageFormat.ColumnNames.AppPageFormatId, appFunctions.Enum_SortOrderBy.Asc, " appIsActive = 'true' "); objCommon.FillDropDownList(ddlMenuItemType, "tblMenuItemType", tblMenuItemType.ColumnNames.AppMenuItemType, tblMenuItemType.ColumnNames.AppMenuItemTypeID, "--Select Menu Item Type--"); if (ddlMenuType.SelectedIndex == 0) { ddlParent.Items.Add(new ListItem("--Select Parent--", "0")); } if ((Request.QueryString.Get("ID") != null)) { objEncrypt = new clsEncryption(); try { hdnPKID.Value = objEncrypt.Decrypt(Request.QueryString.Get("ID"), appFunctions.strKey); } catch (Exception ex) { // noIdFoundRedirect("Employee.aspx"); } objEncrypt = null; SetValuesToControls(); } else { chkCreatePage.Checked = true; chkIsLink.Checked = false; rdbCreateNewPage.Checked = true; rdbUseExistingPage.Checked = false; rdbUseExistingPage_CheckedChanged(null, null); CheckCreatePage(true); chkIsStatic.Checked = true; } CheckLink(chkIsLink.Checked); if ((Request.QueryString.Get("TID") != null)) { objEncrypt = new clsEncryption(); try { hdnMenuTypeId.Value = objEncrypt.Decrypt(Request.QueryString.Get("TID"), appFunctions.strKey); hdnPageName.Value = Request.QueryString.Get("Page"); } catch (Exception ex) { // noIdFoundRedirect("Employee.aspx"); } ddlMenuType.SelectedValue = objEncrypt.Decrypt(Request.QueryString.Get("TID"), appFunctions.strKey); ddlMenuType_SelectedIndexChanged(null, null); objEncrypt = null; } else if ((Request.QueryString.Get("PID") != null)) { objEncrypt = new clsEncryption(); try { strSiteMapId = Convert.ToInt32(objEncrypt.Decrypt(Request.QueryString.Get("PID"), appFunctions.strKey)); } catch (Exception ex) { // noIdFoundRedirect("Employee.aspx"); } tblMenuItem objTemp = new tblMenuItem(); objTemp.Query.AddResultColumn(tblMenuItem.ColumnNames.AppMenuTypeId); objTemp.Where.AppMenuItemId.Value = objEncrypt.Decrypt(Request.QueryString.Get("PID"), appFunctions.strKey); objTemp.Query.Load(); if (objTemp.RowCount > 0) { hdnMenuTypeId.Value = objTemp.s_AppMenuTypeId; ddlMenuType.SelectedValue = objTemp.s_AppMenuTypeId; ddlMenuType_SelectedIndexChanged(null, null); } try { ddlParent.SelectedValue = objEncrypt.Decrypt(Request.QueryString.Get("PID"), appFunctions.strKey).ToString(); } catch (Exception ex) { // noIdFoundRedirect("Employee.aspx"); } objEncrypt = null; } if ((Request.QueryString.Get("ID") != null)) { objEncrypt = new clsEncryption(); try { strSiteMapId = Convert.ToInt32(objEncrypt.Decrypt(Request.QueryString.Get("ID"), appFunctions.strKey)); } catch (Exception ex) { // noIdFoundRedirect("Employee.aspx"); } objEncrypt = null; } if (Request.QueryString.Get("ID") != null || Request.QueryString.Get("PID") != null || Request.QueryString.Get("TID") != null) { GenerateAlias(strSiteMapId); } SetRegulerExpression(); } }