ExecuteReader() public method

执行ExecuteReader
public ExecuteReader ( string commandText ) : System.Data.SqlClient.SqlDataReader
commandText string 存储过程名
return System.Data.SqlClient.SqlDataReader
示例#1
0
 public static SqlDataReader ExecuteReader(SqlTransaction transaction, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
 {
     return(SqlHelper.ExecuteReader(transaction.Connection, transaction, commandType, commandText, commandParameters, SqlHelper.SqlConnectionOwnership.External));
 }
示例#2
0
 public static SqlDataReader ExecuteReader(SqlConnection connection, CommandType commandType, string commandText)
 {
     return(SqlHelper.ExecuteReader(connection, commandType, commandText, null));
 }
示例#3
0
 public static SqlDataReader ExecuteReader(SqlTransaction transaction, CommandType commandType, string commandText)
 {
     return(SqlHelper.ExecuteReader(transaction, commandType, commandText, null));
 }
示例#4
0
 public static SqlDataReader Select(SqlConnection conn, string sql, params SqlParameter[] parms)
 {
     return(SqlHelper.ExecuteReader(conn, CommandType.Text, sql, parms));
 }
示例#5
0
 public static SqlDataReader Select(SqlTransaction trans, string sql, params SqlParameter[] parms)
 {
     return(SqlHelper.ExecuteReader(trans, CommandType.Text, sql, parms));
 }
        public List <Variavel> ListarLinhaNegocioModelo(Variavel entidade)
        {
            var variavel = new List <Variavel>();

            SqlParameter[] parms = new SqlParameter[]
            {
                new SqlParameter()
                {
                    DbType        = DbType.Int32,
                    Direction     = ParameterDirection.Input,
                    ParameterName = "@IdModelo",
                    Value         = entidade.Modelo.IDModelo
                },
                new SqlParameter()
                {
                    DbType        = DbType.Int32,
                    Direction     = ParameterDirection.Input,
                    ParameterName = "@IDLinhaNegocio",
                    Value         = entidade.LinhaNegocio.IDLinhaNegocio
                }
            };
            using (IDataReader reader = SqlHelper.ExecuteReader(ConfigurationManager.ConnectionStrings["Default"].ConnectionString, CommandType.StoredProcedure, "VariavelModeloListar", parms))
            {
                while (reader.Read())
                {
                    var variavelLista = new Variavel();

                    variavelLista.IDVariavel = Convert.ToInt32(reader["IDVariavel"]);

                    variavelLista.TipoVariavel = new TipoVariavel()
                    {
                        IDTipoVariavel = Convert.ToInt32(reader["IdTipoVariavel"])
                    };

                    variavelLista.ClasseVariavel = new ClasseVariavel()
                    {
                        IDClasseVariavel = Convert.ToInt32(reader["IdClasseVariavel"])
                    };

                    variavelLista.TipoSaida = new TipoSaida()
                    {
                        IDTipoSaida = Convert.ToInt32(reader["IdTipoSaida"])
                    };

                    variavelLista.Codigo      = reader["Codigo"].ToString();
                    variavelLista.Descricao   = reader["Descricao"].ToString();
                    variavelLista.Significado = reader["Significado"].ToString();
                    variavelLista.MetodoCientificoObtencao    = reader["MetodoCientificoObtencao"].ToString();
                    variavelLista.MetodoPraticoObtencao       = reader["MetodoPraticoObtencao"].ToString();
                    variavelLista.PerguntaSistema             = reader["PerguntaSistema"].ToString();
                    variavelLista.InteligenciaSistemicaModelo = reader["InteligenciaSistemicaModelo"].ToString();
                    variavelLista.Comentario = reader["Comentario"].ToString();
                    variavelLista.Usuario    = new Usuario()
                    {
                        IDUsuario = Convert.ToInt32(reader["IdUsuario"])
                    };
                    variavelLista.TipoDadoVariavel = new TipoDadoVariavel()
                    {
                        IDTipoDadoVariavel = Convert.ToInt32(reader["IDTipoDadoVariavel"])
                    };
                    variavelLista.IdPai = (reader["IdPai"]) is DBNull? 0 : Convert.ToInt32(reader["IdPai"]);
                    variavel.Add(variavelLista);
                }
                return(variavel);
            }
        }
        public Variavel ListarRegraLogicaProcessoSegmento(Variavel entidade)
        {
            var RegraLogicaProcessoSegmento = new Variavel();

            SqlParameter[] parms = new SqlParameter[]
            {
                new SqlParameter()
                {
                    DbType        = DbType.Int32,
                    Direction     = ParameterDirection.Input,
                    ParameterName = "@IdClasseVariavel",
                    Value         = entidade.ClasseVariavel.IDClasseVariavel
                },
                new SqlParameter()
                {
                    DbType        = DbType.Int32,
                    Direction     = ParameterDirection.Input,
                    ParameterName = "@IdTipoSaida",
                    Value         = entidade.TipoSaida.IDTipoSaida
                },
                new SqlParameter()
                {
                    DbType        = DbType.Int32,
                    Direction     = ParameterDirection.Input,
                    ParameterName = "@IdModelo",
                    Value         = entidade.Modelo.IDModelo
                },
                new SqlParameter()
                {
                    DbType        = DbType.Int32,
                    Direction     = ParameterDirection.Input,
                    ParameterName = "@IdRegraLogica",
                    Value         = entidade.RegraLogica.IdRegraLogica
                }
            };
            using (IDataReader reader = SqlHelper.ExecuteReader(ConfigurationManager.ConnectionStrings["Default"].ConnectionString, CommandType.StoredProcedure, "VariavelRegraLogicaProcessoSegmentoListar", parms))
            {
                RegraLogicaProcessoSegmento.VariavelRegraLogicaLista = new List <VariavelRegraLogica>();
                while (reader.Read())
                {
                    var variavelRegraLogica = new VariavelRegraLogica();

                    variavelRegraLogica.Variavel = new Variavel()
                    {
                        IDVariavel = Convert.ToInt32(reader["IDVariavel"])
                    };
                    variavelRegraLogica.RegraLogica = new RegraLogica()
                    {
                        IdRegraLogica = Convert.ToInt32(reader["IDVariavel"])
                    };
                    variavelRegraLogica.Criterio = new Criterio()
                    {
                        IDCriterio = Convert.ToInt32(reader["IDCriterio"])
                    };
                    variavelRegraLogica.Valor = reader["Valor"].ToString();

                    RegraLogicaProcessoSegmento.VariavelRegraLogicaLista.Add(variavelRegraLogica);
                }
            }

            return(RegraLogicaProcessoSegmento);
        }
        public Variavel ListarOutputGlobal(Variavel entidade)
        {
            var outPutGlobal = new Variavel();

            SqlParameter[] parms = new SqlParameter[]
            {
                new SqlParameter()
                {
                    DbType        = DbType.Int32,
                    Direction     = ParameterDirection.Input,
                    ParameterName = "@IdModelo",
                    Value         = entidade.Modelo.IDModelo
                },
                new SqlParameter()
                {
                    DbType        = DbType.Int32,
                    Direction     = ParameterDirection.Input,
                    ParameterName = "@IdTipoSaida",
                    Value         = entidade.TipoSaida.IDTipoSaida
                },
                new SqlParameter()
                {
                    DbType        = DbType.Int32,
                    Direction     = ParameterDirection.Input,
                    ParameterName = "@IdClasseVariavel",
                    Value         = entidade.ClasseVariavel.IDClasseVariavel
                }
            };
            using (IDataReader reader = SqlHelper.ExecuteReader(ConfigurationManager.ConnectionStrings["Default"].ConnectionString, CommandType.StoredProcedure, "VariavelOutputGlobalListar", parms))
            {
                if (reader.Read())
                {
                    outPutGlobal.IDVariavel   = Convert.ToInt32(reader["IdVariavel"]);
                    outPutGlobal.TipoVariavel = new TipoVariavel()
                    {
                        IDTipoVariavel = Convert.ToInt32(reader["IdTipoVariavel"])
                    };
                    outPutGlobal.ClasseVariavel = new ClasseVariavel()
                    {
                        IDClasseVariavel = Convert.ToInt32(reader["IdClasseVariavel"])
                    };
                    outPutGlobal.TipoSaida = new TipoSaida()
                    {
                        IDTipoSaida = Convert.ToInt32(reader["IdTipoSaida"])
                    };
                    outPutGlobal.TipoDadoVariavel = new TipoDadoVariavel()
                    {
                        IDTipoDadoVariavel = Convert.ToInt32(reader["IdTipoDadoVariavel"])
                    };
                    outPutGlobal.Codigo      = reader["Codigo"].ToString();
                    outPutGlobal.Descricao   = reader["Descricao"].ToString();
                    outPutGlobal.Significado = reader["Significado"].ToString();
                    outPutGlobal.MetodoCientificoObtencao    = reader["MetodoCientificoObtencao"].ToString();
                    outPutGlobal.MetodoPraticoObtencao       = reader["MetodoPraticoObtencao"].ToString();
                    outPutGlobal.PerguntaSistema             = reader["PerguntaSistema"].ToString();
                    outPutGlobal.InteligenciaSistemicaModelo = reader["InteligenciaSistemicaModelo"].ToString();
                    outPutGlobal.Comentario      = reader["Comentario"].ToString();
                    outPutGlobal.DataCriacao     = Convert.ToDateTime(reader["DataCriacao"]);
                    outPutGlobal.DataModificacao = Convert.ToDateTime(reader["DataModificacao"]);
                    if (!string.IsNullOrEmpty(reader["ColunaImportacao"].ToString()))
                    {
                        outPutGlobal.ColunaImportacao = Convert.ToInt32(reader["ColunaImportacao"]);
                    }
                    outPutGlobal.Usuario = new Usuario()
                    {
                        IDUsuario = Convert.ToInt32(reader["IdUsuario"])
                    };
                }
            }

            return(outPutGlobal);
        }
        public List <Criterio> ListarVariavelLista(Criterio entidade)
        {
            var criterio = new List <Criterio>();

            SqlParameter[] parms = new SqlParameter[]
            {
                new SqlParameter()
                {
                    DbType        = DbType.Int32,
                    Direction     = ParameterDirection.Input,
                    ParameterName = "@IdCriterio",
                    Value         = entidade.IDCriterio
                },
                new SqlParameter()
                {
                    DbType        = DbType.Int32,
                    Direction     = ParameterDirection.Input,
                    ParameterName = "@IdVariavel",
                    Value         = entidade.Variavel.IDVariavel
                },
                new SqlParameter()
                {
                    DbType        = DbType.Double,
                    Direction     = ParameterDirection.Input,
                    ParameterName = "@Valor1",
                    Value         = entidade.CriterioVariavel.Valor1
                },
                new SqlParameter()
                {
                    DbType        = DbType.Double,
                    Direction     = ParameterDirection.Input,
                    ParameterName = "@Valor2",
                    Value         = entidade.CriterioVariavel.Valor1
                },
                new SqlParameter()
                {
                    DbType        = DbType.Int32,
                    Direction     = ParameterDirection.Input,
                    ParameterName = "@IdTipoCriterioVariavel",
                    Value         = entidade.TipoCriterioVariavel.IDTipoCriterioVariavel
                }
            };
            using (IDataReader reader = SqlHelper.ExecuteReader(ConfigurationManager.ConnectionStrings["Default"].ConnectionString, CommandType.StoredProcedure, "CriterioVariavelListar", parms))
            {
                while (reader.Read())
                {
                    criterio.Add(new Criterio()
                    {
                        IDCriterio = Convert.ToInt32(reader["IdCriterio"]),
                        Nome       = reader["Nome"].ToString(),
                        Variavel   = new Variavel()
                        {
                            IDVariavel = Convert.ToInt32(reader["IdVariavel"])
                        },
                        CriterioVariavel = new CriterioVariavel()
                        {
                            Valor1 = Convert.ToInt32(reader["Valor1"]),
                            Valor2 = Convert.ToInt32(reader["Valor2"])
                        },
                        TipoCriterioVariavel = new TipoCriterioVariavel()
                        {
                            IDTipoCriterioVariavel = Convert.ToInt32(reader["IDTipoCriterioVariavel"])
                        }
                    });
                }
            }

            return(criterio);
        }
示例#10
0
        /// <summary>
        /// 传入影院ID和电影ID时返回厅院上映信息
        /// </summary>
        /// <param name="mi"></param>
        /// <param name="om"></param>
        /// <returns></returns>
        public List <ShowDetails> FindShowDetails(MovieInfoModel mi, CinemaInfoModel om)
        {
            string str;

            SqlParameter[] sqlParameters = null;
            if (mi.MovieID != 0)
            {
                //通过电影ID查询到该电影信息
                str           = "select * from MovieInfo where MovieID =@MovieID";
                sqlParameters = new SqlParameter[] {
                    new SqlParameter("@MovieID", System.Data.SqlDbType.Int)
                    {
                        Value = mi.MovieID
                    }
                };
            }
            else
            {
                // 在没有电影ID的时候,查询该电影院的Top 1排片电影
                str = " Select Top 1* from MovieInfo where MovieName in " +
                      "(select MovieName from[dbo].[ChipInfo] where CinemaID = @CinemaID " +
                      " and datediff(MINUTE, getdate(),StartTime)>15)";

                sqlParameters = new SqlParameter[] {
                    new SqlParameter("@CinemaID", System.Data.SqlDbType.Int)
                    {
                        Value = om.CinemaID
                    }
                };
            }

            SqlDataReader reader = SqlHelper.ExecuteReader(str, System.Data.CommandType.Text, sqlParameters);

            MovieInfoModel mo = new MovieInfoModel();

            while (reader.Read())
            {
                mo = new MovieInfoModel(reader);
            }
            reader.Close();

            //上映详情集合
            List <ShowDetails> ls = new List <ShowDetails>();

            if (String.IsNullOrEmpty(mo.MovieName))
            {
                return(ls);
            }

            //通过传入的影院ID获取该排片的开始结束时间、且必须为今日排片、离上映时间大于15分钟
            str           = "select * from [dbo].[ChipInfo] where CinemaID=@CinemaID and datediff(MINUTE,getdate(),StartTime)>15 and Convert(nvarchar,StartTime,120) like @TimeNow+'%' and MovieName=@MovieName";
            sqlParameters = new SqlParameter[] {
                new SqlParameter("@CinemaID", System.Data.SqlDbType.Int)
                {
                    Value = om.CinemaID
                },
                new SqlParameter("@MovieName", System.Data.SqlDbType.NVarChar)
                {
                    Value = mo.MovieName
                },
                new SqlParameter("@TimeNow", System.Data.SqlDbType.NVarChar)
                {
                    Value = DateTime.Now.ToString().Substring(0, DateTime.Now.ToString().IndexOf(' ')).Replace('/', '-')
                }
            };

            reader = SqlHelper.ExecuteReader(str, System.Data.CommandType.Text, sqlParameters);

            //排片集合
            List <ChipInfoModel> os = new List <ChipInfoModel>();

            while (reader.Read())
            {
                ChipInfoModel oi = new ChipInfoModel(reader);
                os.Add(oi);
            }
            reader.Close();

            //将该影院所有关于该电影的排片信息(开始结束时间)放入ShowDetails集合
            for (int i = 0; i < os.Count; i++)
            {
                ls.Add(new ShowDetails()
                {
                    ChipInfoID = os[i].ChipInfoID, StartTime = os[i].StartTime, StopTime = os[i].StopTime, Money = mo.MovieMoney, Language = mo.MovieArea
                });
            }

            List <OfficeInfoModel> of = new List <OfficeInfoModel>();

            //通过传入的影院ID获取厅信息
            for (int i = 0; i < os.Count; i++)
            {
                str           = " select * from [dbo].[OfficeInfo] where [OfficeID] in  (@OfficeID)";
                sqlParameters = new SqlParameter[] {
                    new SqlParameter("@OfficeID", System.Data.SqlDbType.Int)
                    {
                        Value = os[i].OfficeID
                    }
                };

                reader = SqlHelper.ExecuteReader(str, System.Data.CommandType.Text, sqlParameters);

                //获取到了所有的厅位信息
                while (reader.Read())
                {
                    OfficeInfoModel ofs = new OfficeInfoModel(reader);
                    of.Add(ofs);
                }
                reader.Close();
            }

            for (int i = 0; i < of.Count; i++)
            {
                ls[i].OfficeID   = of[i].OfficeID;
                ls[i].OfficeName = of[i].OfficeName;
            }

            return(ls);
        }