コード例 #1
0
        //private static readonly SolidBrush ActiveForeGround = new SolidBrush(ColorTranslator.FromHtml("#FF0000"));
        //private static readonly SolidBrush InactiveForeGround = new SolidBrush(ColorTranslator.FromHtml("#00FF00"));
        #endregion

        #region Internal Method
        /// <summary>
        /// テンプレートのヘッダ一覧を取得する
        /// </summary>
        /// <returns></returns>
        internal List <TemplateListItem> Select()
        {
            var result = new List <TemplateListItem>();

            using (var database = new MyLogDatabase(Constants.DatabaseFile())) {
                database.Open();

                var entity = new TemplateEntity(database);
                using (var recset = entity.Select()) {
                    while (recset.Read())
                    {
                        result.Add(new TemplateListItem()
                        {
                            Id   = recset.GetLong(TemplateEntity.Cols.Id),
                            Name = recset.GetString(TemplateEntity.Cols.Name),
                            Sun  = recset.GetBool(TemplateEntity.Cols.Sun) ? ActiveForeGround : InactiveForeGround,
                            Mon  = recset.GetBool(TemplateEntity.Cols.Mon) ? ActiveForeGround : InactiveForeGround,
                            Tue  = recset.GetBool(TemplateEntity.Cols.Tue) ? ActiveForeGround : InactiveForeGround,
                            Wed  = recset.GetBool(TemplateEntity.Cols.Wed) ? ActiveForeGround : InactiveForeGround,
                            Thu  = recset.GetBool(TemplateEntity.Cols.Thu) ? ActiveForeGround : InactiveForeGround,
                            Fri  = recset.GetBool(TemplateEntity.Cols.Fri) ? ActiveForeGround : InactiveForeGround,
                            Sat  = recset.GetBool(TemplateEntity.Cols.Sat) ? ActiveForeGround : InactiveForeGround
                        });
                    }
                }
            }
            return(result);
        }
コード例 #2
0
ファイル: TemplateRepo.cs プロジェクト: OSN-DEV/MyLog
        /// <summary>
        /// テンプレート情報を全件取得する。
        /// </summary>
        /// <returns>テンプレート情報</returns>
        internal ObservableCollection <TemplateData> Select()
        {
            var result = new ObservableCollection <TemplateData>();

            using (var database = new MyLogDatabase(Constants.DatabaseFile())) {
                database.Open();

                // カテゴリ情報を取得
                var categoryEntity = new CategoryEntity(database);
                var categories     = new Dictionary <long, string>();
                using (var recset = categoryEntity.SelectVisible()) {
                    while (recset.Read())
                    {
                        categories.Add(recset.GetLong(CategoryEntity.Cols.Id),
                                       recset.GetString(CategoryEntity.Cols.Name));
                    }
                }

                var headerEntity = new TemplateEntity(database);
                var detailEntity = new TemplateDetailEntity(database);
                using (var recset = headerEntity.Select()) {
                    while (recset.Read())
                    {
                        // ヘッダ情報を取得
                        var templateData = new TemplateData {
                            Id      = recset.GetLong(TemplateEntity.Cols.Id),
                            Name    = recset.GetString(TemplateEntity.Cols.Name),
                            Sun     = recset.GetBool(TemplateEntity.Cols.Sun),
                            Mon     = recset.GetBool(TemplateEntity.Cols.Mon),
                            Tue     = recset.GetBool(TemplateEntity.Cols.Tue),
                            Wed     = recset.GetBool(TemplateEntity.Cols.Wed),
                            Thu     = recset.GetBool(TemplateEntity.Cols.Thu),
                            Fri     = recset.GetBool(TemplateEntity.Cols.Fri),
                            Sat     = recset.GetBool(TemplateEntity.Cols.Sat),
                            LogList = new ObservableCollection <TemplateDetailData>()
                        };

                        // 明細情報を取得
                        SelectDetailByTemplateId(templateData.LogList, detailEntity, templateData.Id, categories);

                        result.Add(templateData);
                    }
                }
            }
            return(result);
        }