/// <summary>
        /// Attribute Listing Tree..
        /// </summary>
        /// <returns></returns>
        public object createTreeAttributeName()
        {
            StringBuilder sql = new StringBuilder();

            sql.Append(MRole.GetDefault(_ctx).AddAccessSQL("SELECT M_Attribute_id  , Name FROM M_Attribute  WHERE IsActive='Y'", "M_Attribute", true, true));
            sql.Append("~");
            sql.Append(MRole.GetDefault(_ctx).AddAccessSQL("SELECT ma.M_Attribute_id,mv.m_attributevalue_id, ma.Name as NameAttribute,mv.Name FROM M_Attribute ma inner JOIN m_attributevalue mv ON ma.M_Attribute_id=mv.M_Attribute_id", "M_Attribute", true, true));

            SqlParamsIn sqlpar = new SqlParamsIn();

            sqlpar.sql      = sql.ToString();
            sqlpar.pageSize = 0;

            VIS.Helpers.SqlHelper sHelper = new VIS.Helpers.SqlHelper();

            DataSet ds = sHelper.ExecuteDataSet(sqlpar);

            if (ds == null || ds.Tables.Count < 1)
            {
                return(null);
            }

            VA005_TreeStructure tree = new VA005_TreeStructure();

            tree.text   = Msg.GetMsg(_ctx, "VA005_AttributeTree");
            tree.NodeID = 0;
            tree.items  = new List <VA005_TreeStructure>();
            LoadAttributeName(ds, tree);

            List <VA005_TreeStructure> final = new List <VA005_TreeStructure>();

            final.Add(tree);
            return(final);
        }
 /// <summary>
 /// Create Attribute set and then fill each attribute set with respective Attribute used in it.
 /// </summary>
 /// <param name="ds"></param>
 /// <param name="parentTree"></param>
 public void LoadAttributeSet(DataSet ds, VA005_TreeStructure parentTree)
 {
     for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
     {
         VA005_TreeStructure attributeSetTree = new VA005_TreeStructure();
         attributeSetTree.text   = System.Net.WebUtility.HtmlEncode(Convert.ToString(ds.Tables[0].Rows[i]["Name"]));
         attributeSetTree.NodeID = Convert.ToInt32(ds.Tables[0].Rows[i]["m_attributeSet_ID"]);
         //attributeSetTree.ParentID = Convert.ToInt32(ds.Tables[0].Rows[i]["m_attributeSet_ID"]);
         attributeSetTree.ImageSource = "Areas/VA005/Images/attSet.png";
         //attributeSetTree.Image2 = "Areas/VA005/Images/edit.png";
         attributeSetTree.Image2     = "Areas/VA005/Images/edt.png";
         attributeSetTree.visibility = "inherit";
         attributeSetTree.ShowInfo   = "none";
         attributeSetTree.padding    = "8px 10px 8px 38px";
         attributeSetTree.margin     = "0 0 0 0";
         attributeSetTree.Type       = "1";
         attributeSetTree.UID        = attributeSetTree.NodeID + "_1_" + exp;
         attributeSetTree.NID        = attributeSetTree.NodeID;
         //attributeSetTree.UID = attributeSetTree.NodeID.ToString();
         attributeSetTree.expanded       = false;
         attributeSetTree.zindex         = "99999";
         attributeSetTree.classforgetnod = "classforgetnod";
         attributeSetTree.items          = new List <VA005_TreeStructure>();
         parentTree.items.Add(attributeSetTree);
         LoadAttributeUse(ds, attributeSetTree, Convert.ToInt32(ds.Tables[0].Rows[i]["m_attributeSet_ID"]));
     }
 }
 /// <summary>
 /// Create Attribute Values
 /// </summary>
 /// <param name="ds"></param>
 /// <param name="parentTree"></param>
 /// <param name="parentID"></param>
 public void LoadAttributeValue(DataSet ds, VA005_TreeStructure parentTree, int parentID)
 {
     DataRow[] drs = ds.Tables[2].Select("m_attribute_id=" + parentID);
     if (drs != null && drs.Length > 0)
     {
         for (int j = 0; j < drs.Length; j++)
         {
             VA005_TreeStructure attributeSetTree = new VA005_TreeStructure();
             attributeSetTree.text   = System.Net.WebUtility.HtmlEncode(Convert.ToString(drs[j]["Name"]));
             attributeSetTree.NodeID = Convert.ToInt32(drs[j]["M_AttributeValue_ID"]);
             //  attributeSetTree.ParentID = 0;
             attributeSetTree.visibility = "none";
             attributeSetTree.ShowInfo   = "none";
             attributeSetTree.padding    = "8px 10px 8px 38px";
             attributeSetTree.margin     = "0 0 0 20px";
             attributeSetTree.Type       = "3";
             attributeSetTree.zindex     = "99999";
             attributeSetTree.UID        = attributeSetTree.NodeID + "_3_" + exp;
             attributeSetTree.NID        = attributeSetTree.NodeID;
             //attributeSetTree.UID = attributeSetTree.NodeID.ToString();
             attributeSetTree.expanded = false;
             parentTree.items.Add(attributeSetTree);
         }
     }
 }
 public void LoadAttributeName(DataSet ds, VA005_TreeStructure parentTree)
 {
     for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
     {
         VA005_TreeStructure attributeSetTree = new VA005_TreeStructure();
         attributeSetTree.text   = Convert.ToString(ds.Tables[0].Rows[i]["Name"]);
         attributeSetTree.NodeID = Convert.ToInt32(ds.Tables[0].Rows[i]["M_Attribute_id"]);
         attributeSetTree.items  = new List <VA005_TreeStructure>();
         parentTree.items.Add(attributeSetTree);
         LoadAttributeItems(ds, attributeSetTree, Convert.ToInt32(ds.Tables[0].Rows[i]["M_Attribute_id"]));
     }
 }
        /// <summary>
        /// USed to Create Tree. This is main function which intialize tree creation.
        /// </summary>
        public object CreateTree(string Expend)
        {
            exp = Expend;
            StringBuilder sql = new StringBuilder();

            sql.Append(MRole.GetDefault(_ctx).AddAccessSQL("SELECT m_attributeSet_ID , Name FROM m_attributeSet WHERE IsActive='Y' ORDER BY LOWER(Name),m_attributeSet_ID", "M_AttributeSet", true, true));
            sql.Append("~");
            sql.Append(MRole.GetDefault(_ctx).AddAccessSQL(@"SELECT m_attribute.m_attribute_ID,m_attribute.Name,m_attributeuse.m_attributeset_id,m_attribute.ATTRIBUTEVALUETYPE
                                        FROM m_attributeuse
                                        JOIN m_attribute
                                        ON m_attributeuse.m_attribute_ID=m_attribute.m_attribute_ID WHERE m_attributeuse.IsActive='Y' AND m_attributeuse.IsActive='Y' ORDER BY m_attribute.Name,m_attribute.m_attribute_ID", "M_AttributeUse", true, true));
            sql.Append("~");
            sql.Append(MRole.GetDefault(_ctx).AddAccessSQL("SELECT m_attribute_ID , name,  M_AttributeValue_ID FROM M_AttributeValue WHERE IsActive='Y' ORDER BY name,m_attribute_ID  ", "M_AttributeValue", true, true));
            sql.Append("~");

            SqlParamsIn sqlpar = new SqlParamsIn();

            sqlpar.sql      = sql.ToString();
            sqlpar.pageSize = 0;

            VIS.Helpers.SqlHelper sHelper = new VIS.Helpers.SqlHelper();

            DataSet ds = sHelper.ExecuteDataSet(sqlpar);

            if (ds == null || ds.Tables.Count < 1)
            {
                return(null);
            }

            VA005_TreeStructure tree = new VA005_TreeStructure();

            tree.text   = Msg.GetMsg(_ctx, "VA005_AttributeSetListing");
            tree.NodeID = 0;
            //tree.ParentID = 0;
            tree.expanded   = true;
            tree.visibility = "none";
            tree.ShowInfo   = "none";
            tree.padding    = "8px 10px 8px 10px";
            tree.margin     = "0 0 0 0";

            //tree.ImageSource = "Areas/VA005/Images/1.png";
            tree.items = new List <VA005_TreeStructure>();
            LoadAttributeSet(ds, tree);
            //hidden
            List <VA005_TreeStructure> final = new List <VA005_TreeStructure>();

            final.Add(tree);


            return(final);
        }
        public void LoadAttributeItems(DataSet ds, VA005_TreeStructure parentTree, int parentID)
        {
            DataRow[] drs = ds.Tables[1].Select("M_Attribute_id=" + parentID);

            if (drs != null && drs.Length > 0)
            {
                for (int j = 0; j < drs.Length; j++)
                {
                    VA005_TreeStructure attributeSetTree = new VA005_TreeStructure();
                    attributeSetTree.text   = Convert.ToString(drs[j]["Name"]);
                    attributeSetTree.NodeID = Convert.ToInt32(drs[j]["M_Attribute_id"]);
                    attributeSetTree.items  = new List <VA005_TreeStructure>();
                    parentTree.items.Add(attributeSetTree);
                }
            }
        }
        /// <summary>
        ///  Create Attribute Used in each attribute Set and then fill each attribute Use with respective Value.
        /// </summary>
        /// <param name="ds"></param>
        /// <param name="parentTree"></param>
        /// <param name="parentID"></param>
        public void LoadAttributeUse(DataSet ds, VA005_TreeStructure parentTree, int parentID)
        {
            DataRow[] drs = ds.Tables[1].Select("m_attributeset_id=" + parentID);

            if (drs != null && drs.Length > 0)
            {
                for (int j = 0; j < drs.Length; j++)
                {
                    VA005_TreeStructure attributeSetTree = new VA005_TreeStructure();
                    attributeSetTree.text = System.Net.WebUtility.HtmlEncode(Convert.ToString(drs[j]["Name"]));
                    ////attributeSetTree.NodeID = Convert.ToInt32(drs[j]["m_attributeSet_ID"]);===================
                    attributeSetTree.NodeID   = Convert.ToInt32(drs[j]["m_attribute_ID"]);
                    attributeSetTree.ParentID = parentID;
                    //attributeSetTree.ImageSource = "Areas/VA005/Images/1.png";
                    attributeSetTree.ImageSource = "Areas/VA005/Images/att.png";
                    attributeSetTree.Image2      = "Areas/VA005/Images/edit.png";
                    //                    attributeSetTree.Image3 = "Areas/VA005/Images/multi-sel2.png";
                    attributeSetTree.Image3     = "Areas/VA005/Images/infop.png";
                    attributeSetTree.visibility = "inherit";
                    attributeSetTree.ShowInfo   = "inherit";
                    attributeSetTree.padding    = "8px 10px 8px 38px";
                    attributeSetTree.margin     = "0 0 0 15px";
                    attributeSetTree.Type       = "2";
                    attributeSetTree.expanded   = false;
                    attributeSetTree.zindex     = "99999";
                    attributeSetTree.UID        = attributeSetTree.NodeID + "_2_" + exp;
                    attributeSetTree.NID        = attributeSetTree.NodeID;
                    //attributeSetTree.UID = attributeSetTree.NodeID.ToString();
                    attributeSetTree.items = new List <VA005_TreeStructure>();
                    parentTree.items.Add(attributeSetTree);

                    if (Convert.ToString(drs[j]["ATTRIBUTEVALUETYPE"]) == "L")
                    {
                        LoadAttributeValue(ds, attributeSetTree, Convert.ToInt32(drs[j]["m_attribute_ID"]));
                    }
                }
            }
        }