Ejemplo n.º 1
0
 public AliancaConta()
 {
     //
     // TODO: Add constructor logic here
     //
     Ativado = true;
     funcionario = new Funcionario();
     maquina = new Maquina();
     alianca = new Alianca();
     conta = new Conta();
 }
Ejemplo n.º 2
0
        public bool Insert(Funcionario funcionario)
        {
            System.Data.IDbConnection objConexao;
            System.Data.IDbCommand objCommand;
            string sql = "INSERT INTO TBL_FUNCIONARIO (FUN_ID, FUN_NOME, FUN_CPF, FUN_SENHA, FUN_ATIVADO) VALUES (?id, ?nome, ?cpf, ?senha, ?ativado)";

            objConexao = Mapped.Connection();
            objCommand = Mapped.Command(sql, objConexao);

            objCommand.Parameters.Add(Mapped.Parameter("?id", funcionario.ID));
            objCommand.Parameters.Add(Mapped.Parameter("?nome", funcionario.Nome));
            objCommand.Parameters.Add(Mapped.Parameter("?cpf", funcionario.CPF));
            objCommand.Parameters.Add(Mapped.Parameter("?senha", funcionario.Senha));
            objCommand.Parameters.Add(Mapped.Parameter("?ativado", funcionario.Ativado));

            objCommand.ExecuteNonQuery();
            objConexao.Close();
            objCommand.Dispose();
            objConexao.Dispose();

            return true;
        }
Ejemplo n.º 3
0
        public Funcionario Select(int id)
        {
            Funcionario obj = null;

            System.Data.IDbConnection objConexao;
            System.Data.IDbCommand objCommand;
            System.Data.IDataReader objDataReader;

            objConexao = Mapped.Connection();
            objCommand = Mapped.Command("SELECT * FROM TBL_FUNCIONARIO WHERE FUN_ID = ?codigo", objConexao);
            objCommand.Parameters.Add(Mapped.Parameter("?codigo", id));

            objDataReader = objCommand.ExecuteReader();
            while (objDataReader.Read())
            {
                obj = new Funcionario();
                obj.ID = Convert.ToInt32(objDataReader["FUN_ID"]);
                obj.Nome = Convert.ToString(objDataReader["FUN_NOME"]);
                obj.CPF = Convert.ToInt32(objDataReader["FUN_CPF"]);
                obj.Ativado = Convert.ToBoolean(objDataReader["FUN_ATIVADO"]);
            }

            objDataReader.Close();
            objConexao.Close();

            objCommand.Dispose();
            objConexao.Dispose();
            objDataReader.Dispose();

            return obj;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Metodo que busca no banco o funcionario desejado
        /// </summary>
        /// <param name="id">id do funcionario</param>
        /// <returns>objeto Funcionario ou null caso nao encontre o id informado</returns>
        public Funcionario Select(int id)
        {
            Funcionario funcionario = null;

            System.Data.IDbConnection objConexao;
            System.Data.IDbCommand objCommand;
            System.Data.IDataReader objDataReader;

            objConexao = Mapped.Connection();
            objCommand = Mapped.Command("SELECT * FROM TBL_FUNCIONARIO AS FUN INNER JOIN TBL_CARGO AS CAR ON FUN.CAR_ID=CAR.CAR_ID WHERE FUN_ID = ?codigo ", objConexao);
            objCommand.Parameters.Add(Mapped.Parameter("?codigo", id));

            objDataReader = objCommand.ExecuteReader();
            while (objDataReader.Read())
            {
                funcionario = new Funcionario();
                funcionario.ID = Convert.ToInt32(objDataReader["FUN_ID"]);
                funcionario.Nome = Convert.ToString(objDataReader["FUN_NOME"]);
                funcionario.CPF = Convert.ToInt32(objDataReader["FUN_CPF"]);
                funcionario.Ativado = Convert.ToBoolean(objDataReader["FUN_ATIVADO"]);
                //puxa os dados do relacionamento
                funcionario.Cargo.ID = Convert.ToInt32(objDataReader["CAR_ID"]);
                funcionario.Cargo.Nome = Convert.ToString(objDataReader["CAR_NOME"]);
            }

            objDataReader.Close();
            objConexao.Close();

            objCommand.Dispose();
            objConexao.Dispose();
            objDataReader.Dispose();

            return funcionario;
        }