예제 #1
0
        private void AddEditorComboBoxItem(Epi.Fields.Field field)
        {
            string lead     = "     ";
            bool   hasValue = false;

            if (field is IFieldWithCheckCodeBefore || field is IFieldWithCheckCodeAfter || field is IFieldWithCheckCodeClick)
            {
                if (field is IFieldWithCheckCodeBefore && !String.IsNullOrEmpty(((IFieldWithCheckCodeBefore)field).CheckCodeBefore.ToString().Trim()))
                {
                    hasValue = true;
                }
                if (field is IFieldWithCheckCodeAfter && !String.IsNullOrEmpty(((IFieldWithCheckCodeAfter)field).CheckCodeAfter.ToString().Trim()))
                {
                    hasValue = true;
                }
                if (field is IFieldWithCheckCodeClick && !String.IsNullOrEmpty(((IFieldWithCheckCodeClick)field).CheckCodeClick.ToString().Trim()))
                {
                    hasValue = true;
                }

                if (hasValue)
                {
                    lead += "*";
                }

                cbxFields.Items.Add(new EditorComboBoxItem(lead + field.Name, field, (field.GetType()).Name));
            }
        }
예제 #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, ""));
            }
        }
예제 #3
0
        /*private void OpenView(object sender, RunCheckCodeEventArgs e)
         * {
         *
         * }*/
        public void CloseView(object sender, RunCheckCodeEventArgs e)
        {
            //execute after stack until current level = view
            while (this.AfterStack.Count > 0)
            {
                this.AfterStack.Pop().Value.Execute();
            }

            this.mCurrentField = null;
            this.mCurrentPage  = null;
            this.mView         = null;

            // then execute current level after_view
            //this.RunCheckCodeCommands(this.mView.CheckCodeAfter);
        }
예제 #4
0
        private void OpenField(object sender, RunCheckCodeEventArgs e)
        {
            this.mCurrentField = this.mView.Fields[e.Parameter];

            this.UnRollField();

            // push after_field onto stack

            if (this.mCurrentField is IFieldWithCheckCodeAfter)
            {
                this.AfterStack.Push(new KeyValuePair <EventActionEnum, StackCommand>(EventActionEnum.CloseField, new StackCommand(this.EpiInterpreter, "field", "after", this.mCurrentField.Name)));
            }

            if (this.mCurrentField is IFieldWithCheckCodeBefore)
            {
                this.ExecuteCheckCode("field", "before", this.mCurrentField.Name);
            }
        }
예제 #5
0
        /// <summary>
        /// Gets a fields's associated controls
        /// </summary>
        /// <param name="field">Field</param>
        /// <returns>A list of controls</returns>
        public List<Control> GetAssociatedControls(Field field)
        {
            #region Input Validation
            if (field == null)
            {
                throw new ArgumentNullException("Field");
            }
            #endregion  //Input Validation

            if (fieldControls.ContainsKey(field))
            {
                return fieldControls[field];
            }
            else
            {
                return new List<Control>();
            }
        }
        private DataRow GetDataTable(DataColumn dataColumn, string tableText, string pattern, Dictionary <string, string> formatStrings, DataRow[] rows, DataTable table)
        {
            pattern = string.Empty;

            IVariable var = (IVariable)this.Context.GetVariable(dataColumn.ColumnName);

            if (var != null)
            {
                if (var.VarType == VariableType.DataSource || var.VarType == VariableType.DataSourceRedefined)
                {
                    formatStrings.TryGetValue(var.Name, out pattern);
                }
                else
                {
                    tableText = "Defined";
                }
            }
            else
            {
                //tableText = "Defined";
                var = new DataSourceVariable(dataColumn.ColumnName, DataType.Unknown);
            }

            DataRow row = table.NewRow();


            if (
                this.Context.CurrentRead != null &&
                this.Context.CurrentRead.IsEpi7ProjectRead &&
                this.Context.CurrentProject.Views.Exists(this.Context.CurrentRead.Identifier) &&
                this.Context.CurrentProject.Views[this.Context.CurrentRead.Identifier].Fields.Exists(var.Name)
                )
            {
                Epi.Fields.Field field = this.Context.CurrentProject.Views[this.Context.CurrentRead.Identifier].Fields[var.Name];
                if (field is FieldWithSeparatePrompt)
                {
                    row[ColumnNames.PROMPT] = ((FieldWithSeparatePrompt)field).PromptText;
                }
                else
                {
                    row[ColumnNames.PROMPT] = var.PromptText;
                }
                //Fiexes for Issue: 943
                if (field.FieldType.ToString() == MetaFieldType.Checkbox.ToString())
                {
                    row[ColumnNames.FIELDTYPE] = "Checkbox";
                }
                else
                {
                    row[ColumnNames.FIELDTYPE] = field.FieldType.ToString();
                }
            }
            else
            {
                row[ColumnNames.PROMPT] = var.PromptText;
                if (var.VarType == VariableType.Permanent)
                {
                    row[ColumnNames.FIELDTYPE] = var.DataType.ToString();
                }
                else
                {
                    if (this.Context.DataSet.Tables.Contains("output"))
                    {
                        row[ColumnNames.FIELDTYPE] = GetVariableType(this.Context.DataSet.Tables["output"].Columns[var.Name].DataType.ToString());
                    }
                    else
                    {
                        row[ColumnNames.FIELDTYPE] = var.DataType.ToString();
                    }
                }
            }

            row[ColumnNames.VARIABLE] = var.Name;

            row[ColumnNames.FORMATVALUE] = pattern;
            row[ColumnNames.SPECIALINFO] = var.VarType.ToString();
            row[ColumnNames.TABLE]       = tableText;


            //  table.Rows.Add(row);

            return(row);
        }
예제 #7
0
 /// <summary>
 /// Gets the data for data grid items
 /// </summary>
 /// <param name="field">The field whose data is to be stored</param>
 /// <param name="control">The control associated with the field</param>
 private void GetDataGridViewData(Field field, Control control)
 {
     if (field is GridField)
     {
         if (Util.IsEmpty(((GridField)field).DataSource))
         {
             DataTable dataTable = view.GetProject().CollectedData.GetGridTableData(view, (GridField)field);
             dataTable.TableName = view.Name + field.Name;
             ((GridField)field).DataSource = dataTable;
         }
         ((DataGridView)control).DataSource = ((GridField)field).DataSource;
     }
 }
예제 #8
0
 /// <summary>
 /// Assign Tab Index of the field
 /// </summary>
 /// <param name="field">The field whose tab index is to be assigned</param>
 /// <param name="page">The page the field belongs to</param>
 private void AssignTabIndex(Field field, Page page)
 {
     ((RenderableField)field).TabIndex = field.GetMetadata().GetFieldTabIndex(field.Id, field.GetView().Id, page.Id);
 }
예제 #9
0
        /*private void OpenView(object sender, RunCheckCodeEventArgs e)
        {

        }*/
        public void CloseView(object sender, RunCheckCodeEventArgs e)
        {
            //execute after stack until current level = view
            while (this.AfterStack.Count > 0)
            {
                    this.AfterStack.Pop().Value.Execute();
            }

            this.mCurrentField = null;
            this.mCurrentPage = null;
            this.mView = null;

            // then execute current level after_view
            //this.RunCheckCodeCommands(this.mView.CheckCodeAfter);
        }
예제 #10
0
        /// <summary>
        /// Sets the data for other masked text boxes that are not dates or times
        /// </summary>
        /// <param name="field">The field whose data is to be stored</param>
        /// <param name="control">The control associated with the field</param>
        private void SetOtherMaskedData(Field field, Control control)
        {
            // This assigning of the control's data to a temp control is done to stop the 'textchanged' event
            // from firing on the change to the TextMaskFormat property, which in turn was causing a dirty
            // event to be thrown and then initiated saves when it shouldn't have. This assignment should
            // not cause the record to become dirty.
            //
            // However, maybe it would be better to just unsubscripe the event here and then re-subscribe after?
            MaskedTextBox tempControl = new MaskedTextBox();
            tempControl.TextMaskFormat = ((MaskedTextBox)control).TextMaskFormat;
            tempControl.Mask = ((MaskedTextBox)control).Mask;
            tempControl.Text = ((MaskedTextBox)control).Text;

            tempControl.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals;
            ((IDataField)field).CurrentRecordValueObject = tempControl.Text;
        }
예제 #11
0
 /// <summary>
 /// Gets the data for combo box items
 /// </summary>
 /// <param name="field">The field whose data is to be stored</param>
 /// <param name="control">The control associated with the field</param>
 private void GetCheckBoxData(Field field, Control control)
 {
     if (((IDataField)field).CurrentRecordValueObject == null)
     {
         ((CheckBox)control).Checked = false;
     }
     else
     {
         bool checkedValue = false;
         bool.TryParse(((IDataField)field).CurrentRecordValueObject.ToString(), out checkedValue);
         ((CheckBox)control).Checked = checkedValue;
     }
 }
예제 #12
0
 /// <summary>
 /// Preselects a field in the check code combo box
 /// </summary>
 /// <param name="field">The field to select</param>
 public void SelectField(Field field)
 {
     foreach (object item in cbxFields.Items)
     {
         if (((EditorComboBoxItem)item).IDVal is Field)
         {
             if (((Field)((EditorComboBoxItem)item).IDVal).Id.Equals(field.Id))
             {
                 cbxFields.SelectedItem = item;
                 break;
             }
         }
     }
 }
예제 #13
0
 /// <summary>
 /// Sets the data for combobox items
 /// </summary>
 /// <param name="field">The field whose data is to be stored</param>
 /// <param name="control">The control associated with the field</param>
 private void SetComboBoxData(Field field, Control control)
 {
     if (((ComboBox)control).SelectedIndex != -1)
     {
         if (field is YesNoField)
         {
             if (((ComboBox)control).SelectedItem.Equals(config.Settings.RepresentationOfYes))
             {
                 ((IDataField)field).CurrentRecordValueObject = "1";
             }
             else if (((ComboBox)control).SelectedItem.Equals(config.Settings.RepresentationOfNo))
             {
                 ((IDataField)field).CurrentRecordValueObject = "0";
             }
         }
         else if (field is DDLFieldOfLegalValues)
         {
             //use .Text instead of .SelectedValue.ToString() here because of issues around sorting
             ((IDataField)field).CurrentRecordValueObject = ((ComboBox)control).Text;
         }
         else if (field is DDLFieldOfCommentLegal)
         {
             ((DDLFieldOfCommentLegal)field).CurrentRecordValueString = (((ComboBox)control).Text);
         }
         else if (field is DDLFieldOfCodes)
         {
             ((IDataField)field).CurrentRecordValueObject = ((ComboBox)control).Text;
         }
         else if (field is DDListField)
         {
             ((IDataField)field).CurrentRecordValueObject = ((ComboBox)control).SelectedValue;
         }
         else
         {
             ((IDataField)field).CurrentRecordValueObject = ((ComboBox)control).SelectedValue;
         }
     }
     else
     {
         ((IDataField)field).CurrentRecordValueObject = null;
     }
 }
예제 #14
0
 /// <summary>
 /// Returns a field's view element
 /// </summary>
 /// <param name="field">The field whose view element is to be obtained</param>
 /// <returns>The view element of the field from the xml project file</returns>
 public XmlElement GetFieldViewElement(Field field)
 {
     XmlNode viewsNode = GetViewsNode();
     XmlNode viewNode = viewsNode.SelectSingleNode("//View[@ViewId= '" + field.GetView().Id + "']");
     XmlElement viewElement = (XmlElement)viewNode;
     return viewElement;
 }
        /// <summary>
        /// Shows the appropriate value selection control to the user depending on the type of field that is being selected for
        /// </summary>
        /// <param name="field">The field that the condition is based upon</param>
        private void ShowValueSelector(Field field)
        {
            txtValue.Visibility = System.Windows.Visibility.Visible;
            if (field is IDataField)
            {
                if (cbxOperator.SelectedValue != null)
                {
                    dateValue.IsEnabled = true;
                    tbxNumericValue.IsEnabled = true;
                    cbxValue.IsEnabled = true;
                    dateLowValue.IsEnabled = true;
                    dateHighValue.IsEnabled = true;
                    tbxLowValue.IsEnabled = true;
                    tbxHighValue.IsEnabled = true;
                    tbxValue.IsEnabled = true;
                }
                else
                {
                    dateValue.IsEnabled = false;
                    tbxNumericValue.IsEnabled = false;
                    cbxValue.IsEnabled = false;
                    dateLowValue.IsEnabled = false;
                    dateHighValue.IsEnabled = false;
                    tbxLowValue.IsEnabled = false;
                    tbxHighValue.IsEnabled = false;
                    tbxValue.IsEnabled = false;

                    tbxNumericValue.Clear();
                    cbxValue.SelectedIndex = -1;
                    tbxLowValue.Clear();
                    tbxHighValue.Clear();
                    tbxValue.Clear();
                    return;
                }

                if (cbxOperator.SelectedValue == null || !cbxOperator.SelectedValue.ToString().Equals(SharedStrings.FRIENDLY_OPERATOR_BETWEEN))
                {
                    txtAnd.Visibility = Visibility.Hidden;
                    dateLowValue.Visibility = Visibility.Hidden;
                    dateHighValue.Visibility = Visibility.Hidden;
                    tbxLowValue.Visibility = Visibility.Hidden;
                    tbxHighValue.Visibility = Visibility.Hidden;

                    // Set which 'value' control is visible
                    if (field is DateField || (field is DateTimeField && !(field is TimeField)))
                    {
                        dateValue.Visibility = Visibility.Visible;
                        tbxNumericValue.Visibility = Visibility.Hidden;
                        cbxValue.Visibility = Visibility.Hidden;
                        tbxValue.Visibility = Visibility.Hidden;

                        if (cbxOperator.SelectedItem.ToString().Equals(SharedStrings.FRIENDLY_OPERATOR_NOT_MISSING))
                        {
                            dateValue.IsEnabled = false;
                            dateValue.Visibility = Visibility.Hidden;
                            txtValue.Visibility = Visibility.Hidden;
                        }
                    }
                    else if (field is NumberField)
                    {
                        dateValue.Visibility = Visibility.Hidden;
                        tbxNumericValue.Visibility = Visibility.Visible;
                        cbxValue.Visibility = Visibility.Hidden;
                        tbxValue.Visibility = Visibility.Hidden;

                        if (cbxOperator.SelectedItem.ToString().Equals(SharedStrings.FRIENDLY_OPERATOR_NOT_MISSING))
                        {
                            tbxNumericValue.IsEnabled = false;
                        }
                    }
                    else if (field is TableBasedDropDownField || field is CheckBoxField || field is YesNoField)
                    {
                        dateValue.Visibility = Visibility.Hidden;
                        tbxNumericValue.Visibility = Visibility.Hidden;
                        cbxValue.Visibility = Visibility.Visible;
                        tbxValue.Visibility = Visibility.Hidden;

                        if (cbxOperator.SelectedItem.ToString().Equals(SharedStrings.FRIENDLY_OPERATOR_NOT_MISSING))
                        {
                            cbxValue.IsEnabled = false;
                        }
                    }
                    else if (field is TextField || field is UpperCaseTextField || field is MultilineTextField)
                    {
                        dateValue.Visibility = Visibility.Hidden;
                        tbxNumericValue.Visibility = Visibility.Hidden;
                        cbxValue.Visibility = Visibility.Hidden;
                        tbxValue.Visibility = Visibility.Visible;

                        if (cbxOperator.SelectedItem.ToString().Equals(SharedStrings.FRIENDLY_OPERATOR_NOT_MISSING))
                        {
                            tbxValue.IsEnabled = false;
                        }
                    }
                }
                else
                {
                    txtAnd.Visibility = Visibility.Visible;
                    dateValue.Visibility = Visibility.Hidden;
                    tbxNumericValue.Visibility = Visibility.Hidden;
                    cbxValue.Visibility = Visibility.Hidden;
                    dateLowValue.Visibility = Visibility.Hidden;
                    dateHighValue.Visibility = Visibility.Hidden;
                    tbxLowValue.Visibility = Visibility.Hidden;
                    tbxHighValue.Visibility = Visibility.Hidden;
                    tbxValue.Visibility = Visibility.Hidden;

                    if (field is DateField || (field is DateTimeField && !(field is TimeField)))
                    {
                        dateLowValue.Visibility = Visibility.Visible;
                        dateHighValue.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        tbxLowValue.Visibility = Visibility.Visible;
                        tbxHighValue.Visibility = Visibility.Visible;
                    }
                }
            }
        }
예제 #16
0
        /// <summary>
        /// Deletes a field from the xml metadata project file
        /// </summary>
        /// <param name="field">A field object</param>
        public void DeleteField(Field field)
        {
            try
            {
                XmlDocument doc = GetXmlDocument();
                XmlNode fieldsNode = GetFieldsNode(field.GetView().ViewElement);
                XmlNode fieldNode = fieldsNode.SelectSingleNode("//Field[@FieldId= '" + field.Id + "']");
                fieldNode.ParentNode.RemoveChild(fieldNode);

                Save();
            }
            catch (Exception ex)
            {
                throw new GeneralException("Could not delete field in the Xml metadata file", ex);
            }
            finally
            {

            }
        }
 public void AssignMembers(Field field)
 {
     base.AssignMembers(field);
 }
예제 #18
0
        private void OpenField(object sender, RunCheckCodeEventArgs e)
        {
            this.mCurrentField = this.mView.Fields[e.Parameter];

            this.UnRollField();

            // push after_field onto stack

            if (this.mCurrentField is IFieldWithCheckCodeAfter)
            {
                this.AfterStack.Push(new KeyValuePair<EventActionEnum, StackCommand>(EventActionEnum.CloseField, new StackCommand(this.EpiInterpreter, "field", "after", this.mCurrentField.Name)));
            }

            if (this.mCurrentField is IFieldWithCheckCodeBefore)
            {
                this.ExecuteCheckCode("field", "before", this.mCurrentField.Name);
            }
        }
예제 #19
0
 /// <summary>
 /// Gets the data for text fields
 /// </summary>
 /// <param name="field">The field whose data is to be stored</param>
 /// <param name="control">The control associated with the field</param>
 private void GetTextData(Field field, Control control)
 {
     if (((IDataField)field).CurrentRecordValueString.Equals(string.Empty) && field is GUIDField)
     {
         control.Text = ((GUIDField)field).NewGuid().ToString();
         SetTextData(field, control);
     }
     else
     {
         control.Text = ((IDataField)field).CurrentRecordValueString;
     }
 }
예제 #20
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);
                        }
                    }
                }
            }
        }
예제 #21
0
 /// <summary>
 /// Sets the data for checkbox items
 /// </summary>
 /// <param name="field">The field whose data is to be stored</param>
 /// <param name="control">The control associated with the field</param>
 private void SetCheckBoxData(Field field, Control control)
 {
     ((IDataField)field).CurrentRecordValueObject = ((CheckBox)control).Checked;
     ((IDataField)field).CurrentRecordValueString = (((CheckBox)control).Checked ? "1" : "0");
 }
예제 #22
0
 /// <summary>
 /// Deletes a field from the database
 /// </summary>
 /// <param name="field">A field object</param>
 public void DeleteField(Field field)
 {
     try
     {
         Query query = db.CreateQuery("delete from metaFields where [UniqueId] = @uniqueId");
         query.Parameters.Add(new QueryParameter("@uniqueId", DbType.Guid, field.UniqueId));
         db.ExecuteNonQuery(query);
     }
     catch (Exception ex)
     {
         throw new GeneralException("Could not delete field in the database", ex);
     }
 }
예제 #23
0
        /// <summary>
        /// Sets the data for number and phone number fields
        /// </summary>        
        /// <param name="field">The field whose data is to be stored</param>
        /// <param name="control">The control associated with the field</param>
        private void SetNumberData(Field field, Control control)
        {
            MaskedTextBox tempControl = new MaskedTextBox();
            tempControl.TextMaskFormat = ((MaskedTextBox)control).TextMaskFormat;
            tempControl.Mask = ((MaskedTextBox)control).Mask;
            tempControl.Text = ((MaskedTextBox)control).Text;

            tempControl.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals;

            if (!string.IsNullOrEmpty(tempControl.Text))
            {
                tempControl.TextMaskFormat = MaskFormat.IncludeLiterals;
                ((IDataField)field).CurrentRecordValueObject = tempControl.Text;
            }
            else
            {
                ((IDataField)field).CurrentRecordValueObject = null;
            }
        }
예제 #24
0
 protected void OnFieldInserted(Field f)
 {
     if (FieldInsertComplete != null)
     {
         FieldInsertComplete(f);
     }
 }
예제 #25
0
        /// <summary>
        /// Sets the data for text fields
        /// </summary>        
        /// <param name="field">The field whose data is to be stored</param>
        /// <param name="control">The control associated with the field</param>
        private void SetTextData(Field field, Control control)
        {
            if (control is TextBox || control is RichTextBox)
            {
                if (field is Epi.Fields.TextField)
                {
                    Epi.Fields.TextField textField = (Epi.Fields.TextField)field;

                    if ((control.Text.Trim().Length <= textField.MaxLength || textField.MaxLength <= 0) || (textField.IsReadOnly))
                    {
                        textField.CurrentRecordValueObject = control.Text;
                    }
                    else
                    {
                        string value = control.Text;

                        if (textField.CurrentRecordValue != null)
                        {
                            if (textField.CurrentRecordValue.Length <= textField.MaxLength)
                            {
                                control.Text = textField.CurrentRecordValue;
                                throw new System.Exception(string.Format("Value {0}: exceeds maximum Length of {1} for field [{2}].", value, textField.MaxLength, textField.Name));
                            }
                            else
                            {
                                textField.CurrentRecordValue = textField.CurrentRecordValue.Substring(0, textField.MaxLength - 1);
                            }
                        }
                        else
                        {
                            control.Text = "";
                            throw new System.Exception(string.Format("Value {0}: exceeds maximum Length of {1} for field [{2}].", value, textField.MaxLength, textField.Name));
                        }
                    }
                }
                else
                {
                    IDataField dataField = (IDataField)field;
                    dataField.CurrentRecordValueObject = control.Text.Trim();
                }
            }
        }
예제 #26
0
파일: View.cs 프로젝트: NALSS/epiinfo-82474
 public void RemoveFromCollection(Field field)
 {
     fields.Remove(field);
 }
예제 #27
0
 /// <summary>
 /// Gets a list of controls for a field
 /// </summary>
 /// <param name="field">The field object</param>
 /// <param name="canvasSize">The size of the page canvas</param>
 /// <returns>A list of controls</returns>
 public List<Control> GetFieldControls(Field field, Size canvasSize)
 {
     if (field is CheckBoxField)
     {
         return GetControls((CheckBoxField)field, canvasSize);
     }
     else if (field is CommandButtonField)
     {
         return GetControls((CommandButtonField)field, canvasSize);
     }
     else if (field is LabelField)
     {
         return GetControls((LabelField)field, canvasSize);
     }
     else if (field is YesNoField)
     {
         return GetControls((YesNoField)field, canvasSize);
     }
     else if (field is GUIDField)
     {
         return GetControls((GUIDField)field, canvasSize);
     }
     else if (field is InputTextBoxField)
     {
         return GetControls((InputTextBoxField)field, canvasSize);
     }
     else if (field is TableBasedDropDownField)
     {
         return GetControls((TableBasedDropDownField)field, canvasSize);
     }
     else if (field is RelatedViewField)
     {
         return GetControls((RelatedViewField)field, canvasSize);
     }
     else if (field is MirrorField)
     {
         return GetControls((MirrorField)field, canvasSize);
     }
     else if (field is ImageField)
     {
         return GetControls((ImageField)field, canvasSize);
     }
     else if (field is GridField)
     {
         return GetControls((GridField)field, canvasSize);
     }
     else if (field is OptionField)
     {
         return GetControls((OptionField)field, canvasSize);
     }
     else if (field is GroupField)
     {
         return GetControls((GroupField)field, canvasSize);
     }
     else
     {
         throw new ArgumentException("Field does not have rendering capability.", field.ToString());
     }
 }
예제 #28
0
 /// <summary>
 /// Constructor for the class
 /// </summary>
 /// <param name="field">The Field to load check code for</param>
 /// <param name="frm">The main form</param>
 public CheckCode(Field field, MakeViewMainForm frm,View currentview)
 {
     mainForm = frm;
     if (currentview != null)
     currentview.MustRefreshFieldCollection = true;
     view = currentview;
     Construct();
     BuildComboBox();
     string Identifier;
     if (field.Name.Trim().IndexOf(' ') > -1)
     {
         Identifier = "[" + field.Name + "]";
     }
     else
     {
         Identifier = field.Name;
     }
     if (field is Epi.Fields.CommandButtonField)
     {
         this.GotoLine("field", "click", Identifier, true);
     }
     else
     this.GotoLine("field", "", Identifier, true);
 }
예제 #29
0
        /// <summary>
        /// Returns a field as a data row
        /// </summary>
        /// <param name="field"></param>
        /// <returns></returns>
        public DataRow GetFieldAsDataRow(Field field)
        {
            string queryString =
                "select F.[FieldId], F.[UniqueId] As UniqueId, F.[Name] As Name, F.[PageId], F.[ViewId], F.[FieldTypeId], F.[CheckCodeAfter] As ControlAfterCheckCode, F.[CheckCodeBefore] As ControlBeforeCheckCode,  " +
                "F.[ControlTopPositionPercentage], F.[ControlLeftPositionPercentage], F.[ControlHeightPercentage], F.[ControlWidthPercentage], " +
                "F.[ControlFontFamily] As ControlFontFamily, F.[ControlFontSize] As ControlFontSize, F.[ControlFontStyle] As ControlFontStyle, F.[ControlScriptName], " +
                "F.[PromptTopPositionPercentage], F.[PromptLeftPositionPercentage], F.[PromptText], F.[PromptFontFamily], F.[PromptFontSize], F.[PromptFontStyle], F.[ControlFontFamily], F.[ControlFontSize], F.[ControlFontStyle], F.[PromptScriptName], " +
                "F.[ShouldRepeatLast], F.[IsRequired], F.[IsReadOnly],  " +
                "F.[ShouldRetainImageSize], F.[Pattern], F.[MaxLength], F.[ShowTextOnRight], " +
                "F.[Lower], F.[Upper], F.[RelateCondition], F.[ShouldReturnToParent], F.[RelatedViewId], " +
                "F.[SourceTableName], F.[CodeColumnName], F.[TextColumnName], " +
                "F.[List], F.[BackgroundColor], " +
                "F.[Sort], F.[IsExclusiveTable], F.[TabIndex], F.[HasTabStop],F.[SourceFieldId], F.[DataTableName] " +
                "from metaFields F where F.[ViewId] = @viewId AND F.[UniqueId] = @uniqueId " +
                "order by F.[ControlTopPositionPercentage], F.[ControlLeftPositionPercentage]";

            Query query = db.CreateQuery(queryString);
            query.Parameters.Add(new QueryParameter("@viewID", DbType.Int32, field.GetView().Id));
            query.Parameters.Add(new QueryParameter("@uniqueId", DbType.Guid, field.UniqueId));

            DataTable table = db.Select(query);
            if (table.Rows.Count > 0)
            {
                return table.Rows[0];
            }

            return null;
        }
예제 #30
0
 public void SuggestRenameFieldInCollectedData(Field field, string nameBeforeEdit)
 {
     if(TableExists(field.GetView().TableName))
     {
         if (dbDriver.ColumnExists(field.GetView().TableName, nameBeforeEdit))
         {
             RenameColumn(nameBeforeEdit, field.Name);
         }
     }
 }
예제 #31
0
 protected void OnFieldUpdated(Field f)
 {
     if (FieldUpdateComplete != null)
     {
         FieldUpdateComplete(f);
     }
 }
예제 #32
0
        /// <summary>
        /// Shows the appropriate value selection control to the user depending on the type of field that is being selected for
        /// </summary>
        /// <param name="field">The field that the condition is based upon</param>
        private void ShowValueSelector(Field field)
        {
            HideValueSelectors();
            if (field is IDataField)
            {
                if (cmbOperator.SelectedValue != null)
                {
                    dpValue.IsEnabled = true;
                    tbxNumericValue.IsEnabled = true;
                    cmbValue.IsEnabled = true;
                    dpLowValue.IsEnabled = true;
                    dpHighValue.IsEnabled = true;
                    tbxLowValue.IsEnabled = true;
                    tbxHighValue.IsEnabled = true;
                    tbxValue.IsEnabled = true;

                    if (cmbOperator.SelectedValue.ToString().Equals(SharedStrings.FRIENDLY_OPERATOR_BETWEEN))
                    {
                        //Show the Lo and Hi value labels
                        txtLoValue.Visibility = Visibility.Visible;
                        txtAnd.Visibility = Visibility.Visible;
                        txtHiValue.Visibility = Visibility.Visible;
                        if (field is DateField || (field is DateTimeField && !(field is TimeField)))
                        {
                            ShowDateLoHiSelector();
                        }
                        else
                        {
                            ShowNumericLoHiSelector();
                        }
                    }
                    else if (!cmbOperator.SelectedItem.ToString().Equals(SharedStrings.FRIENDLY_OPERATOR_NOT_MISSING) && !cmbOperator.SelectedItem.ToString().Equals(SharedStrings.FRIENDLY_OPERATOR_MISSING))
                    {
                        if (field is DateField || (field is DateTimeField && !(field is TimeField)))
                        {
                            ShowDateValueSelector();
                        }
                        else if (field is NumberField)
                        {
                            ShowNumericValueSelector();
                        }
                        else if (field is TableBasedDropDownField || field is CheckBoxField || field is YesNoField)
                        {
                            ShowDDLValueSelector();
                        }
                        else if (field is TextField || field is UpperCaseTextField || field is MultilineTextField)
                        {
                            ShowTextValueSelector();
                        }
                    }
                }
                else  //cmbOperator.SelectedValue == null
                {
                    dpValue.IsEnabled = false;
                    tbxNumericValue.IsEnabled = false;
                    cmbValue.IsEnabled = false;
                    dpLowValue.IsEnabled = false;
                    dpHighValue.IsEnabled = false;
                    tbxLowValue.IsEnabled = false;
                    tbxHighValue.IsEnabled = false;
                    tbxValue.IsEnabled = false;

                    tbxNumericValue.Clear();
                    cmbValue.SelectedIndex = -1;
                    tbxLowValue.Clear();
                    tbxHighValue.Clear();
                    tbxValue.Clear();
                    return;
                }
            }
        }
예제 #33
0
파일: View.cs 프로젝트: NALSS/epiinfo-82474
 public void SaveToCollection(Field field)
 {
     if (field.Id == 0)
     {
         fields.Add(field);
     }
     else
     {
         if(fields.Contains(field))
         {
             fields.Remove(field);
         }
         fields.Add(field);
     }
 }
예제 #34
0
        /// <summary>
        /// Fills in the 'operator' drop-down list based upon the type of field being used in the selection condition
        /// </summary>
        /// <param name="field">The field that the condition is based upon</param>
        private void FillOperatorValues(Field field)
        {
            if (field is IDataField)
            {
                cmbOperator.Items.Clear();

                // Set operator drop-down values
                if (field is NumberField || field is DateField || field is DateTimeField || field is TimeField)
                {
                    cmbOperator.Items.Add(SharedStrings.FRIENDLY_OPERATOR_EQUAL_TO);
                    cmbOperator.Items.Add(SharedStrings.FRIENDLY_OPERATOR_NOT_EQUAL_TO);
                    cmbOperator.Items.Add(SharedStrings.FRIENDLY_OPERATOR_BETWEEN);
                    cmbOperator.Items.Add(SharedStrings.FRIENDLY_OPERATOR_LESS_THAN);
                    cmbOperator.Items.Add(SharedStrings.FRIENDLY_OPERATOR_GREATER_THAN);
                    cmbOperator.Items.Add(SharedStrings.FRIENDLY_OPERATOR_LESS_THAN_OR_EQUAL);
                    cmbOperator.Items.Add(SharedStrings.FRIENDLY_OPERATOR_GREATER_THAN_OR_EQUAL);
                    cmbOperator.Items.Add(SharedStrings.FRIENDLY_OPERATOR_NOT_MISSING);
                    cmbOperator.Items.Add(SharedStrings.FRIENDLY_OPERATOR_MISSING);
                }
                else if (field is CheckBoxField)
                {
                    cmbOperator.Items.Add(SharedStrings.FRIENDLY_OPERATOR_EQUAL_TO);
                    cmbOperator.SelectedIndex = 0;
                    cmbOperator.IsEnabled = false;

                    cmbValue.Items.Add(config.Settings.RepresentationOfYes);
                    cmbValue.Items.Add(config.Settings.RepresentationOfNo);
                    cmbValue.IsEnabled = true;
                }
                else if (field is YesNoField)
                {
                    cmbOperator.Items.Add(SharedStrings.FRIENDLY_OPERATOR_EQUAL_TO);
                    cmbOperator.Items.Add(SharedStrings.FRIENDLY_OPERATOR_NOT_MISSING);
                    cmbOperator.Items.Add(SharedStrings.FRIENDLY_OPERATOR_MISSING);

                    cmbValue.Items.Add(config.Settings.RepresentationOfYes);
                    cmbValue.Items.Add(config.Settings.RepresentationOfNo);
                    cmbValue.Items.Add(config.Settings.RepresentationOfMissing);
                    cmbValue.IsEnabled = true;
                }
                else if (field is TextField || field is UpperCaseTextField || field is TableBasedDropDownField || field is PhoneNumberField)
                {
                    cmbOperator.Items.Add(SharedStrings.FRIENDLY_OPERATOR_EQUAL_TO);
                    cmbOperator.Items.Add(SharedStrings.FRIENDLY_OPERATOR_NOT_EQUAL_TO);
                    cmbOperator.Items.Add(SharedStrings.FRIENDLY_OPERATOR_LIKE);

                    cmbOperator.Items.Add(SharedStrings.FRIENDLY_OPERATOR_IS_ANY_OF);
                    cmbOperator.Items.Add(SharedStrings.FRIENDLY_OPERATOR_IS_NOT_ANY_OF);

                    cmbOperator.Items.Add(SharedStrings.FRIENDLY_OPERATOR_NOT_MISSING);
                    cmbOperator.Items.Add(SharedStrings.FRIENDLY_OPERATOR_MISSING);
                }
                else if (field is OptionField)
                {
                    FillOperatorValues(dashboardHelper.GetColumnType(field.Name));
                }
            }
        }
        public void FieldChangeHandler(object sender, Field field)
        {
            Control currentControl = (Control)sender;

            if (field is Epi.Fields.TableBasedDropDownField)
            {
                ControlFactory factory = ControlFactory.Instance;
                List<Control> fieldControl = factory.GetAssociatedControls(field);

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

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

                    SetFieldData(fieldControl[index]);
                }

                this.EnterCheckCodeEngine.CheckCodeHandler(sender, new RunCheckCodeEventArgs(EventActionEnum.ClickField, ""));
            }
        }
예제 #36
0
        /// <summary>
        /// Gets the data for combobox items
        /// </summary>
        /// <param name="field">The field whose data is to be stored</param>
        /// <param name="control">The control associated with the field</param>
        private void GetComboboxData(Field field, Control control)
        {
            if (string.IsNullOrEmpty(((IDataField)field).CurrentRecordValueString))
            {
                ((ComboBox)control).SelectedIndex = -1;
                ((ComboBox)control).Text = string.Empty;
            }
            else
            {
                if (field is YesNoField)
                {
                    int num;
                    bool isNum = int.TryParse(((IDataField)field).CurrentRecordValueString, out num);
                    if (isNum)
                    {
                        if (int.Parse(((IDataField)field).CurrentRecordValueString) == 1)    //Yes
                        {
                            ((ComboBox)control).Text = config.Settings.RepresentationOfYes;
                        }
                        else //No
                        {
                            ((ComboBox)control).Text = config.Settings.RepresentationOfNo;
                        }
                    }
                    else
                    {
                        if (((IDataField)field).CurrentRecordValueString.Equals(config.Settings.RepresentationOfYes))
                        {
                            ((ComboBox)control).Text = config.Settings.RepresentationOfYes;
                        }
                        else if (((IDataField)field).CurrentRecordValueString.Equals(config.Settings.RepresentationOfNo))
                        {
                            ((ComboBox)control).Text = config.Settings.RepresentationOfNo;
                        }
                    }
                }
                else
                {
                    string findString = ((IDataField)field).CurrentRecordValueString;

                    if (field is TableBasedDropDownField)
                    {
                        DataTable table = ((TableBasedDropDownField)field).CodeTable;
                        string codeName = ((TableBasedDropDownField)field).CodeColumnName;
                        string textColumnName = ((TableBasedDropDownField)field).TextColumnName;

                        ((ComboBox)control).BeginUpdate();

                        int indexCombo = ((ComboBox)control).FindString(findString);

                        if (indexCombo == -1)
                        {
                            if (field is DDLFieldOfCommentLegal)
                            {
                                string numeric, trimmed;

                                System.Windows.Forms.ComboBox.ObjectCollection items = ((ComboBox)control).Items;
                                foreach (var item in items)
                                {
                                    numeric = ((string)item).Substring(0, ((string)item).IndexOf('-'));
                                    trimmed = numeric.TrimStart(new char[] { '0' });
                                    if (trimmed == findString)
                                    {
                                        indexCombo = ((ComboBox)control).FindString(numeric);
                                        break;
                                    }
                                }
                            }
                        }

                        IsComboTextAssign = true;

                        if (indexCombo == -1)
                        {
                            ((System.Windows.Forms.ComboBox)control).Text = string.Empty;
                            ((System.Windows.Forms.ComboBox)control).SelectedText = string.Empty;
                        }
                        else
                        {
                            ((System.Windows.Forms.ComboBox)control).SelectedIndex = indexCombo;
                        }

                        ((ComboBox)control).EndUpdate();
                        IsComboTextAssign = false;
                    }
                }
            }
        }