Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            Context c = new Context
            {
                ContextName      = this.ContextName,
                CreationDateTime = DateTime.Now
            };

            try
            {
                _contextService.Create(c);
            }
            catch (DatabaseException)
            {
                MessageBox.Show("Already exists.");
                return;
            }

            button1.Enabled     = false;
            textBoxName.Enabled = false;
            labelID.Text        = c.Id.ToString();
        }
Пример #2
0
        private void btnCreateContext_Click(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(txtContextName.Text))
            {
                Context c = new Context
                {
                    ContextName      = txtContextName.Text,
                    CreationDateTime = DateTime.Now
                };
                try
                {
                    var contextService = new ContextService();
                    contextService.Create(c);
                }
                catch (DatabaseException)
                {
                    MessageBox.Show("Already exists.");
                    return;
                }

                Switcher.Switch(new StartingPage());
            }
        }