Esempio n. 1
0
        //protected void btnCancel_Click(object sender, EventArgs e)
        //{
        //    ClearPageData();
        //    Session["SelectedSegmentDetail"] = null;
        //}

        protected void gvSegmentDetails_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            try
            {
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    SegmentDetailTreeHelper rowItem = (SegmentDetailTreeHelper)e.Row.DataItem;
                    //((Label)e.Row.FindControl("lblIndent")).Width = Unit.Pixel(rowItem.Level * 30);
                    //((Label)e.Row.FindControl("lblDetailCode")).Text = rowItem.DetailCode;
                    int width = rowItem.Level * 30;

                    string strHTML = string.Empty;
                    if (rowItem.ChildCount > 0)
                    {
                        if (SelectedNodes.Contains(rowItem.SegmentDetailID))
                        {
                            strHTML = "<label style=\"width:" + (width + 10).ToString() + "px;vertical-align:middle;\"><i class=\"ace-icon fa fa-minus-square pull-right\"></i></label> ";
                        }
                        else
                        {
                            strHTML = "<label style=\"width:" + (width + 10).ToString() + "px;vertical-align:middle;\"><i class=\"ace-icon fa fa-plus-square pull-right\"></i></label> ";
                        }
                    }
                    else
                    {
                        strHTML = "<label style=\"width:" + (width + 10).ToString() + "px;vertical-align:middle;\"><i></i></label> ";
                    }

                    LinkButton btnExpand = ((LinkButton)e.Row.FindControl("btnExpand"));
                    btnExpand.Text = "<div>" + strHTML + rowItem.DetailCode + "</div>";

                    //disable Add-Child if AccountCodeFlag raise
                    if (((Segment)Session["SelectedSegment"]).AccountCodeFlag == true)
                    {
                        LinkButton linkButton = ((LinkButton)e.Row.FindControl("lbAddChild"));

                        linkButton.Attributes.Remove("href");
                        linkButton.Attributes.CssStyle[HtmlTextWriterStyle.Color]  = "gray";
                        linkButton.Attributes.CssStyle[HtmlTextWriterStyle.Cursor] = "default";
                        linkButton.ToolTip = "Add Child Disabled.";
                        if (linkButton.Enabled != false)
                        {
                            linkButton.Enabled = false;
                        }

                        if (linkButton.OnClientClick != null)
                        {
                            linkButton.OnClientClick = null;
                        }
                    }

                    if (rowItem.ParentDetailID != 0)
                    {
                        ((LinkButton)e.Row.FindControl("lbAddItem")).Visible = false;
                    }
                    if (rowItem.ParentDetailID == 0)
                    {
                        ((LinkButton)e.Row.FindControl("lbMakeRoot")).Visible = false;
                    }
                    if (rowItem.SegmentDetailID == 0)
                    {
                        ((LinkButton)e.Row.FindControl("btnExpand")).Visible  = false;
                        ((LinkButton)e.Row.FindControl("lbEdit")).Visible     = false;
                        ((LinkButton)e.Row.FindControl("lbDelete")).Visible   = false;
                        ((LinkButton)e.Row.FindControl("lbCut")).Visible      = false;
                        ((LinkButton)e.Row.FindControl("lbPaste")).Visible    = false;
                        ((LinkButton)e.Row.FindControl("lbMakeRoot")).Visible = false;
                        ((LinkButton)e.Row.FindControl("lbAddChild")).Visible = false;
                    }

                    if (Session["SelectedSegmentDetail"] != null && ((SegmentDetail)Session["SelectedSegmentDetail"]).SegmentDetailID == rowItem.SegmentDetailID)
                    {
                        e.Row.Style["background-color"] = "skyblue";
                    }

                    var span = ((System.Web.UI.HtmlControls.HtmlGenericControl)e.Row.Cells[2].FindControl("CustomStatus"));
                    if (rowItem.Status == "A")
                    {
                        span.InnerHtml = "<span class=\"label label-sm label-success arrowed-in arrowed-in-right tooltip-success\" " +
                                         "data-rel=\"tooltip\" data-placement=\"right\" title=\"Active Status. All operation has been enabled.\">Active</span>";
                    }
                    else if (rowItem.Status == "D")
                    {
                        span.InnerHtml = "<span class=\"label label-sm label-danger arrowed-in arrowed-in-right tooltip-error\" " +
                                         "data-rel=\"tooltip\" data-placement=\"right\" title=\"Inactive Status. All operation has been disabled.\">Inactive</span>";
                    }
                }
            }
            catch (Exception ex)
            {
                ((SiteMaster)this.Master).ShowMessage("Error", "An error occurred", ex, true);
            }
        }
Esempio n. 2
0
        private void CreateTreeData()
        {
            try
            {
                SelectedNodes = (List <int>)Session["SelectedNodes"];
                List <SegmentDetail>           data     = (List <SegmentDetail>)Session["SegmentDetailsData"];
                List <SegmentDetailTreeHelper> TreeData = new List <SegmentDetailTreeHelper>();

                if (data.Count > 0)
                {
                    TreeData = data.Where(x => x.ParentDetailID == 0).OrderBy(x => x.DetailCode).Select(x =>
                                                                                                        new SegmentDetailTreeHelper()
                    {
                        SegmentDetailID = x.SegmentDetailID,
                        SegmentID       = Convert.ToInt32(x.SegmentID),
                        DetailCode      = x.DetailCode,
                        DetailDesc      = x.DetailDesc,
                        ParentDetailID  = Convert.ToInt32(x.ParentDetailID),
                        Status          = x.Status,
                        Level           = 0,
                        ChildCount      = data.Where(y => y.ParentDetailID == x.SegmentDetailID).Count()
                    }).ToList();

                    if (SelectedNodes == null || SelectedNodes.Count == 0)
                    {
                        Session["SelectedNodes"] = new List <int>();
                        SelectedNodes            = new List <int>();
                    }
                    else
                    {
                        for (int i = 0; i < TreeData.Count; i++)
                        {
                            if (SelectedNodes.Contains(TreeData[i].SegmentDetailID))
                            {
                                foreach (SegmentDetail sd in data.Where(x => x.ParentDetailID == TreeData[i].SegmentDetailID).OrderByDescending(x => x.DetailCode))
                                {
                                    SegmentDetailTreeHelper objSH = new SegmentDetailTreeHelper()
                                    {
                                        SegmentDetailID = sd.SegmentDetailID,
                                        SegmentID       = Convert.ToInt32(sd.SegmentID),
                                        DetailCode      = sd.DetailCode,
                                        DetailDesc      = sd.DetailDesc,
                                        ParentDetailID  = Convert.ToInt32(sd.ParentDetailID),
                                        Status          = sd.Status,
                                        Level           = TreeData[i].Level + 1,
                                        ChildCount      = data.Where(y => y.ParentDetailID == sd.SegmentDetailID).Count()
                                    };
                                    TreeData.Insert(i + 1, objSH);
                                }
                            }
                        }
                    }
                }

                Session["SegmentDetailsTree"] = TreeData;
                BindGrid();
            }
            catch (Exception ex)
            {
                ((SiteMaster)this.Master).ShowMessage("Error", "An error occurred", ex, true);
            }
        }