private static void AddComboBox(FlowLayoutPanel flowPanel, ICollection <FieldValue> fieldValues, bool?doctorsSide) { if (fieldValues.Count <= 0) { return; } FilledField filledField = GetFilledField(fieldValues.First().Field, doctorsSide); ComboBox comboBox = new ComboBox() { DropDownStyle = ComboBoxStyle.DropDownList, Width = flowPanel.Width - Value }; foreach (var value in fieldValues) { int index = comboBox.Items.Add(value); if (filledField != null) { FieldValueAnswer valueAnswer = filledField.FieldValueAnswers.FirstOrDefault(x => x.FieldValueID == value.ID); if (valueAnswer != null) { comboBox.SelectedIndex = index; } } } flowPanel.Controls.Add(comboBox); }
private static void AddCheckBoxes(FlowLayoutPanel flowPanel, ICollection <FieldValue> fieldValues, bool?doctorsSide) { if (fieldValues.Count <= 0) { return; } FilledField filledField = GetFilledField(fieldValues.First().Field, doctorsSide); foreach (var value in fieldValues) { bool answer = false; if (filledField != null) { FieldValueAnswer valueAnswer = filledField.FieldValueAnswers.FirstOrDefault(x => x.FieldValueID == value.ID); if (valueAnswer != null) { answer = valueAnswer.IsChecked; } } CheckBox checkBox = new CheckBox() { Checked = answer, Text = value.Value, AutoSize = true, Tag = value }; flowPanel.Controls.Add(checkBox); } }
private static void AddLongTextBox(FlowLayoutPanel flowPanel, Field field, bool?doctorsSide) { FilledField filledField = GetFilledField(field, doctorsSide); FlatRichTextBox textBox = new FlatRichTextBox() { Width = flowPanel.Width - Value, AutoSize = true, Tag = field }; if (filledField != null) { textBox.Text = filledField.FieldAnswer.TextValue; } flowPanel.Controls.Add(textBox); }
private void SaveQuestionnaire() { ezkoController.DeleteFilledFields(patient); List <FilledField> filledFields = new List <FilledField>(); try { foreach (Control item in flowLayoutPanel.Controls) { if (item is TextBox textBox && textBox.Text.Trim() != "") { Field field = textBox.Tag as Field; FieldAnswer answer = new FieldAnswer() { TextValue = textBox.Text.Trim() }; FilledField filledField = new FilledField() { Field = field, Patient = patient, FieldAnswer = answer }; filledFields.Add(filledField); } else if (item is FlatRichTextBox richTextBox && richTextBox.Text.Trim() != "") { Field field = richTextBox.Tag as Field; FieldAnswer answer = new FieldAnswer() { TextValue = richTextBox.Text.Trim() }; FilledField filledField = new FilledField() { Field = field, Patient = patient, FieldAnswer = answer }; filledFields.Add(filledField); }