Database1Entities db;
tbl foundTbl;
public Form1()
{
InitializeComponent();
db = new Database1Entities();
}
private void getBtn_Click(object sender, EventArgs e)
{
foundTbl = db.tbl.SingleOrDefault(item => item.name == textBox1.Text);
if (foundTbl != null)
{
textBox2.Text = foundTbl.address;
textBox3.Text = foundTbl.email;
}
}
private void UpdateBtn_Click(object sender, EventArgs e)
{
if (foundTbl != null && MessageBox.Show("Are you sure?")== System.Windows.Forms.DialogResult.OK)
{
foundTbl.address = textBox2.Text;
foundTbl.email = textBox3.Text;
db.SaveChanges();
}
}
private void deleteBtn_Click(object sender, EventArgs e)
{
if (foundTbl != null && MessageBox.Show("Are you sure?") == System.Windows.Forms.DialogResult.OK)
{
db.DeleteObject(foundTbl);
db.SaveChanges();
}
}