public void CloseFieldHandler(object sender, CloseFieldEventArg closeFieldEventArg)
        {
            Control currentControl = (Control)sender;

            if (closeFieldEventArg.Field is Epi.Fields.GridField)
            {

            }
            else if (closeFieldEventArg.Field is ImageField)
            {
                SelectImage(closeFieldEventArg.Field as ImageField, currentControl as PictureBox);
            }
            else
            {
                if (closeFieldEventArg.Field is CheckBoxField)
                {
                    SetCheckBoxData(closeFieldEventArg.Field, currentControl);
                }
                else
                {
                    ControlFactory factory = ControlFactory.Instance;
                    List<Control> fieldControl = factory.GetAssociatedControls(closeFieldEventArg.Field);

                    if (fieldControl.Count > 0)
                    {
                        int index = 0;

                        if (fieldControl.Count > 1)
                        {
                            index++;
                        }
                        if (IsValidData(fieldControl[index]) == false)
                        {
                            return;
                        }

                        SetFieldData(fieldControl[index]);
                    }
                }

                Epi.Page ThisPage = this.EnterCheckCodeEngine.CurrentView.CurrentPage;
                Epi.Fields.Field ThisField = this.EnterCheckCodeEngine.CurrentView.CurrentField;

                this.EnterCheckCodeEngine.CheckCodeHandler(sender, new RunCheckCodeEventArgs(EventActionEnum.CloseField, ""));
                View TestView = this.EnterCheckCodeEngine.CurrentView.View;

                if (
                    ThisPage == this.EnterCheckCodeEngine.CurrentView.CurrentPage
                    && ThisField == this.EnterCheckCodeEngine.CurrentView.CurrentField
                    )
                {
                    if (this.IsLastControlOnPage(currentControl) && closeFieldEventArg.Tab == true)
                    {
                        if (this.IsLastControlOnView(currentControl) && isNewRecord == false)
                        {
                            Page firstPage = this.EnterCheckCodeEngine.CurrentView.View.Pages[0];
                            this.OpenPageHandler(sender, new PageSelectedEventArgs(firstPage));
                        }
                        else if (this.IsLastControlOnView(currentControl) && isNewRecord == true)
                        {
                            if (!AllowOneRecordOnly)
                            {
                                this.GoToRecordHandler(sender, new GoToRecordEventArgs("+"));
                            }
                        }
                        else if (canvas.EnableTabToNextControl)
                        {
                            for (int i = 0; i < TestView.Pages.Count; i++)
                            {
                                Page TestPage = this.EnterCheckCodeEngine.CurrentView.View.Pages[i];
                                if (TestPage.Equals(this.currentPage))
                                {
                                    if (i + 1 < TestView.Pages.Count)
                                    {
                                        this.OpenPageHandler(sender, new PageSelectedEventArgs(TestView.Pages[i + 1]));
                                    }

                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        if (this.canvas.EnableTabToNextControl)
                        {
                            canvas.GoToNextControl(this.currentPage, this.view, currentControl);
                        }
                    }
                }
            }
        }
Example #2
0
        public void CloseFieldHandler(object sender, CloseFieldEventArg closeFieldEventArg)
        {
            Control currentControl = (Control)sender;

            if (closeFieldEventArg.Field is Epi.Fields.GridField)
            {
            }
            else if (closeFieldEventArg.Field is ImageField)
            {
                SelectImage(closeFieldEventArg.Field as ImageField, currentControl as PictureBox);
            }
            else
            {
                if (closeFieldEventArg.Field is CheckBoxField)
                {
                    SetCheckBoxData(closeFieldEventArg.Field, currentControl);
                }
                else
                {
                    ControlFactory factory      = ControlFactory.Instance;
                    List <Control> fieldControl = factory.GetAssociatedControls(closeFieldEventArg.Field);

                    if (fieldControl.Count > 0)
                    {
                        int index = 0;

                        if (fieldControl.Count > 1)
                        {
                            index++;
                        }
                        if (IsValidData(fieldControl[index]) == false)
                        {
                            return;
                        }

                        SetFieldData(fieldControl[index]);
                    }
                }

                Epi.Page         ThisPage  = this.EnterCheckCodeEngine.CurrentView.CurrentPage;
                Epi.Fields.Field ThisField = this.EnterCheckCodeEngine.CurrentView.CurrentField;
                this.EnterCheckCodeEngine.CheckCodeHandler(sender, new RunCheckCodeEventArgs(EventActionEnum.CloseField, ""));
                View TestView = this.EnterCheckCodeEngine.CurrentView.View;

                if (
                    ThisPage == this.EnterCheckCodeEngine.CurrentView.CurrentPage &&
                    ThisField == this.EnterCheckCodeEngine.CurrentView.CurrentField
                    )
                {
                    if (this.IsLastControlOnPage(currentControl) && closeFieldEventArg.Tab == true)
                    {
                        if (this.IsLastControlOnView(currentControl) && isNewRecord == false)
                        {
                            Page firstPage = this.EnterCheckCodeEngine.CurrentView.View.Pages[0];
                            this.OpenPageHandler(sender, new PageSelectedEventArgs(firstPage));
                        }
                        else if (this.IsLastControlOnView(currentControl) && isNewRecord == true)
                        {
                            if (!AllowOneRecordOnly)
                            {
                                this.GoToRecordHandler(sender, new GoToRecordEventArgs("+"));
                            }
                        }
                        else if (canvas.EnableTabToNextControl)
                        {
                            for (int i = 0; i < TestView.Pages.Count; i++)
                            {
                                Page TestPage = this.EnterCheckCodeEngine.CurrentView.View.Pages[i];
                                if (TestPage.Equals(this.currentPage))
                                {
                                    if (i + 1 < TestView.Pages.Count)
                                    {
                                        this.OpenPageHandler(sender, new PageSelectedEventArgs(TestView.Pages[i + 1]));
                                    }

                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        if (this.canvas.EnableTabToNextControl)
                        {
                            canvas.GoToNextControl(this.currentPage, this.view, currentControl);
                        }
                    }
                }
            }
        }