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