protected void dodaj_Click(object sender, EventArgs e) { if (izborVlasnika.Items.Count > 0) { if (name.Text == "" || age.Text == "") { error.Text = "Insert values!"; return; } var a = from pe in db.pets select pe.pet_id; pet p = new pet(); p.name = name.Text; p.age = int.Parse(age.Text); p.description = desc.Text; p.owner_id = int.Parse(izborVlasnika.SelectedValue); p.type_id = 2; p.pet_id = a.Max() + 1; db.pets.InsertOnSubmit(p); db.SubmitChanges(); } else { error.Text = "Insert a owner first"; Response.Redirect("Owner.aspx"); } Response.Redirect(Request.RawUrl); }
protected void usvoji_Click(object sender, EventArgs e) { int idO = -1; int idP = -1; if (usvajanjeVlasnik.Items.Count > 0 && usvajanjeLjubimac.Items.Count > 0) { idO = int.Parse(usvajanjeVlasnik.SelectedValue); idP = int.Parse(usvajanjeLjubimac.SelectedValue); var pets = from p in db.pets where p.pet_id == idP select p; pet pet = pets.FirstOrDefault(); pet.owner_id = idO; db.SubmitChanges(); } Response.Redirect(Request.RawUrl); }
private void detach_pets(pet entity) { this.SendPropertyChanging(); entity.pet_type = null; }
private void attach_pets(pet entity) { this.SendPropertyChanging(); entity.pet_type = this; }
partial void Deletepet(pet instance);
partial void Updatepet(pet instance);
partial void Insertpet(pet instance);