/// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        internal bool SaveModalItem(string conn)
        {
            var dataComponentModal = new Data.Component.ComponentModal(conn);

            this.ComponentModalItemID = dataComponentModal.SaveModalItem(this.ClientID,
                                                                         this.ComponentModalID,
                                                                         this.ComponentID,
                                                                         this.ChildComponentID);
            if (this.ComponentModalItemID != "")
            {
                foreach (LinkComponentField lf in this.Relations)
                {
                    dataComponentModal.SaveItemRelation(this.ClientID,
                                                        this.ComponentModalItemID,
                                                        lf.ParentField,
                                                        lf.RelatedField,
                                                        lf.Parent,
                                                        lf.Child);
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
        internal bool SaveRelation(string conn, List <LinkComponentField> lk)
        {
            var dataComponentModal = new Data.Component.ComponentModal(conn);

            foreach (LinkComponentField lf in lk)
            {
                if (this.Relations.Where(x => x.ModalItemRelationID == lf.ModalItemRelationID).FirstOrDefault() == null)
                {
                    dataComponentModal.SaveItemRelation(this.ClientID,
                                                        this.ComponentModalItemID,
                                                        lf.ParentField,
                                                        lf.RelatedField,
                                                        lf.Parent,
                                                        lf.Child);
                }
                else
                {
                    dataComponentModal.UpdateItemRelation(this.ClientID,
                                                          lf.ModalItemRelationID,
                                                          this.ComponentModalItemID,
                                                          lf.ParentField,
                                                          lf.RelatedField);
                }
            }
            return(true);
        }
        public bool RemoveAllRelations()
        {
            var c = new ClientServer(ClientID);
            var dataComponentModal = new Data.Component.ComponentModal(c.GetServer().Connection());

            dataComponentModal.RemoveAllItemRelation(this.ClientID, this.ComponentModalItemID);
            return(true);
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="clientID"></param>
 /// <param name="componentModalID"></param>
 public ComponentModal(string clientID, string componentModalID)
 {
     this.ClientID           = clientID;
     c                       = new ClientServer(ClientID);
     ComponentModalID        = componentModalID;
     this.ComponentModalRoot = new List <ComponentNode>();
     conn                    = c.GetServer().Connection();
     dataComponentModal      = new Data.Component.ComponentModal(conn);
     LoadModal();
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="clientID"></param>        ///
 public ComponentModal(string clientID)
 {
     ClientID           = clientID;
     c                  = new ClientServer(ClientID);
     ModalName          = "";
     Category           = "";
     ParentComponent    = "";
     ComponentModalRoot = new List <ComponentNode>();
     conn               = c.GetServer().Connection();
     dataComponentModal = new Data.Component.ComponentModal(c.GetServer().Connection());
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="clientID"></param>        ///
 public ComponentModal(string clientID, string name, string category, string parentnode)
 {
     ClientID           = clientID;
     c                  = new ClientServer(ClientID);
     ModalName          = name;
     Category           = category;
     ParentComponent    = parentnode;
     ComponentModalRoot = new List <ComponentNode>();
     conn               = c.GetServer().Connection();
     dataComponentModal = new Data.Component.ComponentModal(c.GetServer().Connection());
 }
        public bool AddRelation(string modalItemID, List <LinkComponentField> lf)
        {
            var dataComponentModal = new Data.Component.ComponentModal(conn);
            var modalitem          = this.ComponentModalRoot.Where(x => x.ComponentModalItemID == modalItemID).FirstOrDefault();

            if (modalitem != null)
            {
                return(modalitem.SaveRelation(conn, lf));
            }
            else
            {
                return(false);
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="modalid"></param>
        /// <returns></returns>
        public bool RemoveItem(string modalid)
        {
            var c = new ClientServer(ClientID);
            var dataComponentModal = new Data.Component.ComponentModal(c.GetServer().Connection());

            if (dataComponentModal.RemoveModalItem(this.ClientID, modalid, this.ComponentModalItemID))
            {
                dataComponentModal.RemoveAllItemRelation(this.ClientID, this.ComponentModalItemID);
                return(true);
            }
            else
            {
                return(false);
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="mrelatedID"></param>
        /// <param name="parentfield"></param>
        /// <param name="relatedfield"></param>
        /// <returns></returns>
        public bool UpdateModalItemRelation(string mrelatedID, string parentfield, string relatedfield)
        {
            var c    = new ClientServer(ClientID);
            var item = this.Relations.Where(x => x.ModalItemRelationID == mrelatedID).FirstOrDefault();
            var dataComponentModal = new Data.Component.ComponentModal(c.GetServer().Connection());

            if (item != null)
            {
                dataComponentModal.UpdateItemRelation(this.ClientID, mrelatedID, this.ComponentModalItemID, parentfield, relatedfield);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="clientid"></param>
        /// <returns></returns>
        public static List <ComponentModal> GetModalList(string clientid)
        {
            DataTable             dt         = new DataTable();
            DataTable             dtModal    = new DataTable();
            DataTable             dtItem     = new DataTable();
            DataTable             dtRelation = new DataTable();
            List <ComponentModal> ModalList  = new List <ComponentModal>();
            var c = new ClientServer(clientid);
            var dataComponentModal = new Data.Component.ComponentModal(c.GetServer().Connection());

            dt      = dataComponentModal.GetAllModal(clientid);
            dtModal = dt.DefaultView.ToTable(true, "Name", "Catgory", "ParentComponent", "ComponentModalID");

            dtItem     = dt.DefaultView.ToTable(true, "ComponentID", "ChildComponentID", "ComponentModalItemID", "ParentName", "ChildName");
            dtRelation = dt.DefaultView.ToTable(true, "ComponentModalItemID", "ParentField", "ComponentModalID",
                                                "RelatedField", "ComponentModalRelationID", "Parent", "Child", "ParentFieldName", "ChildFieldName");

            foreach (DataRow dr in dtModal.Rows)
            {
                var comp = new ComponentModal(clientid);

                comp.ModalName           = dr.IsNull("Name") ? "" : dr["Name"].ToString();
                comp.Category            = dr.IsNull("Catgory") ? "" : dr["Catgory"].ToString();
                comp.ParentComponent     = dr.IsNull("ParentComponent") ? "" : dr["ParentComponent"].ToString();
                comp.ComponentModalID    = dr.IsNull("ComponentModalID") ? "" : dr["ComponentModalID"].ToString();
                dt.DefaultView.RowFilter = "ComponentModalID ='" + comp.ComponentModalID + "'";
                dt.DefaultView.RowFilter = "";
                dtItem = dt.DefaultView.ToTable(true);
                foreach (DataRow dRow in dtItem.Rows)
                {
                    var           componentID  = dRow.IsNull("ComponentID") ? "" : dRow["ComponentID"].ToString();
                    var           ccomponentid = dRow.IsNull("ChildComponentID") ? "" : dRow["ChildComponentID"].ToString();
                    var           cmodalitemid = dRow.IsNull("ComponentModalItemID") ? "" : dRow["ComponentModalItemID"].ToString();
                    var           pname        = dRow.IsNull("ParentName") ? "" : dRow["ParentName"].ToString();
                    var           cname        = dRow.IsNull("ChildName") ? "" : dRow["ChildName"].ToString();
                    ComponentNode cn           = new ComponentNode(clientid, componentID, ccomponentid, cmodalitemid);
                    cn.ParentName = pname;
                    cn.ChildName  = cname;
                    dtRelation.DefaultView.RowFilter = "ComponentModalItemID ='" + cmodalitemid + "'";
                    var dtr = dtRelation.DefaultView.ToTable(true);
                    dtRelation.DefaultView.RowFilter = "";
                    foreach (DataRow drNodeRe in dtr.Rows)
                    {
                        var mrid   = drNodeRe.IsNull("ComponentModalRelationID") ? "" : drNodeRe["ComponentModalRelationID"].ToString();
                        var pf     = drNodeRe.IsNull("ParentField") ? "" : drNodeRe["ParentField"].ToString();
                        var rf     = drNodeRe.IsNull("RelatedField") ? "" : drNodeRe["RelatedField"].ToString();
                        var p      = drNodeRe.IsNull("Parent") ? "" : drNodeRe["Parent"].ToString();
                        var ch     = drNodeRe.IsNull("Child") ? "" : drNodeRe["Child"].ToString();
                        var pfield = drNodeRe.IsNull("ParentFieldName") ? "" : drNodeRe["ParentFieldName"].ToString();
                        var cfield = drNodeRe.IsNull("ChildFieldName") ? "" : drNodeRe["ChildFieldName"].ToString();
                        cn.AddRelation(new LinkComponentField()
                        {
                            ModalItemRelationID = mrid,
                            Child            = ch,
                            Parent           = p,
                            ParentFieldName  = pfield,
                            RelatedFieldName = cfield,
                            ParentField      = pf,
                            RelatedField     = rf
                        });
                    }
                    comp.ComponentModalRoot.Add(cn);
                }
                ModalList.Add(comp);
            }
            return(ModalList);
        }
Example #11
0
        internal bool RemoveItemRelation(string rid, string conn)
        {
            var dataComponentModal = new Data.Component.ComponentModal(conn);

            return(dataComponentModal.RemoveItemRelation(this.ClientID, rid));
        }