Beispiel #1
0
        /// <summary>
        /// Добавляет указанного спортсмена в базу данных
        /// </summary>
        /// <param name="people"></param>
        /// <returns></returns>
        public void AddAthlete(Athlete athlete)
        {
            using (SQLiteCommand cmd = connection.CreateCommand())
            {
                Dictionary<String, String> data = new Dictionary<string, string>();
                data.Add("sportTypeId", athlete.sportTypeId.ToString());
                data.Add("sportCategoryId", athlete.sportCategoryId.ToString());
                data.Add("address", athlete.address);
                data.Add("place", athlete.place);
                data.Add("userId", athlete.userId.ToString());
                data.Add("createDate", athlete.createDateInt64.ToString());

                bool ok = Insert(cmd, TABLE_ATHLETE, data);

                if (!ok)
                    throw new Exception("Не удалось добавить спортсмена!");
            }
        }
        /// <summary>
        /// Загружает информацию о текущем пользователе в контролы
        /// </summary>
        private void LoadUser()
        {
            user = sqlite.GetUser(userId);
            athlete = sqlite.GetAthleteByUserId(user.id);

            tbName.Text = string.Format("{0} {1} {2}", user.name, user.lastName, user.fatherName);
            tbBDay.Text = user.bDay;
            tbAddress.Text = athlete.address;
            tbPhone.Text = user.phone;
            tbPlace.Text = athlete.place;
            cbSportCategory.Text = sqlite.GetValueById(SQLite.TABLE_SPORT_CATEGORY, athlete.sportCategoryId);
            cbSportType.Text = sqlite.GetValueById(SQLite.TABLE_SPORT_TYPE, athlete.sportTypeId);
            cbSex.Text = user.sex;
            tbLogin.Text = user.login;
            tbPassword.Password = user.password;
        }