public ActionResult DeleteOne(int doctorId)
        {
            Doctor thisDoctor = Doctor.Find(doctorId);

            thisDoctor.Delete();
            return(RedirectToAction("index"));
        }
Example #2
0
        public ActionResult Destroy(int id)
        {
            Doctor deleteDoctor = Doctor.Find(id);

            deleteDoctor.Delete();
            return(RedirectToAction("Index"));
        }
        private void BtnDelete_Click(object sender, EventArgs e)
        {
            if (TxtDoctorId.Text != "")
            {
                // Get the data from textboxes
                d.DoctorId = int.Parse(TxtDoctorId.Text);
            }

            bool success = d.Delete(d);

            if (success)
            {
                //Deleted successfully
                MessageBox.Show("Doctor has been successfully deleted.");
                //Load Data on Data Gridview
                DataTable dt = d.Select();
                DgvDoctorList.DataSource = dt;
                Clear();
            }
            else
            {
                //Failed to Delete
                MessageBox.Show("Failed to Delete Doctor. Try Again.");
            }
        }
        public ActionResult Delete(int doctorId)

        {
            Doctor foundDoctor = Doctor.Find(doctorId);

            foundDoctor.Delete();
            return(RedirectToAction("Index"));
        }
Example #5
0
        public string DeleteDoctor(string callType, string xmlMessage)
        {
            string result = "", id = "";
            string logID = Guid.NewGuid().ToString();

            try
            {
                FileLogger.WriteLog(logID + "|Start:" + xmlMessage, 1, "", callType);

                if (Helper.CheckAuthCode(callType, xmlMessage))
                {
                    XmlDocument doc = new XmlDocument();
                    doc.LoadXml(xmlMessage);
                    XmlNode vNode = doc.SelectSingleNode(callType + "/ID");
                    if (vNode == null || vNode.InnerText.Trim().Length == 0)
                    {
                        throw new Exception("ID不能为空");
                    }

                    id = vNode.InnerText.Trim();
                    Doctor h = new Doctor();
                    if (h.Delete(xmlMessage) != "-1")
                    {
                        result = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                                 "<" + callType + ">" +
                                 "<Result>True</Result>" +
                                 "<ID>" + id + "</ID>" +
                                 "<Description></Description></" + callType + ">";
                    }
                    else
                    {
                        result = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                                 "<" + callType + ">" +
                                 "<Result>False</Result>" +
                                 "<Description></Description></" + callType + ">";
                    }
                }
            }
            catch (Exception err)
            {
                result = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                         "<" + callType + ">" +
                         "<Result>False</Result>" +
                         "<Description>" + err.Message + "</Description></" + callType + ">";
            }
            FileLogger.WriteLog(logID + "|End:" + result, 1, "", callType);
            return(result);
        }
Example #6
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            Doctor doctor = (Doctor)dataGridView1.CurrentRow.Tag;

            if (e.ColumnIndex == 6)
            {
                Post post = doctor.GetPost();
                new AddEditDoctor(doctor, post).ShowDialog();
            }
            if (e.ColumnIndex == 7)
            {
                if (MessageBox.Show("Удалить сотрудника " + doctor.Surname + " " + doctor.Name + "?", "Подтвердить", MessageBoxButtons.YesNoCancel) == DialogResult.Yes)
                {
                    doctor.Delete();
                    ReloadData();
                }
            }
        }
Example #7
0
        public void Delete_DeletesDoctorAssociationsFromDatabase_DoctorList()
        {
            //Arrange
            DateTime patientDueDate = new DateTime(1999, 12, 24);
            Patient  testPatient    = new Patient("Mow the lawn", patientDueDate);

            testPatient.Save();
            string testName   = "Home stuff";
            Doctor testDoctor = new Doctor(testName);

            testDoctor.Save();

            //Act
            testDoctor.AddPatient(testPatient);
            testDoctor.Delete();
            List <Doctor> resultPatientCategories = testPatient.GetCategories();
            List <Doctor> testPatientCategories   = new List <Doctor> {
            };

            //Assert
            CollectionAssert.AreEqual(testPatientCategories, resultPatientCategories);
        }
Example #8
0
        public void Delete_DeletesDoctorAssociationsFromDatabase_DoctorList()
        {
            //Arrange
            Patient testPatient = new Patient("Jim", "04/01/1987");

            testPatient.Save();

            string testName   = "Tony";
            Doctor testDoctor = new Doctor(testName);

            testDoctor.Save();

            //Act
            testDoctor.AddPatient(testPatient);
            testDoctor.Delete();

            List <Doctor> resultPatientDoctors = testPatient.GetDoctors();
            List <Doctor> testPatientDoctors   = new List <Doctor> {
            };

            //Assert
            CollectionAssert.AreEqual(testPatientDoctors, resultPatientDoctors);
        }
        static void Main(string[] args)
        {
            Console.WriteLine("press 1 To Add Doctor");
            Console.WriteLine("press 2 To Update Doctor");
            Console.WriteLine("press 3 To Delete Doctor");
            Console.WriteLine("press 4 To see report of patient ");
            Console.WriteLine("press 5 To Get Report of medicine list for a particular patient");
            Console.WriteLine("press 6 Display summary report of Doctor and patient");
            int ch = Convert.ToInt32(Console.ReadLine());

            switch (ch)
            {
            case 1:
            {
                //Insert a Doctor
                Doctor d1 = new Doctor();
                d1.Add();
                break;
            }

            case 2:
            {
                //update doctor
                Doctor d1 = new Doctor();
                d1.Update();
                break;
            }

            case 3:
            {
                //delete a Doctor

                Doctor d1 = new Doctor();
                d1.Delete();
                break;
            }

            case 4:
            {
                //Find a report of patient assigned to a particular doctor
                Console.WriteLine("enter DopctorID to see patients name under that Doc");
                int Docid = Convert.ToInt32(Console.ReadLine());
                using (var hosp = new HospitalContext())
                {
                    var report = hosp.Reports.Where(d => d.DoctorId == Docid);
                    foreach (var item in report)
                    {
                        var hops = new HospitalContext();
                        var pat  = hops.Patients.Single(id => id.PatientId == item.PatientId);
                        Console.WriteLine($"Patient info under Doctor id:{Docid}\n");
                        Console.WriteLine($"{pat.PatientId} {pat.PatientName} ");
                    }
                }
                break;
            }

            case 5:
            {
                //Find a report of medicine list for a particular patient
                Console.WriteLine("Enter patient ID to find his medicines list");
                int Patid = Convert.ToInt32(Console.ReadLine());
                using (var hosp = new HospitalContext())
                {
                    var pres  = hosp.Prescriptions.Where(d => d.PatientId == Patid);
                    var drugs = pres.Select(d => d.DrugId);
                    foreach (var item in drugs)
                    {
                        var newhost = new HospitalContext();
                        var med     = newhost.Drugs.Where(d => d.DrugId == item);
                        foreach (var s in med)
                        {
                            Console.WriteLine($"Drug ID:{s.DrugId} Drug-Name {s.Name}");
                        }
                    }
                }
                break;
            }

            case 6:
            {
                //Display summary report of Doctor and patient(use Include method)

                using (var hosp = new HospitalContext())
                {
                    var report = hosp.Reports.Include(s => s.Doctor).Include(p => p.Patient)
                                 .ToList();
                    foreach (var item in report)
                    {
                        Console.WriteLine($"{item.DoctorId}:{item.Doctor.DoctorName} IS treating {item.Patient.PatientName} ");
                    }
                }
                break;
            }

            default: break;
            }
        }