Exemplo n.º 1
0
        public int SP_SALVAR_CLIENTE(Entidades.Cliente entidade)
        {
            int Codigo = 0;
            Queue<SqlParameter> qParameter = null;
            Database db = null;
            try
            {
                db = new Database();

                using(References.Security.Crypt crp = new References.Security.Crypt())
                {
                    entidade.Password = crp.Codificar(entidade.Password);
                };

                CreateParameters(ref qParameter,
                    new References.DAL.Property() { NomeCampo = "Codigo", Value = entidade.Codigo, Direction = ParameterDirection.Output },
                    new References.DAL.Property() { NomeCampo = "Email", Value = entidade.Email },
                    new References.DAL.Property() { NomeCampo = "Logradouro", Value = entidade.Logradouro },
                    new References.DAL.Property() { NomeCampo = "Cidade", Value = entidade.Cidade },
                    new References.DAL.Property() { NomeCampo = "Complemento", Value = entidade.Complemento },
                    new References.DAL.Property() { NomeCampo = "Bairro", Value = entidade.Bairro },
                    new References.DAL.Property() { NomeCampo = "UF", Value = entidade.UF },
                    new References.DAL.Property() { NomeCampo = "Ativo", Value = entidade.Ativo },
                    new References.DAL.Property() { NomeCampo = "ReceberEmail", Value = entidade.ReceberEmail },
                    new References.DAL.Property() { NomeCampo = "UserID", Value = entidade.UserID },
                    new References.DAL.Property() { NomeCampo = "Password", Value = entidade.Password }
                );

                Codigo = db.ExecuteNonQuery("[dbo].[SP_SALVAR_CLIENTE]", ref qParameter);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (qParameter != null)
                    GC.SuppressFinalize(qParameter);
                if (db != null)
                    db.Dispose();
            }
            return Codigo;
        }
Exemplo n.º 2
0
        public Entidades.Usuario SP_VALIDA_USUARIO(string UserID, string Password)
        {
            Database db = null;
            Queue<SqlParameter> qParameters = null;
            Entidades.Usuario retorno = null;
            try
            {
                db = new Database();

                //Evita InnerScript
                Password = HttpUtility.HtmlEncode(Password);
                UserID = HttpUtility.HtmlEncode(UserID);

                string SenhaCriptografada = string.Empty;

                //Criptografando senha
                using (References.Security.Crypt cript = new References.Security.Crypt())
                {
                    SenhaCriptografada = cript.Codificar(Password);
                };

                CreateParameters(ref qParameters,
                    new Property() { NomeCampo = "UserID", Value = UserID },
                    new Property() { NomeCampo = "Password", Value = SenhaCriptografada }
                    );

                List<Entidades.Usuario> rMapping =
                    Mapping.Mapping<Entidades.Usuario>.ConvertReaderToIEnumerable(
                        db.ExecuteDataReader("SP_VALIDA_USUARIO", ref qParameters)).ToList();

                if (rMapping.Count > 0)
                    retorno = rMapping.ElementAt(0);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return retorno;
        }
Exemplo n.º 3
0
        public void SP_SALVAR_USUARIO(Entidades.Usuario entidade)
        {
            int Codigo = 0;
            Queue<SqlParameter> qParameter = null;
            Database db = null;
            try
            {
                db = new Database();

                //Criptografando senha
                using (References.Security.Crypt cript = new References.Security.Crypt())
                {
                    entidade.Password = cript.Codificar(entidade.Password);
                };

                CreateParameters(ref qParameter,
                    new References.DAL.Property() { NomeCampo = "NomeAdministrador", Value = entidade.NomeAdministrador },
                    new References.DAL.Property() { NomeCampo = "UserID", Value = entidade.UserID },
                    new References.DAL.Property() { NomeCampo = "Password", Value = entidade.Password },
                    new References.DAL.Property() { NomeCampo = "TipoPerfil", Value = entidade.TipoPerfil },
                    new References.DAL.Property() { NomeCampo = "Ativo", Value = entidade.Situacao }
                );

                db.ExecuteNonQuery("[dbo].[SP_SALVAR_USUARIO]", ref qParameter);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (qParameter != null)
                    GC.SuppressFinalize(qParameter);
                if (db != null)
                    db.Dispose();
            }
        }