Example #1
0
        private void SaveFieldConfig( )
        {
            String strTableName = ViewTableList.GetFocusedDisplayText();

            if (String.IsNullOrEmpty(strTableName))
            {
                return;
            }

            Cursor.Current = Cursors.WaitCursor;

            #region Save
            DialogResult result = DevExpress.XtraEditors.XtraMessageBox.Show(String.Format("Do you want to save FieldConfig of table '{0}' ?", strTableName), "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (result == DialogResult.Yes)
            {
                STFieldConfigController configCtrl = new STFieldConfigController();
                foreach (DataRow dr in ((DataView)this.ViewFieldConfig.DataSource).Table.Rows)
                {
                    STFieldConfigInfo configInfo = (STFieldConfigInfo)configCtrl.GetObjectFromDataRow(dr);
                    if (configInfo != null)
                    {
                        configCtrl.UpdateObject(configInfo);
                        isModified = true;
                    }
                }
            }
            #endregion

            isNeedSave = false;

            Cursor.Current = Cursors.Default;
        }
Example #2
0
        void repositoryItemButtonEdit1_ButtonPressed(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            DataRow dr = ViewFieldConfig.GetDataRow(ViewFieldConfig.FocusedRowHandle);

            if (dr != null)
            {
                STFieldConfigInfo configInfo = (STFieldConfigInfo) new STFieldConfigController().GetObjectFromDataRow(dr);
                if (configInfo != null)
                {
                    if (ABCDataLib.Tables.StructureProvider.IsForeignKey(configInfo.TableName, configInfo.FieldName))
                    {
                        String strPKTableName = ABCDataLib.Tables.StructureProvider.GetTableNameOfForeignKey(configInfo.TableName, configInfo.FieldName);

                        ABCCommonForms.FilterBuilderForm filterBuilder = new ABCCommonForms.FilterBuilderForm(strPKTableName);
                        String strOldValue = ViewFieldConfig.GetRowCellValue(ViewFieldConfig.FocusedRowHandle, "FilterString").ToString();
                        filterBuilder.SetFilterString(strOldValue);

                        if (filterBuilder.ShowDialog() == DialogResult.OK)
                        {
                            ViewFieldConfig.SetRowCellValue(ViewFieldConfig.FocusedRowHandle, "FilterString", filterBuilder.FilterString);
                        }
                    }
                }
            }
        }
Example #3
0
        void ViewFieldConfig_CustomRowCellEdit(object sender, DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs e)
        {
            #region AssignedEnum
            if (e.Column.FieldName == "AssignedEnum")
            {
                DataRow dr = ViewFieldConfig.GetDataRow(e.RowHandle);
                if (dr != null)
                {
                    STFieldConfigInfo configInfo = (STFieldConfigInfo) new STFieldConfigController().GetObjectFromDataRow(dr);
                    if (configInfo != null)
                    {
                        if (ABCDataLib.Tables.StructureProvider.DataTablesList.ContainsKey(configInfo.TableName))
                        {
                            if (ABCDataLib.Tables.StructureProvider.GetCSharpVariableType(configInfo.TableName, configInfo.FieldName) == "String")
                            {
                                e.RepositoryItem = repositoryItemComboBox1;
                                return;
                            }
                        }
                    }
                }
                e.RepositoryItem = null;
            }
            #endregion

            if (e.Column.FieldName == "FilterString")
            {
                DataRow dr = ViewFieldConfig.GetDataRow(e.RowHandle);
                if (dr != null)
                {
                    STFieldConfigInfo configInfo = (STFieldConfigInfo) new STFieldConfigController().GetObjectFromDataRow(dr);
                    if (configInfo != null)
                    {
                        if (ABCDataLib.Tables.StructureProvider.IsForeignKey(configInfo.TableName, configInfo.FieldName))
                        {
                            e.RepositoryItem = this.repositoryItemButtonEdit1;
                            return;
                        }
                    }
                }

                e.RepositoryItem = null;
            }
        }
Example #4
0
        void ViewFieldConfig_ShowingEditor(object sender, CancelEventArgs e)
        {
            if (ViewFieldConfig.FocusedColumn.FieldName == "FilterString")
            {
                DataRow dr = ViewFieldConfig.GetDataRow(ViewFieldConfig.FocusedRowHandle);
                if (dr != null)
                {
                    STFieldConfigInfo configInfo = (STFieldConfigInfo) new STFieldConfigController().GetObjectFromDataRow(dr);
                    if (configInfo != null)
                    {
                        if (ABCDataLib.Tables.StructureProvider.IsForeignKey(configInfo.TableName, configInfo.FieldName))
                        {
                            return;
                        }
                    }
                }

                e.Cancel = true;
            }
            else if (ViewFieldConfig.FocusedColumn.FieldName == "Enum")
            {
                DataRow dr = ViewFieldConfig.GetDataRow(ViewFieldConfig.FocusedRowHandle);
                if (dr != null)
                {
                    STFieldConfigInfo configInfo = (STFieldConfigInfo) new STFieldConfigController().GetObjectFromDataRow(dr);
                    if (configInfo != null)
                    {
                        if (ABCDataLib.Tables.StructureProvider.DataTablesList.ContainsKey(configInfo.TableName))
                        {
                            if (ABCDataLib.Tables.StructureProvider.GetCSharpVariableType(configInfo.TableName, configInfo.FieldName) == "String")
                            {
                                return;
                            }
                        }
                    }
                }
                e.Cancel = true;
            }
        }