private GrilleEditedResult OnEditColumn(GrilleEditedElement element) { try { EditorItem <Grille> page = getEditor().getActivePage(); Grille grid = page.EditedObject; if (grid != null && !grid.oid.HasValue) { MessageBoxResult response = MessageDisplayer.DisplayYesNoQuestion("Edit row", "You have to save the grid before editing row.\nDou you want to save the grid?"); if (response != MessageBoxResult.Yes) { return(null); } grid.loaded = true; page.IsModify = true; OperationState state = Save(page); } element.grid = new Grille(); element.grid.code = page.EditedObject.code; element.grid.columnListChangeHandler.originalList = page.EditedObject.columnListChangeHandler.Items.ToList(); element.grid.report = page.EditedObject.report; element.grid.oid = page.EditedObject.oid; element.grid.name = page.EditedObject.name; element.grid.reconciliation = true; element.grid.report = page.EditedObject.report; return(this.GetInputGridService().editCell(element)); } catch (ServiceExecption) { } return(null); }
private GrilleEditedResult OnEdit(GrilleEditedElement element) { if (this.EditEventHandler != null) { return(EditEventHandler(element)); } return(null); }
protected override void OnValidateCell(object sender, GridCellValidationEventArgs args) { GridItem item = (GridItem)this.gridControl.SelectedItem; if (item == null) { item = (GridItem)this.gridControl.CurrentItem; } if (item != null) { ColumnBase col = args.Column; GrilleColumn column = this.Grille.GetColumn(col.FieldName); string oldValue = item.Datas[column.position] != null ? item.Datas[column.position].ToString() : ""; string newValue = args.Value != null?args.Value.ToString() : ""; if (!IsEditionValid(item, column, oldValue, newValue, args)) { args.Handled = true; args.IsValid = false; return; } GrilleEditedElement element = new GrilleEditedElement(); element.column = column; element.oid = item.GetOid(); element.value = new Kernel.Domain.Browser.BrowserData(); element.value.name = newValue; if (this.EditEventHandler != null) { GrilleEditedResult result = EditEventHandler(element); if (result.isError) { args.Handled = true; args.IsValid = false; args.ErrorContent = result.error; return; } else { if (result.datas == null) { args.Handled = true; } else { item.Datas = result.datas; } Refresh(); } } } }
public GrilleEditedResult editCell(GrilleEditedElement element) { try { System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer(); var request = new RestRequest(ResourcePath + "/edit", Method.POST); serializer.MaxJsonLength = int.MaxValue; string json = serializer.Serialize(element); request.AddParameter("application/json", json, ParameterType.RequestBody); var response = RestClient.ExecuteTaskAsync(request); RestResponse queryResult = (RestResponse)response.Result; GrilleEditedResult objects = RestSharp.SimpleJson.DeserializeObject <GrilleEditedResult>(queryResult.Content); return(objects); } catch (Exception e) { logger.Error("Unable to edit cell.", e); throw new ServiceExecption("Unable to edit cell.", e); } }
private GrilleEditedResult OnEditColumn(GrilleEditedElement element) { try { EditorItem <LinkedAttributeGrid> page = getEditor().getActivePage(); Grille grid = page.EditedObject; element.grid = new Grille(); element.attribute = page.EditedObject.attribute; element.grid.code = page.EditedObject.code; element.grid.columnListChangeHandler.originalList = page.EditedObject.columnListChangeHandler.Items.ToList(); element.grid.report = page.EditedObject.report; element.grid.oid = page.EditedObject.oid; element.grid.name = page.EditedObject.name; element.grid.reconciliation = page.EditedObject.reconciliation; element.grid.report = page.EditedObject.report; GrilleEditedResult result = this.GetLinkedAttributeGridService().editCell(element); return(result); } catch (ServiceExecption) { } return(null); }
protected virtual void OnCellValueChanged(object sender, CellValueChangedEventArgs args) { GridItem item = (GridItem)this.gridControl.SelectedItem; if (item == null) { item = (GridItem)this.gridControl.CurrentItem; } if (item != null) { int? oid = item.GetOid(); GridColumn col = args.Column; GrilleColumn column = this.Grille.GetColumn(col.FieldName); string oldValue = item.Datas[column.position] != null ? item.Datas[column.position].ToString() : ""; string newValue = args.Value != null?args.Value.ToString() : ""; GrilleEditedElement element = new GrilleEditedElement(); element.column = column; element.oid = oid; //if (newValue.Equals(oldValue)) return; if (column.type.Equals(ParameterType.MEASURE.ToString())) { decimal val = 0; if (string.IsNullOrWhiteSpace(newValue)) { val = 0; } else if (decimal.TryParse(newValue, out val)) { element.measure = val; } else if (decimal.TryParse(newValue.Replace(".", ","), out val)) { element.measure = val; } else { MessageDisplayer.DisplayError("Wrong measure", "'" + newValue + "'" + " is not a decimal!"); args.Handled = true; //args.Value = args.OldValue; return; } } else if (column.type.Equals(ParameterType.SCOPE.ToString())) { if (string.IsNullOrWhiteSpace(newValue)) { element.value = null; } else { BrowserData data = column.getValue(newValue); if (!AllowUnknowValueForScope && data == null) { MessageDisplayer.DisplayError("Wrong value", "Unknow value : '" + newValue + "'"); args.Handled = true; return; } else { element.value = data; } } } if (column.type.Equals(ParameterType.PERIOD.ToString())) { DateTime date; if (string.IsNullOrWhiteSpace(newValue)) { element.date = null; } else if (DateTime.TryParse(newValue, out date)) { element.date = date.ToShortDateString(); } else { MessageDisplayer.DisplayError("Wrong date", "'" + newValue + "'" + " is not a date!"); args.Handled = true; return; } } if (this.EditEventHandler != null) { GrilleEditedResult result = EditEventHandler(element); if (result.isError) { MessageDisplayer.DisplayError("Wrong value", result.error); args.Handled = true; return; } else { if (result.datas == null) { args.Handled = true; } else { item.Datas = result.datas; } Refresh(); //this.grid.SelectedItem = item; } } } }