예제 #1
0
        private void SaveFieldConfig(String strTableName)
        {
            if (String.IsNullOrWhiteSpace(strTableName))
            {
                return;
            }

            Cursor.Current = Cursors.WaitCursor;

            #region Save

            STFieldConfigsController configCtrl = new STFieldConfigsController();
            foreach (DataRow dr in ((DataView)this.ViewFieldConfig.DataSource).Table.Rows)
            {
                STFieldConfigsInfo configInfo = (STFieldConfigsInfo)configCtrl.GetObjectFromDataRow(dr);
                if (configInfo != null)
                {
                    configCtrl.UpdateObject(configInfo);
                    isModified = true;
                }
            }

            #endregion

            Cursor.Current = Cursors.Default;
        }
예제 #2
0
        public void SaveTables( )
        {
            ABCWaitingDialog.Show("", "Saving . . .!");

            if (this.ViewFieldConfig.DataSource != null)
            {
                STFieldConfigsController configCtrl = new STFieldConfigsController();
                foreach (DataRow dr in ((DataView)this.ViewFieldConfig.DataSource).Table.Rows)
                {
                    STFieldConfigsInfo configInfo = (STFieldConfigsInfo)configCtrl.GetObjectFromDataRow(dr);
                    if (configInfo != null)
                    {
                        configCtrl.UpdateObject(configInfo);
                        isModified = true;
                    }
                }
            }
            STTableConfigsController aliasCtrl = new STTableConfigsController();

            foreach (STTableConfigsInfo aliasInfo in TableList)
            {
                aliasCtrl.UpdateObject(aliasInfo);
            }

            DataConfigProvider.SynchronizeTableConfigs();
            InvalidateTableList();

            ABCWaitingDialog.Close();

            isNeedSaveTable = false;
        }
예제 #3
0
        void repFilter_ButtonPressed(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            DataRow dr = ViewFieldConfig.GetDataRow(ViewFieldConfig.FocusedRowHandle);

            if (dr != null)
            {
                STFieldConfigsInfo configInfo = (STFieldConfigsInfo) new STFieldConfigsController().GetObjectFromDataRow(dr);
                if (configInfo != null)
                {
                    if (DataStructureProvider.IsForeignKey(configInfo.TableName, configInfo.FieldName))
                    {
                        String strPKTableName = DataStructureProvider.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);
                        }
                    }
                }
            }
        }
예제 #4
0
        void ViewFieldConfig_ShowingEditor(object sender, CancelEventArgs e)
        {
            if (ViewFieldConfig.FocusedColumn.FieldName == "FilterString")
            {
                DataRow dr = ViewFieldConfig.GetDataRow(ViewFieldConfig.FocusedRowHandle);
                if (dr != null)
                {
                    STFieldConfigsInfo configInfo = (STFieldConfigsInfo) new STFieldConfigsController().GetObjectFromDataRow(dr);
                    if (configInfo != null)
                    {
                        if (DataStructureProvider.IsForeignKey(configInfo.TableName, configInfo.FieldName))
                        {
                            return;
                        }
                    }
                }

                e.Cancel = true;
            }
            else if (ViewFieldConfig.FocusedColumn.FieldName == "Enum")
            {
                DataRow dr = ViewFieldConfig.GetDataRow(ViewFieldConfig.FocusedRowHandle);
                if (dr != null)
                {
                    STFieldConfigsInfo configInfo = (STFieldConfigsInfo) new STFieldConfigsController().GetObjectFromDataRow(dr);
                    if (configInfo != null)
                    {
                        if (DataStructureProvider.DataTablesList.ContainsKey(configInfo.TableName))
                        {
                            if (DataStructureProvider.GetCodingType(configInfo.TableName, configInfo.FieldName) == "String")
                            {
                                return;
                            }
                        }
                    }
                }
                e.Cancel = true;
            }
        }
예제 #5
0
        private void SetDefaultFieldCaptionFromDictionary(String strTableName)
        {
            STFieldConfigsController fieldConfigCtrl = new STFieldConfigsController();
            STTableConfigsController tableConfigCtrl = new STTableConfigsController();
            STDictionarysController  dictionaryCtrl  = new STDictionarysController();
            DataSet ds = DataQueryProvider.SystemDatabaseHelper.RunQuery(String.Format("SELECT * FROM  STFieldConfigs WHERE TableName='{0}'", strTableName));

            if (ds != null && ds.Tables.Count > 0)
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    STFieldConfigsInfo configInfo = (STFieldConfigsInfo)fieldConfigCtrl.GetObjectFromDataRow(dr);
                    if (configInfo != null)
                    {
                        String strCaptionVN = configInfo.FieldName;
                        String strCaptionEN = configInfo.FieldName;

                        #region Dictionarys
                        DataSet ds2 = DataQueryProvider.SystemDatabaseHelper.RunQuery(String.Format("SELECT * FROM  STDictionarys WHERE ('{0}' LIKE '%'+ KeyString+'%'  AND IsContain='TRUE') OR ('{0}' LIKE KeyString+'%' AND IsStartWith='TRUE') OR ('{0}' LIKE '%' +KeyString AND IsEndWith='TRUE') OR (KeyString='{0}' AND (IsContain='FALSE' OR IsContain IS NULL) AND (IsStartWith='FALSE' OR IsStartWith IS NULL) AND (IsEndWith='FALSE' OR IsEndWith IS NULL) )", configInfo.FieldName));
                        if (ds2 != null && ds2.Tables.Count > 0 && ds2.Tables[0].Rows.Count > 0)
                        {
                            STDictionarysInfo dictInfo = (STDictionarysInfo)dictionaryCtrl.GetObjectFromDataRow(ds2.Tables[0].Rows[0]);
                            if (dictInfo != null)
                            {
                                if (String.IsNullOrWhiteSpace(dictInfo.TranslateVN) == false)
                                {
                                    strCaptionVN = dictInfo.TranslateVN;
                                }
                                if (String.IsNullOrWhiteSpace(dictInfo.TranslateEN) == false)
                                {
                                    strCaptionEN = dictInfo.TranslateEN;
                                }
                            }
                        }
                        #endregion



                        if (DataStructureProvider.IsForeignKey(configInfo.TableName, configInfo.FieldName))
                        {
                            String strPKTableName = DataStructureProvider.GetTableNameOfForeignKey(configInfo.TableName, configInfo.FieldName);

                            STTableConfigsInfo tableConfigInfo = (STTableConfigsInfo)tableConfigCtrl.GetObject(String.Format("SELECT * FROM  STTableConfigs WHERE TableName='{0}' ", strPKTableName));
                            if (tableConfigInfo != null && String.IsNullOrWhiteSpace(tableConfigInfo.CaptionVN) == false)
                            {
                                strCaptionVN = tableConfigInfo.CaptionVN;
                            }
                            if (tableConfigInfo != null && String.IsNullOrWhiteSpace(tableConfigInfo.CaptionEN) == false)
                            {
                                strCaptionEN = tableConfigInfo.CaptionEN;
                            }
                            else
                            {
                                strCaptionEN = strPKTableName.Substring(2, strPKTableName.Length - 3);
                            }
                        }
                        else if (configInfo.FieldName.StartsWith("FK_"))
                        {
                            String strPKTableName = DataStructureProvider.GetTableNameOfPrimaryKey(configInfo.FieldName.Substring(3, configInfo.FieldName.Length - 3));
                            if (String.IsNullOrWhiteSpace(strPKTableName) == false)
                            {
                                STTableConfigsInfo tableConfigInfo = (STTableConfigsInfo)tableConfigCtrl.GetObject(String.Format("SELECT * FROM  STTableConfigs WHERE TableName='{0}' ", strPKTableName));
                                if (tableConfigInfo != null && String.IsNullOrWhiteSpace(tableConfigInfo.CaptionVN) == false)
                                {
                                    strCaptionVN = tableConfigInfo.CaptionVN;
                                }
                                if (tableConfigInfo != null && String.IsNullOrWhiteSpace(tableConfigInfo.CaptionEN) == false)
                                {
                                    strCaptionEN = tableConfigInfo.CaptionEN;
                                }
                                else
                                {
                                    strCaptionEN = strPKTableName.Substring(2, strPKTableName.Length - 3);
                                }
                            }
                        }


                        //if ( String.IsNullOrWhiteSpace( strCaptionVN )==false||String.IsNullOrWhiteSpace( strCaptionEN )==false )
                        //{
                        if (strCaptionVN != configInfo.FieldName)
                        {
                            configInfo.CaptionVN = strCaptionVN;
                        }
                        else
                        {
                            configInfo.CaptionVN = String.Empty;
                        }
                        configInfo.CaptionEN = strCaptionEN;
                        fieldConfigCtrl.UpdateObject(configInfo);
                        //}
                    }
                }
            }
        }
예제 #6
0
        void ViewFieldConfig_CustomRowCellEdit(object sender, DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs e)
        {
            if (e.Column.FieldName == "Format")
            {
                DataRow dr = ViewFieldConfig.GetDataRow(e.RowHandle);
                if (dr != null)
                {
                    STFieldConfigsInfo configInfo = (STFieldConfigsInfo) new STFieldConfigsController().GetObjectFromDataRow(dr);
                    if (configInfo != null)
                    {
                        if (DataStructureProvider.DataTablesList.ContainsKey(configInfo.TableName))
                        {
                            String strType = DataStructureProvider.GetCodingType(configInfo.TableName, configInfo.FieldName);
                            if (strType == "DateTime" || strType == "Nullable<DataTime>" || strType == "int" || strType == "double" || strType == "decimal")
                            {
                                e.RepositoryItem = repoFormat;
                                return;
                            }
                        }
                    }
                }
                e.RepositoryItem = null;
            }

            #region AssignedEnum
            if (e.Column.FieldName == "AssignedEnum")
            {
                DataRow dr = ViewFieldConfig.GetDataRow(e.RowHandle);
                if (dr != null)
                {
                    STFieldConfigsInfo configInfo = (STFieldConfigsInfo) new STFieldConfigsController().GetObjectFromDataRow(dr);
                    if (configInfo != null)
                    {
                        if (DataStructureProvider.DataTablesList.ContainsKey(configInfo.TableName))
                        {
                            if (DataStructureProvider.GetCodingType(configInfo.TableName, configInfo.FieldName) == "String")
                            {
                                e.RepositoryItem = repoEnum;
                                return;
                            }
                        }
                    }
                }
                e.RepositoryItem = null;
            }
            #endregion

            if (e.Column.FieldName == "FilterString")
            {
                DataRow dr = ViewFieldConfig.GetDataRow(e.RowHandle);
                if (dr != null)
                {
                    STFieldConfigsInfo configInfo = (STFieldConfigsInfo) new STFieldConfigsController().GetObjectFromDataRow(dr);
                    if (configInfo != null)
                    {
                        if (DataStructureProvider.IsForeignKey(configInfo.TableName, configInfo.FieldName))
                        {
                            e.RepositoryItem = this.repoFilter;
                            return;
                        }
                    }
                }

                e.RepositoryItem = null;
            }
        }