public void CreateNew( ) { ClearControls(); _udt = null; _newUdt = new UdtWrapper(_cp); SetEdit(true); }
public void LoadUdt(long id) { _udt = new UdtWrapper(_cp); _udt.ID = id; _udt.LoadProperties(); _udt.LoadDefinition(); PopulateDependencies(); RenderUdt(); SetEdit(false); }
private void DropSelected( ) { if (grd.SelectedRows.Count == 0) { return; } if (!MessageService.AskQuestion("Are you sure you want to delete selected types?")) { return; } UdtWrapper udt = null; string errorText = String.Empty; bool ok = false; foreach (DataGridViewRow row in grd.SelectedRows) { if (!Utils.IsDbValueValid(row.Cells[0].Value)) { continue; } udt = new UdtWrapper(_cp); udt.ID = (long)((short)row.Cells[0].Value); udt.Name = (string)row.Cells[2].Value; try { udt.Drop(); ok = true; } catch (Exception ex) { if (String.IsNullOrEmpty(errorText)) { errorText += "Can not drop data type(s) listed below.\r\n"; } errorText += " - " + (string)row.Cells[2].Value + " : " + ex.Message; } } if (!String.IsNullOrEmpty(errorText)) { MessageService.ShowError(errorText); } if (ok) { LoadUdtList(); } }
private void SaveUdt( ) { if (_newUdt != null) { ApplyInputToUdt(_newUdt); _newUdt.Create(); _udt = _newUdt; _newUdt = null; SetEdit(false); } else if (_udt != null) { _udt.Default = cmbDefaultBinding.SelectedItem as string; _udt.Rule = cmbRuleBinding.SelectedItem as string; _udt.Alter(); } }
private void ApplyInputToUdt(UdtWrapper udt) { if (udt == null) { return; } udt.Name = txtName.Text; udt.AllowNulls = chkAllowNulls.Checked; udt.BaseDataType = dtSelector.SelectedDataType; if (dtSelector.WidthEnabled) { udt.Width = dtSelector.DTWidth.ToString(); } else if (dtSelector.PrecisionEnabled) { udt.Width = dtSelector.DTPrecision.ToString(); } else { udt.Width = String.Empty; } if (dtSelector.ScaleEnabled) { udt.Scale = dtSelector.DTScale.ToString(); } else { udt.Scale = String.Empty; } udt.Default = cmbDefaultBinding.SelectedItem as string; udt.Rule = cmbRuleBinding.SelectedItem as string; }