コード例 #1
0
ファイル: NutritionStandards.cs プロジェクト: igprog/ppweb
    public NewNutritionStandard GetData(SQLiteDataReader reader, string[] translations, string lang)
    {
        NewNutritionStandard x = new NewNutritionStandard();

        x.code  = reader.GetValue(0) == DBNull.Value ? null : reader.GetString(0);
        x.title = reader.GetValue(1) == DBNull.Value ? null : T.Tran(reader.GetString(1), translations, string.IsNullOrEmpty(lang) ? "hr" : lang);
        x.desc  = reader.GetValue(2) == DBNull.Value ? null : T.Tran(reader.GetString(2), translations, string.IsNullOrEmpty(lang) ? "hr" : lang);
        Diets D = new Diets();

        x.diet    = D.GetDietData(reader.GetValue(3) == DBNull.Value ? null : reader.GetString(3), lang);
        x.energy  = reader.GetValue(4) == DBNull.Value ? 0 : Convert.ToDouble(reader.GetString(4));
        x.age     = reader.GetValue(5) == DBNull.Value ? null : reader.GetString(5);
        x.gender  = reader.GetValue(6) == DBNull.Value ? null : reader.GetString(6);
        x.country = reader.GetValue(7) == DBNull.Value ? null : reader.GetString(7);
        return(x);
    }
コード例 #2
0
ファイル: NutritionStandards.cs プロジェクト: igprog/ppweb
    public NewNutritionStandard GetNutritionStandardData(string code, string lang)
    {
        NewNutritionStandard x = new NewNutritionStandard();

        try {
            string[] translations = T.Translations(lang);
            using (SQLiteConnection connection = new SQLiteConnection("Data Source=" + Server.MapPath("~/App_Data/" + appDataBase))) {
                connection.Open();
                string sql = string.Format(@"SELECT code, title, description, diet, energy, age, gender, country FROM nutritionStandards WHERE code = '{0}'", code);
                using (SQLiteCommand command = new SQLiteCommand(sql, connection)) {
                    using (SQLiteDataReader reader = command.ExecuteReader()) {
                        while (reader.Read())
                        {
                            x = GetData(reader, translations, lang);
                        }
                    }
                }
            }
            return(x);
        } catch (Exception e) {
            L.SendErrorLog(e, null, null, "NutritionStandards", "GetNutritionStandardData");
            return(x);
        }
    }