private async void DataGrid_RowEditEnding_1(object sender, DataGridRowEditEndingEventArgs e) { //if (((TariffSupUnitLkps)e.Row.Item).TariffCategoryCode != null) //{ // await im.SaveTariffSupUnitLkps((sender as FrameworkElement).DataContext as TariffSupUnitLkps).ConfigureAwait(false); //} }
private void dataGrid_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e) { var snd = sender; DataGridRow gridRow = e.Row; _editMode = false; }
private void RowEdited(object sender, DataGridRowEditEndingEventArgs e) { if (e.EditAction == DataGridEditAction.Commit) { AudioFile f = (AudioFile)e.Row.DataContext; f.Save(); } }
private void grdMain_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e) { RefreshVariablesNames(); VariableBase selectedVarb = (VariableBase)grdVariables.CurrentItem; if (selectedVarb.Name != selectedVarb.NameBeforeEdit) UpdateVariableNameChange(selectedVarb); }
protected void onMeasureNameChange(object sender, DataGridRowEditEndingEventArgs e) { DataGridRow row = e.Row; Kernel.Domain.Measure measure = (Kernel.Domain.Measure)row.Item; if (measure != null) { } }
private void DataGrid_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e) { // drill down from DataGridRow, through row view to our order row DataGridRow dgRow = e.Row; DataRowView rowView = dgRow.Item as DataRowView; Details d = new Details(); d.BrokerCode = g1.SelectedValue as string; }
private async void TriggerGrid_OnRowEditEnding(object sender, DataGridRowEditEndingEventArgs e) { if (e.EditAction != DataGridEditAction.Commit) { return; } await SaveChangesAsync(); }
private void DataGrid_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e) { DinerMax3000.Business.MenuItem newMenuItem = e.Row.Item as DinerMax3000.Business.MenuItem; if (newMenuItem != null && e.EditAction == DataGridEditAction.Commit && e.Row.IsNewItem) { DinerMax3000.WPFClient.DinerMax3000ViewModel currentViewModel = (DinerMax3000.WPFClient.DinerMax3000ViewModel)DataContext; currentViewModel.NewMenuItems.Add(newMenuItem); } }
private void EditStaff(object sender, DataGridRowEditEndingEventArgs e) { CinemaContext db = new(); staff staff = e.Row.Item as staff; bool AllCorrect = true; if (!Regex.IsMatch(staff.Surname, @"^[a-zA-Z]+$") && !Regex.IsMatch(staff.Surname, @"^[а-яА-Я]+$")) { AllCorrect = false; } if (!Regex.IsMatch(staff.NameStaffer, @"^[a-zA-Z]+$") && !Regex.IsMatch(staff.NameStaffer, @"^[а-яА-Я]+$")) { AllCorrect = false; } if (!Regex.IsMatch(staff.NumberTelephon, @"^\+\d\(\d\d\d\)\d\d\d\-\d\d\-\d\d$")) { AllCorrect = false; } if (!Regex.IsMatch(staff.Email, @"^[^\.\ ]\S+\@[a-zA-Z0-9]\S+\.\S+$")) { AllCorrect = false; } if (!Regex.IsMatch(staff.IdPost.ToString(), @"^\d+$")) { AllCorrect = false; } else if (staff.IdPost > maxIdPost) { AllCorrect = false; } int c = db.staff.Count(u => u.IdPost == staff.IdPost); StateCinema stateCinema = db.StateCinemas.Find(staff.IdPost); if ((stateCinema.CountStaffers - c) == 0) { AllCorrect = false; } if (AllCorrect) { if (staff.IdStaffer == 0) { db.staff.Add(staff); } else { staff updateStaff = db.staff.Find(staff.IdStaffer); updateStaff = new (){ Surname = staff.Surname, NameStaffer = staff.NameStaffer, NumberTelephon = staff.NumberTelephon, Email = staff.Email, IdPost = staff.IdPost }; } db.SaveChanges(); MessageBox.Show("Данные успешно обновлены!"); } else { MessageBox.Show("Ошибка добавления данных! Некорректные значения."); } }
private void dataGrid_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e) { DataGrid dataGrid = sender as DataGrid; Assert.IsNotNull(dataGrid); e.Cancel = this._cancelRowEvent; this._rowEditEndingEventArgs = e; this._eventCount++; }
private async void DataGrid_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e) { if (e.Cancel) { return; } var result = await HubProxy.Invoke <bool>("Save", e.Row.Item); }
private void dataGrid_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e) { var snd = sender; DataGridRow gridRow = e.Row; //((Data.ApplicationDataSet.InstancesRow)e.Row).id = Guid.NewGuid(); _editMode = false; }
private void itemaccesories_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e) { PrintingPress.Accessory _Accessory = (PrintingPress.Accessory)itemaccesories.SelectedItem; if (_Accessory != null) { ((PrintingPress.Accessory)itemaccesories.SelectedItem).Calc_Cost = ((PrintingPress.Accessory)itemaccesories.SelectedItem).Cost * ((PrintingPress.Accessory)itemaccesories.SelectedItem).Consumption; ((PrintingPress.Accessory)itemaccesories.SelectedItem).RaisePropertyChanged("Calc_Cost"); } }
private void datagridScore_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e) { //HÀM NÀY CÓ TÁC DỤNG LÀ TABLE THAY ĐỔI LÀ TỰ ĐỘNG CẬP NHẬP SQL NÊN K CẦN CLICK BUTTON, CHỈ CẦN THÔNG BÁO LÀ ĐC SqlCommandBuilder builder = new SqlCommandBuilder(da); da.UpdateCommand = builder.GetUpdateCommand(); da.Update(dt); con.Close(); }
//private void txtcolorsTextChanged(object sender, TextChangedEventArgs e) //{ // if (_inkList != null) // { // _inkList.Clear(); // if (_color_Qty == 0) // { // _color_Qty = 1; // } // int TotalInk = Convert.ToInt16(_color_Qty); // for (int i = 0; i < TotalInk; i++) // { // PrintingPress.Ink _ink = new PrintingPress.Ink(); // _inkList.Add(_ink); // } // if (itemink != null) // { // itemink.ItemsSource = _inkList; // } // } //} private void itemink_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e) { PrintingPress.Ink _ink = (PrintingPress.Ink)itemink.SelectedItem; if (_ink != null) { ((PrintingPress.Ink)itemink.SelectedItem).Cost = (decimal)entity.db.items.Where(x => x.id_item == _ink.Id).FirstOrDefault().unit_cost; ((PrintingPress.Ink)itemink.SelectedItem).RaisePropertyChanged("Cost"); } }
private void dg_data_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e) { if (e.EditAction == DataGridEditAction.Commit) { // FormulaOneDriver driver = e.Row.DataContext as FormulaOneDriver; // driver.Save(); } }
/// <summary> /// No permite agregar filas vacias /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgrHotels_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e) { if (e.EditAction == DataGridEditAction.Commit && isCellCancel) { dgrHotels.RowEditEnding -= dgrHotels_RowEditEnding; dgrHotels.CancelEdit(); dgrHotels.RowEditEnding += dgrHotels_RowEditEnding; } }
private void StealingsDataGrid_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e) { if (e.EditAction == DataGridEditAction.Commit) { Stealings newItem = e.Row.DataContext as Stealings; newItem.AutoID = Data.IdAuto; new DAO().AddStealing(newItem); } }
private void TechViewAutoDataGrid_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e) { if (e.EditAction == DataGridEditAction.Commit) { TechnicalInspections newItem = e.Row.DataContext as TechnicalInspections; newItem.AutoID = Data.IdAuto; new DAO().AddTechnical(newItem); } }
private void MainGrid_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e) { IEditableCollectionView iecv = CollectionViewSource.GetDefaultView((sender as DataGrid).ItemsSource) as IEditableCollectionView; if (iecv.IsAddingNew) { Dispatcher.Invoke(new DispatcherOperationCallback(ResetNewItemTemplate), DispatcherPriority.ApplicationIdle, MainGrid); } }
private void MainGrid_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e) { var s = e.Row; var c = s.Item as DB.Client; entities.Clients.AddOrUpdate(c); entities.SaveChanges(); Refresh(); }
private void DataGrid_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e) { detailsDg.IsReadOnly = true; SMU selectedRow = e.Row.DataContext as SMU; if (e.EditAction == DataGridEditAction.Commit) { } }
private void dgPassenger_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e) { BeaCukai cukai = new BeaCukai(); PAUPassenger passenger = e.Row.Item as PAUPassenger; if (passenger != null) { try { var existing = (from p in cukai.PAUPassenger where /*p.Name == passenger.Name && p.CDst == passenger.CDst && p.FareClass == passenger.FareClass && p.FirstName == passenger.FirstName && p.FlightNo == passenger.FlightNo && p.Gender == passenger.Gender && p.LastName == passenger.LastName && p.Nationality == passenger.Nationality && p.Passport == passenger.Passport && p.PNR == passenger.PNR && p.SeatNo == passenger.SeatNo && p.SEQNo == passenger.SEQNo && p.Notes == passenger.Notes */ p.ID == passenger.ID select p).First(); existing.Name = passenger.Name; existing.BirthDate = passenger.BirthDate; existing.CDst = passenger.CDst; existing.Date = passenger.Date; existing.FareClass = passenger.FareClass; existing.FirstName = passenger.FirstName; existing.FlightDate = passenger.FlightDate; existing.FlightNo = passenger.FlightNo; existing.Gender = passenger.Gender; existing.LastName = passenger.LastName; existing.Nationality = passenger.Nationality; existing.Passport = passenger.Passport; existing.PNR = passenger.PNR; existing.SeatNo = passenger.SeatNo; existing.SEQNo = passenger.SEQNo; existing.Notes = passenger.Notes; existing.Picture = passenger.Picture; } catch (Exception) { return; } cukai.SubmitChanges(); } }
private void dgSupplier_RowEditEnding_1(object sender, DataGridRowEditEndingEventArgs e) { try { /// Handle Updates or Creates if (e.EditAction == DataGridEditAction.Commit) { // Get the Customer changes from the DataGrid Supplier supplier = e.Row.DataContext as Supplier; //if (String.IsNullOrEmpty(customerGroup.CustomerGroupName)) //{ // MessageBox.Show("Must Provide a Customer Group Name", "Customer Group Name", MessageBoxButton.OK, MessageBoxImage.Information); // this.BindData(); // return; //} if ((MessageBox.Show("Are you sure you want to add/modify '" + supplier.SupplierName + "' ?", "Confirm add or modify", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes) != MessageBoxResult.Yes)) { e.Cancel = true; //this.RefreshDataGrid(); return; } //if (supplier.Id < 1) //{ // var Repo = new RepositorySupplier().Add(supplier); // if (Repo) // { // MessageBox.Show("Added successfully"); // } // //ParaUtils.ShowStatusBarMsg(this, "Added CustomerGroup '" + customerGroup.CustomerGroupName + "'"); // //this.ShowCustomerGroupDialog((from c in BobShared.BobSharedUtils.GetDBDataContext().CustomerGroups where c.CustomerGroupId == customerGroup.CustomerGroupId select c).SingleOrDefault()); //} //else //{ // var Repo = new RepositorySupplier().Update(supplier); // if (Repo) // { // MessageBox.Show("Updated successfully"); // } // //ParaUtils.ShowStatusBarMsg(this, "Updated Customer Group '" + customerGroup.CustomerGroupName + "'"); //} // this.BindData(); } } catch (Exception ex) { // BobSharedUtils.HandleException(ex); MessageBox.Show(ex.Message); e.Cancel = true; } }
/// <summary> /// Supposed to be a way to create and update changes happending to the DataGrid and copy it over to the DataTable /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PeopleDataGrid_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e) { if (e.EditAction == DataGridEditAction.Commit) //If changes are commited { PETexamEntities pet = new PETexamEntities(); Persons persons = e.Row.DataContext as Persons; var matchedData = (from per in pet.Set <Persons>() where per.ID == persons.ID select per).SingleOrDefault(); //If user eddits a null table it becomes new data for the table! if (matchedData == null) { //Error Hypothesis //Error may occur because of the syntax (most likely due to error code) // Is it DateOfBirth? Date & Date time is not the same thing. (MOST LIKELY) // DateOfBirth displays MM/dd/yyyy HH:mm:ss which is not how it works in SQL with Date(MM/dd/yyyy) Table <Persons> perTable = pet.Set <Persons>(); Persons _persons = new Persons(); _persons.FirstName = persons.FirstName; _persons.LastName = persons.LastName; _persons.Age = persons.Age; _persons.DateOfBirth = persons.DateOfBirth; _persons.Nationality = persons.Nationality; _persons.HeadShot = persons.HeadShot; _persons.Remarks = persons.Remarks; _persons.GangsID = persons.GangsID; _persons.AgentID = persons.AgentID; perTable.InsertOnSubmit(_persons); perTable.Context.SubmitChanges(); StatusText.Text = "Success: Data Inserted"; } //The only else is if the user eddits a table with existing data //This takes the data and updates it! else { matchedData.FirstName = persons.FirstName; matchedData.LastName = persons.LastName; matchedData.Age = persons.Age; matchedData.DateOfBirth = persons.DateOfBirth; matchedData.Nationality = persons.Nationality; matchedData.HeadShot = persons.HeadShot; matchedData.Remarks = persons.Remarks; matchedData.GangsID = persons.GangsID; matchedData.AgentID = persons.AgentID; pet.SaveChanges(); StatusText.Text = "Success: Data Updated"; } } }
private void DataTab_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e) { RailwaysEntities context = RailwaysData.sharedContext; bool adding = false; try { object entities = context.GetType().GetProperty(curTableName).GetValue(context, null); object dataContext = e.Row.DataContext; try{ object obj = dataContext.GetType().GetProperty("ID").GetValue(dataContext, null); int isNewId; if (obj.GetType() == typeof(short)) { isNewId = (short)obj; if (isNewId == 0) { dataContext.GetType().GetProperty("ID").SetValue(dataContext, (short)RailwaysData.GetIndexForTable(curTableName), null); } } else { isNewId = (int)obj; //0 - значение id вместо null. Все валиные id в базе > 0 if (isNewId == 0) { dataContext.GetType().GetProperty("ID").SetValue(dataContext, RailwaysData.GetIndexForTable(curTableName), null); } } } catch {} MethodInfo mListAdd = entities.GetType().GetMethod("AddObject"); mListAdd.Invoke(entities, new object[] { dataContext }); adding = true; } catch { } try { context.SaveChanges(); context.AcceptAllChanges(); LoggingManager.LogAction(adding ? 6 : 5, curTableName); } catch (Exception ex) { if (ex.InnerException == null) { MessageBox.Show(ex.Message); } else { MessageBox.Show(ex.InnerException.Message); } } }
private void posLibDataGrid_RowEditEnding_1(object sender, DataGridRowEditEndingEventArgs e) { LibPos lp = new LibPos(); lp = e.Row.Item as LibPos; if (lp.posName == "") { currentOUS.posLibrary.Remove(lp); } }
private void DataGridCheckLists_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e) { if (e.EditAction == DataGridEditAction.Commit && handle) { handle = false; (sender as DataGrid).CommitEdit(); handle = true; Database.check_lists.Update((CheckList)e.Row.Item); } }
/// <summary> /// Добавить сотрудника в коллекцию сохранения /// </summary> /// <param name="e"></param> public void AfterEditEmployee(DataGridRowEditEndingEventArgs e) { if (e.EditAction == DataGridEditAction.Commit) { if (!EditOcEmployees.Contains(SelectedEmployee)) { EditOcEmployees.Add(SelectedEmployee); } } }
/// <summary> /// Добавить отдел в коллекцию измененных отделов /// </summary> /// <param name="e"></param> public void AfterEditDepartments(DataGridRowEditEndingEventArgs e) { if (e.EditAction == DataGridEditAction.Commit) { if (!EditOcDepartments.Contains(SelectedDepartment)) { EditOcDepartments.Add(SelectedDepartment); } } }
private void Paperdata_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e) { PinEx pin = e.Row.Item as PinEx; if ((App.Current.Resources["Locator"] as ViewModelLocator).Paper.Pins.Count(x => x.PhysicalChannel == pin.PhysicalChannel) > 1) { MessageBox.Show("物理地址不能重复!", "错误", MessageBoxButton.OK, MessageBoxImage.Error); } e.Cancel = true; }
private void dgDPO_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e) { BeaCukai cukai = new BeaCukai(); PAUDPO dpo = e.Row.Item as PAUDPO; if (dpo != null) { var existing = (from p in cukai.PAUDPO where p.ID == dpo.ID select p).First(); existing.Name = dpo.Name; existing.FirstName = dpo.FirstName; existing.LastName = dpo.LastName; existing.Passport = dpo.Passport; cukai.SubmitChanges(); } }
/// <summary> /// Invoked when the CancelEdit command is executed. /// </summary> protected virtual void OnExecutedCancelEdit(ExecutedRoutedEventArgs e) { DataGridCell cell = CurrentCellContainer; if (cell != null) { DataGridEditingUnit editingUnit = GetEditingUnit(e.Parameter); bool eventCanceled = false; if (cell.IsEditing) { DataGridCellEditEndingEventArgs cellEditEndingEventArgs = new DataGridCellEditEndingEventArgs(cell.Column, cell.RowOwner, cell.EditingElement, DataGridEditAction.Cancel); OnCellEditEnding(cellEditEndingEventArgs); eventCanceled = cellEditEndingEventArgs.Cancel; if (!eventCanceled) { cell.CancelEdit(); HasCellValidationError = false; } } var editableItems = EditableItems; bool needsCommit = IsEditingItem(cell.RowDataItem) && !editableItems.CanCancelEdit; if (!eventCanceled && (CanCancelAddingOrEditingRowItem(editingUnit, cell.RowDataItem) || needsCommit)) { bool cancelAllowed = true; if (!needsCommit) { DataGridRowEditEndingEventArgs rowEditEndingEventArgs = new DataGridRowEditEndingEventArgs(cell.RowOwner, DataGridEditAction.Cancel); OnRowEditEnding(rowEditEndingEventArgs); cancelAllowed = !rowEditEndingEventArgs.Cancel; } if (cancelAllowed) { if (needsCommit) { // If the row is being edited (not added), but it doesn't support // pending changes, then tell the item to commit (this doesn't really // do anything except update the IEditableCollectionView state). // This allows us to exit row editing mode. editableItems.CommitEdit(); } else { CancelRowItem(); } var bindingGroup = cell.RowOwner.BindingGroup; if (bindingGroup != null) { bindingGroup.CancelEdit(); // This is to workaround the bug that BindingGroup // does nor clear errors on CancelEdit bindingGroup.UpdateSources(); } } } // Update the state of row editing UpdateRowEditing(cell); if (!cell.RowOwner.IsEditing) { // Allow the user to cancel the row and avoid being locked to that row. // If the row is still not valid, it means that the source data is already // invalid, and that is OK. HasRowValidationError = false; } // CancelEdit and CommitEdit rely on IsAddingNewItem and IsEditingRowItem CommandManager.InvalidateRequerySuggested(); } e.Handled = true; }
/// <summary> /// Called just before row editing is ended. /// Gives subclasses the opportunity to cancel the operation. /// </summary> protected virtual void OnRowEditEnding(DataGridRowEditEndingEventArgs e) { if (RowEditEnding != null) { RowEditEnding(this, e); } if (AutomationPeer.ListenerExists(AutomationEvents.InvokePatternOnInvoked)) { DataGridAutomationPeer peer = DataGridAutomationPeer.FromElement(this) as DataGridAutomationPeer; if (peer != null) { peer.RaiseAutomationRowInvokeEvents(e.Row); } } }
/// <summary> /// Invoked when the CommitEdit command is executed. /// </summary> protected virtual void OnExecutedCommitEdit(ExecutedRoutedEventArgs e) { DataGridCell cell = CurrentCellContainer; bool validationPassed = true; if (cell != null) { DataGridEditingUnit editingUnit = GetEditingUnit(e.Parameter); bool eventCanceled = false; if (cell.IsEditing) { DataGridCellEditEndingEventArgs cellEditEndingEventArgs = new DataGridCellEditEndingEventArgs(cell.Column, cell.RowOwner, cell.EditingElement, DataGridEditAction.Commit); OnCellEditEnding(cellEditEndingEventArgs); eventCanceled = cellEditEndingEventArgs.Cancel; if (!eventCanceled) { validationPassed = cell.CommitEdit(); HasCellValidationError = !validationPassed; } } // Consider commiting the row if: // 1. Validation passed on the cell or no cell was in edit mode. // 2. A cell in edit mode didn't have it's ending edit event canceled. // 3. The row can be commited: // a. The row is being edited or added and being targeted directly. // b. If the row is being edited (not added), but it doesn't support // pending changes, then tell the row to commit (this doesn't really // do anything except update the IEditableCollectionView state) if (validationPassed && !eventCanceled && (((editingUnit == DataGridEditingUnit.Row) && IsAddingOrEditingRowItem(cell.RowDataItem)) || (!EditableItems.CanCancelEdit && IsEditingItem(cell.RowDataItem)))) { DataGridRowEditEndingEventArgs rowEditEndingEventArgs = new DataGridRowEditEndingEventArgs(cell.RowOwner, DataGridEditAction.Commit); OnRowEditEnding(rowEditEndingEventArgs); if (!rowEditEndingEventArgs.Cancel) { var bindingGroup = cell.RowOwner.BindingGroup; if (bindingGroup != null) { // CommitEdit will invoke the bindingGroup's ValidationRule's, so we need to make sure that all of the BindingExpressions // have already registered with the BindingGroup. Synchronously flushing the Dispatcher to DataBind priority lets us ensure this. // Had we used BeginInvoke instead, IsEditing would not reflect the correct value. Dispatcher.Invoke(new DispatcherOperationCallback(DoNothing), DispatcherPriority.DataBind, bindingGroup); validationPassed = bindingGroup.CommitEdit(); } HasRowValidationError = !validationPassed; if (validationPassed) { CommitRowItem(); } } } if (validationPassed) { // Update the state of row editing UpdateRowEditing(cell); } // CancelEdit and CommitEdit rely on IsAddingNewItem and IsEditingRowItem CommandManager.InvalidateRequerySuggested(); } e.Handled = true; }