Exemplo n.º 1
0
 public UserModel(string name, string surname, GenderModel gender, DateTime birthdate, double weight, double height, string cardNumber, DateTime expirationDate, string tariffPlan, int expiredTrainings, int expiredIndividualTrainings)
 {
     Name                       = name;
     Surname                    = surname;
     Gender                     = gender;
     BirthDate                  = birthdate;
     Weight                     = weight;
     Height                     = height;
     CardNumber                 = cardNumber;
     ExpirationDate             = expirationDate;
     TariffPlan                 = tariffPlan;
     ExpiredTrainings           = expiredTrainings;
     ExpiredIndividualTrainings = expiredIndividualTrainings;
 }
Exemplo n.º 2
0
        private void save_Click(object sender, RoutedEventArgs e)
        {
            GenderModel g    = new GenderModel(gender.Text);
            UserModel   user = new UserModel(
                name.Text,
                surname.Text,
                g,
                DateTime.Parse(birthday.Text),
                int.Parse(weight.Text),
                int.Parse(height.Text),
                cardnumber.Text,
                DateTime.Parse(date_exp.Text),
                tariff_plan.Text,
                int.Parse(trains.Text),
                int.Parse(trains_ind.Text)
                );

            this.NavigationService.GoBack();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Возвращает пользователя с указанной картой
        /// </summary>
        /// <returns></returns>
        public UserModel GetUserByCardNumber(string userCardNumber)
        {
            UserModel obj = null;

            using (MySqlConnection connection = new MySqlConnection(connectionString))
            {
                connection.Open();

                MySqlCommand   select_users = new MySqlCommand("SELECT * FROM clients WHERE CardNumber = @cardnumber", connection);
                MySqlParameter genderParam  = new MySqlParameter("@cardnumber", userCardNumber);
                select_users.Parameters.Add(genderParam);

                using (MySqlDataReader user_reader = select_users.ExecuteReader())
                    while (user_reader.Read())
                    {
                        string      name                       = user_reader.GetString(1);
                        string      surname                    = user_reader.GetString(2);
                        GenderModel gender                     = new GenderModel(user_reader.GetString(3));
                        DateTime    birthdate                  = user_reader.GetDateTime(4);
                        double      weight                     = user_reader.GetDouble(5);
                        double      height                     = user_reader.GetDouble(6);
                        string      cardNumber                 = user_reader.GetString(7);
                        DateTime    expirationDate             = user_reader.GetDateTime(8);
                        string      tariffPlan                 = user_reader.GetString(9);
                        int         expiredTrainings           = user_reader.GetInt32(10);
                        int         expiredIndividualTrainings = user_reader.GetInt32(11);

                        obj = new UserModel(
                            name,
                            surname,
                            gender,
                            birthdate,
                            weight,
                            height,
                            cardNumber,
                            expirationDate,
                            tariffPlan,
                            expiredTrainings,
                            expiredIndividualTrainings);
                    }
            }
            return(obj);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Обновляет списки гендеров и клиентов
        /// </summary>
        private void GetUsersData()
        {
            List <GenderModel> genders = new List <GenderModel>();
            List <UserModel>   users   = new List <UserModel>();

            using (MySqlConnection connection = new MySqlConnection(connectionString))
            {
                connection.Open();

                MySqlCommand select_genders = new MySqlCommand("SELECT gender FROM clients", connection);

                using (MySqlDataReader gender_reader = select_genders.ExecuteReader())
                {
                    while (gender_reader.Read())
                    {
                        GenderModel gender = new GenderModel(gender_reader.GetString(0));
                        genders.Add(gender);
                    }
                }
                foreach (GenderModel gender in genders)
                {
                    MySqlCommand   select_users = new MySqlCommand("SELECT * FROM clients WHERE gender = @gender", connection);
                    MySqlParameter genderParam  = new MySqlParameter("@gender", gender.Name);
                    select_users.Parameters.Add(genderParam);

                    using (MySqlDataReader user_reader = select_users.ExecuteReader())
                    {
                        while (user_reader.Read())
                        {
                            int      expiredIndividualTrainings = 0;
                            int      expiredTrainings           = 0;
                            string   name           = user_reader.GetString(1);
                            string   surname        = user_reader.GetString(2);
                            DateTime birthdate      = user_reader.GetDateTime(4);
                            double   weight         = user_reader.GetDouble(5);
                            double   height         = user_reader.GetDouble(6);
                            string   cardNumber     = user_reader.GetString(7);
                            DateTime expirationDate = user_reader.GetDateTime(8);
                            string   tariffPlan     = user_reader.GetString(9);
                            if (user_reader.GetValue(11) != DBNull.Value)
                            {
                                expiredTrainings = user_reader.GetInt32(10);
                            }
                            if (user_reader.GetValue(11) != DBNull.Value)
                            {
                                expiredIndividualTrainings = user_reader.GetInt32(11);
                            }

                            users.Add(new UserModel(
                                          name,
                                          surname,
                                          gender, birthdate,
                                          weight,
                                          height,
                                          cardNumber,
                                          expirationDate,
                                          tariffPlan,
                                          expiredTrainings,
                                          expiredIndividualTrainings));
                        }
                    }
                }
            }
            Users   = users;
            Genders = genders;
        }