private void InvalidateData( ) { STDictionarysController ctrl = new STDictionarysController(); DataSet ds = ctrl.GetDataSetAllObjects(); if (ds != null && ds.Tables.Count > 0) { this.gridControl1.DataSource = ds.Tables[0]; } }
private void btnSave_Click(object sender, EventArgs e) { ABCWaitingDialog.Show("", "Saving . . .!"); STDictionarysController ctrl = new STDictionarysController(); foreach (DataRow dr in ((DataTable)this.gridControl1.DataSource).Rows) { STDictionarysInfo info = (STDictionarysInfo)ctrl.GetObjectFromDataRow(dr); if (info != null) { if (info.STDictionaryID != Guid.Empty) { ctrl.UpdateObject(info); } else { ctrl.CreateObject(info); } } } InvalidateData(); ABCWaitingDialog.Close(); }
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); //} } } } }