/// <summary> /// 创建一个新的实体对象。 /// 如果需要覆盖,别忘了添加base.AddNew(); /// </summary> /// <returns></returns> public virtual int AddNew() { if (!string.IsNullOrEmpty(_MainBindingGridView.ActiveFilterString)) { _MainBindingGridView.ActiveFilterEnabled = false; } //chendc 2009-02-20 特别说明 : 需要修改为通过实体对象的编辑状态来确认当前实体对象是否已经发生变化。 if (_EditBindingSource.Current != null) { if (checkCanAllowSave()) { return(0); } ObjectState objectState = MB.WinBase.UIDataEditHelper.Instance.GetObjectState(_EditBindingSource.Current); if (objectState == ObjectState.Modified) { _EditBindingSource.CurrentItemRejectChanges(); } else { _EditBindingSource.CancelEdit(); } } _EditBindingSource.DataSource = _ClientRuleObject.CreateNewEntity((int)_ClientRuleObject.MainDataTypeInDoc); return(0); }
void _BindingSource_AddingNew(object sender, AddingNewEventArgs e) { e.NewObject = _ClientRuleObject.CreateNewEntity((int)_ClientRuleObject.MainDataTypeInDoc); //_ClientRuleObject.CreateNewEntity((int)_ClientRuleObject.MainDataTypeInDoc); _IsInAdding = true; }