Example #1
0
 private void saveButton_Click(object sender, EventArgs e)
 {
     Doctor doctor=new Doctor();
     doctor.Name = nameTextBox.Text;
     doctor.DepartmentId = int.Parse(departmentComboBox.SelectedValue.ToString());
     doctor.Id = idforSearch;
     DoctorManager doctorManager=new DoctorManager();
     if (saveButton.Text == "Update")
     {
         bool status = doctorManager.Update(doctor);
         if (status)
         {
             Close();
             MessageBox.Show("Updated Successfully");
         }
         else
         {
             MessageBox.Show("Not updated");
         }
     }
     else if (doctorManager.Save(doctor))
     {
         Close();
         MessageBox.Show("Doctor Successfully Added");
     }
 }
 private void GetDoctorListWithPatients()
 {
     DoctorManager doctorManager=new DoctorManager();
     List<DoctorDepartment> doctorDepartmentList = doctorManager.GetDoctorListWithDepartments();
     foreach (var index in doctorDepartmentList)
     {
         ListViewItem listViewItem=new ListViewItem(index.DoctorName);
         listViewItem.SubItems.Add(index.DepartmentName);
         listViewItem.Tag = index.Id;
         doctorsListView.Items.Add(listViewItem);
     }
 }
 private void searchButton_Click(object sender, EventArgs e)
 {
     doctorsListView.Items.Clear();
     string search = doctorsNameTextBox.Text;
     DoctorManager doctorManager = new DoctorManager();
     List<DoctorDepartment> doctorDepartmentList = doctorManager.SearchDoctorByNameWithDepartment(search);
     foreach (var index in doctorDepartmentList)
     {
         ListViewItem listViewItem = new ListViewItem(index.DoctorName);
         listViewItem.SubItems.Add(index.DepartmentName);
         listViewItem.Tag = index.Id;
         doctorsListView.Items.Add(listViewItem);
     }
 }
 private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (doctorsListView.SelectedItems.Count > 0)
     {
         int doctorId = int.Parse(doctorsListView.SelectedItems[0].Tag.ToString());
         DoctorManager doctorManager = new DoctorManager();
         if (doctorManager.DeleteDoctorById(doctorId))
         {
             Close();
             MessageBox.Show("Doctor Deleted Successfully");
         }
         else
         {
             MessageBox.Show("Doctor having patients cannot be deleted");
         }
     }
     else
     {
         MessageBox.Show("You must Select a row");
     }
 }
Example #5
0
        public DoctorEntryForm(string mode,int doctorId)
        {
            InitializeComponent();
            if (mode == "Update")
            {
                //MessageBox.Show(doctorId.ToString());
                Doctor aDoctor=new Doctor();
                BLL.DoctorManager manager=new DoctorManager();
                aDoctor = manager.GetDoctorById(doctorId);

                idforSearch = aDoctor.Id;

                nameTextBox.Text = aDoctor.Name;
                GetDepartmentsInComboBox();
                departmentComboBox.SelectedValue=aDoctor.DepartmentId;
                saveButton.Text = "Update";

            }
            else
            {
                GetDepartmentsInComboBox();
            }
        }
Example #6
0
 private void GetDoctorsListInComboBox()
 {
     DoctorManager doctorManager=new DoctorManager();
     List<Doctor> doctorList=new List<Doctor>();
     doctorList=doctorManager.GetDoctorList();
     doctorComboBox.DataSource = null;
     doctorComboBox.DataSource = doctorList;
     doctorComboBox.ValueMember = "Id";
     doctorComboBox.DisplayMember = "Name";
 }