コード例 #1
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            lbl.Caption = Chapter == 0 ? $"Introduction to {Book.Title}" : $"{Book.Title} {Chapter}";

            if (Chapter != 0)
            {
                LoadRanges();
            }
            else
            {
                if (!Commentary.Items.Where(x => x.Book == Book.NumberOfBook && x.ChapterBegin == Chapter).Any())
                {
                    var item = new CommentaryItem(Commentary.Session)
                    {
                        Book             = this.Book.NumberOfBook,
                        ChapterBegin     = 0,
                        ChapterEnd       = 0,
                        VerseBegin       = 0,
                        VerseEnd         = 0,
                        Comments         = String.Empty,
                        ParentCommentary = Commentary
                    };
                    item.Save();
                    Commentary.Save();
                    (Commentary.Session as UnitOfWork).CommitChanges();
                }

                LoadRanges();
            }
        }
コード例 #2
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            ConnectionHelper.Connect();

            int commentaryOid = -1;

            using (var uow = new UnitOfWork()) {
                if (!new XPQuery <Commentary>(uow).Any())
                {
                    var commentary = new Commentary(uow)
                    {
                        Abbreviation = String.Empty,
                        Information  = String.Empty,
                        Version      = 4,
                        Title        = String.Empty
                    };

                    using (var dlg = new CommentaryDialog(commentary)) {
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            commentary.Save();
                            uow.CommitChanges();

                            commentaryOid = commentary.Oid;
                        }
                        else
                        {
                            return;
                        }
                    }
                }
                else
                {
                    using (var dlg = new ChooseCommentary()) {
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            commentaryOid = dlg.Commentary.Oid;
                        }
                        else
                        {
                            return;
                        }
                    }
                }
            }

            Application.Run(new MainForm(commentaryOid));
        }
コード例 #3
0
        private void btnAddNew_Click(object sender, EventArgs e)
        {
            var commentary = new Commentary(uow)
            {
                Abbreviation = String.Empty,
                Information  = String.Empty,
                Version      = 4,
                Title        = String.Empty
            };

            using (var dlg = new CommentaryDialog(commentary)) {
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    if (!String.IsNullOrEmpty(commentary.Title))
                    {
                        commentary.Save();
                        uow.CommitChanges();

                        grid.DataSource = new XPQuery <Commentary>(uow).ToList();
                        view.BestFitColumns();
                    }
                }
            }
        }