private void bindingItem_ListChanged(object sender, ListChangedEventArgs e) { /* This event will be called several times during form initialization. * We don't want to do anything with it until the runtime author * list has been passed in. */ // Exit if no parent InvoiceItem parent = (InvoiceItem)bindingInvoice.Current; if (parent == null) { return; } // Get the item affected int index = e.NewIndex; rotiItem changedItem = null; if ((index > -1) && (index < parent.Items.Count)) { changedItem = parent.Items[index]; } // Get the type of change that occured ListChangedType changeType = e.ListChangedType; /* We only need to respond to two types of changes here; updates * and moves. Adds are handled by bindingSourceAuthors_AddingNew(), * and deletes are handled by menuItemBooksDelete_Click(). */ // Dispatch a change handler switch (changeType) { case ListChangedType.ItemChanged: if (changedItem.ItemCode != null) { CommandUpdateItem updateItem = new CommandUpdateItem(changedItem); m_AppController.ExecuteCommand(updateItem); } else { CommandDeleteItem deleteItem = new CommandDeleteItem(changedItem); m_AppController.ExecuteCommand(deleteItem); } break; case ListChangedType.ItemMoved: // Not supported in this app break; } m_Invoices.ResetBindings(); }
public IActionResult UpdateProduct([FromBody] CommandUpdateItem command, [FromServices] HandlerCatalogItem handler, int id) { if (id != command.Id) { return(BadRequest(new { Code = "400", Description = "O Id do parametro e do body estão divergentes" })); } var request = handler.handle(command); if (request.HasError()) { return(BadRequest(request.Error())); } return(Ok(request.ResponseObj())); }
private void itemMasterBindingSource_ListChanged(object sender, ListChangedEventArgs e) { /* This event will be called several times during form initialization. * We don't want to do anything with it until the runtime authors * list has been passed in. */ // Exit if no project list if (m_ItemList == null) { return; } // Get the item affected int index = e.NewIndex; itemMaster changedItem = null; if ((index > -1) && (index < m_ItemList.Count)) { changedItem = m_ItemList[index]; } // Get the type of change that occured ListChangedType changeType = e.ListChangedType; /* We only need to respond to two types of changes here; updates * and moves. Adds are handled by bindingSourceProjects_AddingNew(), * and deletes are handled by menuItemAuthorsDelete_Click(). */ // Dispatch a change handler switch (changeType) { case ListChangedType.ItemChanged: CommandUpdateItem updateAuthor = new CommandUpdateItem(changedItem); m_AppController.ExecuteCommand(updateAuthor); break; case ListChangedType.ItemMoved: // Not supported in this app break; } }
private void saveBtn_Click(object sender, EventArgs e) { if (m_ItemList == null) { return; } itemMaster m_item = (itemMaster)itemMasterBindingSource.Current; if (isNewRecord) { CommandCreateItem createItem = new CommandCreateItem(m_item); itemMaster newItem = (itemMaster)m_AppController.ExecuteCommand(createItem); } else if (!isNewRecord) { CommandUpdateItem updateItem = new CommandUpdateItem(m_item); itemMaster changeItem = (itemMaster)m_AppController.ExecuteCommand(updateItem); } isNewRecord = false; }
private void simpanBtn_Click(object sender, EventArgs e) { if (invoiceItemBindingSource.Current == null) { return; } InvoiceItem currentInvoice = (InvoiceItem)invoiceItemBindingSource.Current; switch (FrmStatus) { case FormStatus.OnEditMode: FrmStatus = FormStatus.Ready; CommandUpdateInvoice updateInvoice = new CommandUpdateInvoice(currentInvoice); m_AppController.ExecuteCommand(updateInvoice); foreach (DataGridViewRow row in dgItem.Rows) { rotiItem item = row.DataBoundItem as rotiItem; if (item != null) { CommandUpdateItem updateItem = new CommandUpdateItem(item); m_AppController.ExecuteCommand(updateItem); } } break; case FormStatus.Ready: FrmStatus = FormStatus.OnEditMode; break; case FormStatus.NewRecord: CommandInsertByDetailInvoice newInvoice = new CommandInsertByDetailInvoice(currentInvoice); m_AppController.ExecuteCommand(newInvoice); break; } }