private void update() { DataClasses1DataContext db = new DataClasses1DataContext(); VendorTable dt = new VendorTable(); try { VendorTable q = (from VendorTable in db.VendorTables where VendorTable.Id == Int32.Parse(domainUpDown1.Text) select VendorTable).Single(); if (textBox2.Text != "") { q.Name = textBox2.Text; } if (textBox3.Text != "") { q.Address = textBox3.Text; } if (textBox4.Text != "") { q.Phone = textBox4.Text; } if (textBox5.Text != "") { q.Email = textBox5.Text; } db.SubmitChanges(); MessageBox.Show("Succesfully updated!\n"); clearFields(); } catch { MessageBox.Show("invalid input!\n"); } }
private void add() { DataClasses1DataContext db = new DataClasses1DataContext(); VendorTable dt = new VendorTable(); try { dt.Name = (textBox2.Text); dt.Address = (textBox3.Text); dt.Phone = (textBox4.Text); dt.Email = (textBox5.Text); db.VendorTables.InsertOnSubmit(dt); db.SubmitChanges(); MessageBox.Show("Succesfully added!\n"); clearFields(); } catch { MessageBox.Show("invalid input"); } }