//Get the data if we haven't already got it private void GetData() { if (!_gotdata) { // hard code for type = "Queue" - this is actually Group filter for Type = Queue // can't work out how to handle this from the API so just hardcoding if (_type == "Queue") { SObjectDef sd = new SObjectDef("Group"); sd.AddField("Id", "", "Id", "Id", true, false, false,null); sd.AddField(_namefield, "", "Name", "@string", true, false, false, null); sd.AddField("Type", "", "Name", "@string", true, false, false, null); DataTable dt = _d.GetData(sd).dt; dt.DefaultView.Sort = _namefield; dt.DefaultView.RowFilter = _namefield + "<>'' and type = 'Queue'"; acb1.ItemsSource = dt.DefaultView; acb1.TextSearchPath = _namefield; _gotdata = true; } else { SObjectDef sd = new SObjectDef(_type); sd.AddField("Id", "", "Id", "Id", true, false, false, null); sd.AddField(_namefield, "", "Name", "@string", true, false, false, null); DataTable dt = _d.GetData(sd).dt; dt.DefaultView.Sort = _namefield; dt.DefaultView.RowFilter = _namefield + "<>''"; acb1.ItemsSource = dt.DefaultView; acb1.TextSearchPath = _namefield; _gotdata = true; } } }
public static string CheckRequireFieldsHaveValues(StackPanel sp, SObjectDef s) { string message = ""; if (sp != null) { foreach (DependencyObject gboxes in sp.Children) { if (gboxes.GetType() == typeof(Telerik.Windows.Controls.GroupBox) || gboxes.GetType() == typeof(Telerik.Windows.Controls.RadExpander)) { //I'm sure there is a better way to do this! but allow the containter to be a Group Box or an Expander UIElementCollection p1 = null; if (gboxes.GetType() == typeof(Telerik.Windows.Controls.GroupBox)) p1 = ((Grid)(((Telerik.Windows.Controls.GroupBox)gboxes).Content)).Children; if (gboxes.GetType() == typeof(Telerik.Windows.Controls.RadExpander)) p1 = ((Grid)(((Telerik.Windows.Controls.RadExpander)gboxes).Content)).Children; foreach (DependencyObject child in p1) { if (child.GetType() == typeof(StackPanel)) { StackPanel spcontrol = (StackPanel)child; foreach (Object spchildControl in spcontrol.Children) { Object childControl = spchildControl; if (childControl != null) { //if there is a scroll then get the child element if (childControl.GetType() == typeof(ScrollViewer)) { ScrollViewer sc = (ScrollViewer)childControl; if (sc.Content.GetType() == typeof(TextBox) || sc.Content.GetType() == typeof(ComboBox) || sc.Content.GetType() == typeof(RadAutoCompleteBox)) { childControl = (Control)sc.Content; } } if (childControl.GetType() == typeof(TextBox)) { TextBox tb = (TextBox)childControl; if (tb.Tag != null) { if (tb.Text == "") { string name = tb.Tag.ToString().Split('|')[0]; bool required = Convert.ToBoolean(tb.Tag.ToString().Split('|')[2]); if (required) message += (message == "" ? "" : ",") + s.GetField(name).Header; } } } else if (childControl.GetType() == typeof(ComboBox)) { ComboBox cb = (ComboBox)childControl; if (cb.Tag != null) { if (cb.Text == "") { string name = cb.Tag.ToString().Split('|')[0]; bool required = Convert.ToBoolean(cb.Tag.ToString().Split('|')[2]); if (required) message += (message == "" ? "" : ",") + s.GetField(name).Header; } } } else if (childControl.GetType() == typeof(RadNumericUpDown)) { RadNumericUpDown nb = (RadNumericUpDown)childControl; if (nb.Tag != null) { if (nb.Value.ToString() == "") { string name = nb.Tag.ToString().Split('|')[0]; bool required = Convert.ToBoolean(nb.Tag.ToString().Split('|')[2]); if (required) message += (message == "" ? "" : ",") + s.GetField(name).Header; } } } else if (childControl.GetType() == typeof(Telerik.Windows.Controls.RadComboBox)) { Telerik.Windows.Controls.RadComboBox cb = (Telerik.Windows.Controls.RadComboBox)childControl; if (cb.Tag != null) { if (cb.Text == "") { string name = cb.Tag.ToString().Split('|')[0]; bool required = Convert.ToBoolean(cb.Tag.ToString().Split('|')[2]); if (required) message += (message == "" ? "" : ",") + s.GetField(name).Header; } } } else if (childControl.GetType() == typeof(AxSearchBox)) { AxSearchBox sb = (AxSearchBox)childControl; //Update Value returns true if the value has been changed string name = sb.Tag.ToString().Split('|')[0]; bool required = Convert.ToBoolean(sb.Tag.ToString().Split('|')[2]); if (sb.Value == "") { if (required) message += (message == "" ? "" : ",") + s.GetField(name).Header; } } else if (childControl.GetType() == typeof(Telerik.Windows.Controls.RadAutoCompleteBox)) { RadAutoCompleteBox acb = (RadAutoCompleteBox)childControl; if (acb.Tag != null) { acb.SearchText = ""; ObservableCollection<string> cblist = (ObservableCollection<string>)acb.SelectedItems; string val = string.Join(";", cblist.ToArray<string>()); if (val == "") { string name = acb.Tag.ToString().Split('|')[0]; bool required = Convert.ToBoolean(acb.Tag.ToString().Split('|')[2]); if (required) message += (message == "" ? "" : ",") + s.GetField(name).Header; } } } else if (childControl.GetType() == typeof(Telerik.Windows.Controls.RadDatePicker)) { RadDatePicker dp = (RadDatePicker)childControl; if (dp.Tag != null) { if (dp.SelectedDate == null) { string name = dp.Tag.ToString().Split('|')[0]; bool required = Convert.ToBoolean(dp.Tag.ToString().Split('|')[2]); if (required) message += (message == "" ? "" : ",") + s.GetField(name).Header; } } } else if (childControl.GetType() == typeof(Telerik.Windows.Controls.RadDateTimePicker)) { RadDateTimePicker dp = (RadDateTimePicker)childControl; if (dp.Tag != null) { if (dp.SelectedDate == null) { string name = dp.Tag.ToString().Split('|')[0]; bool required = Convert.ToBoolean(dp.Tag.ToString().Split('|')[2]); if (required) message += (message == "" ? "" : ",") + s.GetField(name).Header; } } } else if (childControl.GetType() == typeof(CheckBox)) { CheckBox cb = (CheckBox)childControl; if (cb.Tag != null) { string name = cb.Tag.ToString().Split('|')[0]; // can't really be null! } } } } } } } } } return message; }