private void btnSaveAndNew_Clicked(object o, EventArgs args)
        {
            long oldId = location.Id;

            location.Id = -1;
            if (!Validate())
            {
                location.Id = oldId;
                return;
            }

            var saved = GetLocation().CommitChanges();

            if (BusinessDomain.AppConfiguration.DocumentNumbersPerLocation)
            {
                using (EditDocumentNumbersPerLocation dialog = new EditDocumentNumbersPerLocation(saved.Id))
                    dialog.Run();
            }

            if (oldId > 0)
            {
                dlgEditNewLocation.Respond(ResponseType.Ok);
                return;
            }

            location = null;
            InitializeEntries();

            txtName.Text = saved.Name;
        }
Exemple #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();
                }
            }
        }