/// <summary> /// Edit rows /// </summary> /// <param name="sender"></param> /// <param name="args"></param> public void dataGrid_RowValidated(object sender, Syncfusion.UI.Xaml.Grid.RowValidatedEventArgs args) { CustomerDatabaseEntities context = new CustomerDatabaseEntities(); Customer_Details newRecord = args.RowData as Customer_Details; if (sender == null) { return; } Customer_Details order = context.Customer_Details.First(i => i.customerID == newRecord.customerID); if (newRecord != null) { order.customerID = newRecord.customerID; order.email = newRecord.email; order.password = newRecord.password; order.firstName = newRecord.firstName; order.lastName = newRecord.lastName; order.address = newRecord.address; order.city = newRecord.city; order.state = newRecord.state; order.postcode = newRecord.postcode; order.dateOfBirth = newRecord.dateOfBirth; order.dateCreated = newRecord.dateCreated; } context.Entry(order).State = EntityState.Modified; context.SaveChanges(); context.Dispose(); }
/// <summary> /// Changes record /// </summary> /// <param name="sender"></param> /// <param name="args"></param> public void dataGrid_RowValidated(object sender, Syncfusion.UI.Xaml.Grid.RowValidatedEventArgs args) { Employee_Details newRecord = args.RowData as Employee_Details; Employee_Details order = context.Employee_Details.First(i => i.employeeID == newRecord.employeeID); order.employeeID = newRecord.employeeID; order.email = newRecord.email; order.password = newRecord.password; order.firstName = newRecord.firstName; order.lastName = newRecord.lastName; context.Entry(order).State = EntityState.Modified; context.SaveChanges(); }
/// <summary> /// Adds record /// </summary> /// <param name="sender"></param> /// <param name="args"></param> public void dataGrid_RowValidated(object sender, Syncfusion.UI.Xaml.Grid.RowValidatedEventArgs args) { Ticket_Details newRecord = args.RowData as Ticket_Details; Ticket_Details order = context.Ticket_Details.First(i => i.ticketId == newRecord.ticketId); order.ticketId = newRecord.ticketId; order.eventTitle = newRecord.eventTitle; order.eventStart = newRecord.eventStart; order.eventEnd = newRecord.eventEnd; order.price = newRecord.price; order.seatLocation = newRecord.seatLocation; context.Entry(order).State = EntityState.Modified; context.SaveChanges(); }
/// <summary> /// Adds record /// </summary> /// <param name="sender"></param> /// <param name="args"></param> public void dataGrid_RowValidated(object sender, Syncfusion.UI.Xaml.Grid.RowValidatedEventArgs args) { Event_Details newRecord = args.RowData as Event_Details; Event_Details order = context.Event_Details.First(i => i.eventID == newRecord.eventID); order.eventID = newRecord.eventID; order.eventAddress = newRecord.eventAddress; order.eventDescription = newRecord.eventDescription; order.capacity = newRecord.capacity; order.eventStart = newRecord.eventStart; order.eventEnd = newRecord.eventEnd; order.eventLocation = newRecord.eventLocation; order.eventPicture = newRecord.eventPicture; order.eventTitle = newRecord.eventTitle; order.eventGenre = newRecord.eventGenre; order.showOnHomePage = newRecord.showOnHomePage; context.Entry(order).State = EntityState.Modified; context.SaveChanges(); }
internal bool RaiseRowValidate(RowColumnIndex currentCellIndex) { if (IsCurrentRowValidated) { return(true); } #if WinRT || UNIVERSAL // In winrt and universal , the datagrid is from click notification. where we need to call parent validation to raise the cell validation for child grid. if (dataGrid is DetailsViewDataGrid) { var parentDataGrid = dataGrid.GetParentDataGrid(); if (parentDataGrid.SelectedDetailsViewGrid == null || (parentDataGrid.SelectedDetailsViewGrid != null && dataGrid != parentDataGrid.SelectedDetailsViewGrid)) { return(parentDataGrid.ValidationHelper.RaiseRowValidate(parentDataGrid.SelectionController.CurrentCellManager.CurrentRowColumnIndex)); } } #endif if (dataGrid.IsInDetailsViewIndex(currentCellIndex.RowIndex)) { if (dataGrid.SelectionController is GridBaseSelectionController) { var currentDetailsViewGrid = (dataGrid.SelectionController as GridBaseSelectionController).GetCurrentDetailsViewGrid(dataGrid); return(currentDetailsViewGrid.ValidationHelper.RaiseRowValidate(currentDetailsViewGrid.SelectionController.CurrentCellManager.CurrentRowColumnIndex)); } } var dataRow = dataGrid.RowGenerator.Items.FirstOrDefault(item => item.RowIndex == currentCellIndex.RowIndex); if (dataRow == null) { return(true); } errorMessages = new Dictionary <string, string>(); rowIndex = dataRow.RowIndex; var validatingArgs = new RowValidatingEventArgs(dataRow.WholeRowElement.DataContext, currentCellIndex.RowIndex, errorMessages, dataGrid); if (!dataGrid.RaiseRowValidatingEvent(validatingArgs)) { dataRow.VisibleColumns.ForEach (datacolbase => { if (datacolbase.GridColumn == null) { return; } if (datacolbase.ColumnElement == null) { return; } var currentCell = datacolbase.ColumnElement as GridCell; if (currentCell == null) { return; } if (validatingArgs.ErrorMessages.ContainsKey(datacolbase.GridColumn.MappingName)) { currentCell.SetRowValidationError(validatingArgs.ErrorMessages[datacolbase.GridColumn.MappingName]); } else { if (currentCell.HasError) { currentCell.RemoveRowValidationError(); } } }); dataRow.WholeRowElement.SetError(); if (!dataRow.IsEditing) { dataGrid.SelectionController.CurrentCellManager.BeginEdit(); } //WPF-31495 - Set CurrentCellVaildate only for isEditing datarow. if (dataRow.IsEditing) { SetCurrentCellValidated(false); } return(false); } else { RemoveError(dataRow, false); } var args = new RowValidatedEventArgs(validatingArgs.RowData, validatingArgs.RowIndex, validatingArgs.ErrorMessages, dataGrid); dataGrid.RaiseRowValidatedEvent(args); SetCurrentRowValidated(true); //this.dataGrid.VisualContainer.SuspendManipulationScroll = false; errorMessages = null; rowIndex = -1; return(true); }