class:
c#
class clnCadastro {
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 Filler() //for combobox
{
string strQuery;
strQuery = "Select cod_active From T_active";
cldBancoOobjBancoDados = new cldBancoDados();
Return dataset(strQuery);
}
public Oracledatareader Preencherativocomreader(string strNome) //for radiobutton
{
string strQuery;
strQuery = "Select t_a.Description
From t_active t_a Inner Join mesa t_m
on t_a.cod_active = t_m.Active"
Where t_m.name='strNome';
cldBancoOobjBancoDados = new cldBancoDados();
Return datareader(strQuery);
}
public void Save()
{
string strQuery;
strQuery = "INSERT INTO Mesa";
strQuery += (" VALUES(");
strQuery += ("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 btnSalvar_Click(Object Sender, Eventargs and)
{
clnCadastro cadastro = new clnCadastro();
register.name = txtName;
if (radioButtonAtivo.Checked == true)
{
cadastro.ativo = 1;
}
else if (radioButtonInativo.Checked == true)
{
cadastro.ativo = 0;
}
public void Filler() // to use in modify, with combobox
{
clnCartiro cadastro= new clnCadastro ();
comboBoxAtivo.Datasource = registration.Filler(). Tables[0];
comboBoxAtivo.Valuemember = "cod_Ativo";
comboBoxAtivo.Displaymember = "Description";
comboBoxAtivo.Selectedindex = -1; // to go blank before
//to select
//or modify with radiobutton
clnCartiro cadastro= new clnCadastro ();
Oracledatareader drDados;
string name = register.name;
drDados = registration.Filledvocomreader(name);
if (drDados.Read())
{
if (drDados["Description"].toString() == "ACTIVE")
{
radioButtonAtivo.Checked = true;
}
else if (drDados["descricao"].toString() == "INATIVO")
{
radioButtonInativo.Checked = true;
}
}
Bench:
create table table table
(
Cod number(5),
name VARCHAR2(20)not null,
Active number(1)not null,
Constraint Pk_cod_mesa PRIMARY KEY(Cod)
contraint fk_cod_active Foreign key (active) References T_active(cod_Ativo )
);
create table T_active
(
cod_Ativo number (1),
Description char(7),
Constraint Pk_cod_active PRIMARY KEY(Active)
);
Insert into T_ativo values(1,'ASSET');
Insert into T_active values(0,'INACTIVE');
then you save 0 for inactive and 1 for active in the bank
and in modifying it will return the texts to you instead of the numbers
active
inactive
hope I’ve helped
Young man, somewhere you assigns some value to this property (
_ativa
)?– Jéf Bueno
Radionbutton vc inserted as individual objects or is a group - Radiobuttonlist?
– Thiago Lunardi
I got it. VLW.
– enzo