How to save RadioButton in Oracle

0

How do I save only the Dialed RadioButton? Images below what I did. It is saving a value even though I have marked the other one. In my database do I have to create a single field to save any of the information?

Note: I'm using Visual Studio (C #) and SQL Developer (Oracle)

BankCode:

createtableMesa(codnumber(5)notnull,nomeVARCHAR2(20)notnull,ativaVARCHAR2(20)notnull,inativaVARCHAR2(20)notnull,Ativonumber(03)notnull,constraintPK_cod_MesaPRIMARYKEY(cod));

C#:

publicvoidGravar(){stringstrQuery;strQuery="INSERT INTO Mesa";
    strQuery += (" VALUES(");
    strQuery += ("seq_mesa.NEXTVAL,");
    strQuery += ("'" + _nome + "',");
    strQuery += ("'" + _ativa + "',"); //campo onde irei salvar o ativa ou inativa
    strQuery += ("'1'");
    strQuery += (")");

    clnBancoDados ObjClnBancoDados = new clnBancoDados();
    ObjClnBancoDados.ExecutaComando(strQuery);
}

I declared them on top like this:

public string ativa
{
    get { return _ativa; }
    set { _ativa = value; }
}

public string inativa
{
    get { return _inativa; }
    set { _inativa = value; }
}
    
asked by anonymous 27.06.2016 / 23:43

1 answer

0

class: C #

class clnCastastro {

private int _cod;

    public int Cod
    {
        get { return _cod; }
        set { _cod = value; }
    }

    private string _nome;

    public string Nome
    {
        get { return _nome; }
        set { _nome = value; }
    }

    private int _ativo;

    public int Ativo // receberá 0 para inativo ou 1 para ativo
    {
        get { return _ativo; }
        set { _ativo = value; }
    }
}

public DataSet FillField () // for comboBox         {             string strQuery;             strQuery="Select cod_active From T_Active";             cldDataBankDataData = new cldDataBank ();             return objBankData.RetornaDataSet (strQuery);

    } 

public OracleDataReader FillInComReader (string strNome) // to radioButton         {             string strQuery;             strQuery="Select t_a.description From T_Ativo t_a inner join table t_m on t_a.cod_ativo = t_m.Active " where t_m.name = 'strName';             cldDataBankDataData = new cldDataBank ();             return objDataReader (strQuery); }

public void Save () {     string strQuery;     strQuery="INSERT INTO Table";     strQuery + = ("VALUES (");     strQuery + = ("seq_table.NEXTVAL,");     strQuery + = ("'" + _name + "',");     strQuery + = ("'" + _active + "',"); // field where I will save the active or inactive     strQuery + = (")");

clnBancoDados ObjClnBancoDados = new clnBancoDados();
ObjClnBancoDados.ExecutaComando(strQuery);

}

C #

private void btnSave_Click (object sender, EventArgs e)         {             clnCadastro register = new clnCadastro ();             register.name = txtName;

        if (radioButtonAtivo.Checked == true)
        {
            cadastro.ativo = 1;
        }

        else if (radioButtonInativo.Checked == true) 
        {
            cadastro.ativo = 0;
        }

public void FillField () // to use in modify, with comboBox         {             clnCadastro register = new clnCadastro ();             comboBoxActive.DataSource = register.FillActive (). Tables [0];             comboBoxActive.ValueMember="Active_Code";             comboBoxActive.DisplayMember="Description";             comboBoxActive.SelectedIndex = -1; // to remain blank before // to select

// or modify with radioButton  clnCadastro register = new clnCadastro (); OracleDataReader drDados; string name = register.name; drDados = cadastro.PreencherAtivoComReader (name);    if (drDados.Read ())             {                 if (drDados ["description"]. toString () == "ACTIVE")                 {                     radioButtonAtivo.Checked = true;                 }

            else if (drDados["descricao"].toString() == "INATIVO")
            {
                radioButtonInativo.Checked = true;
            }




    }

Bank:

create table Mesa (   cod number (5),   name VARCHAR2 (20) not null,   Active number (1) not null,   constraint PK_cod_Mesa PRIMARY KEY (cod) contraint fk_cod_ativo foreign key (Active) references T_Active (cod_Active) );

create table T_Active ( cod_Active number (1), Description char (7),

constraint PK_cod_Active PRIMARY KEY (Active) );

insert into T_active values (1, 'ACTIVE'); insert into T_active values (0, 'INACTIVE');

then you will save 0 for inactive and 1 for active in the bank and in the modify it will return the texts to you instead of the numbers

active inactive

I hope to have helped

    
16.04.2017 / 17:16