Beispiel #1
0
        public static void GetTrips()
        {
            Trips = new List <Trip>();

            //created a command
            Command = new SqlCommand("SELECT * FROM Trip", Connection);

            //excuted the command
            Reader = Command.ExecuteReader();

            //Reading Data
            while (Reader.Read())
            {
                String    TripId           = (string)Reader["TripId"];
                String    TourGuideId      = (string)Reader["TripId"];
                String    Type             = (string)Reader["TripId"];
                String    Depature         = (string)Reader["TripId"];
                String    Destination      = (string)Reader["TripId"];
                Double    Discount         = (Double)Reader["Discount"];
                DateTime  Start            = (DateTime)Reader["Start"];
                DateTime  End              = (DateTime)Reader["End"];
                Byte[]    TripImage        = (Byte[])Reader["TripImage"];
                TourGuide CurrentTourGuide = SelectTourGuide(TourGuideId);
                Trip      Obj              = new Trip(TripId, CurrentTourGuide, Type, Depature, Destination, Discount, Start, End);
                Obj.TripImage = new CustomImage(TripImage);
                Trips.Add(Obj);
            }
            Reader.Close();
            return;
        }
Beispiel #2
0
        public static void GetTourGuides()
        {
            TourGuides = new List <TourGuide>();

            //created a command
            Command = new SqlCommand("SELECT * from TourGuide", Connection);

            Reader = Command.ExecuteReader();

            //Reading Data
            while (Reader.Read())
            {
                string    Id             = (string)Reader["Id"];
                string    Name           = (string)Reader["Name"];
                string    Nationality    = (string)Reader["Nationality"];
                string    Gender         = (string)Reader["Gender"];
                string    Email          = (string)Reader["Email"];
                string    PhoneNumber    = (string)Reader["PhoneNumber"];
                byte[]    TourGuideImage = (byte[])Reader["TourGuideImage"];
                TourGuide Obj            = new TourGuide(Id, Name, Nationality, Gender, Email, PhoneNumber);
                Obj.UserImage.SetImage(TourGuideImage);
                TourGuides.Add(Obj);
            }
            Reader.Close();
            return;
        }
Beispiel #3
0
        private static void GetTrips()
        {
            Trips = new List <Trip>();

            //created a command
            Command.CommandText = "SELECT * FROM Trip";

            //excuted the command
            Reader = Command.ExecuteReader();

            //Reading Data
            while (Reader.Read())
            {
                String    TripId           = (string)Reader["TripId"];
                String    TourGuideId      = (string)Reader["TourGuideId"];
                String    Depature         = (string)Reader["Depature"];
                String    Destination      = (string)Reader["Destination"];
                Double    Discount         = (Double)Reader["Discount"];
                DateTime  Start            = (DateTime)Reader["TripStartDate"];
                DateTime  End              = (DateTime)Reader["TripEndDate"];
                Byte[]    TripImage        = (Byte[])Reader["Image"];
                TourGuide CurrentTourGuide = SelectTourGuide(TourGuideId);
                if (CurrentTourGuide == null)
                {
                    continue;
                }
                Trip Obj = new Trip(TripId, CurrentTourGuide, Depature, Destination, Discount, Start, End);
                Obj.TripImage = new CustomImage(TripImage);
                Trips.Add(Obj);
                CurrentTourGuide.Trips.Add(Obj);
            }
            Reader.Close();
            return;
        }
        private void AddTourGuide(TourGuide t)
        {
            string name = t.Name, nationality = t.Nationality, phone_number = t.PhoneNumber,
                   language = t.Languages[0], gender = t.Gender, email = t.Email;

            if (AddTourGuideFullData_Name.Text != "")
            {
                name = AddTourGuideFullData_Name.Text;
            }
            if (AddTourGuideFullData_Nationality.Text != "")
            {
                nationality = AddTourGuideFullData_Nationality.Text;
            }
            if (AddTourGuideFullData_PhoneNumber.Text != "")
            {
                phone_number = AddTourGuideFullData_PhoneNumber.Text;
            }
            if (AddTourGuideFullData_language.Text != "")
            {
                language = AddTourGuideFullData_language.Text;
            }
            if (AddTourGuideGender_ComboBox.Text != "")
            {
                gender = AddTourGuideGender_ComboBox.Text;
            }
            if (AddTourGuideFullData_Email.Text != "")
            {
                email = AddTourGuideFullData_Email.Text;
            }
        }
Beispiel #5
0
        private static void GetTourGuides()
        {
            TourGuides = new List <TourGuide>();

            //created a command
            Command.CommandText = "SELECT * from TourGuide";

            Reader = Command.ExecuteReader();

            //Reading Data
            while (Reader.Read())
            {
                string    Id             = (string)Reader["Id"];
                string    Name           = (string)Reader["Name"];
                string    Nationality    = (string)Reader["Nationality"];
                string    Language       = (string)Reader["Language"];
                string    Gender         = (string)Reader["Gender"];
                string    Email          = (string)Reader["Email"];
                string    PhoneNumber    = (string)Reader["PhoneNumber"];
                byte[]    TourGuideImage = (byte[])Reader["Image"];
                TourGuide Obj            = new TourGuide(Id, Name, Nationality, Language, Gender, Email, PhoneNumber);
                Obj.UserImage = new CustomImage(TourGuideImage);
                TourGuides.Add(Obj);
            }
            Reader.Close();
            return;
        }
Beispiel #6
0
 public static void InsertTourGuide(TourGuide CurrentTourGuide)
 {
     Command = new SqlCommand($"INSERT INTO TourGuide values('{ CurrentTourGuide.Id }','{CurrentTourGuide.Name }' ," +
                              $" '{CurrentTourGuide.Nationality}','{ CurrentTourGuide.Gender}','{CurrentTourGuide.Email}'," +
                              $"'{CurrentTourGuide.PhoneNumber}', {CurrentTourGuide.UserImage.GetByteImage()})", Connection);
     TourGuides.Add(CurrentTourGuide);
     Command.ExecuteNonQuery();
     return;
 }
Beispiel #7
0
 public static void InsertTourGuide(TourGuide CurrentTourGuide)
 {
     Command.CommandText = $"INSERT INTO TourGuide values('{ CurrentTourGuide.Id }','{CurrentTourGuide.Name }' ," +
                           $" '{CurrentTourGuide.Nationality}', '{CurrentTourGuide.Language}', '{ CurrentTourGuide.Gender}','{CurrentTourGuide.Email}'," +
                           $"'{CurrentTourGuide.PhoneNumber}', @image)";
     Command.Parameters.AddWithValue("@image", CurrentTourGuide.UserImage.GetByteImage());
     Command.ExecuteNonQuery();
     Command.Parameters.Clear();
     TourGuides.Add(CurrentTourGuide);
     return;
 }
        private void ShowTourGuideFullData(TourGuide t)
        {
            CurrentPanelName_Label.Content = "TourGuide Full Data";
            CurrentCanvas.Visibility       = Visibility.Hidden;
            CurrentCanvas            = TourGuideFullData_Canvas;
            CurrentCanvas.Visibility = Visibility.Visible;

            TourGuideFullData_Name.Content        = t.Name;
            TourGuideFullData_Nationality.Content = t.Nationality;
            TourGuideFullData_Id.Content          = t.Id;
            TourGuideFullData_Email.Content       = t.Email;
            TourGuideFullData_Gender.Content      = t.Gender;
            //  TourGuideFullData_Language.Content = t.Languages[0].ToString();
            TourGuideFullData_IMG.Source          = t.UserImage.GetImage().Source;
            TourGuideFullData_PhoneNumber.Content = t.PhoneNumber;
        }
        public MainWindow()
        {
            InitializeComponent();

            DataBase.Intialize();

            List <string> x = new List <string>();

            x.Add("Arabic");
            CurrentCanvas = Main_Canvas;
            cus           = new Customer("1", "Ali Ahmed", "Egyptian", x, "Male", "*****@*****.**", "01125567777");
            cus.UserImage = new CustomImage("C:/Users/Hadil/Desktop/mejor-guia-natural_LPRIMA20180218_0060_27.jpg");
            //Trip NewTrip = new Trip("2", DataBase.TourGuides[0], "General", "Alex", "Cairo", 0, new DateTime(2018, 5, 1), new DateTime(2018, 5, 10));
            //NewTrip.TripImage = new CustomImage("D:/test.png");
            //DataBase.InsertTrip(NewTrip);

            t = new TourGuide("1", "Ahmed Gamal", "Egyptian", "Male", "*****@*****.**", "01145888");

            t.UserImage = new CustomImage("C:/Users/Hadil/Desktop/mejor-guia-natural_LPRIMA20180218_0060_27.jpg");

            int today = DateTime.Today.Day;

            if (DataBase.Trips.Count != 0)
            {
                TripOfTheDay = DataBase.Trips[today % DataBase.Trips.Count]; //generate trip based on today's date
            }
            if (DataBase.TourGuides.Count != 0)
            {
                TourGuideOfTheMonth = TourGuide.GetBestTourGuide(DateTime.Today.Month - 1); //returns tour guide with maximum salary in the past month
            }
            if (TripOfTheDay != null)
            {
                TripOfTheDay_IMG.Source    = TripOfTheDay.TripImage.GetImage().Source;
                TripOfTheDay_Label.Content = TripOfTheDay.Departure + " - " + TripOfTheDay.Destination;
                ActiveTrip = TripOfTheDay;
            }

            if (TourGuideOfTheMonth == null)
            {
                ;
            }
            //Todo: add message
            //There is no tour guides or max existing haas 0 salary in the past month
        }
Beispiel #10
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);
 }
Beispiel #11
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;
        }
Beispiel #12
0
        /// <summary>
        /// updates old TourGuide in database first then updates the object
        /// </summary>
        public static void UpdateTourGuide(TourGuide CurrentTourGuide, TourGuide NewTourGuide)
        {
            //update databae
            Command.CommandText = $"UPDATE TourGuide set Id = '{NewTourGuide.Id}', Name = '{NewTourGuide.Name}', Nationality = '{NewTourGuide.Nationality}', " +
                                  $"Language = '{NewTourGuide.Language}', Gender = '{NewTourGuide.Gender}', Email = '{NewTourGuide.Email}', PhoneNumber = '{NewTourGuide.PhoneNumber}', " +
                                  $"Image = @image where Id = '{CurrentTourGuide.Id}'";
            Command.Parameters.AddWithValue("@image", NewTourGuide.UserImage.GetByteImage());
            Command.ExecuteNonQuery();
            Command.Parameters.Clear();

            //update object
            CurrentTourGuide.Id          = NewTourGuide.Id;
            CurrentTourGuide.Name        = NewTourGuide.Name;
            CurrentTourGuide.Nationality = NewTourGuide.Nationality;
            CurrentTourGuide.Language    = NewTourGuide.Language;
            CurrentTourGuide.Gender      = NewTourGuide.Gender;
            CurrentTourGuide.Email       = NewTourGuide.Email;
            CurrentTourGuide.PhoneNumber = NewTourGuide.PhoneNumber;
            CurrentTourGuide.UserImage   = NewTourGuide.UserImage;
        }
Beispiel #13
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;
        }
Beispiel #14
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);
 }
        public MainWindow()
        {
            InitializeComponent();

            DataBase.Intialize();

            CurrentCanvas = CustomerFullDetails_Canvas;

            List <string> l = new List <string>();

            l.Add("Arabic");

            cus           = new Customer("1", "Ali Ahmed", "Egyption", l, "Male", "*****@*****.**", "0114849551");
            cus.UserImage = new CustomImage("E:/test.JPG");
            DataBase.Customers.Add(cus);

            CurrentCanvas = Main_Canvas;

            TourGuide t = new TourGuide("1", "ahmed", "egy", "male", "asa", "011");

            t.UserImage = new CustomImage("E:/test.JPG");
            DataBase.TourGuides.Add(t);

            Trip trip = new Trip("2", t, "family", "Cairo", "Alex", 0, new DateTime(2017, 5, 4), new DateTime(2017, 6, 4));

            trip.TripImage = new CustomImage("E:/test.JPG");  //Put a valid image just to test
            DataBase.Trips.Add(trip);


            Trip trip2 = new Trip("3", t, "test", "Rome", "Paris", 0, new DateTime(2017, 5, 4), new DateTime(2017, 6, 4));

            trip2.TripImage = new CustomImage("E:/test.JPG");  //Put a valid image just to test
            //DataBase.Trips.Add(trip2);
            //DataBase.Trips.Add(trip2);
            //DataBase.Trips.Add(trip2);
            //DataBase.Trips.Add(trip2);
            //DataBase.Trips.Add(trip2);
            //DataBase.Trips.Add(trip2);
            //DataBase.Trips.Add(trip2);
            //DataBase.Trips.Add(trip2);
            //DataBase.Trips.Add(trip2);
            //DataBase.Trips.Add(trip2);
            //DataBase.Trips.Add(trip2);
            //DataBase.Trips.Add(trip2);
            //DataBase.Trips.Add(trip2);
            //DataBase.Trips.Add(trip2);
            //DataBase.Trips.Add(trip2);
            //DataBase.Trips.Add(trip2);
            //DataBase.Trips.Add(trip2);
            //DataBase.Trips.Add(trip2);
            //DataBase.Trips.Add(trip2);
            //DataBase.Trips.Add(trip2);
            //DataBase.Trips.Add(trip2);
            //DataBase.Trips.Add(trip2);


            int today = DateTime.Today.Day;

            if (DataBase.Trips.Count != 0)
            {
                TripOfTheDay = DataBase.Trips[today % DataBase.Trips.Count]; //generate trip based on today's date
            }
            if (DataBase.TourGuides.Count != 0)
            {
                TourGuideOfTheMonth = TourGuide.GetBestTourGuide(DateTime.Today.Month - 1); //returns tour guide with maximum salary in the past month
            }
            if (TripOfTheDay != null)
            {
                TripOfTheDay_IMG.Source    = TripOfTheDay.TripImage.GetImage().Source;
                TripOfTheDay_Label.Content = TripOfTheDay.Departure + " - " + TripOfTheDay.Destination;
            }

            if (TourGuideOfTheMonth == null)
            {
                ;
            }
            //Todo: add message
            //There is no tour guides or max existing haas 0 salary in the past month
        }
Beispiel #16
0
 public static void DeleteTourGuide(TourGuide CurrentTourGuide)
 {
     Command.CommandText = $"Delete From TourGuide where Id = '{CurrentTourGuide.Id}'";
     Command.ExecuteNonQuery();
     TourGuides.Remove(CurrentTourGuide);
 }
        private void EditTourGuideData(TourGuide t)
        {
            string name = t.Name, nationality = t.Nationality, phone_number = t.PhoneNumber,
                   gender = t.Gender, email = t.Email;

            bool tourErrorFound = false;

            // if (DataBase.CheckUniqueTourGuideId(t.Id) == true)
            //{
            //  AddTourGuide_Error_ID.Content = "This id is already found!";
            //tourErrorFound = true;

            //}
            //else AddTourGuide_Error_ID.Content = "";
            //todo check unique id
            if (EditTourGuideFullData_Name.Text == "")
            {
                EditTourGuide_Name_ErrorLabel.Content = "This field can't be empty!";
                tourErrorFound = true;
            }
            else
            {
                EditTourGuide_Name_ErrorLabel.Content = "";
            }


            if (EditTourGuideFullData_Nationality.Text.Trim() == "")
            {
                EditTourGuide_Nationality_ErrorLabel.Content = "This field can't be empty!";
                tourErrorFound = true;
            }
            else
            {
                EditTourGuide_Nationality_ErrorLabel.Content = "";
            }
            if (EditTourGuideFullData_Email.Text.Trim() == "")
            {
                EditTourGuide_Email_ErrorLabel.Content = "This field can't be empty!";
                tourErrorFound = true;
            }
            else
            {
                EditTourGuide_Email_ErrorLabel.Content = "";
            }

            /* if (EditTourGuideFullData_Language.Text.Trim() == "")
             * {
             *   EditTourGuide_Language_ErrorLabel.Content = "This field can't be empty!";
             *   tourErrorFound = true;
             * }
             * else EditTourGuide_Language_ErrorLabel.Content = "";
             */if (TourGuideGender_ComboBox.Text == "")
            {
                EditTourGuide_Gender_ErrorLabel.Content = "This field can't be empty!";
                tourErrorFound = true;
            }
            else
            {
                EditTourGuide_Gender_ErrorLabel.Content = "";
            }
            if (EditTourGuideFullData_PhoneNumber.Text == "")
            {
                EditTourGuide_PhoneNumber_ErrorLabel.Content = "This field can't be empty!";
                tourErrorFound = true;
            }
            else
            {
                EditTourGuide_PhoneNumber_ErrorLabel.Content = "";
            }

            if (SelectedPath == "")
            {
                EditTourGuide_Photo_ErrorLabel.Content = "This field can't be empty!";
                tourErrorFound = true;
            }
            else
            {
                EditTourGuide_Photo_ErrorLabel.Content = "";
            }
            if (tourErrorFound == true)
            {
                return;
            }

            //TourGuide temp = new TourGuide(AddTourGuideFullData_Id.Text, AddTourGuideFullData_Name.Text, AddTourGuideFullData_Nationality.Text
            //     , AddTourGuideGender_ComboBox.Text, AddTourGuideFullData_Email.Text, AddTourGuideFullData_PhoneNumber.Text);
            // temp.UserImage = new CustomImage(SelectedPath);
            EditTourGuide_Name_ErrorLabel.Content        = "";
            EditTourGuide_Email_ErrorLabel.Content       = "";
            EditTourGuide_PhoneNumber_ErrorLabel.Content = "";
            // EditTourGuide_Language_ErrorLabel.Content = "";
            EditTourGuide_Gender_ErrorLabel.Content      = "";
            EditTourGuide_Nationality_ErrorLabel.Content = "";



            name = EditTourGuideFullData_Name.Text;

            nationality = EditTourGuideFullData_Nationality.Text;

            phone_number = EditTourGuideFullData_PhoneNumber.Text;

            //   language = EditTourGuideFullData_Language.Text;

            gender = TourGuideGender_ComboBox.Text;

            email = EditTourGuideFullData_Email.Text;
            //  DataBase.UpdateTourGuide(t, t.Id, name, nationality, gender, email, phone_number, t.UserImage);
            //Todo 7war el language
        }