private void propertyGrid_PropertyValueChanged(object s, PropertyValueChangedEventArgs e) { if (propertyGrid.SelectedObject != null) { ((SrePropertyGrid)propertyGrid.SelectedObject).HasChanged = true; int id = 0; SreAttributeProperty aProp = null; SreDataSourceProperty dsProp = null; if (propertyGrid.SelectedObject is SreAttributeProperty) { aProp = ((SreAttributeProperty)propertyGrid.SelectedObject); id = aProp.Id; } else if (propertyGrid.SelectedObject is SreDataSourceProperty) { dsProp = ((SreDataSourceProperty)propertyGrid.SelectedObject); id = dsProp.Id; } if (id != 0) { errorProvider1.SetError(picIcon, "Property has been changed, will be auto saved when the property if unloaded! Click save button to save now."); } else if (dsProp != null) { ValidateNewDataSource(dsProp); } } }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { _editorService = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService; SreAttributeProperty aProperty = context.Instance as SreAttributeProperty; if (_editorService != null) { ListBox lb = new ListBox(); lb.SelectionMode = SelectionMode.One; lb.SelectedValueChanged += OnListBoxSelectedValueChanged; DataTable table = Core.Data.CoreDatabaseObjects.Instance.ExecuteCommand("select distinct code from CodeSet"); foreach (DataRow row in table.Rows) { int index = lb.Items.Add(row["code"].ToString()); if (row["code"].Equals(value)) { lb.SelectedIndex = index; } } _editorService.DropDownControl(lb); if (lb.SelectedItem == null) { return(value); } return(lb.SelectedItem); } return(value); }
private void tsbSave_Click(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; switch (tabControl1.SelectedIndex) { case 2: SreDataSourceProperty.KeepVersion(this.DataSource.Id); this.idpeKeys1.Save(); break; case 3: SreDataSourceProperty.KeepVersion(this.DataSource.Id); this.sreEmails1.Save(); break; case 4: SreDataSourceProperty.KeepVersion(this.DataSource.Id); this.sreDatabases1.Save(); break; } if (propertyGrid.SelectedObject is SreAttributeProperty) { SreAttributeProperty aProp = propertyGrid.SelectedObject as SreAttributeProperty; if ((aProp != null) && (aProp.HasChanged == true)) { MainWindow.SetToolStripStatusLabel("Please wait...Saving..."); Application.DoEvents(); aProp.Save(); aProp.HasChanged = false; errorProvider1.Clear(); DockPanelGlobalAttributes.RefreshData(aProp.Attribute.AttributeId); } } else if (propertyGrid.SelectedObject is SreDataSourceProperty) { SreDataSourceProperty dsProp = propertyGrid.SelectedObject as SreDataSourceProperty; if ((dsProp != null) && (dsProp.HasChanged == true)) { string errorMsg = errorProvider1.GetError(picIcon); if ((errorMsg.StartsWith("Property has been changed, will be auto saved")) || (string.IsNullOrEmpty(errorProvider1.GetError(picIcon)))) { MainWindow.SetToolStripStatusLabel("Please wait...Saving..."); Application.DoEvents(); dsProp.Save(); dsProp.HasChanged = false; errorProvider1.Clear(); DockPanelDataSources.RefreshData(dsProp.DataSource.Id); } } } tsbClearCache_Click(sender, e); }
public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { SreAttributeProperty aProperty = context.Instance as SreAttributeProperty; switch (aProperty.Type) { case AttributeTypes.Int: case AttributeTypes.BigInt: return(new StandardValuesCollection(new AttributePrintValueTypes[] { AttributePrintValueTypes.Value, AttributePrintValueTypes.NumericPrintNullInCaseOfZero, AttributePrintValueTypes.PrintNullInCaseOfNull, AttributePrintValueTypes.Custom })); break; case AttributeTypes.Decimal: return(new StandardValuesCollection(new AttributePrintValueTypes[] { AttributePrintValueTypes.Value, AttributePrintValueTypes.NumericPrintNullInCaseOfZero, AttributePrintValueTypes.PrintNullInCaseOfNull, AttributePrintValueTypes.NumericPrintNullInCaseOfNaN, AttributePrintValueTypes.NumericPrintNullInCaseOfInfinity, AttributePrintValueTypes.NumericPrintNullInCaseOfNaNOrInfinity, AttributePrintValueTypes.Custom })); break; case AttributeTypes.Datetime: return(new StandardValuesCollection(new AttributePrintValueTypes[] { AttributePrintValueTypes.Value, AttributePrintValueTypes.DateTimePrintDate, AttributePrintValueTypes.DateTimePrintMinValue, AttributePrintValueTypes.PrintNullInCaseOfNull, AttributePrintValueTypes.Custom })); break; case AttributeTypes.Codeset: return(new StandardValuesCollection(new AttributePrintValueTypes[] { AttributePrintValueTypes.Value, AttributePrintValueTypes.CodeSetValueEnumCode, AttributePrintValueTypes.CodeSetValueEnumReferenceKey, AttributePrintValueTypes.PrintNullInCaseOfNull, AttributePrintValueTypes.Custom })); break; case AttributeTypes.Bit: return(new StandardValuesCollection(new AttributePrintValueTypes[] { AttributePrintValueTypes.Value, AttributePrintValueTypes.BitPrintZeroOrOne, AttributePrintValueTypes.BitPrintTrueOrFalse, AttributePrintValueTypes.PrintNullInCaseOfNull })); break; default: return(new StandardValuesCollection(new AttributePrintValueTypes[] { AttributePrintValueTypes.Value, AttributePrintValueTypes.PrintNullInCaseOfNull })); } }