protected void btnAddArtikel_Click(object sender, EventArgs e) { if (GridView3.SelectedValue != null && ddlSelecteerKlas.SelectedValue != null) { //checken of die boekenlijst da item al heeft int id = int.Parse(GridView3.SelectedValue.ToString()); IEnumerable<SchoolartikelBoekenlijst> lijst = dc.SchoolartikelBoekenlijsts.Where(x => x.klas == ddlSelecteerKlas.SelectedValue && x.id_schoolartikel == id); if (lijst.Count() == 0) { SchoolartikelBoekenlijst l = new SchoolartikelBoekenlijst(); l.klas = ddlSelecteerKlas.SelectedValue; l.id_schoolartikel = id; Schoolartikel a = dc.Schoolartikels.Where(x => x.id == id).First(); l.prijs = a.prijs; try { dc.SchoolartikelBoekenlijsts.InsertOnSubmit(l); dc.SubmitChanges(); GridView4.DataBind(); } catch (LinqDataSourceValidationException aze) { lblError.Text = "Fout opgetreden bij toevoegen artikel aan lijst "; } } } }
partial void DeleteSchoolartikelBoekenlijst(SchoolartikelBoekenlijst instance);
partial void UpdateSchoolartikelBoekenlijst(SchoolartikelBoekenlijst instance);
partial void InsertSchoolartikelBoekenlijst(SchoolartikelBoekenlijst instance);
private void detach_SchoolartikelBoekenlijsts(SchoolartikelBoekenlijst entity) { this.SendPropertyChanging(); entity.Schoolartikel = null; }
private void attach_SchoolartikelBoekenlijsts(SchoolartikelBoekenlijst entity) { this.SendPropertyChanging(); entity.Boekenlijst = this; }