Esempio n. 1
0
        void ABCGridLookUpEdit_QueryPopUp(object sender, CancelEventArgs e)
        {
            if (String.IsNullOrWhiteSpace(this.ParentCtrlName) == false && String.IsNullOrWhiteSpace(this.ChildField) == false)
            {
                if (ParentControl == null)
                {
                    Form      frm         = this.FindForm();
                    Control[] parentCtrls = frm.Controls.Find(this.ParentCtrlName, true);
                    if (parentCtrls != null && parentCtrls.Length > 0)
                    {
                        if (parentCtrls[0] is IABCBindableControl && parentCtrls[0] is ABCBindingBaseEdit == false)
                        {
                            ParentControl = parentCtrls[0] as IABCBindableControl;
                        }
                        else if (parentCtrls[0] is ABCBindingBaseEdit && (parentCtrls[0] as ABCBindingBaseEdit).EditControl is IABCBindableControl)
                        {
                            ParentControl = (parentCtrls[0] as ABCBindingBaseEdit).EditControl as IABCBindableControl;
                        }
                    }
                }

                if (ParentControl != null && ParentControl is IABCBindableControl && DataStructureProvider.IsTableColumn(LookupTableName, ChildField))
                {
                    object objValue = ParentControl.GetType().GetProperty((ParentControl as IABCBindableControl).BindingProperty).GetValue(ParentControl, null);
                    if (objValue != null)
                    {
                        DataView newView = DataCachingProvider.TryToGetDataView(this.LookupTableName, true);
                        newView.RowFilter = DevExpress.Data.Filtering.CriteriaToWhereClauseHelper.GetDataSetWhere(DevExpress.Data.Filtering.CriteriaOperator.Parse(DefaultFilterString));

                        String strFilter = String.Empty;
                        if (objValue.GetType() == typeof(int) || objValue.GetType() == typeof(double) ||
                            objValue.GetType() == typeof(Nullable <int>) || objValue.GetType() == typeof(Nullable <double>) ||
                            objValue.GetType() == typeof(Boolean) || objValue.GetType() == typeof(Nullable <Boolean>))
                        {
                            strFilter = String.Format(@" {0} = {1} ", ChildField, objValue);
                        }
                        if (objValue.GetType() == typeof(String))
                        {
                            strFilter = String.Format(@" {0} = '{1}' ", ChildField, objValue.ToString());
                        }
                        if (String.IsNullOrWhiteSpace(newView.RowFilter) == false)
                        {
                            strFilter = " AND " + strFilter;
                        }
                        newView.RowFilter += strFilter;

                        this.Properties.DataSource = newView;
                    }
                }
            }
        }
Esempio n. 2
0
        public void InitLayout(ABCView view, XmlNode node)
        {
            OwnerView = view;

            XmlNode child = node.SelectNodes("C")[0];

            if (child == null)
            {
                return;
            }

            String strType = child.Attributes["type"].Value.ToString();

            String strChildType = child.Attributes["type"].Value.ToString();
            Type   type         = TypeResolutionService.CurrentService.GetType(strChildType);

            if (type == null)
            {
                return;
            }

            Component comp = (Component)ABCDynamicInvoker.CreateInstanceObject(type);

            ABCPresentHelper.DeSerialization(comp, child);
            ((IABCControl)comp).OwnerView = view;
            ((IABCControl)comp).InitControl();
            (comp as Control).Parent = this;
            this.EditControl         = (IABCBindableControl)comp;

            if (view.Mode != ViewMode.Design && comp is ABCGridLookUpEdit)
            {
                if (((ABCGridLookUpEdit)comp).Properties.View.Columns.Count <= 2)
                {
                    Component comp2 = (Component)ABCDynamicInvoker.CreateInstanceObject(typeof(ABCLookUpEdit));
                    ((IABCBindableControl)comp2).DataSource = this.DataSource;
                    ((IABCBindableControl)comp2).DataMember = this.DataMember;
                    ((IABCBindableControl)comp2).TableName  = this.TableName;

                    ((IABCControl)comp2).OwnerView = view;
                    ((IABCControl)comp2).InitControl();
                    (comp2 as Control).Parent = this;
                    this.EditControl          = (IABCBindableControl)comp2;
                }
            }

            InvalidateControl();

            if (this.OwnerView == null || (this.OwnerView != null && this.OwnerView.Mode != ViewMode.Design))
            {
                bool   isUse      = true;
                String strRealCol = this.DataMember.Split(':')[0];
                if (!DataStructureProvider.IsTableColumn(this.TableName, strRealCol))
                {
                    isUse = false;
                }

                else if (!DataConfigProvider.TableConfigList.ContainsKey(this.TableName) || !DataConfigProvider.TableConfigList[this.TableName].FieldConfigList.ContainsKey(strRealCol))
                {
                    isUse = false;
                }

                else if (!DataConfigProvider.TableConfigList[this.TableName].FieldConfigList[strRealCol].InUse)
                {
                    isUse = false;
                }

                if (!isUse)
                {
                    this.Visible = false;
                }
            }
        }
Esempio n. 3
0
        public void InvalidateControl( )
        {
            if (EditControl == null && String.IsNullOrWhiteSpace(UIControlType) == false)
            {
                #region Design - FirstTIme
                EditControl            = (IABCBindableControl)ABCBusinessEntities.ABCDynamicInvoker.CreateInstanceObject(Type.GetType(UIControlType));
                EditControl.DataSource = this.DataSource;
                EditControl.DataMember = this.DataMember;
                EditControl.TableName  = this.TableName;

                if (this.DataMember.Contains(":"))
                {
                    SetToReadOnly();
                }
                #endregion
            }

            if (EditControl != null)
            {
                EditControl.DataSource = this.DataSource;
                EditControl.DataMember = this.DataMember;
                EditControl.TableName  = this.TableName;

                this.layoutControl1.Controls.Add((this.EditControl as Control));
                this.LayoutItem.Control = (this.EditControl as Control);

                #region DisplayImage
                if (this.DataMember.Contains(":"))
                {
                    DataCachingProvider.AccrossStructInfo acrrosInfo = DataCachingProvider.GetAccrossStructInfo(TableName, this.DataMember);
                    if (acrrosInfo != null && (acrrosInfo.FieldName == DataStructureProvider.GetNOColumn(acrrosInfo.TableName) ||
                                               acrrosInfo.FieldName == DataStructureProvider.GetNAMEColumn(acrrosInfo.TableName)))
                    {
                        STViewsInfo viewIfo = (STViewsInfo) new STViewsController().GetObject(String.Format("SELECT * FROM STViews WHERE [MainTableName] = '{0}' ", acrrosInfo.TableName));
                        if (viewIfo != null)
                        {
                            this.DisplayImage = true;
                        }
                    }
                }
                else if (DataStructureProvider.IsForeignKey(TableName, this.DataMember))
                {
                    String      strPKTableName = DataStructureProvider.GetTableNameOfForeignKey(TableName, this.DataMember);
                    STViewsInfo viewIfo        = (STViewsInfo) new STViewsController().GetObject(String.Format("SELECT * FROM STViews WHERE [MainTableName] = '{0}' ", strPKTableName));
                    if (viewIfo != null)
                    {
                        this.DisplayImage = true;
                    }
                }
                #endregion

                if (DataStructureProvider.IsNOColumn(this.TableName, this.DataMember))
                {
                    ReadOnly = true;
                }

                #region Permission

                DataCachingProvider.AccrossStructInfo accross = DataCachingProvider.GetAccrossStructInfo(this.TableName, this.DataMember);
                if (ABCScreen.ABCScreenHelper.Instance.CheckFieldPermission(accross.TableName, accross.FieldName, FieldPermission.AllowView) == false)
                {
                    isAllowView = false;
                    ReadOnly    = true;
                }

                if (ReadOnly == false)
                {
                    ReadOnly = !ABCScreen.ABCScreenHelper.Instance.CheckFieldPermission(accross.TableName, accross.FieldName, FieldPermission.AllowEdit);
                }
                #endregion

                if (isAllowView)
                {
                    (this.EditControl as DevExpress.XtraEditors.BaseEdit).CustomDisplayText += new DevExpress.XtraEditors.Controls.CustomDisplayTextEventHandler(ABCBindingBaseEdit_CustomDisplayText);
                }

                if (ReadOnly)
                {
                    SetToReadOnly();
                }
                else
                {
                    if (this.EditControl is DevExpress.XtraEditors.BaseEdit && (this.EditControl as DevExpress.XtraEditors.BaseEdit).Properties != null)
                    {
                        (this.EditControl as DevExpress.XtraEditors.BaseEdit).Properties.AppearanceFocused.BackColor = Color.Bisque;
                    }
                }
            }

            UpdateLabelText();
        }