Пример #1
0
 private void MapRelatedViewId(RelatedViewField field)
 {
     if (field == null)
     {
         return;
     }
     field.RelatedViewID = context.ViewIdMap[field.RelatedViewID];
 }
Пример #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, ""));
            }
        }
 /// <summary>
 /// Constructor for the class
 /// </summary>
 /// <param name="frm">The parent form</param>
 /// <param name="field">The fied to be edited</param>
 public RelateFieldDefinition(Epi.Windows.MakeView.Forms.MakeViewMainForm frm, RelatedViewField field)
     : base(frm)
 {
     InitializeComponent();
     this.mode         = FormMode.Edit;
     this.field        = field;
     this.page         = field.Page;
     this.memoryRegion = frm.EpiInterpreter;
     LoadFormData();
 }
        private void UnMarkRelatedRecoredsAsDeleted(Epi.Data.Services.CollectedDataProvider OutputDriver, View pView, List <int> pIDList)
        {
            if (pIDList.Count < 1)
            {
                return;
            }

            Dictionary <string, bool> VisitedViews = new Dictionary <string, bool>(StringComparer.OrdinalIgnoreCase);
            string        SQL   = null;
            StringBuilder InSQL = new StringBuilder();

            InSQL.Append(" Where FKey In (");
            foreach (int ID in pIDList)
            {
                pView.LoadRecord(ID);
                pView.RecStatusField.CurrentRecordValue = 1;
                pView.SaveRecord(ID);
                InSQL.Append("'");
                InSQL.Append(pView.CurrentGlobalRecordId);
                InSQL.Append("',");
            }
            InSQL.Length = InSQL.Length - 1;
            InSQL.Append(")");

            foreach (Field field in pView.Fields)
            {
                if (field is RelatedViewField)
                {
                    RelatedViewField rvf = field as RelatedViewField;
                    if (!VisitedViews.ContainsKey(rvf.ChildView.Name))
                    {
                        SQL = "Select UniqueKey From [" + rvf.ChildView.TableName + "] " + InSQL.ToString();
                        IDataReader reader    = OutputDriver.ExecuteReader(OutputDriver.CreateQuery(SQL));
                        List <int>  NewIdList = new List <int>();
                        while (reader.Read())
                        {
                            if (reader["UniqueKey"] != DBNull.Value)
                            {
                                NewIdList.Add((int)reader["UniqueKey"]);
                            }
                        }
                        VisitedViews.Add(rvf.ChildView.Name, true);
                        UnMarkRelatedRecoredsAsDeleted(OutputDriver, rvf.ChildView, NewIdList);
                    }
                    else if (field is Epi.Fields.GridField)
                    {
                        Epi.Fields.GridField gf = field as Epi.Fields.GridField;

                        SQL = "Update  [" + gf.TableName + "] Set RecStatus = 1 Where FKey In " + InSQL.ToString();
                        OutputDriver.ExecuteNonQuery(OutputDriver.CreateQuery(SQL));
                    }
                }
            }
        }
Пример #5
0
        /// <summary>
        /// Returns Related view field control.
        /// </summary>
        /// <param name="field">The related view field to get.</param>
        /// <param name="canvasSize">The size of the view canvas.</param>
        /// <returns>A list of the related view's controls.</returns>
        private List <Control> GetControls(RelatedViewField field, Size canvasSize)
        {
            DragableButton button = new DragableButton();

            SetControlProperties(button, field, canvasSize);
            button.Text        = field.PromptText;
            button.FlatStyle   = flatStyle;
            button.UseMnemonic = false;
            List <Control> controls = new List <Control>();

            controls.Add(button);
            return(controls);
        }