示例#1
0
        /// <summary>
        /// Пополнение справочника видов работ
        /// </summary>
        /// <param name="athlete"></param>
        public void AddWorkoutType(WorkoutType wt)
        {
            using (SQLiteCommand cmd = connection.CreateCommand())
            {
                Dictionary<String, String> data = new Dictionary<string, string>();
                data.Add("value", wt.value.ToString());

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

                if (!ok)
                    throw new Exception("Не удалось добавить значение в справочник типов тренировок!");
            }
        }
 private void buttonAdd_Click(object sender, RoutedEventArgs e)
 {
     if (comboBoxReferenceBook.Text.Equals(referencesNames[0]))
     {
         SportType st = new SportType(0, textBoxReferenceBookAddValue.Text);
         sqlite.AddSportType(st);
     }
     else if (comboBoxReferenceBook.Text.Equals(referencesNames[1]))
     {
         MusclesGroup mg = new MusclesGroup(0, textBoxReferenceBookAddValue.Text);
         sqlite.AddMusclesGroup(mg);
     }
     else if (comboBoxReferenceBook.Text.Equals(referencesNames[2]))
     {
         byte sportTypeId = (byte)sqlite.GetIdByValue(SQLite.TABLE_SPORT_TYPE, comboBoxSportTypes.Text);
         WorkType wt = new WorkType(0, sportTypeId, textBoxReferenceBookAddValue.Text, userId);
         sqlite.AddWorkType(wt);
     }
     else if (comboBoxReferenceBook.Text.Equals(referencesNames[3]))
     {
         WorkoutType wt = new WorkoutType(0, textBoxReferenceBookAddValue.Text);
         sqlite.AddWorkoutType(wt);
     }
     else if (comboBoxReferenceBook.Text.Equals(referencesNames[4]))
     {
         WorkoutPlanType wt = new WorkoutPlanType(0, textBoxReferenceBookAddValue.Text);
         sqlite.AddWorkoutPlanType(wt);
     }
     SetAllValuesToListBox();
     textBoxReferenceBookAddValue.Text = "";
 }