Exemplo n.º 1
0
        protected void frmSiteNode_ItemCommand(object sender, FormViewCommandEventArgs e)
        {
            DropDownList ddlParent         = (DropDownList)frmSiteNode.FindControl("ddlParent");
            CheckBoxList chkListRoles      = (CheckBoxList)frmSiteNode.FindControl("chkListRoles");
            TextBox      txtTitle          = (TextBox)frmSiteNode.FindControl("txtTitle");
            TextBox      txtUrl            = (TextBox)frmSiteNode.FindControl("txtUrl");
            TextBox      txtDescription    = (TextBox)frmSiteNode.FindControl("txtDescription");
            CheckBox     chkbIsSiteMapNode = (CheckBox)frmSiteNode.FindControl("chkbIsSiteMapNode");
            HiddenField  hdnSiteMapID      = (HiddenField)frmSiteNode.FindControl("hdnSiteMapID");



            if (e.CommandName.ToString() == "Add")
            {
                TLGX_Consumer.MDMSVC.DC_SiteMap newObj = new MDMSVC.DC_SiteMap();
                newObj.SiteMap_ID    = Guid.NewGuid();
                newObj.ID            = 0;
                newObj.Create_Date   = DateTime.Now;
                newObj.Create_User   = System.Web.HttpContext.Current.User.Identity.Name;
                newObj.Description   = txtDescription.Text;
                newObj.IsActive      = true;
                newObj.IsSiteMapNode = chkbIsSiteMapNode.Checked;
                newObj.ApplicationID = Guid.Parse(ddlApplilcation.SelectedValue);
                if (ddlParent.SelectedIndex != 0)
                {
                    newObj.ParentID = int.Parse(ddlParent.SelectedValue.ToString());
                }
                else
                {
                    newObj.ParentID = 1;
                }

                string Roles = string.Empty;
                foreach (ListItem item in chkListRoles.Items)
                {
                    if (item.Selected)
                    {
                        Roles = Roles + item.Text + ",";
                    }
                }
                Roles = Roles.Trim(',').Trim();
                if (!string.IsNullOrWhiteSpace(Roles))
                {
                    newObj.Roles = Roles;
                }
                newObj.Title = txtTitle.Text;
                newObj.Url   = txtUrl.Text;
                AccSvc.AddSiteMapNode(newObj);
                newObj = null;
                BootstrapAlert.BootstrapAlertMessage(dvMsg, "SiteMap Created Successfully.", BootstrapAlertType.Success);
            }
            else if (e.CommandName.ToString() == "Modify")
            {
                Guid mySiteMap_Id = Guid.Parse(grdSiteMap.SelectedDataKey.Value.ToString());

                TLGX_Consumer.MDMSVC.DC_SiteMap newObj = new MDMSVC.DC_SiteMap();
                newObj.ID            = Convert.ToInt32(hdnSiteMapID.Value);
                newObj.SiteMap_ID    = mySiteMap_Id;
                newObj.Edit_Date     = DateTime.Now;
                newObj.Edit_User     = System.Web.HttpContext.Current.User.Identity.Name;
                newObj.Description   = txtDescription.Text;
                newObj.ApplicationID = Guid.Parse(ddlApplilcation.SelectedValue);

                newObj.IsActive      = true;
                newObj.IsSiteMapNode = chkbIsSiteMapNode.Checked;

                if (ddlParent.SelectedIndex != 0)
                {
                    newObj.ParentID = int.Parse(ddlParent.SelectedValue.ToString());
                }

                string Roles = string.Empty;
                foreach (ListItem item in chkListRoles.Items)
                {
                    if (item.Selected)
                    {
                        Roles = Roles + item.Text + ",";
                    }
                }
                Roles = Roles.Trim(',').Trim();


                if (!string.IsNullOrWhiteSpace(Roles))
                {
                    newObj.Roles = Roles;
                }

                newObj.Title = txtTitle.Text;
                newObj.Url   = txtUrl.Text;

                AccSvc.UpdateSiteMapNode(newObj);
                newObj = null;
            }
            hdnFlag.Value = "true";
            frmSiteNode.ChangeMode(FormViewMode.Insert);
            frmSiteNode.DataBind();
            BootstrapAlert.BootstrapAlertMessage(dvMsg, "SiteMap Edited Successfully.", BootstrapAlertType.Success);
            GetSiteMapMaster();
            //BindParent();
            //BindRoles();
        }