public void RefreshDisplayTree( )
        {
            DisplayTreeListCtrl.TableName = this.TableName;
            DisplayTreeListCtrl.InnerTreeList.Columns.Clear();
            DisplayTreeListCtrl.ColumnConfigs      = this.ColumnList;
            DisplayTreeListCtrl.Manager.ConfigList = this.Manager.ConfigList;//new
            DisplayTreeListCtrl.InitColumns();

            #region Script
            if (String.IsNullOrWhiteSpace(this.TableName))
            {
                if (String.IsNullOrWhiteSpace(Script) == false)
                {
                    DataSet ds = DataQueryProvider.RunQuery(Script);
                    if (ds != null && ds.Tables.Count > 0)
                    {
                        Manager.Invalidate(ds);
                        DisplayTreeListCtrl.InnerTreeList.ColumnsCustomization();
                    }
                }
                return;
            }
            #endregion

            if (DataCachingProvider.LookupTables.ContainsKey(this.TableName))
            {
                Manager.Invalidate(DataCachingProvider.LookupTables[this.TableName]);
            }
            else
            {
                ABCHelper.ConditionBuilder strBuilder = new ABCHelper.ConditionBuilder();
                strBuilder.Append(String.Format(@"SELECT TOP 5 * FROM {0} ", this.TableName));
                if (DataStructureProvider.IsExistABCStatus(this.TableName))
                {
                    strBuilder.AddCondition(QueryGenerator.GenerateCondition(this.TableName, ABCCommon.ABCColumnType.ABCStatus));
                }

                strBuilder.Append(String.Format(@" ORDER BY {0} DESC", DataStructureProvider.GetPrimaryKeyColumn(this.TableName)));

                try
                {
                    DataSet ds = DataQueryProvider.RunQuery(strBuilder.ToString());
                    if (ds != null && ds.Tables.Count > 0)
                    {
                        this.DisplayTreeListCtrl.InnerTreeList.DataSource = ds.Tables[0];
                    }
                }
                catch (Exception ex)
                {
                }
            }

            this.DisplayTreeListCtrl.InnerTreeList.RefreshDataSource();
            DisplayTreeListCtrl.InnerTreeList.ColumnsCustomization();
        }
        public void RefreshDisplayGrid( )
        {
            DisplayGridCtrl.TableName = this.TableName;
            DisplayGridCtrl.Grid.Fields.Clear();
            DisplayGridCtrl.FieldConfigs = this.FieldsList;
            DisplayGridCtrl.InitFields();
            DisplayGridCtrl.Grid.OptionsView.RowTreeWidth = RowTreeWidth;
            DisplayGridCtrl.UseChartControl = UseChartControl;
            DisplayGridCtrl.Script          = Script;

            if (String.IsNullOrWhiteSpace(this.TableName))
            {
                DisplayGridCtrl.LoadDataSourceFromScript();
                return;
            }
            if (DataCachingProvider.LookupTables.ContainsKey(this.TableName))
            {
                this.DisplayGridCtrl.GridDataSource = DataCachingProvider.LookupTables[this.TableName];
            }
            else
            {
                ABCHelper.ConditionBuilder strBuilder = new ABCHelper.ConditionBuilder();
                strBuilder.Append(String.Format(@"SELECT TOP 5 * FROM {0}", this.TableName));


                if (DataStructureProvider.IsExistABCStatus(this.TableName))
                {
                    strBuilder.AddCondition(QueryGenerator.GenerateCondition(this.TableName, ABCCommon.ABCColumnType.ABCStatus));
                }

                strBuilder.Append(String.Format(@" ORDER BY {0} DESC", DataStructureProvider.GetPrimaryKeyColumn(this.TableName)));

                try
                {
                    DataSet ds = DataQueryProvider.RunQuery(strBuilder.ToString());
                    if (ds != null && ds.Tables.Count > 0)
                    {
                        this.DisplayGridCtrl.GridDataSource = ds.Tables[0];
                    }
                }
                catch (Exception ex)
                {
                }
            }

            this.DisplayGridCtrl.RefreshDataSource();
            DisplayGridCtrl.Grid.FieldsCustomization(splitContainerControl2.Panel2);
        }
Example #3
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);
            }
        }
Example #4
0
 public String GetSearchQuery( )
 {
     ABCHelper.ConditionBuilder strBuilder = new ABCHelper.ConditionBuilder();
     GetSearchQuery(strBuilder, this);
     return(strBuilder.ToString());
 }
Example #5
0
        public void RefreshDisplayGrid( )
        {
            DisplayGridView.TableName = this.TableName;
            DisplayGridView.Columns.Clear();
            DisplayGridView.Bands.Clear();

            DisplayGridView.BandConfigs   = this.BandsList;
            DisplayGridView.ColumnConfigs = this.ColumnList;
            DisplayGridView.LoadBands();

            #region Script
            if (String.IsNullOrWhiteSpace(this.TableName))
            {
                if (String.IsNullOrWhiteSpace(Script) == false)
                {
                    DataSet ds = DataQueryProvider.RunQuery(Script);
                    if (ds != null && ds.Tables.Count > 0)
                    {
                        this.DisplayGridCtrl.DataSource = ds.Tables[0];
                        this.DisplayGridCtrl.RefreshDataSource();
                        DisplayGridView.ShowCustomization();
                    }
                }
                return;
            }
            #endregion


            if (DataCachingProvider.LookupTables.ContainsKey(this.TableName))
            {
                this.DisplayGridCtrl.DataSource = DataCachingProvider.LookupTables[this.TableName];
            }
            else
            {
                ABCHelper.ConditionBuilder strBuilder = new ABCHelper.ConditionBuilder();
                strBuilder.Append(String.Format(@"SELECT TOP 5 * FROM {0}", this.TableName));
                if (DataStructureProvider.IsExistABCStatus(this.TableName))
                {
                    strBuilder.AddCondition(QueryGenerator.GenerateCondition(this.TableName, ABCCommon.ABCColumnType.ABCStatus));
                }

                strBuilder.Append(String.Format(@" ORDER BY {0} DESC", DataStructureProvider.GetPrimaryKeyColumn(this.TableName)));

                try
                {
                    DataSet ds = DataQueryProvider.RunQuery(strBuilder.ToString());
                    if (ds != null && ds.Tables.Count > 0)
                    {
                        this.DisplayGridCtrl.DataSource = ds.Tables[0];
                    }
                }
                catch (Exception ex)
                {
                }
            }

            this.DisplayGridCtrl.RefreshDataSource();
            if (DisplayGridView.CustomizationForm == null || DisplayGridView.CustomizationForm.Visible == false)
            {
                DisplayGridView.ShowCustomization();
            }
        }