void Save() { dataEntities db = new dataEntities(); not noe = new not(); noe.note = this.txtnote.Text; db.nots.Add(noe); db.SaveChanges(); this.Close(); MessageBox.Show("successfully!"); }
void delete() { if (listview.SelectedRows.Count == 1) { var row = listview.SelectedRows[0]; string cell = (string)row.Cells["note"].Value; dataEntities db = new dataEntities(); not noe = db.nots.Single(st => st.note == cell); db.nots.Remove(noe); db.SaveChanges(); this.load(); } }
void listview_DoubleClick(object sender, EventArgs e) { if (listview.SelectedRows.Count == 1) { dataEntities db = new dataEntities(); not noe = new not(); var row = listview.SelectedRows[0]; string cell = (string)row.Cells["note"].Value; Form3 a = new Form3(cell); a.ShowDialog(); if(noe.note!=cell) { delete(); } this.load(); } }
public void load() { dataEntities db = new dataEntities(); this.listview.DataSource = db.nots.ToList(); }
public Form3(string note) { InitializeComponent(); ac = new dataEntities(); noe = ac.nots.Single(st=>st.note==note); }