Ejemplo n.º 1
0
        void ABCRepositoryGridLookupEdit_QueryPopUp(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (sender is ABCGridLookUpEdit && this.Grid != null && this.Grid.DefaultView != null)
            {
                (this.Grid.DefaultView as DevExpress.XtraGrid.Views.Grid.GridView).ClearColumnsFilter();
            }

            this.View.ClearColumnsFilter();

            String strTableName = String.Empty;

            if (sender is ABCGridLookUpEdit)
            {
                strTableName = (sender as ABCGridLookUpEdit).LookupTableName;
                if (String.IsNullOrWhiteSpace(strTableName))
                {
                    if (this.Grid != null && this.Grid.DefaultView != null)
                    {
                        DevExpress.XtraGrid.Columns.GridColumn col = (this.Grid.DefaultView as DevExpress.XtraGrid.Views.Grid.GridView).FocusedColumn as DevExpress.XtraGrid.Columns.GridColumn;
                        if (col == null)
                        {
                            return;
                        }

                        object obj = col.GetType().GetField("TableName").GetValue(col);
                        if (obj != null)
                        {
                            strTableName = obj.ToString();
                        }
                    }
                }

                DataCachingProvider.RefreshLookupTable(strTableName);
            }
        }
Ejemplo n.º 2
0
        protected override DevExpress.XtraEditors.Controls.ConvertEditValueEventArgs DoFormatEditValue(object val)
        {
            object objValue = val;

            if (objValue != null && objValue != DBNull.Value)
            {
                if (this.OwnerEdit != null)
                {
                    ABCTextEdit textEdit = (this.OwnerEdit as ABCTextEdit);

                    String strDataMember = textEdit.DataMember;
                    if (DataStructureProvider.IsForeignKey(textEdit.TableName, textEdit.DataMember))
                    {
                        strDataMember = textEdit.DataMember + ":" + DataStructureProvider.GetDisplayColumn(textEdit.TableName);
                    }

                    if (textEdit.BindingManager.Position >= 0 && textEdit.BindingManager.Current != null && textEdit.BindingManager.Current is ABCBusinessEntities.BusinessObject)
                    {
                        if (strDataMember.Contains(":") && objValue is Guid && ABCHelper.DataConverter.ConvertToGuid(objValue) != Guid.Empty)
                        {
                            ABCBusinessEntities.BusinessObject objBinds = textEdit.BindingManager.Current as ABCBusinessEntities.BusinessObject;
                            objValue = DataCachingProvider.GetCachingObjectAccrossTable(objBinds, ABCHelper.DataConverter.ConvertToGuid(objValue), strDataMember);
                        }
                    }
                }
            }
            return(base.DoFormatEditValue(objValue));
        }
Ejemplo n.º 3
0
        public void InvalidateCachingAllNodes( )
        {
            DataList.Clear();
            foreach (TreeConfigNode configNode in ConfigList.Values)
            {
                try
                {
                    if (configNode.InnerData != null && configNode.ParentNode != null)
                    {
                        DataView view = DataCachingProvider.TryToGetDataView(configNode.InnerData.TableName, false);
                        BusinessObjectController Controller = BusinessControllerFactory.GetBusinessController(configNode.InnerData.TableName);

                        //DataSet ds=Controller.GetAllObjects();
                        //if ( ds!=null&&ds.Tables.Count>0 )
                        //{
                        foreach (DataRow dr in view.Table.Rows)
                        {
                            BusinessObject obj = Controller.GetObjectFromDataRow(dr);
                            if (obj != null)
                            {
                                ABCTreeListNode node = new ABCTreeListNode(null, configNode.InnerData.Name, obj);
                                node.Manager = this;
                                node.CachingNode();
                            }
                        }
                        //     }
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }
Ejemplo n.º 4
0
        void ConfigGridView_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            if (e.Column.FieldName == "FieldName" || e.Column.FieldName == "IsUseAlias")
            {
                ABCGridColumn.ColumnConfig config = this.ConfigGridView.GetRow(this.ConfigGridView.FocusedRowHandle) as ABCGridColumn.ColumnConfig;
                if (config != null)
                {
                    if (config.IsUseAlias)
                    {
                        String strCaption = String.Empty;
                        if (config.FieldName.Contains(":"))
                        {
                            DataCachingProvider.AccrossStructInfo structInfo = DataCachingProvider.GetAccrossStructInfo(config.TableName, config.FieldName);
                            if (structInfo != null)
                            {
                                strCaption = DataConfigProvider.GetFieldCaption(structInfo.TableName, structInfo.FieldName);
                            }
                        }
                        else
                        {
                            strCaption = DataConfigProvider.GetFieldCaption(config.TableName, config.FieldName);
                        }

                        if (string.IsNullOrWhiteSpace(strCaption) == false)
                        {
                            config.Caption = strCaption;
                        }
                    }
                }
            }

            RefreshDisplayGrid();
        }
Ejemplo n.º 5
0
        void VGrid_CustomUnboundData(object sender, DevExpress.XtraVerticalGrid.Events.CustomDataEventArgs e)
        {
            if (e.Row != null && (e.Row.Tag is ABCGridColumn.ColumnConfig || e.Row.Tag is ABCGridBandedColumn.ColumnConfig) &&
                (this.ABCGrid == null ||
                 (this.ABCGrid.OwnerView != null && this.ABCGrid.OwnerView.Mode != ViewMode.Design)))
            {
                if (e.Row.Index >= 0 && String.IsNullOrWhiteSpace(this.ABCGrid.TableName) == false && e.Row.Properties.FieldName.Contains(":"))
                {
                    EditorRow gridRow    = e.Row as EditorRow;
                    object    objDataRow = this.VGrid.GetRecordObject(e.ListSourceRowIndex);
                    if (objDataRow == null)
                    {
                        return;
                    }

                    String       strBaseField = e.Row.Properties.FieldName.Split(':')[0];
                    PropertyInfo proInfo      = objDataRow.GetType().GetProperty(strBaseField);
                    if (proInfo == null)
                    {
                        return;
                    }

                    object objValue = proInfo.GetValue(objDataRow, null);
                    e.Value = DataCachingProvider.GetCachingObjectAccrossTable(this.ABCGrid.TableName, ABCHelper.DataConverter.ConvertToGuid(objValue), e.Row.Properties.FieldName);
                }
            }
        }
Ejemplo n.º 6
0
 void ABCLabel_Format(object sender, ConvertEventArgs e)
 {
     if (this.DataMember.Contains(":"))
     {
         e.Value = DataCachingProvider.GetCachingObjectAccrossTable(this.TableName, ABCHelper.DataConverter.ConvertToGuid(e.Value), this.DataMember);
         e.Value = DataFormatProvider.DoFormat(e.Value, this.TableName, this.DataMember);
     }
 }
Ejemplo n.º 7
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;
                    }
                }
            }
        }
Ejemplo n.º 8
0
        public void RunFocusedLink( )
        {
            if (String.IsNullOrWhiteSpace(this.ABCGrid.TableName) == false)
            {
                if (this.ABCGrid == null || (this.ABCGrid.OwnerView != null && this.ABCGrid.OwnerView.Mode != ViewMode.Design))
                {
                    String strTableName = this.ABCGrid.TableName;
                    String strFieldName = VGrid.FocusedRow.Properties.FieldName;

                    String strLinkTableName = String.Empty;
                    Guid   iLinkID          = Guid.Empty;


                    EditorRow gridRow      = this.VGrid.FocusedRow as EditorRow;
                    object    objCellValue = this.VGrid.GetCellValue(gridRow, VGrid.FocusedRecord);
                    if (objCellValue == null || objCellValue.GetType() != typeof(Guid))
                    {
                        return;
                    }
                    if (gridRow.Properties.FieldName.Contains(":"))
                    {
                        DataCachingProvider.AccrossStructInfo acrrosInfo = DataCachingProvider.GetAccrossStructInfo(strTableName, ABCHelper.DataConverter.ConvertToGuid(objCellValue), gridRow.Properties.FieldName);
                        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(strTableName, strFieldName))
                    {
                        strLinkTableName = DataStructureProvider.GetTableNameOfForeignKey(strTableName, strFieldName);
                        iLinkID          = ABCHelper.DataConverter.ConvertToGuid(objCellValue);
                    }

                    if (iLinkID != Guid.Empty)
                    {
                        if (this.ABCGrid.OwnerView != null)
                        {
                            ABCScreen.ABCScreenHelper.Instance.RunLink(strLinkTableName, this.ABCGrid.OwnerView.Mode, false, iLinkID, ABCScreenAction.None);
                        }
                        else
                        {
                            ABCScreen.ABCScreenHelper.Instance.RunLink(strLinkTableName, ViewMode.Runtime, false, iLinkID, ABCScreenAction.None);
                        }
                    }
                }
            }
        }
Ejemplo n.º 9
0
        private void DrawLinkButton(DevExpress.XtraVerticalGrid.Events.CustomDrawRowValueCellEventArgs e)
        {
            if (this.ABCGrid == null ||
                (this.ABCGrid.OwnerView != null && this.ABCGrid.OwnerView.Mode != ViewMode.Design))
            {
                if (e.Row != null && e.Row.Tag is ABCGridColumn.ColumnConfig && String.IsNullOrWhiteSpace(this.ABCGrid.TableName) == false && e.CellValue != null && e.CellValue.GetType() == typeof(int))
                {
                    Boolean isDraw = false;

                    EditorRow gridRow      = e.Row as EditorRow;
                    String    strTableName = this.ABCGrid.TableName;
                    if (gridRow.Properties.FieldName.Contains(":") == false)
                    {
                        if (ForeignColumnList.TryGetValue(gridRow.Properties.FieldName, out isDraw) == false)
                        {
                            if (DataStructureProvider.IsForeignKey(strTableName, gridRow.Properties.FieldName))
                            {
                                ForeignColumnList.Add(gridRow.Properties.FieldName, true);
                            }
                            else
                            {
                                ForeignColumnList.Add(gridRow.Properties.FieldName, false);
                            }
                        }
                    }
                    else
                    {
                        DataCachingProvider.AccrossStructInfo acrrosInfo = DataCachingProvider.GetAccrossStructInfo(strTableName, ABCHelper.DataConverter.ConvertToGuid(e.CellValue), e.Row.Properties.FieldName);
                        if (acrrosInfo != null && (acrrosInfo.FieldName == DataStructureProvider.GetNOColumn(acrrosInfo.TableName) ||
                                                   acrrosInfo.FieldName == DataStructureProvider.GetNAMEColumn(acrrosInfo.TableName)))
                        {
                            isDraw = true;
                        }
                    }

                    if (isDraw)
                    {
                        e.Graphics.DrawImage(ABCControls.ABCImageList.GetImage16x16("DocLink"), e.Bounds.Location);

                        Rectangle r = e.Bounds;
                        r.Width -= 18;
                        r.X     += 18;
                        e.Appearance.DrawString(e.Cache, e.CellText, r);

                        e.Handled = true;
                    }
                }
            }
        }
Ejemplo n.º 10
0
        public void InitGridView( )
        {
            String strFieldName = this.DataMember.Split(':')[0];

            if (DataStructureProvider.IsForeignKey(this.TableName, strFieldName) || DataStructureProvider.IsPrimaryKey(this.TableName, strFieldName))
            {
                if (DataStructureProvider.IsForeignKey(this.TableName, strFieldName))
                {
                    this.LookupTableName = DataStructureProvider.GetTableNameOfForeignKey(this.TableName, strFieldName);
                }
                else
                {
                    this.LookupTableName = this.TableName;
                }
                ABCControls.UICaching.InitDefaultRepositoryGridLookUpEdit(this.LookupTableName, this.Properties, true);


                if (String.IsNullOrWhiteSpace(this.DisplayMember) == false && DataStructureProvider.IsTableColumn(this.LookupTableName, this.DisplayMember))
                {
                    this.Properties.DisplayMember = this.DisplayMember;
                }

                if (String.IsNullOrWhiteSpace(this.ValueMember) == false && DataStructureProvider.IsTableColumn(this.LookupTableName, this.ValueMember))
                {
                    this.Properties.ValueMember = this.ValueMember;
                }

                #region DataSource
                if (String.IsNullOrWhiteSpace(DefaultFilterString))
                {
                    this.Properties.DataSource = DataCachingProvider.TryToGetDataView(this.LookupTableName, false);
                }
                else
                {
                    DataView newView = DataCachingProvider.TryToGetDataView(this.LookupTableName, true);
                    newView.RowFilter          = DevExpress.Data.Filtering.CriteriaToWhereClauseHelper.GetDataSetWhere(DevExpress.Data.Filtering.CriteriaOperator.Parse(DefaultFilterString));
                    this.Properties.DataSource = newView;
                }

                #endregion

                if (this.Enabled)
                {
                    this.Enabled = ABCScreen.ABCScreenHelper.Instance.CheckTablePermission(this.LookupTableName, TablePermission.AllowView);
                }
            }
        }
Ejemplo n.º 11
0
        public static void InitDefaultRepository(ABCGridColumn gridCol)
        {
            try
            {
                #region RepositoryLookupEdit
                if (DataStructureProvider.IsForeignKey(gridCol.TableName, gridCol.FieldName))
                {
                    String strPKTableName = DataStructureProvider.GetTableNameOfForeignKey(gridCol.TableName, gridCol.FieldName);
                    gridCol.ColumnEdit = GetDefaultRepositoryLookUpEdit(strPKTableName, false);
                    (gridCol.ColumnEdit as ABCRepositoryLookUpEdit).DataSource = DataCachingProvider.TryToGetDataView(strPKTableName, false);
                }
                #endregion

                #region Enum
                else if (DataStructureProvider.IsTableColumn(gridCol.TableName, gridCol.FieldName) &&
                         String.IsNullOrWhiteSpace(DataConfigProvider.TableConfigList[gridCol.TableName].FieldConfigList[gridCol.FieldName].AssignedEnum) == false)
                {
                    String strEnum = DataConfigProvider.TableConfigList[gridCol.TableName].FieldConfigList[gridCol.FieldName].AssignedEnum;
                    if (EnumProvider.EnumList.ContainsKey(strEnum))
                    {
                        ABCRepositoryLookUpEdit repo = new ABCRepositoryLookUpEdit();

                        repo.Properties.ValueMember = "ItemName";
                        if (ABCApp.ABCDataGlobal.Language == "VN")
                        {
                            repo.Properties.DisplayMember = "CaptionVN";
                        }
                        else
                        {
                            repo.Properties.DisplayMember = "CaptionEN";
                        }

                        DevExpress.XtraEditors.Controls.LookUpColumnInfo col = new DevExpress.XtraEditors.Controls.LookUpColumnInfo();
                        col.FieldName = repo.Properties.DisplayMember;
                        col.Caption   = DataConfigProvider.GetFieldCaption(gridCol.TableName, gridCol.FieldName);
                        col.Visible   = true;
                        repo.Properties.Columns.Add(col);
                        repo.Properties.DataSource = EnumProvider.EnumList[strEnum].Items.Values.ToArray();
                        gridCol.ColumnEdit         = repo;
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
            }
        }
Ejemplo n.º 12
0
        void TreeList.IVirtualTreeListData.VirtualTreeGetCellValue(VirtualTreeGetCellValueInfo info)
        {
            if (Manager == null)
            {
                return;
            }

            TreeConfigNode config = null;

            if (Manager.ConfigList.TryGetValue(ObjectName, out config) == false)
            {
                return;
            }

            String strField = String.Empty;

            if (config.InnerData.ColumnFieldNames.TryGetValue(info.Column.Caption, out strField) == false)
            {
                return;
            }

            if (String.IsNullOrWhiteSpace(strField))
            {
                return;
            }

            String strFirstField = strField.Split(':')[0];

            if (DataStructureProvider.IsForeignKey(InnerData.AATableName, strFirstField))
            {
                Guid iID = ABCHelper.DataConverter.ConvertToGuid(ABCBusinessEntities.ABCDynamicInvoker.GetValue(InnerData, strFirstField));
                if (iID != Guid.Empty)
                {
                    info.CellData = DataCachingProvider.GetCachingObjectAccrossTable(InnerData.AATableName, iID, strField);
                }
            }
            else
            {
                info.CellData = ABCBusinessEntities.ABCDynamicInvoker.GetValue(InnerData, strFirstField);
                String strEnum = DataConfigProvider.TableConfigList[InnerData.AATableName].FieldConfigList[strFirstField].AssignedEnum;
                if (info.CellData != null && String.IsNullOrWhiteSpace(info.CellData.ToString()) == false && EnumProvider.EnumList.ContainsKey(strEnum))
                {
                    info.CellData = EnumProvider.EnumList[strEnum].Items[info.CellData.ToString()].CaptionVN;
                }
            }
        }
Ejemplo n.º 13
0
        public void InitColumnsFromTable( )
        {
            foreach (String strField in DataStructureProvider.DataTablesList[TableName].ColumnsList.Keys)
            {
                if (!DataConfigProvider.TableConfigList[TableName].FieldConfigList.ContainsKey(strField))
                {
                    continue;
                }

                DataConfigProvider.FieldConfig config = DataConfigProvider.TableConfigList[TableName].FieldConfigList[strField];
                String strCaption = DataConfigProvider.GetFieldCaption(TableName, strField);

                if (config.TypeName == "DateTime" || config.TypeName == "Nullable<DateTime>")
                {
                    this.filterEditorControl1.FilterColumns.Add(new UnboundFilterColumn(strCaption, strField, typeof(DateTime), new RepositoryItemDateEdit(), FilterColumnClauseClass.DateTime));
                }
                if (config.TypeName == "int" || config.TypeName == "Nullable<int>")
                {
                    this.filterEditorControl1.FilterColumns.Add(new UnboundFilterColumn(strCaption, strField, typeof(int), new RepositoryItemSpinEdit(), FilterColumnClauseClass.Generic));
                }
                if (config.TypeName == "Guid" || config.TypeName == "Nullable<Guid>")
                {
                    if (DataStructureProvider.IsForeignKey(TableName, strField))
                    {
                        String strPKTableName             = DataStructureProvider.GetTableNameOfForeignKey(TableName, strField);
                        RepositoryItemLookUpEditBase repo = ABCControls.UICaching.GetDefaultRepository(strPKTableName, false);
                        repo.DataSource = DataCachingProvider.TryToGetDataView(strPKTableName, false);

                        this.filterEditorControl1.FilterColumns.Add(new UnboundFilterColumn(strCaption, strField, typeof(Guid), repo, FilterColumnClauseClass.Lookup));
                    }
                }
                if (config.TypeName == "String")
                {
                    this.filterEditorControl1.FilterColumns.Add(new UnboundFilterColumn(strCaption, strField, typeof(String), new RepositoryItemTextEdit(), FilterColumnClauseClass.String));
                }
                if (config.TypeName == "double")
                {
                    this.filterEditorControl1.FilterColumns.Add(new UnboundFilterColumn(strCaption, strField, typeof(double), new RepositoryItemTextEdit(), FilterColumnClauseClass.Generic));
                }
                if (config.TypeName == "bool" || config.TypeName == "Nullable<bool>")
                {
                    this.filterEditorControl1.FilterColumns.Add(new UnboundFilterColumn(strCaption, strField, typeof(bool), new RepositoryItemCheckEdit(), FilterColumnClauseClass.Generic));
                }
            }
        }
Ejemplo n.º 14
0
        public override string GetDisplayText(object editValue)
        {
            if (editValue != null && editValue != DBNull.Value)
            {
                try
                {
                    if (this.OwnerEdit != null)
                    {
                        ABCTextEdit textEdit = (this.OwnerEdit as ABCTextEdit);
                        if (String.IsNullOrWhiteSpace(textEdit.DataMember) == false && String.IsNullOrWhiteSpace(textEdit.TableName) == false)
                        {
                            String strDataMember = textEdit.DataMember;
                            if (DataStructureProvider.IsForeignKey(textEdit.TableName, textEdit.DataMember))
                            {
                                strDataMember = textEdit.DataMember + ":" + DataStructureProvider.GetDisplayColumn(textEdit.TableName);
                            }

                            if (String.IsNullOrWhiteSpace(strDataMember) == false)
                            {
                                if (!String.IsNullOrWhiteSpace(textEdit.DataSource))
                                {
                                    if (textEdit.BindingManager.Position >= 0 && textEdit.BindingManager.Current != null && textEdit.BindingManager.Current is ABCBusinessEntities.BusinessObject)
                                    {
                                        object objValue = editValue;
                                        if (strDataMember.Contains(":") && editValue is Guid && ABCHelper.DataConverter.ConvertToGuid(editValue) != Guid.Empty)
                                        {
                                            ABCBusinessEntities.BusinessObject objBinds = textEdit.BindingManager.Current as ABCBusinessEntities.BusinessObject;
                                            objValue = DataCachingProvider.GetCachingObjectAccrossTable(objBinds, ABCHelper.DataConverter.ConvertToGuid(editValue), strDataMember);
                                        }
                                        return(DataFormatProvider.DoFormat(objValue, textEdit.TableName, strDataMember));
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                { }
            }

            return(base.GetDisplayText(editValue));
        }
Ejemplo n.º 15
0
        public void RefreshCachingNodes(TreeConfigNode configNode)
        {
            try
            {
                if (configNode.InnerData != null && configNode.ParentNode != null)
                {
                    Dictionary <Guid, ABCTreeListNode> innerList = null;
                    if (this.DataList.TryGetValue(configNode.InnerData.Name, out innerList) == false)
                    {
                        innerList = new Dictionary <Guid, ABCTreeListNode>();
                        this.DataList.Add(configNode.InnerData.Name, innerList);
                    }

                    DataView view = DataCachingProvider.TryToGetDataView(configNode.InnerData.TableName, false);
                    BusinessObjectController Controller = BusinessControllerFactory.GetBusinessController(configNode.InnerData.TableName);
                    String strPK = DataStructureProvider.GetPrimaryKeyColumn(configNode.InnerData.TableName);
                    foreach (DataRow dr in view.Table.Rows)
                    {
                        BusinessObject obj = Controller.GetObjectFromDataRow(dr);
                        if (obj != null)
                        {
                            Guid iID = ABCHelper.DataConverter.ConvertToGuid(ABCBusinessEntities.ABCDynamicInvoker.GetValue(obj, strPK));
                            if (innerList.ContainsKey(iID) == false)
                            {
                                ABCTreeListNode node = new ABCTreeListNode(null, configNode.InnerData.Name, obj);
                                node.Manager = this;
                                node.CachingNode();
                            }
                            else
                            {
                                innerList[iID].InnerData = obj;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Ejemplo n.º 16
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);
                }
            }
            //}
        }
Ejemplo n.º 17
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();
        }
Ejemplo n.º 18
0
        private void InitRepositoryLookupEdit( )
        {
            String strFieldName = this.DataMember.Split(':')[0];

            if (DataStructureProvider.IsForeignKey(this.TableName, strFieldName))
            {
                this.LookupTableName = DataStructureProvider.GetTableNameOfForeignKey(this.TableName, strFieldName);
                ABCControls.UICaching.InitDefaultRepositoryLookupEdit(this.LookupTableName, this.Properties);

                if (String.IsNullOrWhiteSpace(this.DisplayMember) == false && DataStructureProvider.IsTableColumn(this.LookupTableName, this.DisplayMember))
                {
                    this.Properties.DisplayMember = this.DisplayMember;
                }

                if (String.IsNullOrWhiteSpace(this.ValueMember) == false && DataStructureProvider.IsTableColumn(this.LookupTableName, this.ValueMember))
                {
                    this.Properties.ValueMember = this.ValueMember;
                }


                #region DataSource
                if (String.IsNullOrWhiteSpace(DefaultFilterString))
                {
                    this.Properties.DataSource = DataCachingProvider.TryToGetDataView(this.LookupTableName, false);
                }
                else
                {
                    DataView newView = DataCachingProvider.TryToGetDataView(this.LookupTableName, true);
                    newView.RowFilter          = DevExpress.Data.Filtering.CriteriaToWhereClauseHelper.GetDataSetWhere(DevExpress.Data.Filtering.CriteriaOperator.Parse(DefaultFilterString));
                    this.Properties.DataSource = newView;
                }
                #endregion

                if (this.Enabled)
                {
                    this.Enabled = ABCScreen.ABCScreenHelper.Instance.CheckTablePermission(this.LookupTableName, TablePermission.AllowView);
                }
            }
            else if (DataStructureProvider.IsTableColumn(this.TableName, strFieldName) &&
                     String.IsNullOrWhiteSpace(DataConfigProvider.TableConfigList[this.TableName].FieldConfigList[strFieldName].AssignedEnum) == false)
            {
                String strEnum = DataConfigProvider.TableConfigList[this.TableName].FieldConfigList[strFieldName].AssignedEnum;
                if (EnumProvider.EnumList.ContainsKey(strEnum))
                {
                    this.Properties.ValueMember = "ItemName";
                    if (ABCApp.ABCDataGlobal.Language == "VN")
                    {
                        this.Properties.DisplayMember = "CaptionVN";
                    }
                    else
                    {
                        this.Properties.DisplayMember = "CaptionEN";
                    }

                    DevExpress.XtraEditors.Controls.LookUpColumnInfo col = new DevExpress.XtraEditors.Controls.LookUpColumnInfo();
                    col.FieldName = this.Properties.DisplayMember;
                    col.Caption   = DataConfigProvider.GetFieldCaption(this.TableName, strFieldName);
                    col.Visible   = true;
                    this.Properties.Columns.Add(col);

                    this.Properties.DataSource = EnumProvider.EnumList[strEnum].Items.Values.ToArray();
                }
            }
            this.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFit;
            this.Properties.BestFit();
        }
Ejemplo n.º 19
0
        public void ActionSave(bool isShowWaitingDlg)
        {
            if (ChangedItems.Count > 0 && ABCScreenManager.Instance.CheckTablePermission(this.TableName, TablePermission.AllowEdit) == false)
            {
                return;
            }
            if (RemovedItems.Count > 0 && ABCScreenManager.Instance.CheckTablePermission(this.TableName, TablePermission.AllowDelete) == false)
            {
                return;
            }
            if (NewItems.Count > 0 && ABCScreenManager.Instance.CheckTablePermission(this.TableName, TablePermission.AllowNew) == false)
            {
                return;
            }

            if (isShowWaitingDlg)
            {
                ABCHelper.ABCWaitingDialog.Show("", "Đang lưu ....");
            }

            List <T> lstDeletings = new List <T>();
            List <T> lstUpdatings = new List <T>();
            List <T> lstCreatings = new List <T>();

            #region Init
            foreach (T objT in RemovedItems.Values)
            {
                lstDeletings.Add(objT);
            }

            foreach (Guid iID in ChangedItems)
            {
                BusinessObject objT = GetItemByID(iID);
                if (objT != null)
                {
                    BusinessObjectHelper.SetAutoValue(objT);
                    lstUpdatings.Add((T)objT);
                }
            }

            foreach (int iIndex in NewItems)
            {
                BusinessObjectHelper.SetDefaultValue(this[iIndex]);
                BusinessObjectHelper.SetAutoValue(this[iIndex]);
                Guid iID = BusinessObjectHelper.GetIDValue(this[iIndex]);
                if (iID == Guid.Empty)
                {
                    lstCreatings.Add(this[iIndex]);
                }
                else
                {
                    lstUpdatings.Add(this[iIndex]);
                }
            }

            #endregion

            ABCStandardEventArg arg = new ABCStandardEventArg();
            OnSaving(this, ref lstDeletings, ref lstUpdatings, ref lstCreatings, arg);
            if (arg.Cancel)
            {
                return;
            }

            foreach (T objT in lstDeletings)
            {
                DeleteItem(objT);
            }

            foreach (T objT in lstUpdatings)
            {
                Controller.UpdateObject(objT);
            }

            foreach (T objT in lstCreatings)
            {
                Controller.CreateObject(objT);
            }

            ClearDetections();

            DataCachingProvider.RefreshLookupTable(this.TableName);

            OnSaved(this, ref lstDeletings, ref lstUpdatings, ref lstCreatings, new ABCStandardEventArg());

            if (isShowWaitingDlg)
            {
                ABCHelper.ABCWaitingDialog.Close();
            }
        }