ControllerDataGridDataItemClassUpdate Method |
Namespace: SOWIWin.Helper
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();
/// <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); } }