예제 #1
0
        public XOTable(XOApplication XOApplication, XOPTable XOPTable, XWPTable XWPTable, XSPTable XSPTable)
        {
            _xoApplication = XOApplication;

            _xopTable = XOPTable;

            _xwpTable = XWPTable;

            _xspTable = XSPTable;

            _fields = XopTable.Fields.Fields.Select(p => new XOField(this, p,
                XWPTable != null ? XWPTable.Fields.Fields.FirstOrDefault(s => s.FieldName == p.Name) : null,
                XSPTable != null ? XSPTable.Fields.FirstOrDefault(s => s.FieldName == p.Name) : null)).ToArray();

            if (XoApplication.XopDataSet.Relations != null)
            {
                _childrenRelations = XoApplication.XopDataSet.Relations.Relations.Where(p => p.ParentTable == this.Name)
                    .Select(p => new XORelation(
                        this, p, GetXwpRelation(p.Name))
                        ).ToArray();
            }
            else
            {
                _childrenRelations = new XORelation[] { };
            }
        }
            internal RelationDataSourceProperits(XORelation XORelation)
            {
                this.DataSource = GetParentRelationDataSource(XORelation);

                this.ValueMember = XORelation.ParentField.Name;

                this.DisplayMember = XORelation.DisplayedField;

                this.Filter = XORelation.Filter;
            }
 protected override bool IsAdmittedChildRelation(XORelation XORelation)
 {
     return DefaultTableContext.GetChildRelation(XORelation.ChildField).ChildTable.IsCanView;
 }
        protected override object CreateChildRelationControl(XORelation XORelation)
        {
            DataAvail.Controllers.Controller controller = Controller.GetChildController(XORelation.ParentField.Name, XORelation.ChildTable.Name, XORelation.ChildField.Name);

            return CreateChildRelationControl(controller);
        }
 protected virtual bool IsAdmittedChildRelation(XORelation XtraObjectRelation)
 {
     return true;
 }
 protected virtual void BindChildRelationControl(object Control, XORelation XtraObjectRelation)
 {
 }
        protected virtual void InitializeChildRelationControl(object Control, XORelation XtraObjectRelation)
        {

        }
 protected virtual object CreateChildRelationControl(XORelation XtraObjectRelation)
 {
     return null;
 }
        protected virtual object BuildChildRelation(XORelation XtraObjectRelation)
        {
            bool isAdmitted = IsAdmittedChildRelation(XtraObjectRelation);

            object ctl = isAdmitted ? CreateChildRelationControl(XtraObjectRelation) : CreateEmptyControl();

            if (ctl != null)
            {
                InitializeChildRelationControl(ctl, XtraObjectRelation);

                if (isAdmitted)
                    BindChildRelationControl(ctl, XtraObjectRelation);

                AddFieldControl(ctl, string.Format("{0}_{1}_{2}", XtraObjectRelation.ParentTable.Name, XtraObjectRelation.ChildTable.Name, XtraObjectRelation.ChildField.Name), XtraObjectRelation.ChildTable.Caption);
            }

            return ctl;

        }
        protected override void InitializeChildRelationControl(object Control, XORelation XORelation)
        {
            ((System.Windows.Forms.Control)Control).Name = string.Format("ctl{0}_{1}_{2}", XORelation.ParentTable.Name, XORelation.ChildTable.Name, XORelation.ChildField.Name);

            base.InitializeChildRelationControl(Control, XORelation);
        }
 protected override object CreateChildRelationControl(XORelation XORelation)
 {
     return null;
 }
            private static object GetParentRelationDataSource(XORelation ParentRelation)
            {
                object dataSource = Controller.controllerContext.GetDataSource(ParentRelation.ParentTable);

                if (dataSource == null)
                    throw new Exception("Uh huh data source fro parent table not found. Please confirm it is defined in model file");

                return XtraBinding.ItemAdapter.GetBindingListView(dataSource);
            }
        public IBindingListView GetParentRelationDataSource(XORelation ParentRelation)
        {
            object dataSource = Controller.controllerContext.GetDataSource(ParentRelation.ParentTable);

            if (dataSource == null)
                throw new Exception("Uh huh data source fro parent table not found. Please confirm it is defined in model file");

            IBindingListView listView = XtraBinding.ItemAdapter.GetBindingListView(dataSource);

            if (!string.IsNullOrEmpty(ParentRelation.Filter))
            {
                listView.Filter = ParentRelation.Filter;
            }

            return listView;
        }