Пример #1
0
 public static DateTime?GetDateTimeOrNull(this READER reader, int ordinal)
 {
     if (reader.IsDBNull(ordinal))
     {
         return(null);
     }
     else
     {
         return(reader.GetDateTime(ordinal));
     }
 }
Пример #2
0
 public Curso carregarCursoXAluno(NpgsqlDataReader data_reader)
 {
     Curso curso = new Curso();
     curso.Tl_curso = data_reader.IsDBNull(data_reader.GetOrdinal("TL_CURSO")) ? "" : data_reader.GetString(data_reader.GetOrdinal("TL_CURSO"));
     curso.Ds_curso = data_reader.IsDBNull(data_reader.GetOrdinal("DS_CURSO")) ? "" : data_reader.GetString(data_reader.GetOrdinal("DS_CURSO"));
     curso.Duracao_curso = data_reader.IsDBNull(data_reader.GetOrdinal("DUR_CURSO")) ? "" : data_reader.GetString(data_reader.GetOrdinal("DUR_CURSO"));
     curso.Dt_cadastro = data_reader.IsDBNull(data_reader.GetOrdinal("DT_CADASTRO")) ? DateTime.MinValue : data_reader.GetDateTime(data_reader.GetOrdinal("DT_CADASTRO"));
     return curso;
 }
Пример #3
0
 public Curso carregar(NpgsqlDataReader data_reader)
 {
     Curso curso = new Curso();
     curso.Id_curso = data_reader.IsDBNull(data_reader.GetOrdinal("ID_CURSO")) ? 0 : data_reader.GetInt32(data_reader.GetOrdinal("ID_CURSO"));
     curso.Tl_curso = data_reader.IsDBNull(data_reader.GetOrdinal("TL_CURSO")) ? "" : data_reader.GetString(data_reader.GetOrdinal("TL_CURSO"));
     curso.Ds_curso = data_reader.IsDBNull(data_reader.GetOrdinal("DS_CURSO")) ? "" : data_reader.GetString(data_reader.GetOrdinal("DS_CURSO"));
     curso.Obj_curso = data_reader.IsDBNull(data_reader.GetOrdinal("OBJ_CURSO")) ? "" : data_reader.GetString(data_reader.GetOrdinal("OBJ_CURSO"));
     curso.Topicos_curso = data_reader.IsDBNull(data_reader.GetOrdinal("TOPICOS_CURSO")) ? "" : data_reader.GetString(data_reader.GetOrdinal("TOPICOS_CURSO"));
     curso.Pre_req_curso = data_reader.IsDBNull(data_reader.GetOrdinal("PRE_REQ_CURSO")) ? "" : data_reader.GetString(data_reader.GetOrdinal("PRE_REQ_CURSO"));
     curso.Duracao_curso = data_reader.IsDBNull(data_reader.GetOrdinal("DURACAO_CURSO")) ? "" : data_reader.GetString(data_reader.GetOrdinal("DURACAO_CURSO"));
     curso.Dt_cadastro = data_reader.IsDBNull(data_reader.GetOrdinal("DT_CADASTRO")) ? DateTime.MinValue : data_reader.GetDateTime(data_reader.GetOrdinal("DT_CADASTRO"));
     return curso;
 }
        /// <summary>
        /// A helper function that takes the current row from the NpgsqlDataReader
        /// and hydrates a MembershipUser from the values. Called by the 
        /// MembershipUser.GetUser implementation.
        /// </summary>
        /// <param name="reader">NpgsqlDataReader object</param>
        /// <returns>MembershipUser object</returns>
        private MembershipUser GetUserFromReader(NpgsqlDataReader reader)
        {
            object providerUserKey = reader.GetValue(0);
            string username = reader.GetString(1);
            string email = reader.IsDBNull(2) ? string.Empty : reader.GetString(2);
            string passwordQuestion = reader.IsDBNull(3) ? string.Empty : reader.GetString(3);
            string comment = reader.IsDBNull(4) ? string.Empty : reader.GetString(4);
            bool isApproved = reader.IsDBNull(5) ? false : reader.GetBoolean(5);
            bool isLockedOut = reader.IsDBNull(6) ? false : reader.GetBoolean(6);
            DateTime creationDate = reader.IsDBNull(7) ? DateTime.MinValue : reader.GetDateTime(7);
            DateTime lastLoginDate = reader.IsDBNull(8) ? DateTime.MinValue : reader.GetDateTime(8);
            DateTime lastActivityDate = reader.IsDBNull(9) ? DateTime.MinValue : reader.GetDateTime(9);
            DateTime lastPasswordChangedDate = reader.IsDBNull(10) ? DateTime.MinValue : reader.GetDateTime(10);
            DateTime lastLockedOutDate = reader.IsDBNull(11) ? DateTime.MinValue : reader.GetDateTime(11);

            return new MembershipUser(this.Name,
                                                  username,
                                                  providerUserKey,
                                                  email,
                                                  passwordQuestion,
                                                  comment,
                                                  isApproved,
                                                  isLockedOut,
                                                  creationDate,
                                                  lastLoginDate,
                                                  lastActivityDate,
                                                  lastPasswordChangedDate,
                                                  lastLockedOutDate);
        }
Пример #5
0
        public bool GetByPrimaryKey(string pKey)
        {
            string sQuery = "select * from tbm_carrepair WHERE repairid='" + pKey + "'";

            Npgsql.NpgsqlCommand cmd = new Npgsql.NpgsqlCommand(sQuery, Koneksi);
            cmd.CommandText = sQuery;
            Npgsql.NpgsqlDataReader rdr = cmd.ExecuteReader();
            try
            {
                if (rdr.Read())
                {
                    if (!rdr.IsDBNull(rdr.GetOrdinal("repairid")))
                    {
                        m_repairid = rdr.GetString(rdr.GetOrdinal("repairid"));
                    }
                    else
                    {
                        m_repairid = "";
                    };
                    if (!rdr.IsDBNull(rdr.GetOrdinal("carid")))
                    {
                        m_carid = rdr.GetString(rdr.GetOrdinal("carid"));
                    }
                    else
                    {
                        m_carid = "";
                    };

                    if (!rdr.IsDBNull(rdr.GetOrdinal("opadd")))
                    {
                        m_opadd = rdr.GetString(rdr.GetOrdinal("opadd"));
                    }
                    else
                    {
                        m_opadd = "";
                    };
                    if (!rdr.IsDBNull(rdr.GetOrdinal("pcadd")))
                    {
                        m_pcadd = rdr.GetString(rdr.GetOrdinal("pcadd"));
                    }
                    else
                    {
                        m_pcadd = "";
                    };
                    if (!rdr.IsDBNull(rdr.GetOrdinal("luadd")))
                    {
                        m_luadd = rdr.GetDateTime(rdr.GetOrdinal("luadd"));
                    }
                    else
                    {
                        m_luadd = System.DateTime.MinValue;
                    };
                    if (!rdr.IsDBNull(rdr.GetOrdinal("opedit")))
                    {
                        m_opedit = rdr.GetString(rdr.GetOrdinal("opedit"));
                    }
                    else
                    {
                        m_opedit = "";
                    };
                    if (!rdr.IsDBNull(rdr.GetOrdinal("pcedit")))
                    {
                        m_pcedit = rdr.GetString(rdr.GetOrdinal("pcedit"));
                    }
                    else
                    {
                        m_pcedit = "";
                    };
                    if (!rdr.IsDBNull(rdr.GetOrdinal("luedit")))
                    {
                        m_luedit = rdr.GetDateTime(rdr.GetOrdinal("luedit"));
                    }
                    else
                    {
                        m_luedit = System.DateTime.MinValue;
                    };
                    m_dlt = rdr.GetBoolean(rdr.GetOrdinal("dlt"));
                }
                return(true);
            }
            catch (Npgsql.NpgsqlException Ex)
            {
                System.Windows.Forms.MessageBox.Show(Ex.Message, "An error occurred while processing!!!");
                return(false);
            }
            finally
            {
                if (rdr != null)
                {
                    rdr.Close();
                }
            }
        }
Пример #6
0
 public static DateTime GetDateTimeOrDefault(this READER reader, int ordinal) => reader.IsDBNull(ordinal) ? default : reader.GetDateTime(ordinal);
        private MembershipUser GetUserFromReader(string providerName, NpgsqlDataReader reader)
        {
            object providerUserKey = reader.GetValue(0);
            string username = reader.GetString(1);
            string email = reader.GetString(2);
            string passwordQuestion = string.Empty;
            if (reader.GetValue(3) != DBNull.Value)
                passwordQuestion = reader.GetString(3);
            string comment = string.Empty;
            if (reader.GetValue(4) != DBNull.Value)
                comment = reader.GetString(4);
            bool isApproved = reader.GetBoolean(5);
            bool isLockedOut = reader.GetBoolean(6);
            DateTime creationDate = reader.GetDateTime(7);
            DateTime lastLoginDate = new DateTime();
            if (reader.GetValue(8) != DBNull.Value)
                lastLoginDate = reader.GetDateTime(8);
            DateTime lastActivityDate = reader.GetDateTime(9);
            DateTime lastPasswordChangedDate = reader.GetDateTime(10);

            DateTime lastLockedOutDate = new DateTime();
            if (reader.GetValue(11) != DBNull.Value)
                lastLockedOutDate = reader.GetDateTime(11);

            MembershipUser u = new MembershipUser(
                providerName,
                username,
                providerUserKey,
                email,
                passwordQuestion,
                comment,
                isApproved,
                isLockedOut,
                creationDate,
                lastLoginDate,
                lastActivityDate,
                lastPasswordChangedDate,
                lastLockedOutDate);

            return u;
        }
Пример #8
0
        public Usuario carregar(NpgsqlDataReader data_reader)
        {
            Usuario consulta = new Usuario();
            consulta.Id_usuario = data_reader.IsDBNull(data_reader.GetOrdinal("ID_USUARIO")) ? 0 : data_reader.GetInt32(data_reader.GetOrdinal("ID_USUARIO"));
            int id_tipo_usuario = consulta.Id_usuario = data_reader.IsDBNull(data_reader.GetOrdinal("ID_TIPO_USUARIO")) ? 0 : data_reader.GetInt32(data_reader.GetOrdinal("ID_TIPO_USUARIO"));

            if (id_tipo_usuario == (int)Tipo_usuario.ADMINISTRADOR)
            {
                consulta.Tipo = Tipo_usuario.ADMINISTRADOR;
            }
            else if (id_tipo_usuario == (int)Tipo_usuario.ALUNO)
            {
                consulta.Tipo = Tipo_usuario.ALUNO;
            }
            else
            {
                consulta.Tipo = Tipo_usuario.NONE;
            }

            consulta.Nm_usuario = data_reader.IsDBNull(data_reader.GetOrdinal("NM_USUARIO")) ? "" : data_reader.GetString(data_reader.GetOrdinal("NM_USUARIO"));
            consulta.Email_usuario = data_reader.IsDBNull(data_reader.GetOrdinal("EMAIL_USUARIO")) ? "" : data_reader.GetString(data_reader.GetOrdinal("EMAIL_USUARIO"));
            consulta.Senha_usuario = data_reader.IsDBNull(data_reader.GetOrdinal("SENHA_USUARIO")) ? "" : data_reader.GetString(data_reader.GetOrdinal("SENHA_USUARIO"));
            consulta.Link_imagem_usuario = data_reader.IsDBNull(data_reader.GetOrdinal("LINK_IMAGEM_USUARIO")) ? "" : data_reader.GetString(data_reader.GetOrdinal("LINK_IMAGEM_USUARIO"));
            consulta.Dt_cadastro = data_reader.IsDBNull(data_reader.GetOrdinal("DT_CADASTRO")) ? DateTime.MinValue : data_reader.GetDateTime(data_reader.GetOrdinal("DT_CADASTRO"));
            return consulta;
        }
Пример #9
0
 private Questao carregar(NpgsqlDataReader data_reader)
 {
     Questao questao = new Questao();
     questao.Id_questao = data_reader.IsDBNull(data_reader.GetOrdinal("ID_QUESTAO")) ? 0 : data_reader.GetInt32(data_reader.GetOrdinal("ID_QUESTAO"));
     questao.Ds_questao = data_reader.IsDBNull(data_reader.GetOrdinal("DS_QUESTAO")) ? "" : data_reader.GetString(data_reader.GetOrdinal("DS_QUESTAO"));
     questao.Curso_obj.Id_curso = data_reader.IsDBNull(data_reader.GetOrdinal("ID_CURSO")) ? 0 : data_reader.GetInt32(data_reader.GetOrdinal("ID_CURSO"));
     questao.Dt_cadastro = data_reader.IsDBNull(data_reader.GetOrdinal("DT_CADASTRO")) ? DateTime.MinValue : data_reader.GetDateTime(data_reader.GetOrdinal("DT_CADASTRO"));
     return questao;
 }
Пример #10
0
 Aula carregar(NpgsqlDataReader data_reader)
 {
     Aula aula = new Aula();
     aula.Id_aula = data_reader.IsDBNull(data_reader.GetOrdinal("ID_AULA")) ? 0 : data_reader.GetInt32(data_reader.GetOrdinal("ID_AULA"));
     aula.Tl_aula = data_reader.IsDBNull(data_reader.GetOrdinal("TL_AULA")) ? "" : data_reader.GetString(data_reader.GetOrdinal("TL_AULA"));
     aula.Ds_aula = data_reader.IsDBNull(data_reader.GetOrdinal("DS_AULA")) ? "" : data_reader.GetString(data_reader.GetOrdinal("DS_AULA"));
     aula.Curso_obj.Id_curso = data_reader.IsDBNull(data_reader.GetOrdinal("ID_CURSO")) ? 0 : data_reader.GetInt32(data_reader.GetOrdinal("ID_CURSO"));
     aula.Link_aula = data_reader.IsDBNull(data_reader.GetOrdinal("LINK_AULA")) ? "" : data_reader.GetString(data_reader.GetOrdinal("LINK_AULA"));
     aula.Dt_cadastro = data_reader.IsDBNull(data_reader.GetOrdinal("DT_CADASTRO")) ? DateTime.MinValue : data_reader.GetDateTime(data_reader.GetOrdinal("DT_CADASTRO"));
     return aula;
 }
Пример #11
0
 private QuoteServerEvent GetQuoteServerEventFromRecord(NpgsqlDataReader reader)
 {
     var quoteServerEvent = new QuoteServerEvent
     {
         StockSymbol = reader.GetString(9),
         Price = reader.GetDecimal(10),
         QuoteServerTime = reader.GetDateTime(14),
         CryptoKey = reader.GetString(15)
     };
     FillBaseEventPropertiesFromRecord(quoteServerEvent, reader);
     return quoteServerEvent;
 }
Пример #12
0
 private void FillBaseEventPropertiesFromRecord(TransactionEvent te, NpgsqlDataReader reader)
 {
     te.LoggedAt = reader.GetDateTime(1);
     te.OccuredAt = reader.GetDateTime(2);
     te.TransactionId = reader.GetInt32(4);
     te.UserId = (reader.IsDBNull(5)) ? null : reader.GetString(5);
     te.Service = reader.GetString(6);
     te.Server = reader.GetString(7);
 }
Пример #13
0
 private Resposta carregar(NpgsqlDataReader data_reader)
 {
     Resposta resposta = new Resposta();
     resposta.id_resposta = data_reader.IsDBNull(data_reader.GetOrdinal("ID_RESPOSTA")) ? 0 : data_reader.GetInt32(data_reader.GetOrdinal("ID_RESPOSTA"));
     resposta.Ds_resposta = data_reader.IsDBNull(data_reader.GetOrdinal("DS_RESPOSTA")) ? "" : data_reader.GetString(data_reader.GetOrdinal("DS_RESPOSTA"));
     resposta.FL_correta = data_reader.IsDBNull(data_reader.GetOrdinal("FL_CORRETA")) ? false : data_reader.GetBoolean(data_reader.GetOrdinal("FL_CORRETA"));
     resposta.Questao_obj.Id_questao = data_reader.IsDBNull(data_reader.GetOrdinal("ID_QUESTAO")) ? 0 : data_reader.GetInt32(data_reader.GetOrdinal("ID_QUESTAO"));
     resposta.Dt_cadastro = data_reader.IsDBNull(data_reader.GetOrdinal("DT_CADASTRO")) ? DateTime.MinValue : data_reader.GetDateTime(data_reader.GetOrdinal("DT_CADASTRO"));
     return resposta;
 }