private void btnAddSurgery_Click(object sender, EventArgs e) { bool result = true; try { Surgery surgery = GetSurgeryModel(); if (surgery.SurgeryDate == DateTime.MinValue || surgery.OperationId == 0 || surgery.HospitalId == 0) { MessageBox.Show("Enter all mandatory values"); return; } try { int surgeryid = new SurgeryData().AddSurgery(surgery); if (surgeryid == 0) { result = false; } } catch { result = false; } if (result) { PopulateSurgery(); RefreshControls(); MessageBox.Show("Surgery data added successfully"); return; } else { MessageBox.Show("Error while adding surgery : contact admin"); return; } } catch { MessageBox.Show("Error while adding surgery : contact admin"); return; } }
private void PopulateSurgery() { listSurgery.Items.Clear(); listSurgery.Items.Add(new RadListDataItem() { Value = "0", Text = "New" }); List<Surgery> surgeries = new SurgeryData().GetSurgeriesForPatient(_patientid); if (surgeries != null) { foreach (Surgery s in surgeries) { RadListDataItem item = new RadListDataItem(); item.Value = s.SurgeryId; item.Text = s.SurgeryDate.ToString(); listSurgery.Items.Add(item); } listSurgery.SelectedValue = "0"; btnAddSurgery.Visible = true; btnUpdate.Visible = false; } }
private void LoadControls(int surgeryid) { try{ Surgery surgery = new SurgeryData().GetSurgeriesById(surgeryid); if (surgery != null) { datetimeSurgery.Value = (DateTime)surgery.SurgeryDate; txtIPNumber.Text = surgery.IPNumber; txtNotes.Text = surgery.Notes; txtPreOpDiagnosis.Text = surgery.PreOpDiagnosis; txtPostOpDiagnosis.Text = surgery.PostOpDiagnosis; txtReferredBy.Text = surgery.ReferredBy; PopulateData.SelectDropDownItem(ddlHospital, surgery.HospitalId.ToString()); PopulateData.SelectDropDownItem(ddlOpertaion, surgery.OperationId.ToString()); PopulateData.SelectDropDownItem(ddlSurgeon, surgery.SurgeonId.ToString()); PopulateData.SelectDropDownItem(ddlAsstSurgeon, surgery.AssistantSurgeonId.ToString()); PopulateData.SelectDropDownItem(ddlAnaesthetist, surgery.AnaesthetistId.ToString()); PopulateData.SelectDropDownItem(ddlScrubNurse, surgery.ScrubNurseId.ToString()); } } catch { MessageBox.Show("Error while fetching surgery details : contact admin"); return; } }
private void btnUpdate_Click(object sender, EventArgs e) { try { bool result = true; Surgery surgery = GetSurgeryModel(); if (surgery.SurgeryDate == DateTime.MinValue || surgery.OperationId == 0 || surgery.HospitalId == 0) { MessageBox.Show("Enter all mandatory values"); return; } try { result = new SurgeryData().UpdateSurgery(surgery); } catch { result = false; } if (result) { MessageBox.Show("Surgery data updated successfully"); return; } else { MessageBox.Show("Error while updated surgery : contact admin"); return; } } catch { MessageBox.Show("Error while updated surgery : contact admin"); return; } }