Пример #1
0
 public void Set(SelectSql sql)
 {
     if (null != sql)
     {
         if (this.Text.Length != 0 && (this.TableName.Length != 0 && this.ColumnName.Length != 0))
         {
             sql.Where(this.TableName, this.ColumnName, this.Operator, base.Text);
         }
     }
 }
Пример #2
0
 public void Set(SelectSql sql)
 {
     if (null != sql)
     {
         if (!this.Value.IsNull() && (this.TableName.Length != 0 && this.ColumnName.Length != 0))
         {
             sql.Where(this.TableName, this.ColumnName, this.Operator, this.Value);
         }
     }
 }
Пример #3
0
 public void Set(SelectSql sql)
 {
     if (null != sql)
     {
         DateTime? value = base.SelectedDate;
         if (value.HasValue && (this.TableName.Length != 0 && this.ColumnName.Length != 0))
         {
             sql.Where(this.TableName, this.ColumnName, this.Operator, value.Value);
         }
     }
 }
Пример #4
0
        public static IEnumerable<TasinirComboEntity> CreateItemsSource(ICommandAdapter cmd, int duzey, string startsWidth)
        {
            SelectSql sql = new SelectSql();
            sql.Custom("SELECT Id, Adi, TasinirKodu FROM TasinirKod".ToQuery());

            sql.Where(" (LEN(TasinirKodu)- LEN(REPLACE(TasinirKodu,'.',''))) = @0".ToQuery(duzey));

            if (!String.IsNullOrEmpty(startsWidth))
            {
                sql.Where("TasinirKodu", ConditionOperator.StartsWith, startsWidth);
            }

            return cmd.Query<TasinirComboEntity>(sql.ToQuery());
        }
        private void ShowReport(Report report)
        {
            report.Parameters.Clear();
            foreach (var ctrl in this.ReportParameterSearch)
            {
                if (ctrl.HasValue)
                    ctrl.Set(report.Parameters);
            }

            foreach (DataSource ds in report.DataSources)
            {
                SelectSql sql = new SelectSql();
                sql.Custom(ds.ReportSql.ToQuery());

                foreach (var ctrl in this.FieldSearchControls)
                {
                    if (!ctrl.AllowNull && ctrl.Value.IsNull())
                    {
                        base.RadAlert(String.Format("Lütfen {0} Alanı için Veri Giriniz.", ctrl.Label));
                        return;
                    }

                    if (String.Equals(ctrl.DataSourceName, ds.DataSourceName))
                        ctrl.Set(sql);
                    else
                    {
                        if (!String.IsNullOrEmpty(ctrl.AlsoAvailableFor))
                        {
                            string[] arr = ctrl.AlsoAvailableFor.Split(',');
                            foreach(string dsName in arr)
                            {
                                if (String.Equals(dsName, ds.DataSourceName, StringComparison.OrdinalIgnoreCase))
                                {
                                    ctrl.Set(sql);
                                }
                            }
                        }
                    }
                }

                SqlQuery query = sql.ToQuery();//Düzeltme (İç İçe Sorgu Yazlılmasın Diye) Eğer Sıkıntı Çıkarırısa Select * from (...) dene.
                foreach(var par in query.Parameters)
                {
                   if (par.ParameterName.Contains("."))
                   {
                       string orginal = "@" + par.ParameterName;
                       par.ParameterName = par.ParameterName.Replace(".", "");//Düzeltme
                       query.Text.Replace(orginal, "@" + par.ParameterName);
                   }
                }

                ds.ReportSelectQuery = query;

                string sqlString = ds.ReportSelectQuery.Text.ToString();
                foreach (var ctrl in this.SqlParameterSearch)
                {
                    if (ctrl.Value.IsNull())
                    {
                        base.RadAlert(String.Format("Lütfen {0} Alanı için Veri Giriniz.", ctrl.ParameterName));
                        return;
                    }
                    if (ctrl.AlsoAddAsReportParameter)
                        report.Parameters.Add(ctrl.ParameterName, ctrl.Value);

                    if (sqlString.Contains(ctrl.ParameterName))
                        ctrl.Set(ds.ReportSelectQuery);
                }
            }

            switch(Sessions.ShowType)
            {
                case ShowReportType.PopUp:
                    ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "ShowReport", "ShowReportPage();", true);
                    break;
                case ShowReportType.Redirect:
                    base.Response.Redirect("~/Pages/ShowReportPagePopup.aspx");
                    break;
                default:
                    throw new NotSupportedException(Sessions.ShowType.ToString());
            }

            // ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "ShowReport", "ShowReportPage();", true);
        }
 public void Set(SelectSql sql)
 {
     if (null != sql)
     {
         if (this.UcButtonEditSql1.Entity != null && this.ColumnName.Length != 0)
         {
             object value = this.UcButtonEditSql1.Value.ConvertTo(this.DataType);
             if (null != value)
             {
                 sql.Where(this.ColumnName, this.Operator, value);
             }
         }
     }
 }
        public void Set(SelectSql sql)
        {
            if (null != sql)
            {
                if (this.ColumnName.Length != 0)
                {

                    DateTime? d1 = this.txtDate1.SelectedDate;
                    DateTime? d2 = this.txtDate2.SelectedDate;
                    if (d1.HasValue && d2.HasValue)
                    {
                        sql.Where(this.ColumnName, this.Operator, d1.Value, d2.Value);
                    }
                }
            }
        }
 public void Set(SelectSql sql)
 {
     if (null != sql)
     {
         if (this.txt.Value.HasValue && this.ColumnName.Length != 0)
         {
             object value = this.txt.Value.ToString().ConvertTo(this.DataType);
             if (null != value)
             {
                 sql.Where(this.ColumnName, this.Operator, value);
             }
         }
     }
 }
Пример #9
0
        public static SelectSql ToAttributeBasedSelectSql(this Type entityType)
        {
            if (null != entityType)
            {
                object[] attributes = entityType.GetCustomAttributes(true);
                List<SqlTableAttribute> tables = new List<SqlTableAttribute>();
                List<SqlJoinAttribute> joins = new List<SqlJoinAttribute>();
                if (!attributes.IsEmptyList())
                {
                    var tempTables = attributes.OfType<SqlTableAttribute>();
                    if (!tempTables.IsEmptyList())
                    {
                        tables.AddRange(tempTables);
                    }
                    var tempJoins = attributes.OfType<SqlJoinAttribute>();
                    if (!tempJoins.IsEmptyList())
                    {
                        joins.AddRange(tempJoins);
                    }
                }

                if (tables.Count == 0)
                    tables.Add(new SqlTableAttribute(entityType.Name));

                List<SqlColumnAttribute> columns = new List<SqlColumnAttribute>();
                foreach (PropertyInfo pi in entityType.GetProperties(BindingFlags.Public | BindingFlags.Instance))
                {
                    SqlColumnAttribute ca = pi.GetCustomAttribute<SqlColumnAttribute>();
                    if (null != ca)
                    {
                        if (String.IsNullOrEmpty(ca.Column))
                            ca.Column = pi.Name;
                        if (String.IsNullOrEmpty(ca.Alias))
                            ca.Alias = pi.Name;
                    }
                    else
                    {
                        ca = new SqlColumnAttribute(null, pi.Name, null);
                    }

                    columns.Add(ca);
                }

                if (columns.Count == 0)
                    throw new InvalidOperationException(entityType.FullName + " has no valid property");

                SelectSql sql = new SelectSql();
                foreach (SqlTableAttribute item in tables)
                {
                    sql.Table(item.Table, item.Alias);
                    if (item.IsLeftTable)
                    {
                        if (!String.IsNullOrEmpty(item.Alias))
                            sql.SetLeftTable(item.Alias);
                        else
                            sql.SetLeftTable(item.Table);
                    }
                }
                foreach (SqlJoinAttribute item in joins)
                {
                    sql.Join(item.LeftTable, item.LeftColumn, item.Join, item.RightTable, item.RightColumn);
                }
                foreach (SqlColumnAttribute item in columns)
                {
                    sql.Column(item.Table, item.Column, item.Alias);
                }

                return sql;
            }

            return null;
        }
 public void Set(SelectSql sql)
 {
     if (null != sql)
     {
         if (this.cbx.SelectedValue.Length != 0 && this.ColumnName.Length != 0)
         {
             object value = this.cbx.Value.ConvertTo(this.DataType);
             if (null != value)
             {
                 sql.Where(this.ColumnName, this.Operator, value);
             }
         }
     }
 }
 public void Set(SelectSql sql)
 {
     if (null != sql)
     {
         if (this.cbx.CheckedItems.Any() && this.ColumnName.Length != 0)
         {
             object value = this.cbx.Value.ConvertTo(this.DataType);
             if (null != value)
             {
                 List<object> selected = new List<object>();
                 foreach(var item in this.cbx.CheckedItems)
                 {
                     selected.Add(int.Parse(item.Value));
                 }
                 sql.Where(this.ColumnName, this.Operator, selected.ToArray());
             }
         }
     }
 }