I can’t save my record

Asked

Viewed 56 times

-3

Buneas personal, I don’t know how to handle C#, so I’m doing the program following tips on youtube and other tutorials that I find, but I came across a mistake that I haven’t found how to solve...

Every time I click to register the program sends me this

    internal void Insert(int p, string p_2, string p_3, int p_4, string p_5, System.Drawing.Image image, string p_6)
    {
        throw new System.NotImplementedException();
    }

But I have no idea how to solve, my code is right next, if someone knows how to help me would appreciate it a lot, this is just a little program that I’m trying to make my mom use in her work to facilitate

I’m using Visual Studio 2010 C# with SQL Server, if it makes any difference

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Ficha_de_Anamnese.anamneseDBDataSetTableAdapters;
using System.IO;

namespace Ficha_de_Anamnese
{
    public partial class cadastrodeusuario : Form
    {
        public cadastrodeusuario()
        {
            InitializeComponent();
        }

        void Limpar()
        {
            imgpath.Clear();
            senha.Clear();
            confsenha.Clear();
            resposta.Clear();
            email.Clear();
            login.Clear();
            nome.Clear();
            pergunta.SelectedIndex = -1;
            if (imgbox.Image != null)
            {
                imgbox.Image.Dispose();
                imgbox.Image = null;
            }
        }

        private void cadastrodeusuario_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'anamneseDBDataSet.userDB' table. You can move, or remove it, as needed.
            this.userDBTableAdapter.Fill(this.anamneseDBDataSet.userDB);
            // TODO: This line of code loads data into the 'anamneseDBDataSet.pergDB' table. You can move, or remove it, as needed.
            this.pergDBTableAdapter.Fill(this.anamneseDBDataSet.pergDB);
            Limpar();

        }

        private void btn_voltar_Click(object sender, EventArgs e)
        {
            this.Close();
            Inicio back = new Inicio();
            back.Show();
        }

        private void btn_cadastrar_Click(object sender, EventArgs e)
        {
            System.Text.RegularExpressions.Regex rEMail = new System.Text.RegularExpressions.Regex(@"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$");
            if (nome.Text.Trim() == "")
            {
                MessageBox.Show("O campo NOME deve ser preenchido", "Ficha de Anamnese - ERRO", MessageBoxButtons.OK, MessageBoxIcon.Information);
                nome.Focus();
            }
            else if (email.Text.Trim() == "")
            {
                MessageBox.Show("O campo E-MAIL deve ser preenchido", "Ficha de Anamnese - ERRO", MessageBoxButtons.OK, MessageBoxIcon.Information);
                email.Focus();
            }
            else if (!rEMail.IsMatch(email.Text))
            {
                MessageBox.Show("E-Mail inválido!", "Ficha de Anamnese - ERRO", MessageBoxButtons.OK, MessageBoxIcon.Information);
                email.SelectAll();
                email.Focus();
            }
            else if (login.Text.Trim() == "")
            {
                MessageBox.Show("O campo LOGIN deve ser preenchido", "Ficha de Anamnese - ERRO", MessageBoxButtons.OK, MessageBoxIcon.Information);
                login.Focus();
            }
            else if ((login.Text.Length < 6) || (login.Text.Length > 10))
            {
                MessageBox.Show("O login deve ter entre 6 e 10 dígitos");
                login.Focus();
            }
            else if (senha.Text.Trim() == "")
            {
                MessageBox.Show("O campo SENHA deve ser preenchido", "Ficha de Anamnese - ERRO", MessageBoxButtons.OK, MessageBoxIcon.Information);
                senha.Focus();
            }
            else if ((senha.Text.Length < 5) || (senha.Text.Length > 15))
            {
                MessageBox.Show("A senha deve ter entre 5 e 15 dígitos");
                senha.Focus();
            }
            else if (confsenha.Text.Trim() == "")
            {
                MessageBox.Show("O campo REPETIR SENHA deve ser preenchido", "Ficha de Anamnese - ERRO", MessageBoxButtons.OK, MessageBoxIcon.Information);
                confsenha.Focus();
            }
            else if (senha.Text != confsenha.Text)
            {
                MessageBox.Show("As senhas não são iguais!", "Ficha de Anamnese - ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error);
                confsenha.Focus();
            }
            else if (pergunta.Text.Trim() == "")
            {
                MessageBox.Show("Você deve escolher uma pergunta", "Ficha de Anamnese - ERRO", MessageBoxButtons.OK, MessageBoxIcon.Information);
                pergunta.Focus();
            }
            else if (resposta.Text.Trim() == "")
            {
                MessageBox.Show("O campo RESPOSTA deve ser preenchido", "Ficha de Anamnese - ERRO", MessageBoxButtons.OK, MessageBoxIcon.Information);
                resposta.Focus();
            }
            else
            {
                userDBTableAdapter uta = new userDBTableAdapter();
                uta.Insert(int.Parse(login.Text.ToString()), nome.Text, senha.Text, int.Parse(pergunta.SelectedValue.ToString()), resposta.Text, imgbox.Image, email.Text);
                MessageBox.Show("Usuário Registrado com sucesso!", "Ficha de Anamnese - Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }

        private void btn_limpar_Click(object sender, EventArgs e)
        {
            Limpar();
        }

        private void imgbox_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                imgpath.Text = openFileDialog1.FileName;
                imgbox.ImageLocation = openFileDialog1.FileName;
                //Read Image File into Image object.
                Image img = Image.FromFile(imgbox.ImageLocation);
                //ImageConverter Class convert Image object to Byte array.
                byte[] bytes = (byte[])(new ImageConverter()).ConvertTo(img, typeof(byte[]));
            }
        }

        private void login_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!char.IsDigit(e.KeyChar) && e.KeyChar != 08 && e.KeyChar != (char)Keys.Delete)
            {
               e.Handled = true;
               MessageBox.Show("O campo LOGIN só aceita números.", "Ficha de Anamnese - ERRO", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
    }
}
  • 1

    Programming without studying basic language? It’s too difficult a path.

  • I already decided deleting and redoing everything again, I don’t know if here you have this to close topic, but if you have, you can already close

1 answer

1

Henry, this is not a mistake. The exception is purposeful precisely to indicate that your program is not complete.

internal void Insert(int p, string p_2, string p_3, int p_4, string p_5, System.Drawing.Image image, string p_6)
{
    throw new System.NotImplementedException();
}

This is a method that seems a lot to have been generated automatically and you need to implement its logic. Or it may be a feature not implemented in any library you are using. (More likely to be the first option)

  • but in the case, as I said there, I don’t know how to handle C# (or any other language), I’ll do it according to youtube and other tutorials, know tell me if there’s a way I can find out in a simple way what’s happening?

  • @Henriquesp Maybe you didn’t get to this point of the tutorial that you are following or ended up skipping some stage. Edit your question by adding the link to your reference material.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.