protected void Page_Load(object sender, EventArgs e) { PetControllers pet = new PetControllers(); gvPets.DataSource = pet.Listar(); gvPets.DataBind(); }
protected void btnExcluir_Click(object sender, EventArgs e) { PetControllers ctrl = new PetControllers(); Pet pet = new Pet(); pet.Id = Convert.ToInt32(Session["ID"].ToString()); pet.CategoriaId = Convert.ToInt32(txtCodigo.Text); pet.Nome = txtNome.Text; pet.Raca = txtRaca.Text; pet.Sexo = rdbSexo.SelectedValue; ctrl.Excluir(pet); }
protected void btnSalvar_Click(object sender, EventArgs e) { Session["Codigo"] = txtCodigo.Text; Session["Nome"] = txtNome.Text; Session["Raca"] = txtRaca.Text; Session["Sexo"] = rdbSexo.SelectedValue; PetControllers ctrl = new PetControllers(); Pet pet = new Pet(); pet.CategoriaId = Convert.ToInt32(Session["Codigo"].ToString()); pet.Nome = Session["Nome"].ToString(); pet.Raca = Session["Raca"].ToString(); pet.Sexo = Session["Sexo"].ToString(); ctrl.Adicionar(pet); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { PetControllers ctrl = new PetControllers(); Pet pet = new Pet(); pet.Id = Convert.ToInt32(Session["ID"].ToString()); pet = ctrl.LocalizarPorID(pet.Id); txtCodigo.Text = Convert.ToString(pet.CategoriaId); txtNome.Text = pet.Nome; txtRaca.Text = pet.Raca; rdbSexo.SelectedValue = pet.Sexo; Session["Codigo"] = txtCodigo.Text; Session["Nome"] = txtNome.Text; Session["Raca"] = txtRaca.Text; Session["Sexo"] = rdbSexo.SelectedValue; } }