protected void OnDeleteItemClick(object sender, EventArgs e)
        {
            DataGridViewRow row = scene.SelectedRows[0];

            int id = (int)row.Tag;

            using (var transaction = new UnitOfWork())
            {
                try
                {
                    var session = Module.OpenSession();

                    SEPO_FIXTURE_AF_OBJECTS obj = session.Get <SEPO_FIXTURE_AF_OBJECTS>(id);
                    session.Delete(obj);

                    transaction.Commit();

                    scene.Rows.Remove(row);
                }
                catch (Exception)
                {
                    transaction.Rollback();
                    throw;
                }
            }
        }
Exemplo n.º 2
0
        private void OkButton_Click(object sender, EventArgs e)
        {
            if (dialogType == DialogType.Add)
            {
                SEPO_FIXTURE_AF_OBJECTS obj = new SEPO_FIXTURE_AF_OBJECTS();

                obj.ID_TYPE = (int)boTypeBox.SelectedValue;

                if ((int)groupFileBox.SelectedValue != 0)
                {
                    obj.ID_FILE_GROUP = (int)groupFileBox.SelectedValue;
                }

                if ((int)ownerBox.SelectedValue != -1)
                {
                    obj.ID_OWNER = (int)ownerBox.SelectedValue;
                }

                using (var transaction = new UnitOfWork())
                {
                    try
                    {
                        var session = obj_lib.Module.OpenSession();

                        session.Save(obj);

                        transaction.Commit();

                        Id           = obj.ID;
                        DialogResult = DialogResult.OK;
                    }
                    catch (Exception)
                    {
                        transaction.Rollback();
                        throw;
                    }
                }
            }
            else
            {
                var session = obj_lib.Module.OpenSession();

                SEPO_FIXTURE_AF_OBJECTS obj = session.Get <SEPO_FIXTURE_AF_OBJECTS>(Id);

                obj.ID_TYPE = (int)boTypeBox.SelectedValue;

                if ((int)groupFileBox.SelectedValue != 0)
                {
                    obj.ID_FILE_GROUP = (int)groupFileBox.SelectedValue;
                }
                else
                {
                    obj.ID_FILE_GROUP = null;
                }

                if ((int)ownerBox.SelectedValue != -1)
                {
                    obj.ID_OWNER = (int)ownerBox.SelectedValue;
                }
                else
                {
                    obj.ID_OWNER = null;
                }

                using (var transaction = new UnitOfWork())
                {
                    try
                    {
                        session.Update(obj);

                        transaction.Commit();

                        DialogResult = DialogResult.OK;
                    }
                    catch (Exception)
                    {
                        transaction.Rollback();
                        throw;
                    }
                }
            }
        }