Edit level mismatch in AcceptChange: WinformEdit level mismatch in AcceptChange: Winform
Old forum URL: forums.lhotka.net/forums/t/8023.aspx
simon posted on Friday, November 20, 2009
I have a root BO with two child BO:
RootBO:
public class TechDoc : BusinessBase
{
#region Business Methods
private static PropertyInfo RowIdProperty = RegisterProperty(c => c.RowId);
public int RowId
{
get { return GetProperty(RowIdProperty); }
set { SetProperty(RowIdProperty, value); }
}
private static PropertyInfo RelDocProperty = RegisterProperty(c => c.RelDoc);
public Document RelDoc
{
get
{
return GetProperty(RelDocProperty);
}
set
{
SetProperty(RelDocProperty, value);
}
}
public class Document : BusinessBase
{
#region Business Methods
private static PropertyInfo DocIdProperty = RegisterProperty(c => c.DocId);
public Guid DocId
{
get { return GetProperty(DocIdProperty); }
set { SetProperty(DocIdProperty, value); }
}
private static PropertyInfo LeafNameProperty = RegisterProperty(c => c.LeafName);
public string LeafName
{
get { return GetProperty(LeafNameProperty); }
set { SetProperty(LeafNameProperty, value); }
}
private static PropertyInfo SizeProperty = RegisterProperty(c => c.Size);
#endregion
#region Validation Rules
protected override void AddBusinessRules()
{
// TODO: add validation rules
}
#endregion
public static Document NewChildDocument()
{
return DataPortal.CreateChild();
}
public static Document GetChildDocument(int listId,int docLibRowId,bool? orginFlag)
{
Document obj= DataPortal.FetchChild(new Criteria(listId, docLibRowId, orginFlag));
if (obj.DocId ==Guid.Empty)
return null;
else
return obj ;
}
private Document()
{ /* Require use of factory methods */ }
#endregion
#region Data Access
[RunLocal ]
protected override void Child_Create()
{
using (BypassPropertyChecks)
{
DocId = Guid.NewGuid();
}
}
private void Child_Fetch(Criteria criteria)
{
using (var ctx = ContextManager.GetManager(MES.DalLinq.Database.Document))
{
var d = (from i in ctx.DataContext.ALLDoc
where i.ListId == criteria.Id && i.DoclibRowId == criteria.DocLibRowId && i.OriginFlag == criteria.OriginFlag
select i).SingleOrDefault();
if (d != null)
{
using (BypassPropertyChecks)
{
DocId = d.DocId;
LeafName = d.LeafName;
}
}
}
}
in winform
private void InitBinding()
{
hyperLinkEdit1.DataBindings.Add("EditValue", techDocBindingSource, "RelDoc.LeafName" l);
textEdit7.DataBindings.Add("EditValue", techDocBindingSource, "RelDoc.Size");
}
private void sbAttachRelease_Click(object sender, EventArgs e)
{
Document doc = Common.OpenFileDialog("");
if (doc != null)
{
if (_TechDoc.RelDoc == null)
_TechDoc.RelDoc = MES.Library.DMS.Document.NewChildDocument();
_TechDoc.RelDoc.LeafName = doc.Name;
_TechDoc.RelDoc.Extension = doc.Ext;
_TechDoc.RelDoc.OriginFlag = false;
_TechDoc.RelDoc.Size = doc.Size;
_TechDoc.RelDoc.DocContent = doc.Stream;
}
}
protected bool Save()
{
bool ret = false;
try
{
BaseBindingSource.EndEdit();
BindingTree.Apply();
BaseBO = (BaseBO as ISavable).Save();
ret = true;
}
catch
{
//MessageBox.Show(ex.Message);
ret = false;
throw;
}
return ret;
}
###########################################
when call the save. rasie error:Edit level mismatch in AcceptChanges
how can i solve it! help me.
Copyright (c) Marimer LLC