protected void Button1_Click(object sender, EventArgs e) { using (var db = new AGRODataContext(Server.MapPath("\\"))) { var mPrice = double.TryParse(TextBox2.Text, out double _mPrice) ? _mPrice : (double?)null; var pCulture = int.TryParse(CultureDropDown.SelectedValue, out int _pCulture) ? _pCulture : (int?)null; var pAnimals = int.TryParse(AnimalsDropDown.SelectedValue, out int _pAnimals) ? _pAnimals : (int?)null; var place = new Places { Pname = TextBox1.Text.Trim(), MPrice = mPrice, PCulture = pCulture, PAnimals = pAnimals }; db.Places.InsertOnSubmit(place); try { db.SubmitChanges(); BindGrid(); } catch (Exception exception) { Debug.WriteLine($"Somethig wrong: {exception.Message}"); } } }
private void detach_Places(Places entity) { this.SendPropertyChanging(); entity.Cultures = null; }
private void attach_Places(Places entity) { this.SendPropertyChanging(); entity.Cultures = this; }
partial void DeletePlaces(Places instance);
partial void UpdatePlaces(Places instance);
partial void InsertPlaces(Places instance);