-1
Is my registration logic correct? Because I am not able to save the fields in the Database, follows below the button code:
private void cmdSalvarGuiche_Click_1(object sender, EventArgs e)
    {
        if (MessageBox.Show(this, "Deseja realmente Salvar o item selecionado", "Atenção", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes)
        {
            if (lstTipoSenha_id.SelectedIndex >= 0)
            {
                string guiche = "";
                string computador = "";
                int tipoSenha_id = 0;
                int ordem = 0;
                bool podeAtenderOutros = true;
                string filaDoGuiche = "";
                string funcionario = "";
                try
                {
                    if ((lstTipoSenha_id.SelectedIndex >= 0) && (lstTipoSenha_id.Text.Trim().Length > 0))
                        tipoSenha_id = Convert.ToInt32(oAtende.dtGuiches.Rows[lstTipoSenha_id.SelectedIndex]["id"]);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Erro : " + ex.Message);
                }
                if (tipoSenha_id == 0)
                {
                    MessageBox.Show(this, "Informar o tipo da senha é brigatório", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    lstTipoSenha_id.Focus();
                    return;
                }
                if (guiche == "")
                {
                    MessageBox.Show(this, "Informar a fila do Guiche é brigatório", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    this.ActiveControl = txtGuiche;
                    return;
                }
                if (ordem == 0)
                {
                    MessageBox.Show(this, "Informar a ordem é brigatório", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    this.ActiveControl = txtOrdem;
                    return;
                }
                if (funcionario == "")
                {
                    MessageBox.Show(this, "Informar o nome completo é brigatório", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    this.ActiveControl = txtFuncionario;
                    return;
                }
                if (podeAtenderOutros == false)
                {
                    MessageBox.Show(this, "Informar a opção de atender outros é brigatório", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    this.ActiveControl = cbPodeAtenderOutros;
                    return;
                }
                try
                {
                    if ((lstFilaDoGuiche.SelectedIndex >= 0) && (lstFilaDoGuiche.Text.Trim().Length > 0))
                        tipoSenha_id = Convert.ToInt32(lstTipoSenha_id.SelectedValue);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Erro ao cadastrar a fila do guiche!!! Por favor verifique o campo: " + ex.Message);
                }
                if (filaDoGuiche == "")
                {
                    MessageBox.Show(this, "Informar a fila do Guiche é brigatório", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    lstFilaDoGuiche.Focus();
                    return;
                }
                if (computador == "")
                {
                    MessageBox.Show(this, "Informar o computador é brigatório", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    this.ActiveControl = txtComputador;
                    return;
                }
                if (id > 0)
                {
                    if (MessageBox.Show(this, "Deseja alterar a senha: " + Environment.NewLine + " " + guiche + " " + computador + " " + " " + tipoSenha_id + " " + Ordem + " " + podeAtenderOutros + " " + filaDoguiche + " " + funcionario + "" + Environment.NewLine +
                        "para: " +
                        Environment.NewLine +
                        "    " + lstTipoSenha_id.Text + " " + lstFilaDoGuiche.Text + " " + txtOrdem.Text + "?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
                    {
                        return;
                    }
                }
                //chama o método salvarGuiche passando os parametros correspondentes do botão cmdSalvarGuiche
                if (oAtende.salvarGuiche(id, guiche, computador, tipoSenha_id,
                             ordem, podeAtenderOutros, filaDoGuiche, funcionario) == true)
                {
                    carregargrid();
                    cmdNova_Click(null, null);
                    lblMensagem.Text = "Salvo com sucesso";
                }
            }
        }
    }
This is my code for the save method Guide which is in the class clsAtendimento.Cs:
        public bool salvarGuiche(int id, string guiche, string computador, int tipoSenha_id,
                                 int ordem, bool podeAtenderOutros, string filaDoGuiche, string funcionario)
        {
            try
            {
                if (id > 0)
                    oDB.SqlComando = " UPDATE tblAtendimentoGuiches SET (guiche, computador, tipoSenha_id, ordem, podeAtenderOutros, filaDoGuiche, funcionario) VALUES ( " +
                                ", '" + guiche + "', '"+computador+"', '" + tipoSenha_id + "', '" +ordem +"', '" +Convert.ToInt32(podeAtenderOutros) + "', '" +filaDoGuiche +
                                "', '" + funcionario+ "')";
                else
                    oDB.SqlComando = " INSERT INTO tblAtendimentoSenhasProtocolos ( guiche, computador, tipoSenha_id, ordem, podeAtenderOutros, filaDoGuiche, funcionario) VALUES ( " +
                                ", '" + guiche + "', '" + computador + "', '" + tipoSenha_id + "','" + ordem + "', '" + Convert.ToInt32(podeAtenderOutros) + "', '" + filaDoGuiche +
                                "','" + funcionario + "')";
                return oDB.ExecutarComando();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro : " + ex.Message);
                return false;
            }
        }
						
The Code generates some error?
– Leo Longhi
Welcome to [en.so]. I realized that you are creating multiple questions for the same problem, when it won’t actually help you get an answer faster, instead read the guide [Ask] and do a [tour]to learn a little more about the operation of the site so increase your chances of getting a good response.
– Jéf Bueno
Possible duplicate of Problem writing form data
– Jéf Bueno
My intention was not to flood, but rather I updated my code, and also did according to Stack’s standards
– Gabriel Correia