Beispiel #1
0
        private void Addbtn_Click_1(object sender, RoutedEventArgs e)
        {
            if (dtgadmtour.SelectedIndex >= 0)
            {
                TourInfo tour  = new TourInfo();
                int      index = dtgadmtour.SelectedIndex;

                try
                {
                    tour.TourCountry = (dtgadmtour.Items[index] as TourInfo).TourCountry;
                    tour.TourCity    = (dtgadmtour.Items[index] as TourInfo).TourCity;

                    tour.TourBegin    = (dtgadmtour.Items[index] as TourInfo).TourBegin;
                    tour.TourEnd      = (dtgadmtour.Items[index] as TourInfo).TourEnd;
                    tour.MaxSeats     = (dtgadmtour.Items[index] as TourInfo).MaxSeats;
                    tour.CurrentSeats = (dtgadmtour.Items[index] as TourInfo).CurrentSeats;
                    tour.DiscountId   = (dtgadmtour.Items[index] as TourInfo).DiscountId;
                    tour.Price        = (dtgadmtour.Items[index] as TourInfo).Price;
                    dBForAdmin.AddTour(tour);
                    dBForAdmin.tours.Add(tour);
                    AdminUpdateDatabase();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Beispiel #2
0
        private void Chgbtn_Click_1(object sender, RoutedEventArgs e)
        {
            if (dtgadmtour.SelectedIndex >= 0)
            {
                TourInfo tour  = new TourInfo();
                int      index = dtgadmtour.SelectedIndex;;

                tour.TourCountry  = (dtgadmtour.Items[index] as TourInfo).TourCountry;
                tour.TourCity     = (dtgadmtour.Items[index] as TourInfo).TourCity;
                tour.Id           = (dtgadmtour.Items[index] as TourInfo).Id;
                tour.TourBegin    = (dtgadmtour.Items[index] as TourInfo).TourBegin;
                tour.TourEnd      = (dtgadmtour.Items[index] as TourInfo).TourEnd;
                tour.MaxSeats     = (dtgadmtour.Items[index] as TourInfo).MaxSeats;
                tour.CurrentSeats = (dtgadmtour.Items[index] as TourInfo).CurrentSeats;
                tour.DiscountId   = (dtgadmtour.Items[index] as TourInfo).DiscountId;
                tour.Price        = (dtgadmtour.Items[index] as TourInfo).Price;

                dBForAdmin.UpdateTour(tour);

                AdminUpdateDatabase();
            }
        }
Beispiel #3
0
 private void Dltbtn_Click_1(object sender, RoutedEventArgs e)
 {
     if (dtgadmtour.SelectedIndex >= 0)
     {
         if (MessageBox.Show("Are you sure you want to delete", "Check", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
         {
             try
             {
                 TourInfo tour  = new TourInfo();
                 int      index = dtgadmtour.SelectedIndex;
                 tour.Id = (dtgadmtour.Items[index] as TourInfo).Id;
                 //dBTravelAgency.tours.Remove(dtgadmtour.Items[index] as TourInfo);
                 //  dBStore.students.RemoveAt(index);
                 dBForAdmin.DeleteTour(tour.Id);
                 AdminUpdateDatabase();
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
         }
     }
 }
Beispiel #4
0
        public void AddTour(TourInfo tour)
        {
            try
            {
                using (SqlConnection sqlConnection = new SqlConnection(connectDB))
                {
                    sqlConnection.Open();

                    SqlCommand sqlCommand = new SqlCommand
                    {
                        CommandText = "sp_addtour",
                        CommandType = CommandType.StoredProcedure,
                        Connection  = sqlConnection
                    };

                    SqlParameter sqlParameter = new SqlParameter
                    {
                        ParameterName = "@TourCountry",
                        Value         = tour.TourCountry,
                        SqlDbType     = System.Data.SqlDbType.NVarChar,
                        Size          = 50
                    };
                    sqlCommand.Parameters.Add(sqlParameter);

                    sqlParameter = new SqlParameter
                    {
                        ParameterName = "@TourCity",
                        Value         = tour.TourCity,
                        SqlDbType     = SqlDbType.NVarChar,
                        Size          = 50
                    };
                    sqlCommand.Parameters.Add(sqlParameter);

                    sqlParameter = new SqlParameter
                    {
                        ParameterName = "@TourBegin",
                        Value         = tour.TourBegin,
                        SqlDbType     = SqlDbType.Date
                    };
                    sqlCommand.Parameters.Add(sqlParameter);

                    sqlParameter = new SqlParameter
                    {
                        ParameterName = "@TourEnd",
                        Value         = tour.TourEnd,
                        SqlDbType     = SqlDbType.Date,
                    };

                    sqlCommand.Parameters.Add(sqlParameter);

                    sqlParameter = new SqlParameter
                    {
                        ParameterName = "@MaxSeats",
                        Value         = tour.MaxSeats,
                        SqlDbType     = SqlDbType.Int,
                    };
                    sqlCommand.Parameters.Add(sqlParameter);

                    sqlParameter = new SqlParameter
                    {
                        ParameterName = "@CurrentSeats",
                        Value         = tour.CurrentSeats,
                        SqlDbType     = SqlDbType.Int,
                    };
                    sqlCommand.Parameters.Add(sqlParameter);

                    sqlParameter = new SqlParameter
                    {
                        ParameterName = "@Price",
                        Value         = tour.Price,
                        SqlDbType     = SqlDbType.Money,
                    };
                    sqlCommand.Parameters.Add(sqlParameter);

                    if (sqlCommand.ExecuteNonQuery() > 0)
                    {
                        MessageBox.Show("Task completed succesfully");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #5
0
        public void SelectAdminAll()
        {
            try
            {
                using (SqlConnection sqlConnection = new SqlConnection(connectDB))
                {
                    string zapros = "select T.TourCountry,T.TourTown,Tim.TourBegin,Tim.TourEnd,T.MaxSeats,Tim.CurrentSeats,S.DiscountId,T.Price,T.id from dbo.Tour T join dbo.TourTime Tim on T.TourTimeId = Tim.Id join dbo.Seasons S on S.Id = T.SeasonId";

                    string zapros1 = "select u.LastName,u.FirstName,u.BirthDate,u.UserLogin,u.UserPassword,u.Id from dbo.UserPeson u where u.RoleName='User'";
                    sqlConnection.Open();

                    SqlCommand sqlComand = new SqlCommand
                    {
                        CommandText = zapros,
                        Connection  = sqlConnection
                    };

                    SqlCommand sqlComand1 = new SqlCommand
                    {
                        CommandText = zapros1,
                        Connection  = sqlConnection
                    };

                    using (SqlDataReader sqlDataReader1 = sqlComand1.ExecuteReader())
                    {
                        while (sqlDataReader1.Read())
                        {
                            User user = new User();
                            user.LastName     = sqlDataReader1[0].ToString();
                            user.FirstName    = sqlDataReader1[1].ToString();
                            user.BirthDate    = Convert.ToDateTime(sqlDataReader1[2]);
                            user.Userlogin    = sqlDataReader1[3].ToString();
                            user.UserPassword = sqlDataReader1[4].ToString();
                            user.Id           = (int)sqlDataReader1[5];
                            users.Add(user);
                        }
                    }


                    using (SqlDataReader sqlDataReader = sqlComand.ExecuteReader())
                    {
                        while (sqlDataReader.Read())
                        {
                            TourInfo tour = new TourInfo();
                            tour.TourCountry  = sqlDataReader[0].ToString();
                            tour.TourCity     = sqlDataReader[1].ToString();
                            tour.TourBegin    = Convert.ToDateTime(sqlDataReader[2]);
                            tour.TourEnd      = Convert.ToDateTime(sqlDataReader[3]);
                            tour.MaxSeats     = (int)sqlDataReader[4];
                            tour.CurrentSeats = (int)sqlDataReader[5];
                            tour.DiscountId   = (int)sqlDataReader[6];
                            tour.Price        = Convert.ToDouble(sqlDataReader[7]);
                            tour.Id           = (int)sqlDataReader[8];
                            tours.Add(tour);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #6
0
        public void SelectAll()
        {
            try
            {
                using (SqlConnection sqlConnection = new SqlConnection(connectDB))
                {
                    string zapros  = "select T.FirstName,T.LastName, doc.Serial,doc.Number,ph.PhoneNumber,pay.TourId[TourId],pay.DiscountId, pay.TotalSum,T.Id from dbo.Tourists T join dbo.Documents Doc on T.Id = Doc.TouristId join dbo.TouristsPhones ph on t.Id = ph.TouristId Join dbo.Payment pay on pay.TouristId = t.Id";
                    string zapros1 = "select T.TourCountry,T.TourTown,Tim.TourBegin,Tim.TourEnd,T.MaxSeats,Tim.CurrentSeats,S.DiscountId,T.Price,T.id from dbo.Tour T join dbo.TourTime Tim on T.TourTimeId = Tim.Id join dbo.Seasons S on S.Id = T.SeasonId";
                    string zapros2 = "select d.DiscountType,d.Number,d.Id from dbo.Discounts d ";

                    sqlConnection.Open();

                    SqlCommand sqlComand = new SqlCommand
                    {
                        CommandText = zapros,
                        Connection  = sqlConnection
                    };

                    SqlCommand sqlComand1 = new SqlCommand
                    {
                        CommandText = zapros1,
                        Connection  = sqlConnection
                    };
                    SqlCommand sqlComand2 = new SqlCommand
                    {
                        CommandText = zapros2,
                        Connection  = sqlConnection
                    };

                    using (SqlDataReader sqlDataReader = sqlComand.ExecuteReader())
                    {
                        while (sqlDataReader.Read())
                        {
                            TouristInfo tourist = new TouristInfo();
                            tourist.FirstName = sqlDataReader[0].ToString();
                            tourist.LastName  = sqlDataReader[1].ToString();
                            tourist.Serial    = sqlDataReader[2].ToString();
                            if (string.IsNullOrWhiteSpace(tourist.Serial))
                            {
                                tourist.Serial = "-";
                            }
                            tourist.Number      = sqlDataReader[3].ToString();
                            tourist.PhoneNumber = sqlDataReader[4].ToString();
                            tourist.TourId      = (int)sqlDataReader[5];
                            tourist.DiscountId  = (int)sqlDataReader[6];
                            tourist.TotalSum    = Convert.ToDouble(sqlDataReader[7]);
                            tourist.Id          = (int)sqlDataReader[8];
                            tourists.Add(tourist);
                        }
                    }
                    using (SqlDataReader sqlDataReader = sqlComand1.ExecuteReader())
                    {
                        while (sqlDataReader.Read())
                        {
                            TourInfo tour = new TourInfo();
                            tour.TourCountry = sqlDataReader[0].ToString();
                            tour.TourCity    = sqlDataReader[1].ToString();
                            tour.TourBegin   = Convert.ToDateTime(sqlDataReader[2]);

                            tour.TourEnd      = Convert.ToDateTime(sqlDataReader[3]);
                            tour.MaxSeats     = (int)sqlDataReader[4];
                            tour.CurrentSeats = (int)sqlDataReader[5];
                            tour.DiscountId   = (int)sqlDataReader[6];
                            tour.Price        = Convert.ToDouble(sqlDataReader[7]);
                            tour.Id           = (int)sqlDataReader[8];
                            tours.Add(tour);
                        }
                    }
                    using (SqlDataReader sqlDataReader = sqlComand2.ExecuteReader())
                    {
                        while (sqlDataReader.Read())
                        {
                            Discount discount = new Discount();
                            discount.Type   = sqlDataReader[0].ToString();
                            discount.Number = (int)sqlDataReader[1];
                            discount.Id     = (int)sqlDataReader[2];
                            discounts.Add(discount);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }