I'm developing an ASP.NET application, which aims to register events and add clients to these registered events, forming a list of clients for each event.
My question is this:
In the Events table there are three types of input (integer type - because it saves the amount of input available for such an event), which are Courtesy, Bonus and Vip. So far so good. When I'm adding a new client for a particular event, I need to select the type of entry for it on a radio button. Whenever I add a client, I need the amount of the Event input type to decrease 1.
What I'm not getting is retrieving the value of the input type selected on the radiobutton to do the manipulation of the data.
NOTE: In the form to include client I select in a dropdownlist the desired event. I do not know if they need this information or if I can retrieve the values for each type of entry.
It seems to be simple, but as I'm at the beginning, I caught up at this point.
protected void btnIncluir_Click(object sender, EventArgs e)
{
var db = new TheOneWebEntities();
var cliente = new Cliente();
cliente.Nome = tbNome.Text;
cliente.Cpf = tbCpf.Text;
cliente.Email = tbEmail.Text;
cliente.Telefone = tbTelefone.Text;
cliente.EventoId = Convert.ToInt32(ddlEvento.SelectedValue);
int totalEntrada;
if (rbCortesia.Checked)
{
if (evento.Cortesia <= 0)
{
Util.Alertar("Cortesia esgotada");
}
else
{
totalEntrada = cliente.Evento.Cortesia - 1;
cliente.Evento.Cortesia = totalEntrada;
}
}
else
{
if (rbBonus.Checked)
{
if (evento.Bonus <= 0)
{
Util.Alertar("Bônus esgotado");
}
else
{
totalEntrada = cliente.Evento.Bonus - 1;
cliente.Evento.Bonus = totalEntrada;
}
}
else
{
if (rbVip.Checked)
{
if (evento.Vip <= 0)
{
Util.Alertar("VIP esgotado");
}
else
{
totalEntrada = cliente.Evento.Vip - 1;
cliente.Evento.Vip = totalEntrada;
}
}
}
}
var dataCadastro = DateTime.Now.ToString();
cliente.DataCadastro = Convert.ToDateTime(dataCadastro);
cliente.UsuarioId = WebMatrix.WebData.WebSecurity.CurrentUserId;
db.Clientes.Add(cliente);
db.SaveChanges();
Util.Alertar("Cliente adicionado com sucesso!");
Response.Redirect("~/User/MeusClientes.aspx");
}