Exemplo n.º 1
0
        public string Cadastrar(ClienteEnt cliente)
        {
            try
            {
                cliente.PodeCadastrar();
                DbCliente dbCliente = new DbCliente();
                string    retorno   = "";
                switch (dbCliente.Cadastrar(cliente))
                {
                case RetornosDoModel.Cadastrado:
                    retorno = "Cadastrado com sucesso";
                    break;

                case RetornosDoModel.Existe:
                    retorno = "já existe um registro como este no banco de dados";
                    break;

                case RetornosDoModel.Erro:
                    retorno = "falha ao tentar cadastrar";
                    break;
                }
                return(retorno);
            }
            catch (ExceptionCliente erro)
            {
                return(erro.Message);
            }
            catch (Exception erro)
            {
                return(erro.Message);
            }
        }
Exemplo n.º 2
0
        private void txtAluno_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                try
                {
                    DbCliente bd = new DbCliente();

                    lbalunos.DataSource = bd.Select(string.Format("select id_aluno, id_cliente, nome, Descricao, ano_recente from tbl_alunos a join tbl_turma t on a.id_turma = t.id_turma  where nome like '%{0}%'", txtAluno.Text));
                }
                catch (Exception erro)
                {
                    MessageBox.Show(erro.Message);
                }
            }
        }
Exemplo n.º 3
0
        public string Alterar(ClienteEnt cliente)
        {
            try
            {
                cliente.PodeCadastrar();
                DbCliente dbCliente = new DbCliente();

                return(dbCliente.Alterar(cliente));
            }
            catch (ExceptionCliente erro)
            {
                return(erro.Message);
            }
            catch (Exception erro)
            {
                return(erro.Message);
            }
        }
Exemplo n.º 4
0
 public static void Salvar(string Codcli, string nome, double valor)
 {
     DbCliente.Add(new Cliente(Codcli, nome, valor));
 }
Exemplo n.º 5
0
 public static Cliente Buscar(string codigo)
 {
     return(DbCliente.Find(z => z.Numero == codigo));
 }
Exemplo n.º 6
0
        public RetornosDoModel CarregarClientePorId(ClienteEnt cliente, ref string mensagem)
        {
            DbCliente db = new DbCliente();

            return(db.CarregarCliente(cliente, ref mensagem));
        }
Exemplo n.º 7
0
 public ClienteController(DbCliente dbCliente)
 {
     this.dbCliente = dbCliente;
 }