Пример #1
0
        private void buttonCadastrar_Click(object sender, EventArgs e)
        {
            try
            {
                localhost.Cartao  cartao  = new localhost.Cartao();
                localhost.Usuario usuario = new localhost.Usuario();
                cartao.Numero          = textBoxNumero.Text;
                cartao.Bandeira        = textBoxBandeira.Text;
                cartao.CodigoSeguranca = textBoxCodigoSeguranca.Text;
                usuario.UsuarioId      = Convert.ToInt32(comboBoxUsuario.SelectedValue);
                cartao.Usuario         = usuario;
                localhost.Service1 sv = new localhost.Service1();

                String retornoMsg = sv.InsertCartao(cartao);

                if (retornoMsg == null || "".Equals(retornoMsg))
                {
                    MessageBox.Show("Cartão Cadastrado com Sucesso!");
                }
                else
                {
                    MessageBox.Show(retornoMsg);
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show("Erro ao conectar e inserir " + ex.Message);
            }
        }