예제 #1
0
        //删除预约信息
        public void DeleteCustomerAppointment(int id)
        {
            //删除预约表
            List <CustomerAppointment> customerAppointment = db.CustomerAppointment.Where(p => p.CustomerAppointmentID == id).ToList();

            if (customerAppointment.Count > 0)
            {
                foreach (var item in customerAppointment)
                {
                    //利用所有的预约id去查有没有体检信息,有则删除体检信息
                    ClientMdicalIformation clientMdicalIformation = db.ClientMdicalIformation.Where(p => p.CustomerAppointmentID == item.CustomerAppointmentID).ToList().FirstOrDefault();
                    if (clientMdicalIformation != null)
                    {
                        //删除客户回访信息
                        List <CustomerReturnVisit> customerReturnVisit = db.CustomerReturnVisit.Where(p => p.ConclusionID == clientMdicalIformation.ConclusionID).ToList();
                        if (customerReturnVisit.Count > 0)
                        {
                            foreach (var item1 in customerReturnVisit)
                            {
                                CustomerReturnVisit customerReturnVisit1 = db.CustomerReturnVisit.Where(p => p.ConclusionID == item1.ConclusionID).ToList().FirstOrDefault();
                                db.CustomerReturnVisit.Remove(customerReturnVisit1);
                                db.SaveChanges();
                            }
                        }

                        //删除客户关怀信息
                        List <CustomerCare> customerCare = db.CustomerCare.Where(p => p.ConclusionID == clientMdicalIformation.ConclusionID).ToList();
                        if (customerCare.Count() > 0)
                        {
                            foreach (var item2 in customerCare)
                            {
                                int          customerCareid = item2.CustomerCareID;
                                CustomerCare customerCare1  = db.CustomerCare.Where(p => p.ConclusionID == item2.ConclusionID).ToList().FirstOrDefault();
                                db.CustomerCare.Remove(customerCare1);
                                db.SaveChanges();
                            }
                        }

                        //删除体检信息之后才能删除内外科
                        db.ClientMdicalIformation.Remove(clientMdicalIformation);
                        db.SaveChanges();
                        //删除外科体检信息
                        int SurgicalExaminationID = clientMdicalIformation.SurgicalExaminationID;
                        SurgicalExamination surgicalExamination = db.SurgicalExamination.Find(SurgicalExaminationID);
                        db.SurgicalExamination.Remove(surgicalExamination);
                        db.SaveChanges();
                        //删除内科体检信息
                        int MedicalExaminationID = clientMdicalIformation.MedicalExaminationID;
                        MedicalExamination medicalExamination = db.MedicalExamination.Find(MedicalExaminationID);
                        db.MedicalExamination.Remove(medicalExamination);
                        db.SaveChanges();

                        //删除预约记录
                        CustomerAppointment customerAppointment1 = db.CustomerAppointment.Find(item.CustomerAppointmentID);
                        db.CustomerAppointment.Remove(customerAppointment1);
                        db.SaveChanges();
                    }
                }
            }
        }
예제 #2
0
        public ActionResult Booking(CustomerAppointment custBooking)
        {
            using (GerGarageDbEntities db = new GerGarageDbEntities())
            {
                CustomersBooking booking = new CustomersBooking();

                JobDetail jobCard = new JobDetail();

                jobCard.BookingId       = custBooking.BookingId;
                booking.BookingDate     = custBooking.BookingDate;
                booking.CustomerName    = custBooking.CustomerName;
                jobCard.CustomerName    = custBooking.CustomerName;
                booking.CustomerEmail   = custBooking.CustomerEmail;
                booking.VehicleMake     = custBooking.VehicleMake;
                jobCard.CarMake         = custBooking.VehicleMake;
                booking.VehicleModel    = custBooking.VehicleModel;
                jobCard.CarModel        = custBooking.VehicleModel;
                booking.VehicleNumber   = custBooking.VehicleNumber;
                jobCard.CarNumber       = custBooking.VehicleNumber;
                booking.VehicleFuelType = custBooking.VehicleFuelType;
                booking.ServiceType     = custBooking.ServiceType;
                jobCard.ServiceType     = custBooking.ServiceType;
                booking.ServiceDate     = custBooking.ServiceDate;
                jobCard.ServiceDate     = custBooking.ServiceDate;
                booking.Remarks         = custBooking.Remarks;
                jobCard.CustomerMessage = custBooking.Remarks;

                db.CustomersBookings.Add(booking);
                db.JobDetails.Add(jobCard);
                db.SaveChanges();
            }

            ViewData["Confirmed"] = "Your Booking was succesfull";
            return(RedirectToAction("Home,Index"));
        }
예제 #3
0
        public static CustomerAppointmentDto ToDto(this CustomerAppointment customerAppointment)
        {
            if (customerAppointment == null)
            {
                return(null);
            }

            return(Mapper.Map <CustomerAppointment, CustomerAppointmentDto>(customerAppointment));
        }
예제 #4
0
 //修改预约保存
 public void EditSaChangsCustomerAppointment(CustomerAppointment customerAppointment)
 {
     Dal.EditSaChangsCustomerAppointment(customerAppointment);
 }
예제 #5
0
        //修改预约的查询
        public CustomerAppointment EditCustomerAppointment(int id)
        {
            CustomerAppointment customerAppointment = Dal.EditCustomerAppointment(id);

            return(customerAppointment);
        }
예제 #6
0
 //新增客户预约信息
 public void AddCustomerAppointment(CustomerAppointment customerAppointment)
 {
     Dal.AddCustomerAppointment(customerAppointment);
 }
예제 #7
0
 //保存预约的修改
 public void EditSaChangsCustomerAppointment(CustomerAppointment customerAppointment)
 {
     db.Entry(customerAppointment).State = System.Data.Entity.EntityState.Modified;
     db.SaveChanges();
 }
예제 #8
0
        //按预约id查询一个预约信息
        public CustomerAppointment EditCustomerAppointment(int id)
        {
            CustomerAppointment customerAppointment = db.CustomerAppointment.Find(id);

            return(customerAppointment);
        }
예제 #9
0
 //新增预约信息
 public void AddCustomerAppointment(CustomerAppointment customerAppointment)
 {
     db.CustomerAppointment.Add(customerAppointment);
     db.SaveChanges();
 }
 public ActionResult EditCustomerAppointment(CustomerAppointment customerAppointment)
 {
     Bll.EditSaChangsCustomerAppointment(customerAppointment);
     return(RedirectToAction("CustomerAppointment"));
 }
 //新增客户预约
 public ActionResult AddCustomerAppointment(CustomerAppointment customerAppointment)
 {
     Bll.AddCustomerAppointment(customerAppointment);
     return(RedirectToAction("CustomerAppointment"));
 }