public static void SetValue(Control control, string textValue, Type columnType) { IEnumerator enumerator = null; if (control is TextBox) { TextBox box = (TextBox)control; box.Text = textValue; } if (control is Label) { Label label = (Label)control; label.Text = textValue; } if (control is UltraLabel) { UltraLabel label2 = (UltraLabel)control; label2.Text = textValue; } if (control is UltraDateTimeEditor) { UltraDateTimeEditor editor = (UltraDateTimeEditor)control; editor.Text = textValue; } if (control is UltraTextEditor) { UltraTextEditor editor2 = (UltraTextEditor)control; editor2.Text = textValue; } if (control is UltraNumericEditor) { UltraNumericEditor editor3 = (UltraNumericEditor)control; if (editor3.NumericType == NumericType.Double) { editor3.Value = double.Parse(textValue, CultureInfo.CurrentCulture); } else { editor3.Value = long.Parse(textValue, CultureInfo.CurrentCulture); } } if (control is UltraMaskedEdit) { UltraMaskedEdit edit = (UltraMaskedEdit)control; edit.Text = textValue; } if (control is UltraCheckEditor) { UltraCheckEditor editor4 = (UltraCheckEditor)control; if ((textValue == "true") || (textValue == "True")) { editor4.Checked = true; } else { editor4.Checked = false; } } if (control is CheckBox) { CheckBox box2 = (CheckBox)control; if ((textValue == "true") || (textValue == "True")) { box2.Checked = true; } else { box2.Checked = false; } } if (!(control is ComboBox)) { goto Label_0252; } ComboBox box3 = (ComboBox)control; object objectValue = RuntimeHelpers.GetObjectValue(box3.SelectedValue); if (box3.DisplayMember == box3.ValueMember) { box3.SelectedIndex = box3.FindStringExact(textValue); goto Label_0252; } string valueMember = box3.ValueMember; valueMember = valueMember.Substring(valueMember.IndexOf(".") + 1); try { enumerator = box3.Items.GetEnumerator(); while (enumerator.MoveNext()) { object obj3 = RuntimeHelpers.GetObjectValue(enumerator.Current); DataRowView view = (DataRowView)obj3; if (view.Row[valueMember].ToString().Trim().Equals(textValue.Trim())) { box3.SelectedItem = RuntimeHelpers.GetObjectValue(obj3); goto Label_023F; } } } finally { if (enumerator is IDisposable) { (enumerator as IDisposable).Dispose(); } } Label_023F: box3.SelectedValue = RuntimeHelpers.GetObjectValue(ConvertStringToTyped(textValue, columnType)); Label_0252: if (typeof(DeklaritComboBox).IsAssignableFrom(control.GetType())) { DeklaritComboBox box4 = (DeklaritComboBox)control; object obj4 = RuntimeHelpers.GetObjectValue(box4.Value); if (box4.DisplayMember == box4.ValueMember) { box4.SelectedIndex = box4.FindStringExact(textValue); } else { string str2 = box4.ValueMember; str2 = str2.Substring(str2.IndexOf(".") + 1); ValueListItemEnumerator enumerator2 = box4.Items.GetEnumerator(); while (enumerator2.MoveNext()) { ValueListItem current = enumerator2.Current; DataRowView listObject = (DataRowView)current.ListObject; if (listObject.Row[str2].ToString().Trim().Equals(textValue.Trim())) { box4.SelectedItem = current; break; } } box4.Value = RuntimeHelpers.GetObjectValue(ConvertStringToTyped(textValue, columnType)); } } if (typeof(UltraComboEditor).IsAssignableFrom(control.GetType())) { UltraComboEditor editor5 = (UltraComboEditor)control; object obj5 = RuntimeHelpers.GetObjectValue(editor5.Value); if (editor5.DisplayMember == editor5.ValueMember) { editor5.SelectedIndex = editor5.FindStringExact(textValue); } else { string str3 = editor5.ValueMember; str3 = str3.Substring(str3.IndexOf(".") + 1); ValueListItemEnumerator enumerator3 = editor5.Items.GetEnumerator(); while (enumerator3.MoveNext()) { ValueListItem item2 = enumerator3.Current; DataRowView view3 = (DataRowView)item2.ListObject; if (view3.Row[str3].ToString().Trim().Equals(textValue.Trim())) { editor5.SelectedItem = item2; break; } } editor5.Value = RuntimeHelpers.GetObjectValue(ConvertStringToTyped(textValue, columnType)); } } }
public void SetNullItemClickBase(object sender, DataRow currentRow) { Control sourceControl = ((ContextMenu)((MenuItem)sender).Parent).SourceControl; string controlId = ""; if (sourceControl.Tag != null) { controlId = Conversions.ToString(sourceControl.Tag); } if (sourceControl is DeklaritComboBox) { DeklaritComboBox box = (DeklaritComboBox)sourceControl; if (box.ComboBox.Tag != null) { controlId = Conversions.ToString(box.ComboBox.Tag); box.SelectedIndex = -1; } } if ((controlId.Length == 0) && (sourceControl.Parent != null)) { sourceControl = sourceControl.Parent; controlId = Conversions.ToString(sourceControl.Tag); } this.GetControl(controlId).Focus(); if (sourceControl is TextBox) { TextBox box2 = (TextBox)sourceControl; box2.Text = ""; } if (sourceControl is UltraDateTimeEditor) { UltraDateTimeEditor editor = (UltraDateTimeEditor)sourceControl; editor.Value = RuntimeHelpers.GetObjectValue(Convert.DBNull); } if (sourceControl is UltraTextEditor) { UltraTextEditor editor2 = (UltraTextEditor)sourceControl; editor2.Text = ""; } if (sourceControl is UltraNumericEditor) { UltraNumericEditor editor3 = (UltraNumericEditor)sourceControl; editor3.Value = RuntimeHelpers.GetObjectValue(Convert.DBNull); } if (sourceControl is UltraMaskedEdit) { UltraMaskedEdit edit = (UltraMaskedEdit)sourceControl; edit.Text = ""; } if (sourceControl is LinkUltraLabelPrompt) { LinkUltraLabelPrompt prompt = (LinkUltraLabelPrompt)sourceControl; prompt.UltraLabel.Text = ""; prompt.UltraLabel.Focus(); string descriptionTag = prompt.DescriptionTag; if ((descriptionTag != null) && (descriptionTag.Length != 0)) { currentRow[descriptionTag] = RuntimeHelpers.GetObjectValue(Convert.DBNull); } } currentRow[controlId] = RuntimeHelpers.GetObjectValue(Convert.DBNull); DataColumn column = currentRow.Table.Columns[controlId]; if (((column != null) && (column.ExtendedProperties["TreatEmptyAsNull"] != null)) && (Convert.ToBoolean(column.ExtendedProperties["TreatEmptyAsNull"].ToString()) && !column.DataType.Equals(typeof(DateTime)))) { currentRow[controlId] = RuntimeHelpers.GetObjectValue(FormHelperClass.EmptyValue(column.DataType)); } }
public static void SetReadOnly(Control control, bool readOnlyValue) { if (control is TextBox) { TextBox box = (TextBox)control; box.ReadOnly = readOnlyValue; } if (control is Label) { Label label = (Label)control; label.Enabled = !readOnlyValue; } if (control is UltraDateTimeEditor) { UltraDateTimeEditor editor = (UltraDateTimeEditor)control; editor.Enabled = !readOnlyValue; } if (control is UltraTextEditor) { UltraTextEditor editor2 = (UltraTextEditor)control; editor2.Enabled = !readOnlyValue; } if (control is UltraNumericEditor) { UltraNumericEditor editor3 = (UltraNumericEditor)control; editor3.Enabled = !readOnlyValue; } if (control is UltraMaskedEdit) { UltraMaskedEdit edit = (UltraMaskedEdit)control; edit.Enabled = !readOnlyValue; } if (control is UltraCheckEditor) { UltraCheckEditor editor4 = (UltraCheckEditor)control; editor4.Enabled = !readOnlyValue; } if (control is CheckBox) { CheckBox box2 = (CheckBox)control; box2.Enabled = !readOnlyValue; } if (control is ComboBox) { ComboBox box3 = (ComboBox)control; box3.Enabled = !readOnlyValue; } if (control is Button) { Button button = (Button)control; button.Enabled = !readOnlyValue; } if (control is LinkUltraLabelPrompt) { LinkUltraLabelPrompt prompt = (LinkUltraLabelPrompt)control; prompt.Enabled = !readOnlyValue; } if (typeof(DeklaritComboBox).IsAssignableFrom(control.GetType())) { DeklaritComboBox box4 = (DeklaritComboBox)control; box4.Enabled = !readOnlyValue; } if (typeof(UltraComboEditor).IsAssignableFrom(control.GetType())) { UltraComboEditor editor5 = (UltraComboEditor)control; editor5.Enabled = !readOnlyValue; } }