Beispiel #1
0
        public void RefreshFormat( )
        {
            DataFormatProvider.FieldFormat format = DataFormatProvider.FieldFormat.Date;
            switch (formatType)
            {
            case ABCDateFormat.Date:
                format = DataFormatProvider.FieldFormat.Date;
                break;

            case ABCDateFormat.DateAndTime:
                format = DataFormatProvider.FieldFormat.DateAndTime;
                break;

            case ABCDateFormat.Month:
                format = DataFormatProvider.FieldFormat.Month;
                break;

            case ABCDateFormat.MonthAndYear:
                format = DataFormatProvider.FieldFormat.MonthAndYear;
                break;

            case ABCDateFormat.Time:
                format = DataFormatProvider.FieldFormat.Time;
                break;

            case ABCDateFormat.Year:
                format = DataFormatProvider.FieldFormat.Year;
                break;
            }

            DataFormatProvider.ABCFormatInfo formatInfo = DataFormatProvider.GetFormatInfo(format);
            //     this.Properties.Appearance.TextOptions.HAlignment=DevExpress.Utils.HorzAlignment.Far;
            this.Properties.DisplayFormat.FormatType   = formatInfo.FormatInfo.FormatType;
            this.Properties.DisplayFormat.FormatString = formatInfo.FormatInfo.FormatString;
            this.Properties.EditFormat.FormatType      = formatInfo.FormatInfo.FormatType;
            this.Properties.EditFormat.FormatString    = formatInfo.FormatInfo.FormatString;

            this.Properties.Mask.UseMaskAsDisplayFormat = true;
            this.Properties.Mask.EditMask = formatInfo.FormatInfo.FormatString;
            this.Properties.Mask.MaskType = formatInfo.MaskType;
        }
Beispiel #2
0
        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);
            }
        }
        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);
        }