/// <summary> /// Очищает текстовые поля /// </summary> private void ClearData() { TextBoxNumber.Clear(); TextBoxCrew1.Clear(); TextBoxCrew2.Clear(); TextBoxCost.Clear(); }
private void UserControl_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Return) { if (TextBoxNumber.IsKeyboardFocused) { Keyboard.Focus(TextBoxSymbol); TextBoxSymbol.SelectAll(); } else if (TextBoxSymbol.IsKeyboardFocused) { Keyboard.Focus(TextBoxDescription); TextBoxDescription.SelectAll(); } else if (TextBoxDescription.IsKeyboardFocused) { Keyboard.Focus(TextBoxNumber); TextBoxNumber.SelectAll(); } if (Keyboard.Modifiers == ModifierKeys.Shift) { RaiseEvent(new RoutedEventArgs(EntryCompleteEvent, this)); } } }
private void BtnCancel_Click(object sender, RoutedEventArgs e) { TextBoxName.Clear(); TextBoxFamily.Clear(); TextBoxThirdName.Clear(); TextBoxAddress.Clear(); TextBoxNumber.Clear(); }
private string GetTextValue(Control c) { Type t = c.GetType(); if (t == typeof(KryptonTextBox)) { return(((KryptonTextBox)c).Text); } else if (t == typeof(KryptonComboBox)) { KryptonComboBox kc = c as KryptonComboBox; if (kc.SelectedItem == null) { return(string.Empty); } else { return(kc.SelectedItem.ToString()); } } else if (t == typeof(TextBoxNumber)) { TextBoxNumber tbn = c as TextBoxNumber; Field field = (Field)c.Tag; if (!field.IsEmptyData(tbn.Value) || !string.IsNullOrEmpty(tbn.Text)) { return(tbn.Value.ToString()); } else { return(string.Empty); } } else if (t == typeof(KryptonDateTimePicker)) { return(((KryptonDateTimePicker)c).Value.ToString()); } else if (t == typeof(KryptonCheckBox)) { return(((KryptonCheckBox)c).Checked.ToString()); } else if (t == typeof(KryptonCheckedListBox)) { return(ConvertExtension.ToString(((KryptonCheckedListBox)c).Items, ";")); } return(string.Empty); }
private Control CreateNumericControl(ObjectData obj, Field field) { TextBoxNumber num = new TextBoxNumber(); if (field.FieldType == FieldType.Rating) { num.DecimalPlaces = 1; num.Maximum = 10; } else { NumberProperty prop = (NumberProperty)field.Data; num.DecimalPlaces = prop.DecimalPlaces; double d = decimal.ToDouble(decimal.MaxValue); d = Math.Sqrt(d); decimal dm = Convert.ToDecimal(d); num.Maximum = prop.Bounds ? prop.Maximum : dm; num.Minimum = prop.Bounds ? prop.Minimum : decimal.Negate(dm); num.Increment = prop.Increment; num.ThousandsSeparator = prop.Thousands; num.Prefix = prop.Prefix; num.Suffix = prop.Suffix; } object val = obj[field]; if (field.IsEmptyData(val)) { num.Text = string.Empty; } else { num.Value = Convert.ToDecimal(obj[field]); } /*num.StateCommon.Border.Rounding = 4; * num.StateCommon.Border.Width = 2;*/ return(num); }
public void BeginEdit() { Keyboard.Focus(TextBoxNumber); TextBoxNumber.SelectAll(); }
private void SetTextValue(Control c, string value) { Type t = c.GetType(); Field field = (Field)c.Tag; if (t == typeof(KryptonTextBox)) { ((KryptonTextBox)c).Text = value; } else if (t == typeof(KryptonComboBox)) { KryptonComboBox kc = c as KryptonComboBox; if (field.FieldType == FieldType.Select) { int idx = kc.Items.IndexOf(value); if (idx != -1) { kc.SelectedIndex = idx; } } else { bool created = false; ObjectData od = obj.GetReferenceData(field, value, ref created); if (od != null) { int idx = kc.Items.IndexOf(od); if (idx == -1) { kc.Items.Add(od); } kc.SelectedItem = od; if (created) { this.AddDataItem(field, od); } } } } else if (t == typeof(TextBoxNumber)) { TextBoxNumber tbn = c as TextBoxNumber; tbn.Value = decimal.Parse(value); } else if (t == typeof(KryptonDateTimePicker)) { ((KryptonDateTimePicker)c).Value = Convert.ToDateTime(value); } else if (t == typeof(KryptonCheckBox)) { ((KryptonCheckBox)c).Checked = bool.Parse(value); } else if (t == typeof(ListBoxControl)) { ListBoxControl kclb = c as ListBoxControl; if (!string.IsNullOrEmpty(value)) { string[] clb = value.Split(new char[] { ';' }); List <ObjectData> added = new List <ObjectData>(); foreach (string s in clb) { bool created = false; ObjectData od = obj.GetReferenceData(field, s, ref created); if (od != null) { if (!kclb.Exist(od)) { kclb.AddItem(od); if (created) { added.Add(od); } } kclb.SelectData(od); } } this.AddDataItem(field, added); } } }
protected void SaveData() { this.Data.Objects.ClearData(this.obj); foreach (Control ctrl in this.controls) { Field field = (Field)ctrl.Tag; switch (field.FieldType) { case FieldType.Boolean: KryptonCheckBox check = (KryptonCheckBox)ctrl; this.obj[field] = check.Checked; break; case FieldType.Date: KryptonDateTimePicker date = (KryptonDateTimePicker)ctrl; if (date.Checked) { this.obj[field] = date.Value; } else { this.obj[field] = DateTime.MinValue; } break; case FieldType.Image: if (ctrl is ImageSelectBase) { this.obj[field] = ((ImageSelectBase)ctrl).CreateImageData(); } break; case FieldType.List: ListData ld = (ListData)this.obj[field]; foreach (ObjectData od in ((ListBoxControl)ctrl).ListData) { ld.Objects.Add(od); } break; case FieldType.Memo: KryptonTextBox memo = (KryptonTextBox)ctrl; this.obj[field] = memo.Text; break; case FieldType.Number: TextBoxNumber num = (TextBoxNumber)ctrl; this.obj[field] = num.Value; break; case FieldType.Rating: TextBoxNumber raiting = (TextBoxNumber)ctrl; this.obj[field] = raiting.Value; break; case FieldType.Reference: KryptonComboBox box = (KryptonComboBox)ctrl; if (box.SelectedIndex == -1) { this.obj[field] = 0; } else { this.obj[field] = (ObjectData)box.SelectedItem; } break; case FieldType.Select: KryptonComboBox selectBox = ctrl as KryptonComboBox; this.obj[field] = selectBox.SelectedIndex; break; case FieldType.Text: KryptonTextBox text = ctrl as KryptonTextBox; this.obj[field] = text.Text; break; case FieldType.Url: KryptonTextBox url = ctrl as KryptonTextBox; this.obj[field] = url.Text; break; case FieldType.Table: this.obj[field] = ((TableControl)ctrl).CreateTableData(); break; } } foreach (Field f in this.updatedFields.Keys) { this.obj[f] = this.updatedFields[f]; } if (obj.IsNew) { database.Objects.Add(this.obj); } else { database.Objects.Update(this.obj); } }