Exemple #1
0
        public virtual EditControl getControl(dynamic _param_field, dynamic _param_id = null, dynamic _param_extraParmas = null)
        {
            #region default values
            if (_param_id as Object == null)
            {
                _param_id = new XVar("");
            }
            if (_param_extraParmas as Object == null)
            {
                _param_extraParmas = new XVar(XVar.Array());
            }
            #endregion

            #region pass-by-value parameters
            dynamic field       = XVar.Clone(_param_field);
            dynamic id          = XVar.Clone(_param_id);
            dynamic extraParmas = XVar.Clone(_param_extraParmas);
            #endregion

            dynamic className = null, ctrl = null;
            if ((XVar)(MVCFunctions.count(extraParmas)) && (XVar)(extraParmas["getDetKeyReadOnlyCtrl"]))
            {
                className      = XVar.Clone(this.classNamesForEdit[Constants.EDIT_FORMAT_READONLY]);
                ctrl           = XVar.Clone(MVCFunctions.createControlClass((XVar)(className), (XVar)(field), (XVar)((XVar.Pack(this.pageObject != null) ? XVar.Pack(this.pageObject) : this)), (XVar)(id), (XVar)(this.connection)));
                ctrl.container = XVar.Clone(this);
                return(XVar.UnPackEditControl(ctrl ?? new XVar()));
            }
            if ((XVar)(MVCFunctions.count(extraParmas)) && (XVar)(extraParmas["getConrirmFieldCtrl"]))
            {
                className = XVar.Clone(this.classNamesForEdit[Constants.EDIT_FORMAT_PASSWORD]);
                ctrl      = XVar.Clone(MVCFunctions.createControlClass((XVar)(className), (XVar)(field), (XVar)((XVar.Pack(this.pageObject != null) ? XVar.Pack(this.pageObject) : this)), (XVar)(id), (XVar)(this.connection)));
                if (XVar.Pack(extraParmas["isConfirm"]))
                {
                    ctrl.field = XVar.Clone(CommonFunctions.GetPasswordField());
                }
                ctrl.container = XVar.Clone(this);
                return(XVar.UnPackEditControl(ctrl ?? new XVar()));
            }
            if (XVar.Pack(!(XVar)(this.controls.KeyExists(field))))
            {
                dynamic editFormat = null, userControl = null;
                userControl = new XVar(false);
                editFormat  = XVar.Clone(this.pSetEdit.getEditFormat((XVar)(field)));
                if ((XVar)(editFormat == Constants.EDIT_FORMAT_TEXT_FIELD) && (XVar)(CommonFunctions.IsDateFieldType((XVar)(this.pSetEdit.getFieldType((XVar)(field))))))
                {
                    editFormat = new XVar(Constants.EDIT_FORMAT_DATE);
                }
                if ((XVar)(this.pageType == Constants.PAGE_SEARCH) || (XVar)(this.pageType == Constants.PAGE_LIST))
                {
                    dynamic pageTypebyLookupFormat = null;
                    pageTypebyLookupFormat = XVar.Clone(this.pSetEdit.getPageTypeByFieldEditFormat((XVar)(field), new XVar(Constants.EDIT_FORMAT_LOOKUP_WIZARD)));
                    if ((XVar)(editFormat == Constants.EDIT_FORMAT_TEXT_FIELD) && (XVar)(pageTypebyLookupFormat != XVar.Pack("")))
                    {
                        dynamic localPSet = null;
                        localPSet = XVar.Clone(new ProjectSettings((XVar)(this.pSetEdit._table), (XVar)(pageTypebyLookupFormat)));
                        if (localPSet.getLinkField((XVar)(field)) != localPSet.getDisplayField((XVar)(field)))
                        {
                            className = new XVar("LookupTextField");
                        }
                        else
                        {
                            className = XVar.Clone(this.classNamesForSearch[editFormat]);
                        }
                    }
                    else
                    {
                        className = XVar.Clone(this.classNamesForSearch[editFormat]);
                    }
                }
                else
                {
                    className = XVar.Clone(this.classNamesForEdit[editFormat]);
                }
                if ((XVar)(className == this.classNamesForEdit[Constants.EDIT_FORMAT_FILE]) && (XVar)(this.pSetEdit.isBasicUploadUsed((XVar)(field))))
                {
                    className = new XVar("FileFieldSingle");
                }
                if (XVar.Pack(!(XVar)(className)))
                {
                    if (editFormat != XVar.Pack(""))
                    {
                        className   = XVar.Clone(MVCFunctions.Concat("Edit", editFormat));
                        userControl = new XVar(true);
                        if (XVar.Pack(!(XVar)(this.pageObject == null)))
                        {
                            this.pageObject.AddJSFile((XVar)(MVCFunctions.Concat("include/runnerJS/controls/", className, ".js")), new XVar("include/runnerJS/editControls/Control.js"));
                        }
                    }
                    else
                    {
                        className = XVar.Clone(this.classNamesForEdit[Constants.EDIT_FORMAT_TEXT_FIELD]);
                    }
                }
                this.controls.InitAndSetArrayItem(MVCFunctions.createControlClass((XVar)(className), (XVar)(field), (XVar)((XVar.Pack(this.pageObject != null) ? XVar.Pack(this.pageObject) : this)), (XVar)(id), (XVar)(this.connection)), field);
                this.controls[field].container = XVar.Clone(this);
                if (XVar.Pack(userControl))
                {
                    this.controls[field].format = XVar.Clone(className);
                    this.controls[field].initUserControl();
                }
            }
            if (!XVar.Equals(XVar.Pack(id), XVar.Pack("")))
            {
                this.controls[field].setID((XVar)(id));
            }
            return(XVar.UnPackEditControl(this.controls[field] ?? new XVar()));
        }