public int AddSurgery(Surgery model) { try { model.CreatedOn = DateTime.Now; entities.Surgeries.Add(model); return entities.SaveChanges(); } catch (Exception x) { throw x; } }
public bool UpdateSurgery(Surgery model) { try { Surgery surgery = entities.Surgeries.Where(x => x.SurgeryId == model.SurgeryId).SingleOrDefault(); if (surgery != null) { model.CreatedOn = surgery.CreatedOn; entities.Entry(surgery).CurrentValues.SetValues(model); entities.SaveChanges(); return true; } else { return false; } } catch (Exception x) { throw x; } }
private Surgery GetSurgeryModel() { Surgery surgery = new Surgery(); RadListDataItem item = listSurgery.SelectedItem; surgery.SurgeryId = Convert.ToInt32(item.Value.ToString().Trim()); surgery.PatientId = _patientid; surgery.SurgeryDate = (DateTime)(datetimeSurgery.DateTimePickerElement.Value); surgery.OperationId = Convert.ToInt32(ddlOpertaion.SelectedValue.ToString().Trim()); surgery.HospitalId = Convert.ToInt32(ddlHospital.SelectedValue.ToString().Trim()); surgery.Notes = txtNotes.Text.Trim(); surgery.IPNumber = txtIPNumber.Text.Trim(); surgery.PreOpDiagnosis = txtPreOpDiagnosis.Text.Trim(); surgery.PostOpDiagnosis = txtPostOpDiagnosis.Text.Trim(); surgery.ReferredBy = txtReferredBy.Text.Trim(); surgery.SurgeonId = Convert.ToInt32(ddlSurgeon.SelectedValue.ToString().Trim()); surgery.AssistantSurgeonId = Convert.ToInt32(ddlAsstSurgeon.SelectedValue.ToString().Trim()); surgery.AnaesthetistId = Convert.ToInt32(ddlAnaesthetist.SelectedValue.ToString().Trim()); surgery.ScrubNurseId = Convert.ToInt32(ddlScrubNurse.SelectedValue.ToString().Trim()); return surgery; }