//public void ClearBorderColor() //{ // checkbox.BorderBrush = new SolidColorBrush(UIManager.GetColorFromInfoColor(InfoColor.Black)); // checkbox.BorderThickness = new Thickness(1); //} public void SetBinding(EntityInstanceProperty property) { Binding binding = new Binding("Value"); binding.Source = property; checkbox.SetBinding(CheckBox.IsCheckedProperty, binding); }
public FunctionResult GetCodeFunctionEntityResult(DR_Requester resuester, int codeFunctionEntityID, DP_DataRepository dataItem) { var codeFunctionEntity = bizCodeFunction.GetCodeFunctionEntity(resuester, codeFunctionEntityID); var parameters = new List <object>(); //var formulaUsageParemeters = new List<FormulaUsageParemetersDTO>(); foreach (var column in codeFunctionEntity.CodeFunctionEntityColumns) { EntityInstanceProperty property = dataItem.GetProperty(column.ColumnID); if (property != null) { //FormulaUsageParemetersDTO formulaUsageParemeter = new FormulaUsageParemetersDTO(); //formulaUsageParemeter.ParameterName = property.Name; //formulaUsageParemeter.ParameterValue = (property.Value != null ? property.Value.ToString() : "<Null>"); //formulaUsageParemeters.Add(formulaUsageParemeter); //stringParamList += (stringParamList == "" ? "" : ",") + column.FunctionColumnParamName; //paramList.Add(column.FunctionColumnParamName); if (property.Value != null) { parameters.Add(Convert.ChangeType(property.Value, column.FunctionColumnDotNetType)); } else { parameters.Add(null); } } } var result = GetCodeFunctionResult(resuester, codeFunctionEntity.CodeFunctionID, parameters); // result.FormulaUsageParemeters = formulaUsageParemeters; return(result); }
List <QueryItem> GetRemoveQueryQueue(DR_Requester requester) { List <QueryItem> result = new List <QueryItem>(); var removeItems = GetRemoveItems(ListData); foreach (var item in removeItems) { List <EntityInstanceProperty> listEditProperties = new List <EntityInstanceProperty>(); foreach (var col in item.Item1.RelationshipColumns) { var prop = item.Item2.GetProperty(col.SecondSideColumnID); if (prop == null) { prop = new EntityInstanceProperty(col.SecondSideColumn); } prop.Value = null; listEditProperties.Add(prop); } result.Add(new QueryItem(GetTableDrivedDTO(requester, item.Item2.TargetEntityID), Enum_QueryItemType.Update, listEditProperties, item.Item2)); } foreach (var queryItem in result) { queryItem.Query = GetUpdateQuery(queryItem); } return(result); }
private Tuple <Enum_QueryItemType, List <EntityInstanceProperty> > GetQueryDeleteOrUpdateNull(DP_DataRepository item, ChildRelationshipInfo parentChildRelatoinshipInfo) { Enum_QueryItemType queryItemType; List <EntityInstanceProperty> listEditProperties = new List <EntityInstanceProperty>(); if (parentChildRelatoinshipInfo == null) { queryItemType = Enum_QueryItemType.Delete; } else { if (parentChildRelatoinshipInfo.RelationshipDeleteOption == RelationshipDeleteOption.DeleteCascade) { queryItemType = Enum_QueryItemType.Delete; } else { queryItemType = Enum_QueryItemType.Update; foreach (var col in parentChildRelatoinshipInfo.Relationship.RelationshipColumns) { var prop = item.GetProperty(col.SecondSideColumnID); if (prop == null) { prop = new EntityInstanceProperty(col.SecondSideColumn); } prop.Value = null; listEditProperties.Add(prop); } } } return(new Tuple <Enum_QueryItemType, List <EntityInstanceProperty> >(queryItemType, listEditProperties)); }
//public void ClearBorderColor() //{ // textBox.BorderBrush = new SolidColorBrush(UIManager.GetColorFromInfoColor(InfoColor.Black)); // textBox.BorderThickness = new Thickness(1); //} public void SetBinding(EntityInstanceProperty property) { Binding binding = new Binding("Value"); binding.Source = property; binding.Mode = BindingMode.TwoWay; if (textBox is PDatePicker) { if (valueIsString && stringDateIsMiladi == false) { textBox.SetBinding(PDatePicker.SelectedPersianDateProperty, binding); } else { textBox.SetBinding(PDatePicker.SelectedDateProperty, binding); } } else { if (valueIsString && stringDateIsMiladi == false) { binding.Converter = new ConverterDate(); textBox.SetBinding(DatePicker.SelectedDateProperty, binding); } else { textBox.SetBinding(DatePicker.SelectedDateProperty, binding); } } }
//public void ClearBorderColor() //{ // textBox.BorderBrush = new SolidColorBrush(UIManager.GetColorFromInfoColor(InfoColor.Black)); // textBox.BorderThickness = new Thickness(1); //} public void SetBinding(EntityInstanceProperty property) { Binding binding = new Binding("Value"); binding.Source = property; binding.Mode = BindingMode.TwoWay; if (valueIsString) { if (stringTimeISAMPMFormat == true) { if (stringTimeIsMiladi == false) { binding.Converter = new ConverterAMPMShamsi(); textBox.SetBinding(RadTimePicker.SelectedValueProperty, binding); } else { binding.Converter = new ConverterAMPM(); textBox.SetBinding(RadTimePicker.SelectedValueProperty, binding); } } else { binding.Converter = new ConverterLongTime(); textBox.SetBinding(RadTimePicker.SelectedValueProperty, binding); } } else { textBox.SetBinding(RadTimePicker.SelectedValueProperty, binding); } }
//public void ClearBorderColor() //{ // textBox.BorderBrush = new SolidColorBrush(UIManager.GetColorFromInfoColor(InfoColor.Black)); // textBox.BorderThickness = new Thickness(1); //} public void SetBinding(EntityInstanceProperty property) { Binding binding = new Binding("Value"); binding.Mode = BindingMode.TwoWay; binding.Source = property; binding.Converter = new ConverterNumber(); textBox.SetBinding(RadMaskedNumericInput.ValueProperty, binding); }
//public void ClearBorderColor() //{ // combo.BorderBrush = new SolidColorBrush(UIManager.GetColorFromInfoColor(InfoColor.Black)); // combo.BorderThickness = new Thickness(1); //} public void SetBinding(EntityInstanceProperty property) { Binding binding = new Binding("Value"); binding.Source = property; //if (ValueIsTitleOrValue) // combo.SetBinding(ComboBox.TextProperty, binding); //else combo.SetBinding(ComboBox.SelectedValueProperty, binding); }
public void SetBinding(EntityInstanceProperty property) { var bindinga = textBox.GetBindingExpression(TextBox.TextProperty); Binding binding = new Binding("Value"); binding.Mode = BindingMode.TwoWay; binding.Source = property; textBox.SetBinding(TextBox.TextProperty, binding); }
public frmDataSelect(int entityID) { InitializeComponent(); Entity = bizTableDrivedEntity.GetTableDrivedEntity(MyProjectManager.GetMyProjectManager.GetRequester(), entityID, EntityColumnInfoType.WithSimpleColumns, EntityRelationshipInfoType.WithoutRelationships); lblEntity.Text = Entity.Alias; foreach (var col in Entity.Columns.Where(x => x.PrimaryKey)) { EntityInstanceProperty keyColumn = new EntityInstanceProperty(col); // keyColumn.ColumnID = col.ID; //keyColumn.IsKey = true; //keyColumn.Name = col.Name; keyColumns.Add(keyColumn); } dtgKeyColumns.ItemsSource = keyColumns; }
internal void SetBinding(object dataItem, EntityInstanceProperty property) { System.Windows.Threading.Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Input, new Action(() => { var dataRow = this.DataControl.GetRowForItem(dataItem); var cell = dataRow.GetCell(this); if (cell != null) { if (cell.Content != null) { (cell.Tag as I_ControlHelper).SetBinding(property); if (property.Name == "Name") { (cell.Tag as I_ControlHelper).SetBackgroundColor(InfoColor.Blue); } } } })); }
//public void ClearBorderColor() //{ // textBox.BorderBrush = new SolidColorBrush(UIManager.GetColorFromInfoColor(InfoColor.Black)); // textBox.BorderThickness = new Thickness(1); //} public void SetBinding(EntityInstanceProperty property) { Binding binding = new Binding("Value"); binding.Source = property; binding.Mode = BindingMode.TwoWay; binding.Converter = new ConverterDate(); DateConverterParameter param = GetConverterParameter(); binding.ConverterParameter = param; (textBox as MyDateTimePicker).SetBinding(MyDateTimePicker.SelectedDateTimeProperty, binding); //if(property.Value!=null) //(textBox as MyDateTimePicker).SelectedDateTime = Convert.ToDateTime(property.Value); //پارامتر بشن خصوصیات بالا و در کانورتر از همون گت و ست استفاده یشه if (valueIsString) { //if (!hasnotDatePicker && !hasnotTimePicker) //{ //} //else if (!hasnotDatePicker) //{ // if (stringDateIsMiladi == false) // binding.Converter = new ConverterDateOnlyShamsi(); // binding.con //} //else if (!hasnotTimePicker) //{ //if (stringTimeISAMPMFormat == true) //{ // if (stringTimeIsMiladi == false) // binding.Converter = new ConverterTimeOnlyAMPMShamsi(); // else // binding.Converter = new ConverterTimeOnlyAMPM(); //} //else // binding.Converter = new ConverterTimeOnlyLong(); //} } }
public FunctionResult GetDatabaseFunctionValue(DR_Requester requester, int functionID, DP_DataRepository dataItem) { // var formulaUsageParemeters = new List<FormulaUsageParemetersDTO>(); var databaseFunctionEntity = bizDatabaseFunction.GetDatabaseFunctionEntity(requester, functionID); // List<object> paramList = new List<object>(); List <Tuple <string, object> > parameters = new List <Tuple <string, object> >(); if (databaseFunctionEntity != null) { foreach (var column in databaseFunctionEntity.DatabaseFunctionEntityColumns) { object value = null; if (column.ColumnID != 0) { EntityInstanceProperty property = dataItem.GetProperty(column.ColumnID); if (property != null) { value = property.Value; } } else { if (column.FixedParam == Enum_FixedParam.RequesterIdentity) { value = requester.Identity.ToString(); } } //FormulaUsageParemetersDTO formulaUsageParemeter = new FormulaUsageParemetersDTO(); //formulaUsageParemeter.ParameterName = column.FunctionColumnParamName; //formulaUsageParemeter.ParameterValue = (value != null ? value.ToString() : "<Null>"); //formulaUsageParemeters.Add(formulaUsageParemeter); parameters.Add(new Tuple <string, object>(column.FunctionColumnParamName, value)); } } var result = GetDatabaseFunctionValue(requester, databaseFunctionEntity.DatabaseFunction, parameters); // result.FormulaUsageParemeters = formulaUsageParemeters; return(result); }
public override bool TryGetMember(GetMemberBinder binder, out object result) { if (m_properties.ContainsKey(binder.Name)) { var property = m_properties.FirstOrDefault(x => x.Key == binder.Name).Value; OnProperyCalled(property); if (!property.ValueSearched) { property.ValueSearched = true; if (Definition) { if (property.PropertyType == PropertyType.Relationship) { var dataItem = new DP_DataRepository(property.PropertyRelationship.EntityID2, property.PropertyRelationship.Entity2); var entity = bizTableDrivedEntity.GetPermissionedEntity(Requester, dataItem.TargetEntityID); var properties = FormulaInstanceInternalHelper.GetProperties(Requester, entity, property, Definition); //newObject.PropertyGetCalled += BindableTypeDescriptor_PropertyGetCalled; //newObject.PropertySetChanged += FormulaObject_PropertySetChanged; //newObject.PropertyChanged += FormulaObject_PropertyChanged; if (property.PropertyRelationship.TypeEnum == Enum_RelationshipType.OneToMany) { var newObject = GetCustomSingleData(property, dataItem, Requester, Definition, properties, UsedFormulaIDs); //var list = new List<MyCustomSingleData>(); //DataItems.Add(newObject); property.Value = new MyCustomMultipleData(Requester, entity.ID, new List <MyCustomSingleData>() { newObject }); } else { var newObject = GetCustomSingleData(property, dataItem, Requester, Definition, properties, UsedFormulaIDs); property.Value = newObject; } } else { property.Value = GetPropertyDefaultValue(property); } } else { if (property.PropertyType == PropertyType.Relationship) { var entity = bizTableDrivedEntity.GetPermissionedEntity(Requester, property.PropertyRelationship.EntityID2); var properties = FormulaInstanceInternalHelper.GetProperties(Requester, entity, property, Definition); if (property.PropertyRelationshipProperties == null || property.PropertyRelationshipProperties.Count == 0) { throw new Exception("adasdasd"); } List <DP_DataRepository> relatedDataItems = GetRelatedDataItems(DataItem, property.PropertyRelationship, property.PropertyRelationshipProperties); if (property.PropertyRelationship.TypeEnum == Enum_RelationshipType.OneToMany) { var list = new List <MyCustomSingleData>(); foreach (var relatedDataItem in relatedDataItems) { list.Add(GetCustomSingleData(property, relatedDataItem, Requester, Definition, GetCloneProperties(properties), UsedFormulaIDs)); } var newObject = new MyCustomMultipleData(Requester, entity.ID, list); // DataItems.Add(newObject); // //newObject.PropertyGetCalled += BindableTypeDescriptor_PropertyGetCalled; //} property.Value = newObject; } else if (relatedDataItems.Any()) { var newObject = GetCustomSingleData(property, relatedDataItems.First(), Requester, Definition, properties, UsedFormulaIDs); //newObject.PropertyGetCalled += BindableTypeDescriptor_PropertyGetCalled; //newObject.PropertySetChanged += FormulaObject_PropertySetChanged; //newObject.PropertyChanged += FormulaObject_PropertyChanged; property.Value = newObject; } } else { if (property.PropertyType == PropertyType.Column) { EntityInstanceProperty dataproperty = DataItem.GetProperty(property.ID); if (dataproperty != null) { property.Value = dataproperty.Value; } else { throw new Exception("Date property" + " " + property.Name + " not found!"); } } else if (property.PropertyType == PropertyType.FormulaParameter) { var formula = property.Context as FormulaDTO; if (UsedFormulaIDs != null && UsedFormulaIDs.Contains(formula.ID)) { throw new Exception("Loop"); } if (UsedFormulaIDs == null) { UsedFormulaIDs = new List <int>(); } UsedFormulaIDs.Add(formula.ID); Application.Current.Dispatcher.Invoke((Action) delegate { var value = FormulaFunctionHandler.CalculateFormula(formula.ID, DataItem, Requester, UsedFormulaIDs); if (value.Exception == null) { //if ((property.Context is FormulaDTO) && (property.Context as FormulaDTO).ValueCustomType != ValueCustomType.None) // property.Value = GetCustomTypePropertyValue(property, (property.Context as FormulaDTO).ValueCustomType, value.Result); //else property.Value = value.Result; // e.FormulaUsageParemeters = value.FormulaUsageParemeters; } else { throw value.Exception; } }); } else if (property.PropertyType == PropertyType.State) { Application.Current.Dispatcher.Invoke((Action) delegate { DP_DataRepository dataItem = DataItem; var stateresult = StateHandler.GetStateResult(property.ID, DataItem, Requester); if (string.IsNullOrEmpty(stateresult.Message)) { property.Value = stateresult.Result; } else { throw new Exception(stateresult.Message); } }); } else if (property.PropertyType == PropertyType.Code) { Application.Current.Dispatcher.Invoke((Action) delegate { DP_DataRepository dataItem = DataItem; var coderesult = CodeFunctionHandler.GetCodeFunctionResult(Requester, property.ID, dataItem); if (coderesult.Exception == null) { property.Value = coderesult.Result; } else { throw coderesult.Exception; } //if ((property.Context is CodeFunctionDTO) && (property.Context as CodeFunctionDTO).ValueCustomType != ValueCustomType.None) // property.Value = GetCustomTypePropertyValue(property, (property.Context as CodeFunctionDTO).ValueCustomType, result.Result); //else }); } else if (property.PropertyType == PropertyType.DBFunction) { Application.Current.Dispatcher.Invoke((Action) delegate { DP_DataRepository dataItem = DataItem; var coderesult = DatabaseFunctionHandler.GetDatabaseFunctionValue(Requester, property.ID, dataItem); if (coderesult.Exception == null) { property.Value = coderesult.Result; } else { throw coderesult.Exception; } //if ((property.Context is CodeFunctionDTO) && (property.Context as CodeFunctionDTO).ValueCustomType != ValueCustomType.None) // property.Value = GetCustomTypePropertyValue(property, (property.Context as CodeFunctionDTO).ValueCustomType, result.Result); //else }); } } } } result = property.Value; return(true); } else { throw new Exception("Property" + " " + binder.Name + " not found!"); } }
private void IdentityProp_PropertyValueChanged(object sender, PropertyValueChangedArg e, EntityInstanceProperty targetFk, QueryItem queryItem) { var oldValue = targetFk.Value.ToString(); targetFk.Value = e.NewValue; if (!string.IsNullOrEmpty(queryItem.Query)) { queryItem.Query = queryItem.Query.Replace(oldValue, e.NewValue.ToString()); } }
private QueryItem SetSortedTree(DR_Requester requester, List <QueryItem> result, DP_DataRepository item, QueryItem parentQueryItem = null, ChildRelationshipInfo parentChildRelationshipInfo = null) { List <EntityInstanceProperty> editingProperties = new List <EntityInstanceProperty>(); foreach (var child in item.ChildRelationshipInfos.Where(x => x.Relationship.MastertTypeEnum == Enum_MasterRelationshipType.FromForeignToPrimary)) { List <EntityInstanceProperty> foreignKeyProperties = new List <EntityInstanceProperty>(); //foreach (var relCol in child.Relationship.RelationshipColumns) //{ // var prop = item.GetProperty(relCol.FirstSideColumnID); // foreignKeyProperties.Add(prop); //} bool isSelfTable = false; if (child.Relationship.RelationshipColumns.All(x => x.FirstSideColumnID == x.SecondSideColumnID)) { isSelfTable = true; //foreach (var prop in item.GetProperties()) // childItem.AddProperty(prop.Column, prop.Value); } if (child.RelatedData.Any()) { foreach (var pkData in child.RelatedData) { var pkQueryItem = SetSortedTree(requester, result, pkData); //int pkIdentityColumnID = 0; //if (pkData.IsNewItem) // if (pkData.KeyProperties.Any(x => x.IsIdentity)) // { // pkIdentityColumnID = pkData.KeyProperties.First(x => x.IsIdentity).ColumnID; // } // queryItem.FKSources.Add(new FKToPK(child.Relationship, pkQueryItem, pkIdentityColumnID, isSelfTable)); if (child.RelationshipIsChangedForUpdate) { foreach (var relCol in child.Relationship.RelationshipColumns) { var fkprop = item.GetProperty(relCol.FirstSideColumnID); if (fkprop == null) { fkprop = new EntityInstanceProperty(relCol.FirstSideColumn); } var pkprop = pkData.GetProperty(relCol.SecondSideColumnID); if (pkData.IsNewItem && (pkprop.Column.IsIdentity || pkprop.PKIdentityColumn != null)) { fkprop.Value = "{" + fkprop.ColumnID + "}"; fkprop.PKIdentityColumn = pkprop; } else { fkprop.Value = pkData.GetProperty(relCol.SecondSideColumnID).Value; } //fkprop.IsHidden = child.IsHidden; foreignKeyProperties.Add(fkprop); } } } } else { if (item.IsNewItem || (child.RelationshipIsChangedForUpdate && child.RemovedDataForUpdate.Any())) { foreach (var relCol in child.Relationship.RelationshipColumns) { var fkprop = item.GetProperty(relCol.FirstSideColumnID); if (fkprop == null) { fkprop = new EntityInstanceProperty(relCol.FirstSideColumn); } fkprop.Value = null; //prop.IsHidden = child.IsHidden; foreignKeyProperties.Add(fkprop); } } } foreach (var fkProp in foreignKeyProperties) { fkProp.HasForeignKeyData = true; editingProperties.Add(fkProp); } } if (parentChildRelationshipInfo != null && parentChildRelationshipInfo.Relationship.MastertTypeEnum == Enum_MasterRelationshipType.FromPrimartyToForeign) { bool isSelfTable = false; if (parentChildRelationshipInfo.Relationship.RelationshipColumns.All(x => x.FirstSideColumnID == x.SecondSideColumnID)) { isSelfTable = true; //foreach (var prop in item.GetProperties()) // childItem.AddProperty(prop.Column, prop.Value); } //int pkIdentityColumnID = 0; //if (parentItem.IsNewItem) // if (parentItem.KeyProperties.Any(x => x.IsIdentity)) // { // pkIdentityColumnID = parentItem.KeyProperties.First(x => x.IsIdentity).ColumnID; // } //parentQueryItem همون طرف pk هست //var relationship = bizRelationship.GetRelationship(parentChildRelationshipInfo.Relationship.PairRelationshipID); //queryItem.FKSources.Add(new FKToPK(relationship, parentQueryItem, pkIdentityColumnID, isSelfTable)); if (parentChildRelationshipInfo.RelationshipIsChangedForUpdate && item.IsEdited) //اینجا edited اضافه شد چون ممکنه یک به چند باشه و فقط یک داده فرزند اضافه شده باشد { foreach (var relCol in parentChildRelationshipInfo.Relationship.RelationshipColumns) { var fkprop = item.GetProperty(relCol.SecondSideColumnID); if (fkprop == null) { fkprop = new EntityInstanceProperty(relCol.SecondSideColumn); } var pkprop = parentQueryItem.DataItem.GetProperty(relCol.FirstSideColumnID); if (parentQueryItem.DataItem.IsNewItem && (pkprop.Column.IsIdentity || pkprop.PKIdentityColumn != null)) { fkprop.Value = "{" + fkprop.ColumnID + "}"; fkprop.PKIdentityColumn = pkprop; } else { fkprop.Value = pkprop.Value; } fkprop.HasForeignKeyData = true; //fkprop.IsHidden = parentChildRelationshipInfo.IsHidden; editingProperties.Add(fkprop); } } } QueryItem queryItem = new QueryItem(GetTableDrivedDTO(requester, item.TargetEntityID), item.IsNewItem ? Enum_QueryItemType.Insert : Enum_QueryItemType.Update, editingProperties, item); result.Add(queryItem); foreach (var child in item.ChildRelationshipInfos.Where(x => x.Relationship.MastertTypeEnum == Enum_MasterRelationshipType.FromPrimartyToForeign)) { foreach (var childItem in child.RelatedData) { SetSortedTree(requester, result, childItem, queryItem, child); } } return(queryItem); }
private void BindableTypeDescriptor_PropertyGetCalled(object sender, PropertyGetArg e) { if (e.PropertyInfo.ValueSearched == false) { if (e.PropertyInfo.PropertyType == PropertyType.Relationship) { List <DP_DataRepository> relatedDataItems = GetRelatedDataItems((sender as CustomObject).DataItem, e.PropertyInfo.PropertyRelationship, e.PropertyInfo.PropertyRelationshipProperties); if (e.PropertyInfo.PropertyRelationship.TypeEnum == Enum_RelationshipType.OneToMany) { var list = FormulaInstanceInternalHelper.GetNewFormulaObjectList(e.PropertyInfo); var entity = bizTableDrivedEntity.GetPermissionedEntity(Requester, e.PropertyInfo.PropertyRelationship.EntityID2); foreach (var relatedDataItem in relatedDataItems) { var newObject = FormulaInstanceInternalHelper.GetNewFormulaObject(e.PropertyInfo); newObject.DataItem = relatedDataItem; list.Add(newObject); newObject.PropertyGetCalled += BindableTypeDescriptor_PropertyGetCalled; //newObject.PropertySetChanged += FormulaObject_PropertySetChanged; //newObject.PropertyChanged += FormulaObject_PropertyChanged; //////newObject.PropertySetChanged += (sender1, e1) => NewObject_PropertySetChanged(sender1, e1, sender as FormulaObject); //////newObject.PropertyGetCalled += (sender1, e1) => NewObject_PropertyGetCalled(sender1, e1, sender as FormulaObject); } e.PropertyInfo.Value = list; var properties = FormulaInstanceInternalHelper.GetProperties(entity, e.PropertyInfo, false); foreach (CustomObject item in (e.PropertyInfo.Value as IList)) { //بهتر نوشته شود.برای لیست لازم نیست هر دفعه خصوصیات خوانده شوند if (item.PropertiesLoaded == false) { item.SetProperties(properties); } } } else if (relatedDataItems.Any()) { var entity = bizTableDrivedEntity.GetPermissionedEntity(Requester, e.PropertyInfo.PropertyRelationship.EntityID2); var properties = FormulaInstanceInternalHelper.GetProperties(entity, e.PropertyInfo, false); var newObject = FormulaInstanceInternalHelper.GetNewFormulaObject(e.PropertyInfo); newObject.DataItem = relatedDataItems.First(); newObject.PropertyGetCalled += BindableTypeDescriptor_PropertyGetCalled; //newObject.PropertySetChanged += FormulaObject_PropertySetChanged; //newObject.PropertyChanged += FormulaObject_PropertyChanged; e.PropertyInfo.Value = newObject; if ((e.PropertyInfo.Value as CustomObject).PropertiesLoaded == false) { (e.PropertyInfo.Value as CustomObject).SetProperties(properties); } } e.PropertyInfo.ValueSearched = true; } else if (e.PropertyInfo.PropertyType == PropertyType.Column) { e.PropertyInfo.ValueSearched = true; EntityInstanceProperty property = (sender as CustomObject).DataItem.GetProperty(e.PropertyInfo.ID); if (property != null) { e.PropertyInfo.Value = property.Value; } } else if (e.PropertyInfo.PropertyType == PropertyType.FormulaParameter) { if (UsedFormulaIDs != null && UsedFormulaIDs.Contains(e.PropertyInfo.ParameterFormulaID)) { AddException("Loop"); } UsedFormulaIDs.Add(e.PropertyInfo.ParameterFormulaID); Application.Current.Dispatcher.Invoke((Action) delegate { e.PropertyInfo.ValueSearched = true; var value = FormulaFunctionHandler.CalculateFormula(e.PropertyInfo.ParameterFormulaID, (sender as CustomObject).DataItem, Requester, false, UsedFormulaIDs); if (string.IsNullOrEmpty(value.Exception)) { //if ((e.PropertyInfo.Context is FormulaDTO) && (e.PropertyInfo.Context as FormulaDTO).ValueCustomType != ValueCustomType.None) // e.PropertyInfo.Value = GetCustomTypePropertyValue(e.PropertyInfo, (e.PropertyInfo.Context as FormulaDTO).ValueCustomType, value.Result); //else e.PropertyInfo.Value = value.Result; e.FormulaUsageParemeters = value.FormulaUsageParemeters; } else { AddException(value.Exception); } }); } else if (e.PropertyInfo.PropertyType == PropertyType.State) { Application.Current.Dispatcher.Invoke((Action) delegate { DP_DataRepository dataItem = (sender as CustomObject).DataItem; e.PropertyInfo.ValueSearched = true; var result = StateHandler.GetStateResult(e.PropertyInfo.ID, (sender as CustomObject).DataItem, Requester); if (string.IsNullOrEmpty(result.Message)) { e.PropertyInfo.Value = result.Result; } else { AddException(result.Message); } }); } else if (e.PropertyInfo.PropertyType == PropertyType.Code) { Application.Current.Dispatcher.Invoke((Action) delegate { DP_DataRepository dataItem = (sender as CustomObject).DataItem; e.PropertyInfo.ValueSearched = true; var result = CodeFunctionHandler.GetCodeFunctionResult(Requester, e.PropertyInfo.ID, dataItem); if (result.ExecutionException == null) { e.PropertyInfo.Value = result.Result; } else { AddException(result.ExecutionException.Message); e.PropertyInfo.Value = ""; } //if ((e.PropertyInfo.Context is CodeFunctionDTO) && (e.PropertyInfo.Context as CodeFunctionDTO).ValueCustomType != ValueCustomType.None) // e.PropertyInfo.Value = GetCustomTypePropertyValue(e.PropertyInfo, (e.PropertyInfo.Context as CodeFunctionDTO).ValueCustomType, result.Result); //else }); } } if (PropertyGetCalled != null) { PropertyGetCalled(sender, e); } }
//private void CheckRelationshipReadonlyEnablity() //{ //} //اونی که کلید نداره قتی اول میشه موقع آپدیت اونی که کلید داره مقدار موجود اولیو نمیگیره؟؟ //تنها یکبار و برای نمایش مقادیر در کنترلهای ساده و غیر فرمی صدا زده میشود //public bool ShowTypePropertyControlValue(DP_DataRepository dataItem, SimpleColumnControl typePropertyControl, string value) //{ // return typePropertyControl.SetValue(value); //} public void SetBinding(DP_DataRepository dataItem, SimpleColumnControl typePropertyControl, EntityInstanceProperty property) { typePropertyControl.SimpleControlManager.SetBinding(dataItem, property); }
//private void RelatedDataColumnValueChanged(object sender, RelatedDataColumnValueChangedArg e, FormulaDTO formula, DP_DataRepository dataItem, int columnID) //{ //} public void CalculateProperty(EntityInstanceProperty dataProperty, ColumnCustomFormulaDTO columnCustomFormula, DP_DataRepository dataItem, bool asDefault) { var key = "formulaCalculated" + "_" + dataProperty.ColumnID; EditArea.RemoveDataItemMessage(dataItem, key); if (columnCustomFormula.OnlyOnNewData) { if (!dataItem.IsNewItem) { AddDataMessageItem(dataItem, key, ControlItemPriority.Normal, "فرمول" + " " + columnCustomFormula.Formula.Name + " " + "بروی داده موجود اعمال نمی شود"); return; } } if (columnCustomFormula.OnlyOnEmptyValue) { if (dataProperty.Value != null && !string.IsNullOrEmpty(dataProperty.Value.ToString())) { AddDataMessageItem(dataItem, key, ControlItemPriority.Normal, "فرمول" + " " + columnCustomFormula.Formula.Name + " " + "بروی خصوصیت دارای مقدار اعمال نمی شود"); return; } } var result = AgentUICoreMediator.GetAgentUICoreMediator.formulaManager.CalculateFormula(columnCustomFormula.Formula.ID, dataItem, AgentUICoreMediator.GetAgentUICoreMediator.GetRequester()); dataProperty.FormulaID = columnCustomFormula.Formula.ID; dataProperty.FormulaException = null; dataProperty.FormulaUsageParemeters = result.FormulaUsageParemeters; if (result.Exception == null) { //dataProperty.Value = result.Result; // AddDataMessageItem(dataItem, key, ControlItemPriority.Normal, "محاسبه شده توسط فرمول" + " " + columnCustomFormula.Formula.Title); } else { dataProperty.FormulaException = result.Exception.Message; // dataProperty.Value = ""; //اینجا خطا روی ستون یا رابطه بدهد AddDataMessageItem(dataItem, key, ControlItemPriority.Normal, "خطا در محاسبه فرمول" + " " + columnCustomFormula.Formula.Title + ":" + " " + dataProperty.FormulaException); } if (asDefault) { dataProperty.Value = result.Result; } else { var uiColumnValue = new UIColumnValueDTO(); uiColumnValue.ColumnID = columnCustomFormula.ID; //ابجکت نشه؟ExactValue uiColumnValue.ExactValue = result.Result.ToString(); uiColumnValue.EvenHasValue = !columnCustomFormula.OnlyOnEmptyValue; uiColumnValue.EvenIsNotNew = !columnCustomFormula.OnlyOnNewData; List <UIColumnValueDTO> uIColumnValues = new List <UIColumnValueDTO>() { uiColumnValue }; EditArea.SetColumnValueFromState(dataItem, uIColumnValues, null, columnCustomFormula.Formula); } }
public void SetBinding(object dataItem, EntityInstanceProperty property) { MyControlHelper.SetBinding(property); }
public void SetBinding(object dataItem, EntityInstanceProperty property) { DataGridColumn.SetBinding(dataItem, property); }
private void ValidateSimpleColumn(DP_DataRepository dataItem, EntityInstanceProperty dataColumn, SimpleColumnControl simplePropertyControl) { if (simplePropertyControl.Column.IsMandatory == true) { if (dataColumn.Value == null || dataColumn.Value.ToString() == "") { if (dataItem.IsNewItem == false || simplePropertyControl.Column.IsIdentity == false) { AddColumnControlValidationMessage(simplePropertyControl, "مقدار دهی این خصوصیت اجباری می باشد", dataItem); } } } if (dataColumn.Value != null && dataColumn.Value.ToString() != "") { if (simplePropertyControl.Column.StringColumnType != null) { if (simplePropertyControl.Column.StringColumnType.MaxLength != 0 && simplePropertyControl.Column.StringColumnType.MaxLength != -1) { if (dataColumn.Value.ToString().Length > simplePropertyControl.Column.StringColumnType.MaxLength) { string message = "حداکثر طول این خصوصیت" + " " + simplePropertyControl.Column.StringColumnType.MaxLength + " " + "کاراکتر می باشد"; AddColumnControlValidationMessage(simplePropertyControl, message, dataItem); } } if (simplePropertyControl.Column.StringColumnType.MinLength != 0 && simplePropertyControl.Column.StringColumnType.MinLength != null) { if (dataColumn.Value.ToString().Length < simplePropertyControl.Column.StringColumnType.MinLength) { string message = "حداقل طول این خصوصیت" + " " + simplePropertyControl.Column.StringColumnType.MinLength + " " + "کاراکتر می باشد"; AddColumnControlValidationMessage(simplePropertyControl, message, dataItem); } } } if (simplePropertyControl.Column.NumericColumnType != null) { if (simplePropertyControl.Column.NumericColumnType.MinValue != null) { var value = Convert.ToDouble(dataColumn.Value); if (value < simplePropertyControl.Column.NumericColumnType.MinValue.Value) { string message = "حداقل مقدار این خصوصیت" + " " + simplePropertyControl.Column.NumericColumnType.MinValue.Value + " " + "می باشد"; AddColumnControlValidationMessage(simplePropertyControl, message, dataItem); } } if (simplePropertyControl.Column.NumericColumnType.MaxValue != null) { var value = Convert.ToDouble(dataColumn.Value); if (value > simplePropertyControl.Column.NumericColumnType.MaxValue.Value) { string message = "حداکثر مقدار این خصوصیت" + " " + simplePropertyControl.Column.NumericColumnType.MaxValue.Value + " " + "می باشد"; AddColumnControlValidationMessage(simplePropertyControl, message, dataItem); } } if (simplePropertyControl.Column.NumericColumnType.Precision != 0) { var value = Convert.ToDouble(dataColumn.Value); if (value.ToString().Replace(".", "").Length > simplePropertyControl.Column.NumericColumnType.Precision) { string message = "تعداد اعداد این خصوصیت از مقدار تعیین شده" + " " + simplePropertyControl.Column.NumericColumnType.Precision + " " + "بیشتر می باشد"; AddColumnControlValidationMessage(simplePropertyControl, message, dataItem); } } if (simplePropertyControl.Column.NumericColumnType.Scale != 0) { var value = Convert.ToDouble(dataColumn.Value); if (value.ToString().Contains(".")) { var splt = value.ToString().Split('.')[1]; if (splt.Length > simplePropertyControl.Column.NumericColumnType.Scale) { string message = "تعداد اعشار این خصوصیت از مقدار تعیین شده" + " " + simplePropertyControl.Column.NumericColumnType.Scale + " " + "بیشتر می باشد"; AddColumnControlValidationMessage(simplePropertyControl, message, dataItem); } } } } if (simplePropertyControl.Column.StringColumnType != null) { if (!string.IsNullOrEmpty(simplePropertyControl.Column.StringColumnType.Format)) { Regex regex = new Regex(simplePropertyControl.Column.StringColumnType.Format); if (!regex.IsMatch(dataColumn.Value.ToString())) { string message = "فرمت این خصوصیت صحیح نمی باشد"; AddColumnControlValidationMessage(simplePropertyControl, message, dataItem); } } } if (simplePropertyControl.Column.ColumnValueRange != null && simplePropertyControl.Column.ColumnValueRange.Details.Any()) { List <ColumnValueRangeDetailsDTO> validValueRange = null; if (dataItem.ColumnKeyValueRanges.Any(x => x.Key == simplePropertyControl.Column.ID && x.Value.Any())) { validValueRange = dataItem.ColumnKeyValueRanges.First(x => x.Key == simplePropertyControl.Column.ID && x.Value.Any()).Value; } else { validValueRange = simplePropertyControl.Column.ColumnValueRange.Details; } //if (simplePropertyControl.Column.ColumnValueRange.ValueFromTitleOrValue) //{ // if (!validValueRange.Any(x => x.KeyTitle == dataColumn.Value)) // { // string message = "مقدار این خصوصیت در لیست مقادیر مجاز نمی باشد"; // AddColumnControlValidationMessage(simplePropertyControl, message, dataItem); // } //} //else //{ if (!validValueRange.Any(x => x.Value == dataColumn.Value.ToString())) { string message = "مقدار این خصوصیت در لیست مقادیر مجاز نمی باشد"; AddColumnControlValidationMessage(simplePropertyControl, message, dataItem); } //} } } }