Ejemplo n.º 1
0
        private async void editbtn_Click(object sender, EventArgs e)
        {
            Notifications obj = notificationsBindingSource.Current as Notifications;

            if (obj != null)
            {
                using (notificationsaddform notifiadd = new notificationsaddform(obj))
                {
                    if (notifiadd.ShowDialog() == DialogResult.OK)
                    {
                        try
                        {
                            notificationsBindingSource.EndEdit();
                            await test.SaveChangesAsync();

                            MessageBox.Show("Успешно изменено");
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private async void addbtn_Click(object sender, EventArgs e)
        {
            using (notificationsaddform notifiadd = new notificationsaddform(new Notifications()))
            {
                if (notifiadd.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        notificationsBindingSource.Add(notifiadd.NotificationInfo);
                        test.Notifications.Add(notifiadd.NotificationInfo);
                        await test.SaveChangesAsync();

                        MessageBox.Show("Успешно добавлено");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }