public string Update(Guide_Reservation guideReservation)
        {
            Guide_Reservation newGuideReservation = db.Guide_Reservation.Where(r => r.Id == guideReservation.Id).FirstOrDefault();

            if (guideReservation.ID_Guide == "choose")
            {
                newGuideReservation.ID_Guide      = null;
                newGuideReservation.IsPaid        = guideReservation.IsPaid;
                newGuideReservation.People_Number = guideReservation.People_Number;
                newGuideReservation.TotalPrice    = guideReservation.TotalPrice;
            }
            else
            {
                newGuideReservation.ID_Guide      = guideReservation.ID_Guide;
                newGuideReservation.IsPaid        = guideReservation.IsPaid;
                newGuideReservation.People_Number = guideReservation.People_Number;
                newGuideReservation.TotalPrice    = guideReservation.TotalPrice;
            }

            db.Entry(newGuideReservation).State = System.Data.Entity.EntityState.Modified;

            if (db.SaveChanges() > 0)
            {
                return("更新成功");
            }

            return("更新失败");
        }
Beispiel #2
0
        public string UpdateMemberById(Member member)
        {
            var result = db.Members.FirstOrDefault(m => m.Id == member.Id);

            if (result != null)
            {
                try
                {
                    db.Members.Attach(result);
                    result.Name            = member.Name;
                    result.Email           = member.Email;
                    result.Phone           = member.Phone;
                    result.Birth           = member.Birth;
                    db.Entry(member).State = System.Data.Entity.EntityState.Modified;
                    if (db.SaveChanges() > 0)
                    {
                        return("更新成功");
                    }
                }
                catch (Exception ex)
                {
                    throw;
                }
            }

            return("更新失败");
        }
Beispiel #3
0
        public string Update(Tour tour)
        {
            Tour newTour = db.Tours.FirstOrDefault(h => h.Id == tour.Id);

            newTour.Province = tour.Province;
            newTour.Name     = tour.Name;
            newTour.Course   = tour.Course;
            newTour.TourDate = tour.TourDate;

            db.Entry(newTour).State = System.Data.Entity.EntityState.Modified;

            if (db.SaveChanges() > 0)
            {
                return("更新成功");
            }

            return("更新失败");
        }
Beispiel #4
0
        public string Update(Hotel hotel)
        {
            Hotel newHotel = db.Hotels.FirstOrDefault(h => h.Id == hotel.Id);

            newHotel.Address       = hotel.Address;
            newHotel.Name          = hotel.Name;
            newHotel.Country       = hotel.Country;
            newHotel.ContactNumber = hotel.ContactNumber;
            newHotel.Area          = hotel.Area;

            db.Entry(newHotel).State = System.Data.Entity.EntityState.Modified;

            if (db.SaveChanges() > 0)
            {
                return("更新成功");
            }

            return("更新失败");
        }
Beispiel #5
0
        public string Update(Hotel_Reservation hotelReservation)
        {
            Hotel_Reservation newHotelReservation = db.Hotel_Reservation.Where(r => r.Id == hotelReservation.Id).FirstOrDefault();


            newHotelReservation.IsPaid = hotelReservation.IsPaid;

            db.Entry(newHotelReservation).State = System.Data.Entity.EntityState.Modified;

            if (db.SaveChanges() > 0)
            {
                return("更新成功");
            }

            return("更新失败");
        }
        public string Update(CustomTour customTourReservation)
        {
            CustomTour newCustomTourReservation = db.CustomTours.Where(r => r.Id == customTourReservation.Id).FirstOrDefault();

            newCustomTourReservation.IsPaid     = customTourReservation.IsPaid;
            newCustomTourReservation.TotalPrice = customTourReservation.TotalPrice;

            db.Entry(newCustomTourReservation).State = System.Data.Entity.EntityState.Modified;

            if (db.SaveChanges() > 0)
            {
                return("更新成功");
            }

            return("更新失败");
        }
Beispiel #7
0
        public string Update(Golf golf)
        {
            Golf newGolf = db.Golves.FirstOrDefault(h => h.Id == golf.Id);

            newGolf.Address = golf.Address;
            newGolf.Name    = golf.Name;
            newGolf.City    = golf.City;

            db.Entry(newGolf).State = System.Data.Entity.EntityState.Modified;

            if (db.SaveChanges() > 0)
            {
                return("更新成功");
            }

            return("更新失败");
        }
Beispiel #8
0
        public string Update(Vehicle_Reservation vehicleReservation)
        {
            Vehicle_Reservation newVehicleReservation = db.Vehicle_Reservation.Where(r => r.Id == vehicleReservation.Id).FirstOrDefault();


            newVehicleReservation.IsPaid        = vehicleReservation.IsPaid;
            newVehicleReservation.People_Number = vehicleReservation.People_Number;
            newVehicleReservation.TotalPrice    = vehicleReservation.TotalPrice;
            newVehicleReservation.Type          = vehicleReservation.Type;

            db.Entry(newVehicleReservation).State = System.Data.Entity.EntityState.Modified;

            if (db.SaveChanges() > 0)
            {
                return("更新成功");
            }

            return("更新失败");
        }
Beispiel #9
0
        public string Update(FormCollection formCollection)
        {
            string id = "", photoUrl = "", photo = "", description = "";

            foreach (var key in formCollection.AllKeys)
            {
                id          = formCollection["id"];
                description = formCollection["description"];
                photo       = formCollection["photo"];
            }

            if (Request.Files.Count > 0)
            {
                try
                {
                    //  Get all files from Request object
                    HttpFileCollectionBase files = Request.Files;
                    for (int i = 0; i < files.Count; i++)
                    {
                        //string path = AppDomain.CurrentDomain.BaseDirectory + "Uploads/";
                        //string filename = Path.GetFileName(Request.Files[i].FileName);

                        HttpPostedFileBase file = files[i];

                        // Checking for Internet Explorer
                        if (Request.Browser.Browser.ToUpper() == "IE" || Request.Browser.Browser.ToUpper() == "INTERNETEXPLORER")
                        {
                            string[] testfiles = file.FileName.Split(new char[] { '\\' });
                            photoUrl = testfiles[testfiles.Length - 1];
                        }
                        else
                        {
                            photoUrl = file.FileName;
                        }

                        if (!System.IO.Directory.Exists(Server.MapPath("~/Uploads/")))
                        {
                            System.IO.Directory.CreateDirectory(Server.MapPath("~/Uploads/"));
                        }

                        // Get the complete folder path and store the file inside it.
                        string fullPathUrl = Path.Combine(Server.MapPath("~/Uploads/"), photoUrl);

                        Golf_Package newGolfPackage = db.Golf_Package.FirstOrDefault(g => g.Id == id);

                        newGolfPackage.Photo       = "/Uploads/" + photoUrl;;
                        newGolfPackage.Description = description;

                        db.Entry(newGolfPackage).State = System.Data.Entity.EntityState.Modified;

                        if (db.SaveChanges() > 0)
                        {
                            file.SaveAs(fullPathUrl);
                            return("更新成功");
                        }
                    }
                    // Returns message that successfully uploaded
                    //return "File Uploaded Successfully!";
                }
                catch (DbEntityValidationException dbEx)
                {
                    StringBuilder sb = new StringBuilder();
                    foreach (var validationErrors in dbEx.EntityValidationErrors)
                    {
                        foreach (var validationError in validationErrors.ValidationErrors)
                        {
                            sb.Append("Property:" + validationError.PropertyName + "  Error: " + validationError.ErrorMessage);
                        }
                    }

                    return(sb.ToString());
                }
            }
            else
            {
                Golf_Package newGolfPackage = db.Golf_Package.FirstOrDefault(g => g.Id == id);

                newGolfPackage.Photo       = "/Uploads/" + photo;
                newGolfPackage.Description = description;

                db.Entry(newGolfPackage).State = System.Data.Entity.EntityState.Modified;

                if (db.SaveChanges() > 0)
                {
                    return("更新成功");
                }
            }

            return("更新失败");
        }
Beispiel #10
0
        public string Update(FormCollection formCollection)
        {
            string id = "", photoUrl = "", area = "", address = "", hotelId = "", country = "", phone = "", name = "", description = "",
                   photo = "", singleRoomPhoto = "", doubleRoomPhoto = "", otherRoomPhoto = "";
            StringBuilder allPhotoUrls = new StringBuilder();

            foreach (var key in formCollection.AllKeys)
            {
                id              = formCollection["id"];
                area            = formCollection["area"];
                description     = formCollection["description"];
                address         = formCollection["address"];
                hotelId         = formCollection["hotelId"];
                country         = formCollection["country"];
                phone           = formCollection["phone"];
                name            = formCollection["name"];
                photo           = formCollection["photo"];
                singleRoomPhoto = formCollection["singleRoomPhoto"];
                doubleRoomPhoto = formCollection["doubleRoomPhoto"];
                otherRoomPhoto  = formCollection["otherRoomPhoto"];
            }



            if (Request.Files.Count > 0)
            {
                try
                {
                    //  Get all files from Request object
                    HttpFileCollectionBase files = Request.Files;
                    for (int i = 0; i < files.Count; i++)
                    {
                        //string path = AppDomain.CurrentDomain.BaseDirectory + "Uploads/";
                        //string filename = Path.GetFileName(Request.Files[i].FileName);

                        HttpPostedFileBase file = files[i];

                        // Checking for Internet Explorer
                        if (Request.Browser.Browser.ToUpper() == "IE" || Request.Browser.Browser.ToUpper() == "INTERNETEXPLORER")
                        {
                            string[] testfiles = file.FileName.Split(new char[] { '\\' });
                            photoUrl = testfiles[testfiles.Length - 1];
                        }
                        else
                        {
                            photoUrl = file.FileName;
                        }

                        if (!System.IO.Directory.Exists(Server.MapPath("~/Uploads/")))
                        {
                            System.IO.Directory.CreateDirectory(Server.MapPath("~/Uploads/"));
                        }

                        // Get the complete folder path and store the file inside it.
                        string fullPathUrl = Path.Combine(Server.MapPath("~/Uploads/"), photoUrl);
                        file.SaveAs(fullPathUrl);
                        allPhotoUrls.Append(photoUrl + ";");
                    }
                    // Returns message that successfully uploaded
                    //return "File Uploaded Successfully!";
                }
                catch (DbEntityValidationException dbEx)
                {
                    StringBuilder sb = new StringBuilder();
                    foreach (var validationErrors in dbEx.EntityValidationErrors)
                    {
                        foreach (var validationError in validationErrors.ValidationErrors)
                        {
                            sb.Append("Property:" + validationError.PropertyName + "  Error: " + validationError.ErrorMessage);
                        }
                    }

                    return(sb.ToString());
                }
            }
            else
            {
                Hotel_Package newHotelPackages = db.Hotel_Package.FirstOrDefault(g => g.Id == id);
                Hotel         hotels           = db.Hotels.Where(h => h.Id == hotelId).FirstOrDefault();

                newHotelPackages.Country         = country;
                newHotelPackages.Area            = area;
                newHotelPackages.Photo           = "/Uploads/" + photo;
                newHotelPackages.SingRommPhoto   = "/Uploads/" + singleRoomPhoto;
                newHotelPackages.DoubleRoomPhoto = "/Uploads/" + doubleRoomPhoto;
                newHotelPackages.OtherRoomPhoto  = "/Uploads/" + otherRoomPhoto;
                newHotelPackages.Hotel           = hotels;
                newHotelPackages.Description     = description;

                db.Entry(newHotelPackages).State = System.Data.Entity.EntityState.Modified;

                if (db.SaveChanges() > 0)
                {
                    return("更新成功");
                }
            }

            string[] photos            = allPhotoUrls.ToString().Split(';');

            Hotel_Package newHotelPackage = db.Hotel_Package.FirstOrDefault(g => g.Id == id);
            Hotel         hotel           = db.Hotels.Where(h => h.Id == hotelId).FirstOrDefault();

            newHotelPackage.Country         = country;
            newHotelPackage.Area            = area;
            newHotelPackage.Photo           = "/Uploads/" + photos[0];
            newHotelPackage.SingRommPhoto   = "/Uploads/" + photos[1];
            newHotelPackage.DoubleRoomPhoto = "/Uploads/" + photos[2];
            newHotelPackage.OtherRoomPhoto  = "/Uploads/" + photos[3];
            newHotelPackage.Hotel           = hotel;
            newHotelPackage.Description     = description;

            db.Entry(newHotelPackage).State = System.Data.Entity.EntityState.Modified;

            if (db.SaveChanges() > 0)
            {
                return("更新成功");
            }

            return("更新失败");
        }