Пример #1
0
        /// <summary>
        /// 获取数据源
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="list"></param>
        /// <returns></returns>
        public DataSet GetDataSource(ReportsEntity entity, List <ReportParamsEntity> list)
        {
            DataCommand command = null;
            DataSet     ds      = null;

            if (entity.DsType == (int)EDataSourceType.SQL)
            {
                command = DataCommandManager.CreateCustomDataCommand("GitWMS", CommandType.Text, entity.DataSource);
            }
            else
            {
                command = DataCommandManager.CreateCustomDataCommand("GitWMS", CommandType.StoredProcedure, entity.DataSource);
            }
            if (list != null)
            {
                foreach (ReportParamsEntity item in list)
                {
                    DbType dbType = DbType.String;
                    if (item.ParamType == "datetime" || item.ParamType == "date")
                    {
                        dbType            = DbType.DateTime;
                        item.DefaultValue = string.IsNullOrEmpty(item.DefaultValue) ? DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") : item.DefaultValue;
                    }
                    else if (item.ParamType == "int")
                    {
                        dbType            = DbType.Int32;
                        item.DefaultValue = string.IsNullOrEmpty(item.DefaultValue) ? "0" : item.DefaultValue;
                    }
                    else
                    {
                        item.DefaultValue = string.IsNullOrEmpty(item.DefaultValue) ? "" : item.DefaultValue;
                    }
                    command.AddParameterValue(item.ParamName, item.DefaultValue, dbType);
                }
            }
            ds = command.ExecuteDataSet();

            return(ds);
        }