public override void Add() { FormColouring f = new FormColouring(); f.Text = GetLocalized("New Colouring"); f.Colouring = new Domain.Colouring(); if (f.ShowDialog(OwnerForm) == DialogResult.OK) { try { ClientEnvironment.ColouringService.SaveOrUpdate(f.Colouring); } catch (EntityException ex) { // 2think: what details should we show? // 2think: how to localize? using (FrmEntityExceptionDetails form = new FrmEntityExceptionDetails(ex)) { form.Text = GetLocalized("CannotSaveColouring"); form.ShowDialog(this); } } } RefreshData(); }
/// <summary> /// Add new item /// </summary> public override void Add() { Employee emp = new Employee(); using (EmployeeFrm frm = new EmployeeFrm()) { frm.Entity = emp; if (frm.ShowDialog(this) == DialogResult.OK) { if (emp.ID == 0) { try { ClientEnvironment.EmployeeService.Save(emp); } catch (EntityException ex) { // 2think: what details should we show? // 2think: how to localize? using (FrmEntityExceptionDetails form = new FrmEntityExceptionDetails(ex)) { form.Text = GetLocalized("CannotSaveEmployee"); form.ShowDialog(this); } } } else { try { ClientEnvironment.EmployeeService.SaveOrUpdate(emp); } catch (EntityException ex) { // 2think: what details should we show? // 2think: how to localize? using (FrmEntityExceptionDetails form = new FrmEntityExceptionDetails(ex)) { form.Text = GetLocalized("CannotSaveEmployee"); form.ShowDialog(this); } } } RefreshData(); } } }
private bool Login() { try { if (ClientEnvironment.ServerStateService.CanInteract) { if (ClientEnvironment.ServerStateService.ServerReady) { LoginResult result = ClientEnvironment.DoLogin(teLogin.Text, tePassword.Text); switch (result) { case LoginResult.Successful: if (ClientEnvironment.AuthorizationService.GetCurrentUser().ShouldChangePassword) { using (ChangePasswordForm cpf = new ChangePasswordForm()) { cpf.SetCaption(Localizer.GetLocalized("ShouldChangePassword")); cpf.ShowDialog(); } } return true; case LoginResult.WrongLogin: case LoginResult.WrongPassword: XtraMessageBox.Show(this, Localizer.GetLocalized("WrongLoginOrPassword"), string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error); break; case LoginResult.UserIsInactive: XtraMessageBox.Show(this, Localizer.GetLocalized("UserIsInactive"), string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error); break; } } } } catch (EntityException ex) { // 2think: how to localize? using (FrmEntityExceptionDetails frm = new FrmEntityExceptionDetails(ex)) { frm.ShowDialog(this); } } catch (Exception ex) { if (ex is SocketException || ex.InnerException is SocketException) { XtraMessageBox.Show(this, Localizer.GetLocalized("ServerIsUnavailable"), string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error); } else { XtraMessageBox.Show(this, ex.Message, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error); } } return false; }
protected virtual void ProcessEntityException(EntityException ex) { using (FrmEntityExceptionDetails form = new FrmEntityExceptionDetails(ex)) { form.Text = GetLocalized("CannotSaveAbsence"); form.ShowDialog(this); } }
public override void Delete() { List<long> ids = new List<long>(); foreach (int rowHandle in mainGridView.GetSelectedRows()) { AbsenceTypeWrapper atw = (AbsenceTypeWrapper)mainGridView.GetRow(rowHandle); ids.Add(atw.AbsenceType.ID); } if (ids.Count == 1) { try { ClientEnvironment.AbsenceTypeService.DeleteByID(ids[0]); } catch (EntityException ex) { // 2think: what details should we show? // 2think: how to localize? using (FrmEntityExceptionDetails form = new FrmEntityExceptionDetails(ex)) { form.Text = GetLocalized("CannotDeleteAbsenceType"); form.ShowDialog(this); } } } else { try { ClientEnvironment.AbsenceTypeService.DeleteListByID(ids); } catch (EntityException) { // can't obtain more details while deleting list ErrorMessage(GetLocalized("SomeAbsenceTypesNotDeleted")); } } RefreshData(); }
public override void Edit() { AbsenceTypeWrapper e = (AbsenceTypeWrapper)mainGridView.GetRow(mainGridView.FocusedRowHandle); if (e == null) { return; } FormAbsenceType f = new FormAbsenceType(); f.Text = GetLocalized("Edit Absence Type"); f.AbsenceType = e; if (f.ShowDialog(OwnerForm) == DialogResult.OK) { f.AbsenceType.DecomposeName(ClientEnvironment.LanguageId); try { ClientEnvironment.AbsenceTypeService.SaveOrUpdate(f.AbsenceType.AbsenceType); } catch (EntityException ex) { // 2think: what details should we show? // 2think: how to localize? using (FrmEntityExceptionDetails form = new FrmEntityExceptionDetails(ex)) { form.Text = GetLocalized("CannotSaveAbsenceType"); form.ShowDialog(this); } } } RefreshData(); }
public override void Add() { FormAbsenceType f = new FormAbsenceType(); f.Text = GetLocalized("New Absence Type"); f.AbsenceType = new AbsenceTypeWrapper(new Domain.AbsenceType(), ""); if (f.ShowDialog(OwnerForm) == DialogResult.OK) { f.AbsenceType.DecomposeName(ClientEnvironment.LanguageId); try { ClientEnvironment.AbsenceTypeService.SaveOrUpdate(f.AbsenceType.AbsenceType); } catch (EntityException ex) { // 2think: what details should we show? // 2think: how to localize? using (FrmEntityExceptionDetails form = new FrmEntityExceptionDetails(ex)) { form.Text = GetLocalized("CannotSaveAbsenceType"); form.ShowDialog(this); } } } RefreshData(); }
public override void Delete() { //XtraMessageBox.Show(this, "Delete", this.Name, MessageBoxButtons.OK); List<long> ids = new List<long>(); foreach (int rowHandle in mainGridView.GetSelectedRows()) { Domain.Colouring col = (Domain.Colouring)mainGridView.GetRow(rowHandle); ids.Add(col.ID); } if (ids.Count == 1) { try { ClientEnvironment.ColouringService.DeleteByID(ids[0]); } catch (EntityException ex) { // 2think: what details should we show? // 2think: how to localize? using (FrmEntityExceptionDetails form = new FrmEntityExceptionDetails(ex)) { form.Text = GetLocalized("CannotDeleteColouring"); form.ShowDialog(this); } } } else { try { ClientEnvironment.ColouringService.DeleteListByID(ids); } catch (EntityException) { // can't obtain more details while deleting list ErrorMessage(GetLocalized("SomeColouringsNotDeleted")); } } RefreshData(); }
public override void Edit() { Domain.Colouring l = (Domain.Colouring)mainGridView.GetRow(mainGridView.FocusedRowHandle); if (l == null) { return; } FormColouring f = new FormColouring(); f.Text = GetLocalized("Edit Colouring"); f.Colouring = l; if (f.ShowDialog(OwnerForm) == DialogResult.OK) { try { ClientEnvironment.ColouringService.SaveOrUpdate(f.Colouring); } catch (EntityException ex) { // 2think: what details should we show? // 2think: how to localize? using (FrmEntityExceptionDetails form = new FrmEntityExceptionDetails(ex)) { form.Text = GetLocalized("CannotSaveColouring"); form.ShowDialog(this); } } } RefreshData(); }
private static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.ThreadException += Application_ThreadException; ClientEnvironment.IsRuntimeMode = true; UCBaseEntity.IsDesignMode = false; DefaultDiction.BuildDefaultResource(); RemotingConfiguration.Configure("Baumax.Client.exe.config", false); // Define channel security IEnumerator channelEnum = ChannelServices.RegisteredChannels.GetEnumerator(); while (channelEnum.MoveNext()) { BasicChannelWithSecurity channel = channelEnum.Current as BasicChannelWithSecurity; if (channel != null) { channel.ITransportContext.IKeyStore.SetKey("/BAUMAX/SES", new KeyProvider_SelfEstablishingSymmetric()); } } if (!DoLogin()) { return; } try { mainForm = new MainForm(); mainForm.Text += String.Format(" - '{0}'", ClientEnvironment.AuthorizationService.GetCurrentUser().LoginName); ClientEnvironment.MainForm = mainForm; RequestNotificationService.Attach(mainForm); GenuineGlobalEventProvider.GenuineChannelsGlobalEvent += GenuineGlobalEventProvider_GenuineChannelsGlobalEvent; ReportLocalizer.InitDevExPreviewLocalizer(); DevExLocalizer.InitDevExLocalizer(); DevExGridLocalizer.InitDevExGridLocalizer(); Application.Run(mainForm); ClientEnvironment.DoLogout(); } catch (EntityException ex) { log.Error("Unhandled", ex); // 2think: how to localize? using (FrmEntityExceptionDetails frm = new FrmEntityExceptionDetails(ex)) { frm.Text = "Unhandled exception"; frm.ShowDialog(); } } catch (Exception ex) { log.Error("Unhandled", ex); MessageBox.Show(ex.ToString(), "Unhandled exception"); } }
private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e) { log.Error("Unhandled", e.Exception); if (e.Exception is EntityException) { // 2think: how to localize? using (FrmEntityExceptionDetails frm = new FrmEntityExceptionDetails(e.Exception as EntityException)) { frm.Text = "Unhandled exception"; frm.ShowDialog(); } } else { MessageBox.Show(e.Exception.ToString(), "Unhandled exception"); } }