public void ClickFieldHandler(object sender, ClickFieldEventArg e)
        {
            Control currentControl = (Control)sender;
            if (e.Field is RelatedViewField)
            {
                this.EnterCheckCodeEngine.CheckCodeHandler(sender, new RunCheckCodeEventArgs(EventActionEnum.ClickField, ""));

                if (CheckRequiredFields(currentControl))
                {
                    RelatedViewField rvField = (RelatedViewField)e.Field;
                    Epi.View childView = rvField.GetProject().Metadata.GetChildView(rvField);

                    if (childView == null)
                    {
                        MsgBox.Show(SharedStrings.WARNING_CHILD_VIEW_NOT_SET, SharedStrings.ENTER);
                    }
                    else
                    {
                        childView.ReturnToParent = rvField.ShouldReturnToParent;
                        if (childView != null)
                        {
                            this.SetFieldData();
                            this.EnterCheckCodeEngine.SaveRecord();
                            childView.ForeignKeyField.CurrentRecordValueString = rvField.GetView().CurrentGlobalRecordId;
                            this.OpenViewHandler(this, new OpenViewEventArgs(childView));

                        }
                    }
                }
            }
            else if (e.Field is CommandButtonField)
            {
                ControlFactory factory = ControlFactory.Instance;
                Epi.Page ThisPage = this.EnterCheckCodeEngine.CurrentView.CurrentPage;
                Epi.Fields.Field ThisField = this.EnterCheckCodeEngine.CurrentView.CurrentField;

                this.EnterCheckCodeEngine.CheckCodeHandler(sender, new RunCheckCodeEventArgs(EventActionEnum.ClickField, ""));
            }
            else if (e.Field is ImageField)
            {
                SelectImage(e.Field as ImageField, sender as PictureBox);
            }
            else if (e.Field is CheckBoxField)
            {
                ControlFactory factory = ControlFactory.Instance;
                Epi.Page ThisPage = this.EnterCheckCodeEngine.CurrentView.CurrentPage;
                Epi.Fields.Field ThisField = this.EnterCheckCodeEngine.CurrentView.CurrentField;
                this.EnterCheckCodeEngine.CheckCodeHandler(sender, new RunCheckCodeEventArgs(EventActionEnum.ClickField, ""));
            }
            else if (e.Field is OptionField)
            {
                ControlFactory factory = ControlFactory.Instance;
                Epi.Page ThisPage = this.EnterCheckCodeEngine.CurrentView.CurrentPage;
                Epi.Fields.Field ThisField = this.EnterCheckCodeEngine.CurrentView.CurrentField;
                this.EnterCheckCodeEngine.CheckCodeHandler(sender, new RunCheckCodeEventArgs(EventActionEnum.ClickField, ""));
            }
        }
Exemple #2
0
        public void ClickFieldHandler(object sender, ClickFieldEventArg e)
        {
            Control currentControl = (Control)sender;

            if (e.Field is RelatedViewField)
            {
                this.EnterCheckCodeEngine.CheckCodeHandler(sender, new RunCheckCodeEventArgs(EventActionEnum.ClickField, ""));

                if (CheckRequiredFields(currentControl))
                {
                    RelatedViewField rvField   = (RelatedViewField)e.Field;
                    Epi.View         childView = rvField.GetProject().Metadata.GetChildView(rvField);

                    if (childView == null)
                    {
                        MsgBox.Show(SharedStrings.WARNING_CHILD_VIEW_NOT_SET, SharedStrings.ENTER);
                    }
                    else
                    {
                        childView.ReturnToParent = rvField.ShouldReturnToParent;
                        if (childView != null)
                        {
                            this.SetFieldData();
                            this.EnterCheckCodeEngine.SaveRecord();
                            childView.ForeignKeyField.CurrentRecordValueString = rvField.GetView().CurrentGlobalRecordId;
                            this.OpenViewHandler(this, new OpenViewEventArgs(childView));
                        }
                    }
                }
            }
            else if (e.Field is CommandButtonField)
            {
                ControlFactory   factory   = ControlFactory.Instance;
                Epi.Page         ThisPage  = this.EnterCheckCodeEngine.CurrentView.CurrentPage;
                Epi.Fields.Field ThisField = this.EnterCheckCodeEngine.CurrentView.CurrentField;

                this.EnterCheckCodeEngine.CheckCodeHandler(sender, new RunCheckCodeEventArgs(EventActionEnum.ClickField, ""));
            }
            else if (e.Field is ImageField)
            {
                SelectImage(e.Field as ImageField, sender as PictureBox);
            }
            else if (e.Field is CheckBoxField)
            {
                ControlFactory   factory   = ControlFactory.Instance;
                Epi.Page         ThisPage  = this.EnterCheckCodeEngine.CurrentView.CurrentPage;
                Epi.Fields.Field ThisField = this.EnterCheckCodeEngine.CurrentView.CurrentField;
                this.EnterCheckCodeEngine.CheckCodeHandler(sender, new RunCheckCodeEventArgs(EventActionEnum.ClickField, ""));
            }
            else if (e.Field is OptionField)
            {
                ControlFactory   factory   = ControlFactory.Instance;
                Epi.Page         ThisPage  = this.EnterCheckCodeEngine.CurrentView.CurrentPage;
                Epi.Fields.Field ThisField = this.EnterCheckCodeEngine.CurrentView.CurrentField;
                this.EnterCheckCodeEngine.CheckCodeHandler(sender, new RunCheckCodeEventArgs(EventActionEnum.ClickField, ""));
            }
        }