private void okButton_Click(object sender, EventArgs e) { if (passwordTextBox.Text != repasswordTextBox.Text) { MessageBox.Show("Hasło i powtórzone hasło nie zgadzają się", "EnovaTools", MessageBoxButtons.OK, MessageBoxIcon.Error); passwordTextBox.Focus(); passwordTextBox.SelectAll(); canClose = false; } else { WebContext dc = Enova.Business.Old.Core.ContextManager.WebContext; Enova.Business.Old.DB.Web.User user = (Enova.Business.Old.DB.Web.User) this.DataSource; ((Enova.Business.Old.DB.Web.User)DataSource).Password = passwordTextBox.Text; ((Enova.Business.Old.DB.Web.User)DataSource).Encrypt(); if (user.EntityState != System.Data.EntityState.Added && user.EntityState != System.Data.EntityState.Detached) { if (!profiles.ContainsKey("SYNCH_AGENT_KODE")) { var prof = new SynchProfileItem() { TableName = "Users", Parent = user.ID, Type = "bool", Key = "SYNCH_AGENT_KODE" }; dc.AddToSynchProfileItems(prof); profiles.Add("SYNCH_AGENT_KODE", prof); } profiles["SYNCH_AGENT_KODE"].Value = synchAgentKodeTextBox.Text; if (!profiles.ContainsKey("SYNCH_KONTRAH_ENABLED")) { var prof = new SynchProfileItem() { TableName = "Users", Parent = user.ID, Type = "bool", Key = "SYNCH_KONTRAH_ENABLED" }; dc.AddToSynchProfileItems(prof); profiles.Add("SYNCH_KONTRAH_ENABLED", prof); } profiles["SYNCH_KONTRAH_ENABLED"].Value = synchKontrahEnabledCheckBox.Checked.ToString(); if (!profiles.ContainsKey("SYNCH_KONTRAH_FILTR_AGENT")) { var prof = new SynchProfileItem() { TableName = "Users", Parent = user.ID, Type = "bool", Key = "SYNCH_KONTRAH_FILTR_AGENT" }; dc.AddToSynchProfileItems(prof); profiles.Add("SYNCH_KONTRAH_FILTR_AGENT", prof); } profiles["SYNCH_KONTRAH_FILTR_AGENT"].Value = synchKontrahFiltrAgentCheckBox.Checked.ToString(); if (!profiles.ContainsKey("SYNCH_TOWARY_ENABLED")) { var prof = new SynchProfileItem() { TableName = "Users", Parent = user.ID, Type = "bool", Key = "SYNCH_TOWARY_ENABLED" }; dc.AddToSynchProfileItems(prof); profiles.Add("SYNCH_TOWARY_ENABLED", prof); } profiles["SYNCH_TOWARY_ENABLED"].Value = synchTowaryEnabledCheckBox.Checked.ToString(); if (!profiles.ContainsKey("SYNCH_ZAMOWIENIA_ENABLED")) { var prof = new SynchProfileItem() { TableName = "Users", Parent = user.ID, Type = "bool", Key = "SYNCH_ZAMOWIENIA_ENABLED" }; dc.AddToSynchProfileItems(prof); profiles.Add("SYNCH_ZAMOWIENIA_ENABLED", prof); } profiles["SYNCH_ZAMOWIENIA_ENABLED"].Value = synchZamowEnabledCheckBox.Checked.ToString(); if (!profiles.ContainsKey("SYNCH_ZAMOWIENIA_FILTR_AGENT")) { var prof = new SynchProfileItem() { TableName = "Users", Parent = user.ID, Type = "bool", Key = "SYNCH_ZAMOWIENIA_FILTR_AGENT" }; dc.AddToSynchProfileItems(prof); profiles.Add("SYNCH_ZAMOWIENIA_FILTR_AGENT", prof); } profiles["SYNCH_ZAMOWIENIA_FILTR_AGENT"].Value = synchZamFiltrAgentCheckBox.Checked.ToString(); } canClose = true; Close(); } }