Click or drag to resize

ControllerDataGridDataItemClassUpdate Method

Data items was changed update to database.

Namespace:  SOWIWin.Helper
Assembly:  SOWIWin.Helper (in SOWIWin.Helper.dll) Version: 19.1.23.1 (19.1.23.622)
Syntax
Remarks
Validating before data items update into database. Details see Validate. Data item handling:

If property Action is Create then insert to database.

If property Action is Update then update data item in database.

If property Action is Delete then delete data item in database.

Source code of this mehtod Update. Used App object and this methods Insert, Update and Delete

this.PageDataGridUI.DataGridMain.CommitEdit(System.Windows.Controls.DataGridEditingUnit.Row, true);
if (!this.Validate())
{
    return;
}
SOWIData.IDataStandard lItem;
for (int i = 0; i < this.DataItems.Count; i++)
{
    lItem = (SOWIData.IDataStandard)this.DataItems[i];
    if (lItem.ActionDB == SOWIData.Actions.Create)
    {   //* Create -> Insert *
        AppModule.Insert(this.DataItems[i]);
    }
    if (lItem.ActionDB == SOWIData.Actions.Update)
    {   //* Update *
        AppModule.Update(this.DataItems[i]);
    }
    if (lItem.ActionDB == SOWIData.Actions.Delete)
    {   //* Delete *
        AppModule.Delete(lItem.ID);
    }
}
this.Load();
Examples
This example override base class method Update and use static App methods Insert, Update and Delete
/// <summary>
/// Update by static App methods Insert, Update and Delete
/// </summary>
public override void Update()
{
    try
    {
        this.PageDataGridUI.DataGridMain.CommitEdit(System.Windows.Controls.DataGridEditingUnit.Row, true);
        SOWIData.Management.AppOption lItem;
        for (int i = 0; i < this.DataItems.Count; i++)
        {
            lItem = this.DataItems[i];
            if (lItem.ActionDB == SOWIData.Actions.Create)
            {   //* Create -> Insert *
                SOWIApp.Management.AppOption.Insert(lItem, this.ConnectionString, this.UserName);
            }
            if (lItem.ActionDB == SOWIData.Actions.Update)
            {   //* Update *
                SOWIApp.Management.AppOption.Update(lItem, this.ConnectionString, this.UserName);
            }
            if (lItem.ActionDB == SOWIData.Actions.Delete)
            {   //* Delete *
                SOWIApp.Management.AppOption.Delete(lItem.ID, this.ConnectionString, this.UserName);
            }
        }
        this.Load();
    }
    catch (Exception ex)
    {
        SOWIWin.Helper.Message.Show(ref ex);
    }
}
See Also