예제 #1
0
        public override void edit(int id)
        {
            Format Format = (from p in db.Format
                             where p.Id == id
                             select p).FirstOrDefault();

            FormatForm FormatViewer = new FormatForm();

            FormatViewer.mainEntity = Format;
            FormatViewer.controller = this;

            if (FormatViewer.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                db.SaveChanges();
            }
        }
예제 #2
0
        public override void add()
        {
            try
            {
                Format     Format       = new Format(); // initilize entity
                FormatForm FormatViewer = new FormatForm();
                FormatViewer.mainEntity = Format;
                FormatViewer.controller = this;

                if (FormatViewer.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    db.Format.Add(Format); //add format to db
                    db.SaveChanges();
                }
            }
            catch (System.InvalidOperationException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }