Example #1
0
        public bool IsEditable(View view, Field field, ParentField derivationField, string derivedValue)
        {
            if (derivationField == null)
            {
                return(true);
            }


            if (derivedValue == null)
            {
                return(true);
            }

            Dictionary <string, Dictionary <string, Field> > deriveds = GetDeriveds(view);

            if (deriveds.ContainsKey(derivedValue))
            {
                if (deriveds[derivedValue].ContainsKey(field.Name))
                {
                    return(false);
                }
            }

            return(true);
        }
Example #2
0
        protected override void BeforeEdit(EditEventArgs e)
        {
            string[] views = new string[4] {
                ShadeViews.Job.ToString(), ShadeViews.V_Contact.ToString(), ShadeViews.v_Proposal.ToString(), ShadeViews.Organization.ToString()
            };
            if (views.Contains(e.View.Name))
            {
                Durados.ParentField parentField = e.View.GetParentField("d_LastUpdatedBy");
                if (parentField != null)
                {
                    string fieldName = parentField.Name;
                    if (!e.Values.ContainsKey(fieldName))
                    {
                        e.Values.Add(fieldName, ((Database)e.View.Database).GetUserID());
                    }
                    else
                    {
                        e.Values[fieldName] = ((Database)e.View.Database).GetUserID();
                    }
                }

                if (!e.Values.ContainsKey("d_LastUpdateDate"))
                {
                    e.Values.Add("d_LastUpdateDate", DateTime.Now.ToString());
                }
                else
                {
                    e.Values["d_LastUpdateDate"] = DateTime.Now.ToString();
                }
            }
            base.BeforeEdit(e);
        }
Example #3
0
        public ParentField GetFirstNonEquivalentParentField()
        {
            ParentField equivalent = GetEquivalentParentField();

            //changed by br 2
            return(ChildrenView.Fields.Values.FirstOrDefault(f => f.FieldType == FieldType.Parent && f.Name != equivalent.Name) as ParentField);
            //return (ParentField)ChildrenView.Fields.Values.Where(f => f.FieldType == FieldType.Parent && f.Name != equivalent.Name).First();
        }
Example #4
0
        public virtual bool IsDuplicable()
        {
            ParentField parentField = GetRelatedParentField();

            if (parentField == null)
            {
                return(false);
            }
            return(parentField.Integral);
        }
Example #5
0
        public View GetOtherParentView(out ParentField parentField, out ParentField fkField)
        {
            parentField = null;
            fkField     = null;

            View childrenView = ChildrenView;
            View view         = View;
            View parentView   = null;

            var parentFields = childrenView.Fields.Values.Where(f => f.FieldType == FieldType.Parent);

            foreach (ParentField field in parentFields)
            {
                if (!field.ParentView.Base.Equals(view.Base))
                {
                    parentField = field;
                    parentView  = field.ParentView;
                }
                else
                {
                    fkField = field;
                }
            }

            if (parentView == null)
            {
                if (parentFields.Count() == 2)
                {
                    if (((ParentField)parentFields.FirstOrDefault()).ParentView.Equals(((ParentField)parentFields.LastOrDefault()).ParentView))
                    {
                        ParentField p1 = (ParentField)parentFields.FirstOrDefault();
                        ParentField p2 = (ParentField)parentFields.LastOrDefault();

                        if (!p1.DataRelation.ChildColumns[0].Equals(this.DataRelation.ChildColumns[0]))
                        {
                            parentField = p1;
                            fkField     = p2;
                        }
                        else
                        {
                            parentField = p2;
                            fkField     = p1;
                        }
                        parentView = parentField.ParentView;
                    }
                }
            }

            return(parentView);
        }
Example #6
0
        public List <ParentField> GetDependencyDynasty()
        {
            List <ParentField> dependencyFields = new List <ParentField>();

            ParentField dependencyField = DependencyField;

            while (dependencyField != null)
            {
                dependencyFields.Add(dependencyField);

                dependencyField = dependencyField.DependencyField;
            }

            return(dependencyFields);
        }
Example #7
0
        public bool EqualInDatabase(ParentField field)
        {
            if (field.DataRelation.ChildColumns.Length != DataRelation.ChildColumns.Length)
            {
                return(false);
            }

            for (int i = 0; i < field.DataRelation.ChildColumns.Length; i++)
            {
                if (!field.DataRelation.ChildColumns[i].ColumnName.Equals(DataRelation.ChildColumns[i].ColumnName))
                {
                    return(false);
                }
            }

            return(true);
        }
Example #8
0
        public bool IsEditable(View view, Field field, System.Data.DataRow row)
        {
            ParentField derivationField = GetDerivationField(view);

            if (derivationField == null)
            {
                return(true);
            }

            string derivedValue = derivationField.GetValue(row);

            if (derivedValue == null)
            {
                return(true);
            }

            return(IsEditable(view, field, derivationField, derivedValue));
        }
Example #9
0
        private string GetFromCache()
        {
            ParentField parentField = GetEquivalentParentField();
            string      tableName   = parentField.View.DataTable.TableName;
            string      columnName  = parentField.GetColumnsNames()[0];

            if (View.Database.ForeignKeys.ContainsKey(tableName) && View.Database.ForeignKeys[tableName].ContainsKey(columnName))
            {
                string name = View.Database.ForeignKeys[tableName][columnName];
                if (name.Contains(_bkname_))
                {
                    string[] s = name.Split(new string[] { _bkname_ }, StringSplitOptions.None);
                    return(s.Last());
                }
            }


            return(null);
        }
Example #10
0
        public bool IsDerivationEditable(Dictionary <string, object> values)
        {
            if (View.Derivation == null)
            {
                return(true);
            }

            ParentField derivationField = View.Derivation.GetDerivationField(View);

            if (values.ContainsKey(derivationField.Name))
            {
                object derivedValue = values[derivationField.Name];
                if (derivedValue != null && !derivedValue.Equals(string.Empty))
                {
                    return(View.Derivation.IsEditable(View, this, derivationField, derivedValue.ToString()));
                }
                else
                {
                    return(true);
                }
            }
            return(true);
        }
Example #11
0
        private ParentField GetRelatedParentField(View childrenView)
        {
            if (relatedParentField != null)
            {
                return(relatedParentField);
            }

            foreach (ParentField parentField in childrenView.Fields.Values.Where(parentField => parentField.FieldType == FieldType.Parent))
            {
                if (DataRelation.RelationName == parentField.DataRelation.RelationName)
                {
                    relatedParentField = parentField;
                    break;
                }
            }

            if (relatedParentField == null)
            {
                throw new DuradosException("Parent children relation is invalid.");
            }

            return(relatedParentField);
        }
Example #12
0
        public override void LoadValues(Dictionary <string, object> values, DataRow dataRow, Durados.View view, Durados.ParentField parentField, Durados.View rootView, string dynastyPath, string prefix, string postfix, Dictionary <string, Durados.Workflow.DictionaryField> dicFields, string internalDynastyPath)
        {
            if (view.Equals(rootView))
            {
                dynastyPath         = GetViewDisplayName((View)view) + ".";
                internalDynastyPath = view.Name + ".";
            }
            foreach (Field field in view.Fields.Values.Where(f => f.FieldType == FieldType.Column))
            {
                LoadValue(values, dataRow, view, field, dynastyPath, prefix, postfix, dicFields, internalDynastyPath);
            }

            var childrenFields = view.Fields.Values.Where(f => f.FieldType == FieldType.Children && ((ChildrenField)f).LoadForBlockTemplate);

            foreach (ChildrenField field in childrenFields)
            {
                string   name         = prefix + dynastyPath + field.DisplayName + postfix;
                string   internalName = prefix + internalDynastyPath + field.Name + postfix;
                DataView value        = GetDataView(field, dataRow);
                if (!values.ContainsKey(name))
                {
                    values.Add(name, value);
                    dicFields.Add(internalDynastyPath, new Durados.Workflow.DictionaryField {
                        DisplayName = field.DisplayName, Type = field.DataType, Value = value
                    });
                }

                foreach (ColumnField columnField in field.ChildrenView.Fields.Values.Where(f => f.FieldType == FieldType.Column))
                {
                    if (columnField.Upload != null)
                    {
                        value.Table.Columns[columnField.Name].ExtendedProperties["ImagePath"] = columnField.GetUploadPath();
                    }
                }
            }

            foreach (ParentField field in view.Fields.Values.Where(f => f.FieldType == FieldType.Parent))
            {
                if (view.Equals(rootView))
                {
                    dynastyPath         = view.DisplayName + ".";
                    internalDynastyPath = view.Name + ".";
                }
                LoadValue(values, dataRow, view, field, dynastyPath, prefix, postfix, dicFields, internalDynastyPath);



                DataRow parentRow  = dataRow.GetParentRow(field.DataRelation.RelationName);
                View    parentView = (View)field.ParentView;
                if (parentRow == null)
                {
                    string key = field.GetValue(dataRow);
                    if (!string.IsNullOrEmpty(key))
                    {
                        parentRow = parentView.GetDataRow(key, dataRow.Table.DataSet);
                    }
                }
                if (parentRow != null && parentField != field)
                {
                    if (parentView != rootView)
                    {
                        //dynastyPath += field.DisplayName + ".";
                        dynastyPath         = GetDynastyPath(dynastyPath, (ParentField)parentField, field);
                        internalDynastyPath = GetInternalDynastyPath(internalDynastyPath, (ParentField)parentField, field);
                        LoadValues(values, parentRow, parentView, field, rootView, dynastyPath, prefix, postfix, dicFields, internalDynastyPath);
                    }
                }
            }
        }
Example #13
0
 public BeforeDropDownOptionsEventArgs(ParentField parentField, string sql)
     : base()
 {
     this.parentField = parentField;
     this.sql         = sql;
 }