private void AddMainSecretaryDisposeEvent(object sender, EventArgs e) { Control addMainSecretaryButton = Utils.FindControl(this, "addMainSecretaryButton"); Control personsToMainSecretaryBox = Utils.FindControl(this, "personsToMainSecretaryBox"); //Создаем управляющего секретариатом SecretaryForm form = (SecretaryForm)sender; if (form.CorrectOnClose) { Person person = form.Person; MainSecretary mainSecretary = new MainSecretary(person, chancery.Company, form.Salary); mainSecretary.Persist(); //Добавляем управляющего в секретариат chancery.MainSecretary = mainSecretary; Controls.Remove(addMainSecretaryButton); Controls.Remove(personsToMainSecretaryBox); Controls.Remove((Control)sender); UpdateSecretariesBox(); UpdatePersonsToSecretaryBox(); AddMainSecretaryInfoForms(); } }
private void CommitEditMainSecretaryEvent(object sender, EventArgs e) { Control changeMainSecretaryButton = Utils.FindControl(this, "changeMainSecretaryButton"); Control personsToMainSecretaryBox = Utils.FindControl(this, "personsToMainSecretaryBox"); if (mainSecretaryChanged) { //Удаляем старого управляющего chancery.MainSecretary.Delete(); chancery.MainSecretary = null; //Добавляем нового управляющего mainSecretary.Persist(); chancery.MainSecretary = mainSecretary; Controls.Remove(changeMainSecretaryButton); Controls.Remove(personsToMainSecretaryBox); Controls.Remove((Control)sender); mainSecretaryChanged = false; UpdateSecretariesBox(); UpdatePersonsToSecretaryBox(); AddMainSecretaryInfoForms(); } }