public bool AddImaging(Imaging imaging) { try { entities.Imagings.Add(imaging); entities.SaveChanges(); return true; } catch (Exception x) { throw x; } }
private void btnAddImaging_Click(object sender, EventArgs e) { string name = txtImagingName.Text.Trim(); if (name == "") { MessageBox.Show("Enter imaging"); return; } else { Imaging imaging = new Imaging() { ImagingName = name, CreatedOn = DateTime.Now }; bool result = new MasterData().AddImaging(imaging); if (result) { txtImagingName.Text = ""; MessageBox.Show("Imaging added successfully"); } else { MessageBox.Show("Cannot add imaging : contact Admin"); } } }