public void InvalidateControl( ) { if (EditControl == null) { #region init String strType = DataStructureProvider.GetCodingType(this.TableName, this.DataMember.Split(':')[0]); if (strType == "String" || strType == "Nullable<String>") { EditControl = (ISearchControl)ABCBusinessEntities.ABCDynamicInvoker.CreateInstanceObject(typeof(ABCTextSearch)); } else if (strType == "bool" || strType == "Nullable<bool>") { EditControl = (ISearchControl)ABCBusinessEntities.ABCDynamicInvoker.CreateInstanceObject(typeof(ABCBoolSearch)); } else if (strType == "DateTime" || strType == "Nullable<DateTime>") { EditControl = (ISearchControl)ABCBusinessEntities.ABCDynamicInvoker.CreateInstanceObject(typeof(ABCDateTimeSearch)); } else if (strType == "int" || strType == "Nullable<int>" || strType == "Guid" || strType == "Nullable<Guid>" || strType == "double" || strType == "Nullable<double>" || strType == "decimal" || strType == "Nullable<decimal>") { if (DataStructureProvider.IsForeignKey(this.TableName, this.DataMember.Split(':')[0]) || DataStructureProvider.IsPrimaryKey(this.TableName, this.DataMember.Split(':')[0])) { EditControl = (ISearchControl)ABCBusinessEntities.ABCDynamicInvoker.CreateInstanceObject(typeof(ABCGridLookUpEditSearch)); } else { EditControl = (ISearchControl)ABCBusinessEntities.ABCDynamicInvoker.CreateInstanceObject(typeof(ABCNumbSearch)); } } if (EditControl != null) { EditControl.GetType().GetProperty("DataMember").SetValue(EditControl, this.DataMember, null); EditControl.GetType().GetProperty("TableName").SetValue(EditControl, this.TableName, null); if (EditControl is ABCGridLookUpEdit) { ((ABCGridLookUpEdit)EditControl).Initialize(OwnerView); } } #endregion } if (EditControl != null) { EditControl.GetType().GetProperty("DataMember").SetValue(EditControl, this.DataMember, null); EditControl.GetType().GetProperty("TableName").SetValue(EditControl, this.TableName, null); EditControl.SetFormatInfo(); this.layoutControl1.Controls.Add((this.EditControl as Control)); this.LayoutItem.Control = (this.EditControl as Control); } UpdateLabelText(); }
public DataSet GetDataSetByColumn(String strFieldName, object objValue) { if (DataStructureProvider.IsTableColumn(TableName, strFieldName) == false) { return(null); } String strTypeName = DataStructureProvider.GetCodingType(TableName, strFieldName); if (strTypeName == "String" || strTypeName == "DateTime" || strTypeName == "Guid" || strTypeName == "Nullable<Guid>") { return(GetDataSet(String.Format("SELECT * FROM {0} WHERE {1} = '{2}' ", TableName, strFieldName, objValue))); } return(GetDataSet(String.Format("SELECT * FROM {0} WHERE {1} = {2} ", TableName, strFieldName, objValue))); }
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; } }
public void GetSearchQuery(ABCHelper.ConditionBuilder strBuilder, Control current) { if (current is ISearchControl) { String strResult = ((ISearchControl)current).SearchString; if (String.IsNullOrWhiteSpace(strResult) == false) { strBuilder.AddCondition(strResult); } } else if (current is IABCBindableControl) { System.Reflection.PropertyInfo proInfo = current.GetType().GetProperty((current as IABCBindableControl).BindingProperty); if (proInfo != null) { object objValue = proInfo.GetValue(current, null); if (objValue != null) { String strType = DataStructureProvider.GetCodingType((current as IABCBindableControl).TableName, (current as IABCBindableControl).DataMember); if (strType == "int" || strType == "Nullable<int>" || strType == "double" || strType == "Nullable<double>" || strType == "bool" || strType == "Nullable<bool>") { strBuilder.AddCondition(String.Format(" [{0}] = {1} ", (current as IABCBindableControl).DataMember, objValue)); } if (strType == "String" || strType == "Nullable<String>") { strBuilder.AddCondition(String.Format(" [{0}] LIKE '%{1}%' ", (current as IABCBindableControl).DataMember, objValue.ToString())); } if (strType == "Guid" || strType == "Nullable<Guid>") { strBuilder.AddCondition(String.Format(" [{0}] = '{1}' ", (current as IABCBindableControl).DataMember, objValue.ToString())); } if (strType == "DateTime" || strType == "Nullable<DateTime>") { DataFormatProvider.FieldFormat format = DataFormatProvider.FieldFormat.None; DataFormatProvider.ABCFormatInfo formatInfo = DataFormatProvider.GetFormatInfo((current as IABCBindableControl).TableName, (current as IABCBindableControl).DataMember); if (formatInfo != null) { format = formatInfo.ABCFormat; } if (format == DataFormatProvider.FieldFormat.None) { format = DataFormatProvider.FieldFormat.Date; } DateTime dtValue1 = DateTime.MinValue; DateTime dtValue2 = DateTime.MaxValue; if (objValue is DateTime) { dtValue1 = Convert.ToDateTime(objValue); } if (objValue is Nullable <DateTime> && (objValue as Nullable <DateTime>).HasValue) { dtValue1 = (objValue as Nullable <DateTime>).Value; } if (format == DataFormatProvider.FieldFormat.Month || format == DataFormatProvider.FieldFormat.MonthAndYear) { dtValue1 = new DateTime(dtValue1.Year, dtValue1.Month, 1); dtValue2 = dtValue1.AddMonths(1).AddSeconds(-30); } else if (format == DataFormatProvider.FieldFormat.Year) { dtValue1 = new DateTime(dtValue1.Year, 1, 1); dtValue2 = dtValue1.AddYears(1).AddSeconds(-30); } else { dtValue1 = new DateTime(dtValue1.Year, dtValue1.Month, dtValue1.Day); dtValue2 = dtValue1; } String strFrom = TimeProvider.GenCompareDateTime((current as IABCBindableControl).DataMember, ">=", dtValue1); String strTo = TimeProvider.GenCompareDateTime((current as IABCBindableControl).DataMember, "<=", dtValue2); strBuilder.AddCondition(String.Format(" ( {0} AND {1} ) ", strFrom, strTo)); } } } } foreach (Control ctrl in current.Controls) { GetSearchQuery(strBuilder, ctrl); } }
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; } }
public static List <Type> GetControlTypes(String strTableName, String strFieldName) { List <Type> lstTypes = new List <Type>(); String[] strArr = strFieldName.Split(':'); if (strArr.Length <= 0) { return(lstTypes); } if (strArr.Length == 1) { #region Level 1 String strFieldNameTemp = strArr[0]; String strTableNameTemp = strTableName; if (DataStructureProvider.IsForeignKey(strTableNameTemp, strFieldNameTemp)) { #region Foreign Key lstTypes.Add(typeof(ABCLookUpEdit)); lstTypes.Add(typeof(ABCTextEdit)); lstTypes.Add(typeof(ABCGridLookUpEdit)); lstTypes.Add(typeof(ABCRadioGroup)); lstTypes.Add(typeof(ABCCheckedListBox)); if (DataStructureProvider.GetTableNameOfForeignKey(strTableNameTemp, strFieldNameTemp) == "GEPeriods") { lstTypes.Add(typeof(ABCPeriodEdit)); } #endregion } else { String strEnumName = DataConfigProvider.TableConfigList[strTableNameTemp].FieldConfigList[strFieldNameTemp].AssignedEnum; if (String.IsNullOrWhiteSpace(strEnumName) == false && EnumProvider.EnumList.ContainsKey(strEnumName)) { #region Enum lstTypes.Add(typeof(ABCLookUpEdit)); lstTypes.Add(typeof(ABCRadioGroup)); lstTypes.Add(typeof(ABCCheckedListBox)); #endregion } else { #region Common String strType = DataStructureProvider.GetCodingType(strTableNameTemp, strFieldNameTemp); if (strType == "DateTime" || strType == "Nullable<DateTime>") { lstTypes.Add(typeof(ABCDateEdit)); lstTypes.Add(typeof(ABCTimeEdit)); lstTypes.Add(typeof(ABCMonthYearEdit)); } if (strType == "int" || strType == "Nullable<int>") { lstTypes.Add(typeof(ABCTextEdit)); lstTypes.Add(typeof(ABCSpinEdit)); DataFormatProvider.ABCFormatInfo formatInfo = DataFormatProvider.GetFormatInfo(strTableNameTemp, strFieldNameTemp); if (formatInfo != null) { if (formatInfo.ABCFormat == DataFormatProvider.FieldFormat.Year) { lstTypes.Add(typeof(ABCYearEdit)); } if (formatInfo.ABCFormat == DataFormatProvider.FieldFormat.Month || formatInfo.ABCFormat == DataFormatProvider.FieldFormat.MonthAndYear) { lstTypes.Add(typeof(ABCMonthEdit)); } } } if (strType == "String" || strType == "Nullable<String>") { lstTypes.Add(typeof(ABCTextEdit)); lstTypes.Add(typeof(ABCLabel)); lstTypes.Add(typeof(ABCMemoEdit)); lstTypes.Add(typeof(ABCMemoExEdit)); lstTypes.Add(typeof(ABCRichEditControl)); } if (strType == "double" || strType == "decimal" || strType == "Nullable<double>" || strType == "Nullable<decimal>") { lstTypes.Add(typeof(ABCTextEdit)); lstTypes.Add(typeof(ABCSpinEdit)); lstTypes.Add(typeof(ABCCalcEdit)); } if (strType == "bool" || strType == "Nullable<bool>") { lstTypes.Add(typeof(ABCCheckEdit)); lstTypes.Add(typeof(ABCCheckPanel)); lstTypes.Add(typeof(ABCRadioGroup)); // lstTypes.Add( typeof( ABCCheckedListBox ) ); } #endregion } } lstTypes.Add(typeof(ABCSearchControl)); #endregion } else { #region Level n String strFieldNameTemp = String.Empty; String strTableNameTemp = strTableName; for (int i = 0; i < strArr.Length; i++) { strFieldNameTemp = strArr[i]; if (DataStructureProvider.IsForeignKey(strTableNameTemp, strFieldNameTemp) == false) { break; } strTableNameTemp = DataStructureProvider.GetTableNameOfForeignKey(strTableNameTemp, strFieldNameTemp); } String strType = DataStructureProvider.GetCodingType(strTableNameTemp, strFieldNameTemp); if (strType == "DateTime" || strType == "Nullable<DateTime>") { lstTypes.Add(typeof(ABCDateEdit)); lstTypes.Add(typeof(ABCTimeEdit)); } if (strType == "int" || strType == "double" || strType == "decimal" || strType == "Nullable<int>" || strType == "Nullable<double>" || strType == "Nullable<decimal>") { lstTypes.Add(typeof(ABCTextEdit)); lstTypes.Add(typeof(ABCLabel)); } if (strType == "String" || strType == "Nullable<String>") { lstTypes.Add(typeof(ABCTextEdit)); lstTypes.Add(typeof(ABCLabel)); lstTypes.Add(typeof(ABCMemoEdit)); lstTypes.Add(typeof(ABCRichEditControl)); } if (strType == "bool" || strType == "Nullable<bool>") { lstTypes.Add(typeof(ABCCheckEdit)); lstTypes.Add(typeof(ABCCheckPanel)); } #endregion } return(lstTypes); }