示例#1
0
        void ViewTableConfig_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            STTableConfigsInfo objTableConfig = null;

            if (isNeedSaveField)
            {
                objTableConfig = (STTableConfigsInfo)ViewTableConfig.GetRow(e.PrevFocusedRowHandle);
                if (objTableConfig != null && String.IsNullOrWhiteSpace(objTableConfig.TableName) == false)
                {
                    DialogResult result = ABCHelper.ABCMessageBox.Show(String.Format("Do you want to save the table '{0}' ?", objTableConfig.TableName), "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (result == DialogResult.Yes)
                    {
                        SaveFieldConfig(objTableConfig.TableName);
                    }
                }
                isNeedSaveField = false;
            }

            objTableConfig = (STTableConfigsInfo)ViewTableConfig.GetRow(e.FocusedRowHandle);
            if (objTableConfig == null || String.IsNullOrWhiteSpace(objTableConfig.TableName))
            {
                return;
            }

            DataSet ds = DataQueryProvider.SystemDatabaseHelper.RunQuery(String.Format("SELECT * FROM  STFieldConfigs WHERE TableName='{0}'", objTableConfig.TableName));

            if (ds != null && ds.Tables.Count > 0)
            {
                this.GridFieldConfig.DataSource = ds.Tables[0];
            }
        }
示例#2
0
        void Form_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (isNeedSaveField || isNeedSaveTable)
            {
                DialogResult result = ABCHelper.ABCMessageBox.Show("Do you want to save ?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    STTableConfigsInfo objTableConfig = (STTableConfigsInfo)ViewTableConfig.GetRow(ViewTableConfig.FocusedRowHandle);
                    if (objTableConfig != null && String.IsNullOrWhiteSpace(objTableConfig.TableName) == false)
                    {
                        SaveFieldConfig(objTableConfig.TableName);
                    }

                    SaveTables();
                }
            }

            if (isModified)
            {
                DataConfigProvider.SynchronizeTableConfigs();
                foreach (HostSurface surface in OwnerStudio.SurfaceManager.DesignSurfaces)
                {
                    (surface.DesignerHost.RootComponent as ABCView).RefreshBindingControl();
                }
            }
        }
示例#3
0
        private void InvalidateTableList( )
        {
            Dictionary <String, STTableConfigsInfo> lstConfig = new Dictionary <String, STTableConfigsInfo>();

            STTableConfigsController aliasCtrl = new STTableConfigsController();
            DataSet ds = aliasCtrl.GetDataSetAllObjects();

            if (ds != null && ds.Tables.Count > 0)
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    STTableConfigsInfo configInfo = (STTableConfigsInfo)aliasCtrl.GetObjectFromDataRow(dr);
                    if (configInfo != null)
                    {
                        if (DataStructureProvider.DataTablesList.ContainsKey(configInfo.TableName) && !lstConfig.ContainsKey(configInfo.TableName))
                        {
                            lstConfig.Add(configInfo.TableName, configInfo);
                        }
                        else
                        {
                            aliasCtrl.DeleteObject(configInfo);
                        }
                    }
                }
            }


            foreach (String strTableName in DataStructureProvider.DataTablesList.Keys)
            {
                if (lstConfig.ContainsKey(strTableName) == false)
                {
                    STTableConfigsInfo newInfo = new STTableConfigsInfo();
                    newInfo.TableName = strTableName;
                    newInfo.CaptionEN = strTableName;
                    newInfo.IsCaching = false;
                    aliasCtrl.CreateObject(newInfo);

                    lstConfig.Add(newInfo.TableName, newInfo);
                }
            }

            TableList.Clear();
            foreach (STTableConfigsInfo info in lstConfig.Values)
            {
                TableList.Add(info);
            }

            this.GridTableConfig.DataSource = TableList;
            this.GridTableConfig.RefreshDataSource();
        }
示例#4
0
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            STTableConfigsInfo objTableConfig = (STTableConfigsInfo)ViewTableConfig.GetRow(ViewTableConfig.FocusedRowHandle);

            if (objTableConfig == null || String.IsNullOrWhiteSpace(objTableConfig.TableName))
            {
                return;
            }

            SetDefaultFieldCaptionFromDictionary(objTableConfig.TableName);
            DataSet ds = DataQueryProvider.SystemDatabaseHelper.RunQuery(String.Format("SELECT * FROM  STFieldConfigs WHERE TableName='{0}'", objTableConfig.TableName));

            if (ds != null && ds.Tables.Count > 0)
            {
                this.GridFieldConfig.DataSource = ds.Tables[0];
            }
        }
示例#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);
                        //}
                    }
                }
            }
        }