Esempio n. 1
0
        protected override void btnEdit_Clicked(object o, EventArgs args)
        {
            int selectedRow = grid.FocusedRow;

            if (selectedRow < 0)
            {
                return;
            }

            Location location = entities [selectedRow];

            selectedId = location.Id;

            // Added transaction to ensure that we are connected to the same server in case of
            // master-slave replication
            using (new DbMasterScope(BusinessDomain.DataAccessProvider)) {
                using (EditNewLocation dialog = new EditNewLocation(location, selectedGroupId)) {
                    if (dialog.Run() != ResponseType.Ok)
                    {
                        ReinitializeGrid(true, null);
                        return;
                    }

                    location = dialog.GetLocation().CommitChanges();
                }

                OnEntitiesChanged(location.Deleted ? LocationsGroup.DeletedGroupId : location.GroupId);
            }
        }
Esempio n. 2
0
        protected override void btnNew_Clicked(object o, EventArgs args)
        {
            selectedId = null;

            // Added transaction to ensure that we are connected to the same server in case of
            // master-slave replication
            using (new DbMasterScope(BusinessDomain.DataAccessProvider)) {
                Location location;
                using (EditNewLocation dialog = new EditNewLocation(null, selectedGroupId)) {
                    if (dialog.Run() != ResponseType.Ok)
                    {
                        ReinitializeGrid(true, null);
                        return;
                    }

                    location   = dialog.GetLocation().CommitChanges();
                    selectedId = location.Id;
                }

                OnEntitiesChanged(location.GroupId);

                if (BusinessDomain.AppConfiguration.DocumentNumbersPerLocation)
                {
                    using (EditDocumentNumbersPerLocation editDocumentNumbersPerLocation = new EditDocumentNumbersPerLocation(selectedId.Value))
                        editDocumentNumbersPerLocation.Run();
                }
            }
        }