Exemplo n.º 1
0
        public void RefreshDisplayGrid( )
        {
            DisplayGridView.TableName = this.TableName;
            DisplayGridView.Columns.Clear();
            DisplayGridView.ColumnConfigs = this.ColumnList;
            DisplayGridView.InitColumns();

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

            if (ABCDataLib.Tables.CachingProvider.LookupTables.ContainsKey(this.TableName))
            {
                this.DisplayGridCtrl.DataSource = ABCDataLib.Tables.CachingProvider.LookupTables[this.TableName];
            }
            else
            {
                ConditionBuilder strBuilder = new ConditionBuilder();
                strBuilder.Append(String.Format(@"SELECT TOP 5 * FROM {0} ", this.TableName));
                if (ABCDataLib.Tables.StructureProvider.IsExistABCStatus(this.TableName))
                {
                    strBuilder.AddCondition(ABCDataLib.Generation.QueryGenerator.GenerateCondition(this.TableName, DataDefine.ColumnType.ABCStatus));
                }
                strBuilder.Append(String.Format(@" ORDER BY {0} DESC", ABCDataLib.Tables.StructureProvider.GetPrimaryKeyColumn(this.TableName)));

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

            this.DisplayGridCtrl.RefreshDataSource();
            DisplayGridView.ShowCustomization();
        }
Exemplo n.º 2
0
        public void Test_Block()
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            ConditionBuilder builder = new ConditionBuilder();

            builder.Append("A.CreateTime", SqlOperator.Equal, DateTime.Now);
            builder.Between("B.CreateTime", DateTime.Now, DateTime.Now.AddDays(1));

            //builder.Block(RelationType.And, childBuilder);
            builder.Or(child =>
            {
                child.Equal("D.CreateTime", DateTime.Now);
                child.Equal("E.CreateTime", DateTime.Now);
                child.Equal("E.CreateTime", DateTime.Now);
                child.And(c2 =>
                {
                    c2.Append("HH.CreateTime", SqlOperator.Equal, 5);
                });
            }).Or(child =>
            {
                child.Append(RelationType.And, "E.CreateTime", SqlOperator.Equal, DateTime.Now);
            });
            builder.Append(RelationType.And, "F.CreateTime", SqlOperator.Equal, DateTime.Now);
            builder.Append(RelationType.And, "A.ID", SqlOperator.In, new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });

            builder.Append(RelationType.And, "B.ID", SqlOperator.In, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
            builder.AppendRaw("E.CreateTime like '%123456%'");
            builder.Between("H.CreateTime", DateTime.Now, DateTime.Now.AddDays(5));

            var result = builder.ToString();

            stopwatch.Stop();

            var param = builder.GetParamDict().ToJson();

            Console.WriteLine(result);
            Console.WriteLine(param);

            Console.WriteLine(stopwatch.Elapsed.Milliseconds);
        }