Ejemplo n.º 1
0
        public static void UpdateTourGuide(TourGuide CurrentTourGuide, string Id, string Name, string Nationality, string Language, string Gender, string Email, string PhoneNumber, CustomImage TourGuideImage)
        {
            //update databae
            Command.CommandText = $"UPDATE TourGuide set Id = '{Id}', Name = '{Name}', Nationality = '{Nationality}', " +
                                  $"Language = '{Language}', Gender = '{Gender}', Email = '{Email}', PhoneNumber = '{PhoneNumber}', " +
                                  $"Image = @image where Id = '{CurrentTourGuide.Id}'";
            Command.Parameters.AddWithValue("@image", TourGuideImage.GetByteImage());
            Command.ExecuteNonQuery();
            Command.Parameters.Clear();

            //update object
            CurrentTourGuide.Id          = Id;
            CurrentTourGuide.Name        = Name;
            CurrentTourGuide.Nationality = Nationality;
            CurrentTourGuide.Gender      = Gender;
            CurrentTourGuide.Email       = Email;
            CurrentTourGuide.PhoneNumber = PhoneNumber;
            CurrentTourGuide.UserImage   = TourGuideImage;
        }
Ejemplo n.º 2
0
 public static bool UpdateTourGuide(TourGuide CurrentTourGuide, string Id, string Name, string Nationality, string Gender, string Email, string PhoneNumber, CustomImage TourGuideImage)
 {
     if (CheckUniqueTourGuideId(Id) || CurrentTourGuide.Id == Id)
     {
         Command = new SqlCommand($"UPDATE Customer set Id = '{Id}', set Name = '{Name}', set Nationality = '{Nationality}', " +
                                  $"set Gender = '{Gender}', set Email = '{Email}', set PhoneNumber = '{PhoneNumber}', " +
                                  $"set TourGuideImage = {TourGuideImage.GetByteImage()} where Id = '{CurrentTourGuide.Id}'",
                                  Connection);
         CurrentTourGuide.Id          = Id;
         CurrentTourGuide.Name        = Name;
         CurrentTourGuide.Nationality = Nationality;
         CurrentTourGuide.Gender      = Gender;
         CurrentTourGuide.Email       = Email;
         CurrentTourGuide.PhoneNumber = PhoneNumber;
         CurrentTourGuide.UserImage   = TourGuideImage;
         return(true);
     }
     return(false);
 }
Ejemplo n.º 3
0
        public static void UpdateCustomer(Customer CurrentCustomer, string Id, string Name, string Nationality, string Language, string Gender, string Email, string PhoneNumber, CustomImage CustomerImage)
        {
            //update database
            Command.CommandText = $"UPDATE Customer set Id = '{Id}', set Name = '{Name}', set Nationality = '{Nationality}', " +
                                  $"set Language = '{Language}', set Gender = '{Gender}', set Email = '{Email}', set PhoneNumber = '{PhoneNumber}'," +
                                  $"set Image = @image where Id = '{CurrentCustomer.Id}'";
            Command.Parameters.AddWithValue("@image", CustomerImage.GetByteImage());
            Command.ExecuteNonQuery();
            Command.Parameters.Clear();

            //update object
            CurrentCustomer.Id           = Id;
            CurrentCustomer.Name         = Name;
            CurrentCustomer.Nationality  = Nationality;
            CurrentCustomer.Languages[0] = Language;
            CurrentCustomer.Gender       = Gender;
            CurrentCustomer.Email        = Email;
            CurrentCustomer.PhoneNumber  = PhoneNumber;
            CurrentCustomer.UserImage    = CustomerImage;
        }
Ejemplo n.º 4
0
        public static void UpdateTrip(Trip CurrentTrip, string TripId, string TourGuideId, string Type, string Depature, string Destination, double Discount, DateTime Start, DateTime End, CustomImage TripImage)
        {
            //update database
            //update Trip table
            Command.CommandText = $"UPDATE Trips set TripId = '{TripId}', set TourGuideId = '{TourGuideId}', set Type = '{Type}', " +
                                  $"set Depature = '{Depature}', set Destination = '{Destination}', set Discont = {Discount}, set Start = '{Start}'," +
                                  $"set End = '{End}', set Image = @Image  where TripId = '{CurrentTrip.TripId}'";
            Command.Parameters.AddWithValue("@image", TripImage.GetByteImage());
            Command.ExecuteNonQuery();
            Command.Parameters.Clear();

            //update TripsTickets Table
            Command.CommandText = $"UPDATE TripsTickets set TripId = '{TripId}' where TripId = '{CurrentTrip.TripId}'";
            Command.ExecuteNonQuery();

            //update Transactions Table
            Command.CommandText = $"UPDATE Transactions set TripId = '{TripId}' where TripId = '{CurrentTrip.TripId}'";
            Command.ExecuteNonQuery();

            //update objects
            CurrentTrip.TripId = TripId;

            //remove the trip from the previous TourGuide and add it to the new selected tourguide
            CurrentTrip.Tour.Trips.Remove(CurrentTrip);
            TourGuide NewTour = SelectTourGuide(TourGuideId);

            CurrentTrip.Tour = NewTour;
            NewTour.Trips.Add(CurrentTrip);


            CurrentTrip.Type        = Type;
            CurrentTrip.Departure   = Depature;
            CurrentTrip.Destination = Destination;
            CurrentTrip.Discount    = Discount;
            CurrentTrip.Start       = Start;
            CurrentTrip.End         = End;
            CurrentTrip.TripImage   = TripImage;
        }
Ejemplo n.º 5
0
 public static bool UpdateTrip(Trip CurrentTrip, string TripId, string TourGuideId, string Type, string Depature, string Destination, double Discount, DateTime Start, DateTime End, CustomImage TripImage)
 {
     if (CheckUniqueTripId(TripId) || TripId == CurrentTrip.TripId)
     {
         Command = new SqlCommand($"UPDATE Trips set TripId = '{TripId}', set TourGuideId = '{TourGuideId}', set Type = '{Type}', " +
                                  $"set Depature = '{Depature}', set Destination = '{Destination}', set Discont = {Discount}, set Start = '{Start}'," +
                                  $"set End = '{End}', set Image = {TripImage.GetByteImage()}  where TripId = '{CurrentTrip.TripId}'", Connection);
         Command            = new SqlCommand($"UPDATE TripsTickets set TripId = '{TripId}' where TripId = '{CurrentTrip.TripId}'");
         Command            = new SqlCommand($"UPDATE Transactions set TripId = '{TripId}' where TripId = '{CurrentTrip.TripId}'");
         CurrentTrip.TripId = TripId;
         TourGuide T = SelectTourGuide(TourGuideId);
         CurrentTrip.Tour        = T;
         CurrentTrip.Type        = Type;
         CurrentTrip.Departure   = Depature;
         CurrentTrip.Destination = Destination;
         CurrentTrip.Discount    = Discount;
         CurrentTrip.Start       = Start;
         CurrentTrip.End         = End;
         CurrentTrip.TripImage   = TripImage;
         Command.ExecuteNonQuery();
         return(true);
     }
     return(false);
 }