Example #1
0
        private void btn_Adicionar_Click(object sender, EventArgs e)
        {
            try
            {
                tblClienteDTO objCliente = new tblClienteDTO();
                objCliente.NomeMusica = txt_NomeM.Text.Trim();
                objCliente.NomeAutor  = txt_NomeA.Text.Trim();



                if (txt_idM.Text != "")
                {
                    MessageBox.Show("Deixe o campo 'Id Música' vazio, ele será gerado automaticamente");
                }
                else
                {
                    sql = string.Format("insert into TBL_Musica values(null,'{1}','{2}','{3}','{4}')"
                                        , txt_idM.Text, txt_NomeM.Text, txt_NomeA.Text, txt_idG.Text, txt_idCd.Text);

                    bd.AlterarTabelas(sql);

                    MessageBox.Show("Música cadastrada com sucesso!!", "Cadastrar", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Limpar();
                    dgv_listar_musica.DataSource = bd.ConsultarDadosTabela("SELECT * from TBL_Musica");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro: " + ex.Message, "Erro!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #2
0
        private void btn_Salvar_Click(object sender, EventArgs e)
        {
            try
            {
                tblClienteDTO objCliente = new tblClienteDTO();
                objCliente.Login = txt_CadastrarLogin.Text.Trim();
                objCliente.Senha = txt_CadastraSenha.Text.Trim();


                sql = string.Format("insert into TBL_Login values('{0}','{1}')"
                                    , txt_CadastrarLogin.Text, txt_CadastraSenha.Text);

                bd.AlterarTabelas(sql);

                MessageBox.Show("Cadastrado com sucesso!!", "Cadastrar", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Limpar();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro: " + ex.Message, "Erro!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }