public void Edit(entity.ROOM r) { conn = new SqlConnection(connstring); conn.Open(); q = new SqlCommand("update room set type='" + r.TYPE + "', price=" + r.PRICE + ", category='" + r.CATEGORY + "' where name='" + r.NAME + "'", conn); try { q.ExecuteNonQuery(); MessageBox.Show("Successfully Saved"); } catch (Exception) { MessageBox.Show("Not Saved"); } }
public bool Add(entity.ROOM r) { try { HOTELMANAGEMENTEntities hm = new HOTELMANAGEMENTEntities(); hm.ROOMs.Add(r); hm.SaveChanges(); return(true); } catch (Exception ex) { ex.ToString(); return(false); } }