UIControllerRowChanged Property

Gets the value determining REEDITindicating that the current row was changed, and will be save to the database, after the SavingRow event will execute.

Definition

Namespace: Firefly.Box
Assembly: Firefly.Box (in Firefly.Box.dll) Version: debug-master-v:33791
C#
public bool RowChanged { get; }

Property Value

Boolean

Remarks

The RowChanged property is set to true, if the value of a column that is part of the Columns property collection was changed.
A Column value can change without settings the RowChanged property, if the column's OnChangeMarkRowAsChanged property is set to false, or if the value was set using the fixme method.
The RowChanged property affects the behavior of SavingRow event, see it for in depth coverage of the subject.

Example

RowChanged and SavingRow
This example is based on test data. The code for the entities included in this test data can be found in the documentation of Entity
This example uses automatic tools to generate parts of the user interface. Those tools can be found in the example of the documentation of Form
C#
using Firefly.Box;
using Firefly.Box.UI;

namespace TestFirefly.Box.Documentation
{
    class RowChangedDemo
    {
        public void Run()
        {
            var jobs = new Pubs.Jobs();
            jobs.InitializeWithTestData();

            var uic = new UIController()
            {
                From = jobs,
                View = UITools.GenerateFormWithGridFor(
                "RowChanged and SavingRow Demo",
                "This example demonstrates the deferent scenarios regarding the RowChanged property.\n" +
                "\nA. Initial State:\n" +
                "        Click the \"Check If Row Was Changed\" button and you'll see that the row was NOT changed.\n" +
                "\nB. User Changed a Value:\n" +
                "   1. Change the job's description.\n" +
                "   2. Click the \"Check If Row Was Changed\" button and you'll see that the row was changed.\n" +
                "   3. Click the \"Undo Changes In Row\" and you'll see that the change was reverted.\n" +
                "   4. Click the \"Check If Row Was Changed\" button and you'll see that the row was NOT changed.\n" +
                "\nC. Value Changes Done In Code:\n" +
                "   1. Click the \"Add 1 to Min Level\" you'll see that the value of Min Level was changed.\n" +
                "   2. Click the \"Check If Row Was Changed\" button and you'll see that the row was changed.\n" +
                "   3. Click the \"Undo Changes In Row\" and you'll see that the change was reverted.\n" +
                "   4. Click the \"Check If Row Was Changed\" button and you'll see that the row was NOT changed.\n" +
                "\nD. Changes to a column set to \"OnChangeMarkRowAsChanged = false\".\n"+
                "        A change to a value of such a column, doesn't set the RowChanged property.\n" +
                "   1. Change the job's Max Level Value.\n" +
                "   2. Click the \"Check If Row Was Changed\" button and you'll see that the row was NOT changed.\n" +
                "   3. Leave the row and reenter it, you'll see that the value of max level, returned to it's original one.\n" +
                "      Because the RowChanged property was not set, the SavingRow event didn't happen, and the\n" +
                "      changes were not saved to the database.\n" +
                "   4. Click the \"Add 1 to Max Level\" you'll see that the value of Max Level was changed.\n" +
                "   5. Click the \"Check If Row Was Changed\" button and you'll see that the row was NOT changed.\n" +
                "\nE. Setting a value using the \"SilentSet\" method:\n" +
                "   1. Click the \"Add 1 to Min Level Without Marking Row As Changed\".\n" +
                "   2. Click the \"Check If Row Was Changed\" button and you'll see that the row was NOT changed.\n\n"+
                "Thank you for your patience. ",
                                         jobs.Id,
                                         jobs.Description,
                                         jobs.MinLevel,
                                         jobs.MaxLevel)
            };

            jobs.MaxLevel.OnChangeMarkRowAsChanged = false;


            var btnSetMinLevel = new Button
            {
                Text = "Add 1 to Min Level",
                Width = 150
            };
            btnSetMinLevel.Click += (a, b) => jobs.MinLevel.Value++;

            var btnSetMinLevelWithoutMarkingRowAsChanged = new Button
            {
                Text =
                    "Add 1 to Min Level Without Marking Row As Changed",
                Width = 305
            };
        //    btnSetMinLevelWithoutMarkingRowAsChanged.Click +=
        //        (a, b) => jobs.MinLevel.SilentSet(jobs.MinLevel + 1);

            var btnSetMaxLevel = new Button
            {
                Text = "Add 1 To Max Level",
                Width = 150
            };
            btnSetMaxLevel.Click += (a, b) => jobs.MaxLevel.Value++;

            var btnCheckRowChanged = new Button
            {
                Text = "Check If Row Was Changed",
                Width = 150
            };
            btnCheckRowChanged.Click += (a, b) =>
                                        System.Windows.Forms.MessageBox.Show("Row was " +
                                                                             (uic.RowChanged ? "Changed" : "NOT Changed"));

            var btnUndoChangesInRow = new Button
            {
                Text = "Undo Changes In Row",
                Width = 150
            };
            btnUndoChangesInRow.Click += (a, b) => uic.Raise(Command.UndoChangesInRow);

            uic.SavingRow += ( b) => System.Windows.Forms.MessageBox.Show("Changes are being saved to the database");

            UITools.AddControlsToForm(uic.View, btnCheckRowChanged, btnUndoChangesInRow);
            UITools.AddControlsToForm(uic.View, btnSetMinLevel, btnSetMaxLevel);
            UITools.AddControlsToForm(uic.View, btnSetMinLevelWithoutMarkingRowAsChanged);

            uic.Run();
        }
    }
}

See Also