示例#1
0
        private void ViewOrEdit(object sender)
        {
            Button btn = (Button)sender;

            if (btn is null && !string.IsNullOrEmpty(btn.Name))
            {
                return;
            }
            if (DataGridListOfDoctors.SelectedIndex == -1)
            {
                MessageBox.Show("Select the row corresponding to the doctor", "No row selected");
                return;
            }
            //Open a new window with existing doctor details
            ClassDoctor             doc = (ClassDoctor)DataGridListOfDoctors.SelectedItem;
            WindowDoctorDataEdition windowDoctorDataEdition = new WindowDoctorDataEdition(doc);

            if (btn.Name.Equals(ButtonViewDetails.Name))
            {
                windowDoctorDataEdition.ReadOnly = true;
            }
            else if (btn.Name.Equals(ButtonEdit.Name))
            {
                windowDoctorDataEdition.ReadOnly = false;
            }
            windowDoctorDataEdition.AddNewDoctor = false;
            windowDoctorDataEdition.ShowDialog();
            if ((bool)windowDoctorDataEdition.DialogResult)
            {
                UpdateDoctor(doc, windowDoctorDataEdition.AddNewDoctor);
                LoadDataToDataGrid();
            }
            return;
        }
示例#2
0
        private void ButtonAdd_Click(object sender, RoutedEventArgs e)
        {
            //Open a new window adding a new doctor
            ClassDoctor             doc = new ClassDoctor();
            WindowDoctorDataEdition windowDoctorDataEdition = new WindowDoctorDataEdition(doc);

            windowDoctorDataEdition.ReadOnly     = false;
            windowDoctorDataEdition.AddNewDoctor = true;
            bool update = (bool)windowDoctorDataEdition.ShowDialog();

            if (update)
            {
                UpdateDoctor(doc, windowDoctorDataEdition.AddNewDoctor);
                LoadDataToDataGrid();
            }
        }