示例#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;
                    }
                }
            }
        }
示例#2
0
        void LayoutItem_MouseUp(object sender, MouseEventArgs e)
        {
            //if ( OwnerView!=null&&OwnerView.Mode!=ViewMode.Design)
            //{
            if (e.Button == System.Windows.Forms.MouseButtons.Left && this.DisplayImage && EditControl != null &&
                this.LayoutItem.TextSize.Width - 18 < e.X && e.X < this.LayoutItem.TextSize.Width)
            {
                BindingSource  binding = (this.EditControl as Control).DataBindings[0].DataSource as BindingSource;
                BusinessObject busObj  = binding.DataSource as BusinessObject;

                #region Link by ID

                object obj = EditControl.GetType().GetProperty("EditValue").GetValue(EditControl, null);
                Guid   iID = ABCHelper.DataConverter.ConvertToGuid(obj);

                String strLinkTableName = String.Empty;
                Guid   iLinkID          = Guid.Empty;
                if (this.DataMember.Contains(":"))
                {
                    DataCachingProvider.AccrossStructInfo acrrosInfo = DataCachingProvider.GetAccrossStructInfo(busObj, iID, this.DataMember);
                    if (acrrosInfo != null && (acrrosInfo.FieldName == DataStructureProvider.GetNOColumn(acrrosInfo.TableName) ||
                                               acrrosInfo.FieldName == DataStructureProvider.GetNAMEColumn(acrrosInfo.TableName)))
                    {
                        strLinkTableName = acrrosInfo.TableName;
                        iLinkID          = acrrosInfo.TableID;
                    }
                }
                else if (DataStructureProvider.IsForeignKey(TableName, this.DataMember))
                {
                    strLinkTableName = DataStructureProvider.GetTableNameOfForeignKey(TableName, this.DataMember);
                    iLinkID          = iID;
                }
                else
                {
                    strLinkTableName = TableName;
                    iLinkID          = BusinessObjectHelper.GetIDValue(busObj);
                }


                if (iLinkID != Guid.Empty && String.IsNullOrWhiteSpace(strLinkTableName) == false)
                {
                    ABCScreen.ABCScreenHelper.Instance.RunLink(strLinkTableName, this.OwnerView.Mode, false, iLinkID, ABCScreenAction.None);
                    return;
                }
                #endregion

                if (String.IsNullOrWhiteSpace(this.LinkScreen) == false)
                {
                    String[] strArrays = this.ParamFields.Split(';');
                    object[] lstParams = new object[strArrays.Length];
                    for (int i = 0; i < strArrays.Length; i++)
                    {
                        object objParam = strArrays[i];
                        if (DataStructureProvider.IsTableColumn(busObj.AATableName, strArrays[i]))
                        {
                            objParam = ABCBusinessEntities.ABCDynamicInvoker.GetValue(busObj, strArrays[i]);
                        }
                        lstParams[i] = objParam;
                    }

                    ABCScreen.ABCScreenHelper.Instance.RunLink(this.LinkScreen, this.OwnerView.Mode, false, ABCScreenAction.None, lstParams);
                }
            }
            //}
        }