Exemplo n.º 1
0
 public frmConflict(ucConflicts ucConflicts)
 {
     InitializeComponent();
     ucConflicts.Dock = DockStyle.Fill;
     this.Controls.Add(ucConflicts);
 }
Exemplo n.º 2
0
        private bool SaveData()
        {
            try
            {
                BeforeDataSave?.Invoke(this, new EventArgs());

                this.PostEditor();

                if (dxValidationProvider != null)
                {
                    if (!dxValidationProvider.Validate())
                    {
                        return(false);
                    }
                }

                if (this.DataContext != null)
                {
                    this.ShowProgressPanel();

                    this.DataContext.SubmitChanges(ConflictMode.ContinueOnConflict);
                    this.SetMode(Mode.Default);
                }

                DataSaved?.Invoke(this, new EventArgs());
                return(true);
            }
            catch (ChangeConflictException e)
            {
                this.CloseProgressPanel();

                ucConflicts ucConflicts = new ucConflicts();

                if (this.DataContext.ChangeConflicts.Count > 0)
                {
                    foreach (System.Data.Linq.ObjectChangeConflict objectChangeConflict in this.DataContext.ChangeConflicts)
                    {
                        if (objectChangeConflict.IsDeleted)
                        {
                            Conflict conflict = new Conflict();
                            conflict.Message     = "Der Datensatz existiert nicht mehr";
                            conflict.RefreshMode = RefreshMode.KeepChanges;
                            ucConflicts.Conflicts.Add(conflict);

                            //Database.tsysClient client = this.DataContext.ChangeConflicts[0].Object as Database.tsysClient;
                            //XtraMessageBox.Show(System.String.Format("Der Datensatz <b>\"{0}\"</b> existiert in der Datenbank nicht mehr.", client.Name), "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, DevExpress.Utils.DefaultBoolean.True);
                        }
                        else if (objectChangeConflict.MemberConflicts.Count > 0 &&
                                 objectChangeConflict.MemberConflicts[0].IsModified)
                        {
                            Conflict conflict = new Conflict();
                            conflict.Message     = "Der Datensatz wurde in der Datenbank geändert";
                            conflict.RefreshMode = RefreshMode.KeepChanges;
                            ucConflicts.Conflicts.Add(conflict);


                            //Database.tsysClient client = this.DataContext.ChangeConflicts[0].Object as Database.tsysClient;
                            //XtraMessageBox.Show(
                            //    System.String.Format(
                            //        "Der Datensatz <b>\"{0}\"</b> wurde in der Datenbank geändert. Datenbankwert: {2}, Neuer Wert: {1}",
                            //        this.DataContext.ChangeConflicts[0].MemberConflicts[0].Member.Name,
                            //        this.DataContext.ChangeConflicts[0].MemberConflicts[0].CurrentValue,
                            //        this.DataContext.ChangeConflicts[0].MemberConflicts[0].DatabaseValue),
                            //        "Fehler",
                            //        MessageBoxButtons.OK,
                            //        MessageBoxIcon.Exclamation,
                            //        DevExpress.Utils.DefaultBoolean.True);
                        }
                    }
                    //this.DataContext.ChangeConflicts.ResolveAll(RefreshMode.KeepChanges);

                    frmConflict frm = new frmConflict(ucConflicts);
                    frm.ShowDialog();
                }



                return(false);
            }
            catch (SqlException exception)
            {
                this.CloseProgressPanel();

                if (exception.Number == 547) // Constraint error
                {
                    XtraMessageBox.Show("Datensatz wird noch von anderer Stelle referenziert und kann daher nicht gelöscht werden.", "Hinweis", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    XtraMessageBox.Show(exception.ToString(), "Hinweis", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }

                return(false);
            }
            catch (Exception err)
            {
                this.CloseProgressPanel();

                XtraMessageBox.Show(err.ToString(), "Hinweis", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(false);
            }
            finally
            {
                this.CloseProgressPanel();
            }
        }