Пример #1
0
        private void ProcessControl(Control c, BusinessObject _obj)
        {
            IEditControl editControl = c as IEditControl;

            if (editControl != null)
            {
                string fieldName = editControl.FieldName;

                string    ownFieldName  = fieldName;
                string    aggrFieldName = String.Empty;
                MetaField ownField      = null;
                MetaField aggrField     = null;
                if (ownFieldName.Contains("."))
                {
                    string[] mas = ownFieldName.Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries);
                    if (mas.Length > 1)
                    {
                        ownFieldName  = mas[0];
                        aggrFieldName = mas[1];
                        string aggrClassName = _obj.Properties[ownFieldName].GetMetaType().Attributes[McDataTypeAttribute.AggregationMetaClassName].ToString();
                        aggrField = MetaDataWrapper.GetMetaFieldByName(aggrClassName, aggrFieldName);
                    }
                }
                ownField = _obj.Properties[ownFieldName].GetMetaType();

                object eValue = editControl.Value;

                bool makeChange = true;

                MetaField field = (aggrField == null) ? ownField : aggrField;
                if ((!field.IsNullable && eValue == null) ||
                    _obj.Properties[ownFieldName].IsReadOnly)
                {
                    makeChange = false;
                }

                if (makeChange)
                {
                    if (aggrField == null)
                    {
                        _obj[ownFieldName] = eValue;
                    }
                    else
                    {
                        //make aggregation
                        MetaObject aggrObj = (MetaObject)_obj[ownFieldName];
                        aggrObj[aggrFieldName] = eValue;
                    }
                }
            }

            BaseServiceEditControl bsc = c as BaseServiceEditControl;

            if (bsc != null)
            {
                bsc.Save(_obj);
            }
        }
Пример #2
0
 private static void MakeDataBindColl(ControlCollection _coll, object _obj)
 {
     foreach (Control c in _coll)
     {
         if (c is MCDataBoundControl)
         {
             MCDataBoundControl dbcontrol = (MCDataBoundControl)c;
             dbcontrol.DataItem = _obj;
             dbcontrol.DataBind();
             continue;
         }
         else if (c is BaseServiceEditControl)
         {
             BaseServiceEditControl bscontrol = (BaseServiceEditControl)c;
             bscontrol.DataItem = _obj;
             bscontrol.DataBind();
             continue;
         }
         else if (c.Controls.Count > 0)
         {
             MakeDataBindColl(c.Controls, _obj);
         }
     }
 }