Mediar.Framework—业务的实现2(UI 与对象实体的通信)

    UI 与对象实体的通信

1 前面已经谈到UI通过对象属性的名称从对象中获取值,UI控件的值是在changed 事件后赋给对象。因为对象实体是已知的,UI控件的值对应的是对象的属性,所以根据对象中属性名称获取值是比较容易的。当然设置对象与获取对象的值,都在对象实体中有相应的方法。这个方法比较通用,现在有不少架构都这么写.下面两个方法都使用了反射对property进行读写.

 

ContractedBlock.gif ExpandedBlockStart.gif
None.gif public object GetValue(string propertyName)
None.gif
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif{
InBlock.gif
InBlock.gif            Type t;
InBlock.gif
InBlock.gif            System.Reflection.PropertyInfo p;
InBlock.gif
InBlock.gif            System.Reflection.MethodInfo m;
InBlock.gif
InBlock.gif            
object rtn;
InBlock.gif
InBlock.gif            
if ((propertyName == "UniqueID"))
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif
InBlock.gif                
return mUniqueID;
InBlock.gif
ExpandedSubBlockEnd.gif            }

InBlock.gif
InBlock.gif            
string nestedPropertyName = string.Empty;
InBlock.gif
InBlock.gif            
bool nestedProperty = false;
InBlock.gif
InBlock.gif            
int dotIndex;
InBlock.gif
InBlock.gif            dotIndex 
= propertyName.IndexOf('.');
InBlock.gif
InBlock.gif            
if ((dotIndex > -1))
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif
InBlock.gif                nestedPropertyName 
= propertyName.Substring(dotIndex + 1);
InBlock.gif
InBlock.gif                propertyName 
= propertyName.Substring(0, dotIndex);
InBlock.gif
InBlock.gif                nestedProperty 
= true;
InBlock.gif
ExpandedSubBlockEnd.gif            }

InBlock.gif
InBlock.gif            t 
= this.GetType();
InBlock.gif
InBlock.gif            p 
= t.GetProperty(propertyName);
InBlock.gif
InBlock.gif            
if (p != null)
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif
InBlock.gif                m 
= p.GetGetMethod(false);
InBlock.gif
InBlock.gif                
if ((m == null))
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif
InBlock.gif                    
throw new Exception("Property: " + t.Name + "." + propertyName + " has no GET method.");
InBlock.gif
ExpandedSubBlockEnd.gif                }

InBlock.gif
ExpandedSubBlockEnd.gif            }

InBlock.gif
InBlock.gif            
else
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif
InBlock.gif                m 
= t.GetMethod(propertyName);
InBlock.gif
InBlock.gif                
if ((m == null))
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif
InBlock.gif                    
throw new Exception("Function: " + t.Name + "." + propertyName + " does not exist.");
InBlock.gif
ExpandedSubBlockEnd.gif                }

InBlock.gif
ExpandedSubBlockEnd.gif            }

InBlock.gif
InBlock.gif            rtn 
= m.Invoke(thisnull);
InBlock.gif
InBlock.gif            
if ((!((rtn == null)) && nestedProperty))
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif
InBlock.gif                rtn 
= ((BizObject)(rtn)).GetValue(nestedPropertyName);
InBlock.gif
ExpandedSubBlockEnd.gif            }

InBlock.gif
InBlock.gif            
return rtn;
InBlock.gif
ExpandedBlockEnd.gif        }

None.gif
None.gif 
None.gif
None.gif        
public void SetProperty(string propertyName, object value)
None.gif
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif{
InBlock.gif
InBlock.gif            
try
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif
InBlock.gif                Type t;
InBlock.gif
InBlock.gif                System.Reflection.PropertyInfo p;
InBlock.gif
InBlock.gif                System.Reflection.MethodInfo m;
InBlock.gif
InBlock.gif                
string nestedPropertyName = string.Empty;
InBlock.gif
InBlock.gif                
bool nestedProperty = false;
InBlock.gif
InBlock.gif                
int dotIndex;
InBlock.gif
InBlock.gif                System.Exception Ex;
InBlock.gif
InBlock.gif                t 
= this.GetType();
InBlock.gif
InBlock.gif                dotIndex 
= propertyName.IndexOf('.');
InBlock.gif
InBlock.gif                
if ((dotIndex > -1))
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif
InBlock.gif                    nestedPropertyName 
= propertyName.Substring(dotIndex + 1);
InBlock.gif
InBlock.gif                    propertyName 
= propertyName.Substring(0, dotIndex);
InBlock.gif
InBlock.gif                    nestedProperty 
= true;
InBlock.gif
ExpandedSubBlockEnd.gif                }

InBlock.gif
InBlock.gif                p 
= t.GetProperty(propertyName);
InBlock.gif
InBlock.gif                
if ((p == null))
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif
InBlock.gif                    Ex 
= new CustomBizObjectException("Property: " + t.Name + "." + propertyName + " does not exist.");
InBlock.gif
InBlock.gif                    Ex.Source 
= "BizObject_SetProperty(propertyName, value)";
InBlock.gif
InBlock.gif                    
throw Ex;
InBlock.gif
ExpandedSubBlockEnd.gif                }

InBlock.gif
InBlock.gif                
else
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif
InBlock.gif                    
if (nestedProperty)
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif
InBlock.gif                        
object rtn;
InBlock.gif
InBlock.gif                        rtn 
= this.GetValue(propertyName);
InBlock.gif
InBlock.gif                        
if ((rtn == null))
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif                        
dot.gif{
InBlock.gif
InBlock.gif                            Ex 
= new CustomBizObjectException(t.Name + "." + propertyName + " does not exist.");
InBlock.gif
InBlock.gif                            Ex.Source 
= "BizObject_SetProperty(propertyName, value)";
InBlock.gif
InBlock.gif                            
throw Ex;
InBlock.gif
ExpandedSubBlockEnd.gif                        }

InBlock.gif
InBlock.gif                        
else
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif                        
dot.gif{
InBlock.gif
InBlock.gif                            ((BizObject)(rtn)).SetProperty(nestedPropertyName, value);
InBlock.gif
ExpandedSubBlockEnd.gif                        }

InBlock.gif
ExpandedSubBlockEnd.gif                   }

InBlock.gif
InBlock.gif                    
else
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif
InBlock.gif                        m 
= p.GetSetMethod(false);
InBlock.gif
InBlock.gif                        
if ((m == null))
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif                        
dot.gif{
InBlock.gif
InBlock.gif                            Ex 
= new CustomBizObjectException("Function: " + t.Name + "." + propertyName + " has no SET method.");
InBlock.gif
InBlock.gif                            Ex.Source 
= "BizObject_SetProperty(propertyName, value)";
InBlock.gif
InBlock.gif                            
throw Ex;
InBlock.gif
ExpandedSubBlockEnd.gif                        }

InBlock.gif
InBlock.gif                        
else
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif                        
dot.gif{
InBlock.gif
InBlock.gif                            
if ((value == null))
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif                            
dot.gif{
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif                                m.Invoke(
thisnew object[] dot.gifnull });
InBlock.gif
ExpandedSubBlockEnd.gif                            }

InBlock.gif
InBlock.gif                            
else if ((value.GetType().IsSubclassOf(p.PropertyType)))
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif                            
dot.gif{
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif                                m.Invoke(
thisnew object[] dot.gif{ value });
InBlock.gif
ExpandedSubBlockEnd.gif                            }

InBlock.gif
InBlock.gif                            
else
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif                            
dot.gif{
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif                                m.Invoke(
thisnew object[] dot.gif{ System.Convert.ChangeType(value, p.PropertyType) });
InBlock.gif
ExpandedSubBlockEnd.gif                            }

InBlock.gif
ExpandedSubBlockEnd.gif                        }

InBlock.gif
ExpandedSubBlockEnd.gif                    }

InBlock.gif
ExpandedSubBlockEnd.gif                }

InBlock.gif
ExpandedSubBlockEnd.gif            }

InBlock.gif
InBlock.gif            
catch (Exception ex)
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif
InBlock.gif                ex 
= new CustomBizObjectException("Caught Exception when Setting " + this.GetType().Name + "." + propertyName, ex);
InBlock.gif
InBlock.gif                ex.Source 
= "BizObject_SetProperty(propertyName, value)";
InBlock.gif
InBlock.gif                
throw ex;
InBlock.gif
ExpandedSubBlockEnd.gif            }

InBlock.gif
InBlock.gif           
InBlock.gif
ExpandedBlockEnd.gif        }

None.gif
None.gif



2 新建,保存,刷新,取消

     在主窗口中应该可以看到 新建,保存,刷新,取消这几个BUTTON。Mediar.framework 把所有的对象看归纳成只有这几个操作,通过这几个操作来控制对象。这几个button的事件调用活动窗口中的相应方法,最后调用对应的对象中相关方法.

 

主窗体中:    

ContractedBlock.gif ExpandedBlockStart.gif
None.gifprivate void toolStripBase_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
None.gif
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif{
InBlock.gif
InBlock.gif            BizObjectBoundEdit m 
= this.ActiveMdiChild as BizObjectBoundEdit;
InBlock.gif
InBlock.gif 
InBlock.gif
InBlock.gif            
switch (e.ClickedItem.Name)
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif
InBlock.gif                
case "toolStripButtonNew":
InBlock.gif
InBlock.gif                    m.NewButtonPressed();
InBlock.gif
InBlock.gif                    ActiveMenu();
InBlock.gif
InBlock.gif                    
break;
InBlock.gif
InBlock.gif                
case "toolStripButtonCancel":
InBlock.gif
InBlock.gif                    m.CancelButtonPressed();
InBlock.gif
InBlock.gif                    
break;
InBlock.gif
InBlock.gif                
case "toolStripButtonSave":
InBlock.gif
InBlock.gif                    m.UpdateButtonPressed();
InBlock.gif
InBlock.gif                    
break;
InBlock.gif
InBlock.gif                
case "toolStripButtonRefresh":
InBlock.gif
InBlock.gif                    m.RefreshButtonPressed();
InBlock.gif
InBlock.gif                    
break;
InBlock.gif
ExpandedSubBlockEnd.gif            }

InBlock.gif
ExpandedBlockEnd.gif        }

None.gif
None.gif 
None.gif
None.gif




 所有的对象UI都继承一个基础窗体,下面的方法作为共用方法写在这个基础窗体中。mRootBizObject 为窗体中对应的对象实体。这里就讲的比较的粗枝大叶了,不然决对不是一个短短的文章可以写清楚的。

      

ContractedBlock.gif ExpandedBlockStart.gif
None.gifpublic virtual void NewButtonPressed()
None.gif
ExpandedBlockStart.gifContractedBlock.gif         
dot.gif{
InBlock.gif
InBlock.gif              
this.Cursor = Cursors.WaitCursor;
InBlock.gif
InBlock.gif              
if (mRootBizObject == null
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif              
dot.gif{
InBlock.gif
InBlock.gif                   ChangeRootBizObject(
this.CreateNewBizObject(null));
InBlock.gif
ExpandedSubBlockEnd.gif              }
 
InBlock.gif
InBlock.gif              
else 
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif              
dot.gif{
InBlock.gif
InBlock.gif                   ChangeRootBizObject(
this.CreateNewBizObject(mRootBizObject.GetType()));
InBlock.gif
ExpandedSubBlockEnd.gif              }

InBlock.gif
InBlock.gif              DisplayObject(mRootBizObject);
InBlock.gif
InBlock.gif              
this.Cursor = Cursors.Default;
InBlock.gif
ExpandedBlockEnd.gif         }

None.gif
None.gif 
None.gif
None.gif        
public virtual void CancelButtonPressed()
None.gif
ExpandedBlockStart.gifContractedBlock.gif         
dot.gif{
InBlock.gif
InBlock.gif              
this.Cursor = Cursors.WaitCursor;
InBlock.gif
InBlock.gif              mRootBizObject.CancelEdit();
InBlock.gif
InBlock.gif              DisplayObject(mRootBizObject);
InBlock.gif
InBlock.gif              
this.Cursor = Cursors.Default;
InBlock.gif
ExpandedBlockEnd.gif         }

None.gif
None.gif 
None.gif
None.gif        
public virtual bool UpdateButtonPressed()
None.gif
ExpandedBlockStart.gifContractedBlock.gif         
dot.gif{
InBlock.gif
InBlock.gif              
bool retVal;
InBlock.gif
InBlock.gif              
this.Cursor = Cursors.WaitCursor;
InBlock.gif
InBlock.gif              
if (mRootBizObject.Update()) 
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif              
dot.gif{
InBlock.gif
InBlock.gif                   retVal 
= true;
InBlock.gif
ExpandedSubBlockEnd.gif              }
 
InBlock.gif
InBlock.gif              
else 
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif              
dot.gif{
InBlock.gif
InBlock.gif                   retVal 
= false;
InBlock.gif
InBlock.gif                   MessageBox.Show(
"Your changes were NOT saved.  Please review any error messages and try your save again.", mFriendlyClassName, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
InBlock.gif
ExpandedSubBlockEnd.gif              }

InBlock.gif
InBlock.gif              
this.Cursor = Cursors.Default;
InBlock.gif
InBlock.gif              
return retVal;
InBlock.gif
ExpandedBlockEnd.gif         }
   
None.gif
None.gif 
None.gif
None.gif        
public virtual void RefreshButtonPressed()
None.gif
ExpandedBlockStart.gifContractedBlock.gif         
dot.gif{
InBlock.gif
InBlock.gif              
this.Cursor = Cursors.WaitCursor;
InBlock.gif
InBlock.gif              mRootBizObject.ReSelect();
InBlock.gif
InBlock.gif              
this.Cursor = Cursors.Default;
InBlock.gif
ExpandedBlockEnd.gif         }

None.gif
None.gif 
None.gif
None.gif

新建需要通过工厂中的 CreateBizObject方法,因为每个对象都需要包括一个工厂,就需要在新建的时候构造传入。对象新建可以在InitializeValues方法设对象default 值。

 

ContractedBlock.gif ExpandedBlockStart.gif
None.gifpublic BizObject CreateBizObject()
None.gif
ExpandedBlockStart.gifContractedBlock.gif         
dot.gif{
InBlock.gif
InBlock.gif              BizObject bo;
InBlock.gif
InBlock.gif              bo 
= CreateBizObject(this);
InBlock.gif
InBlock.gif              UpdateCache(bo);
InBlock.gif
InBlock.gif              
return bo;
InBlock.gif
ExpandedBlockEnd.gif         }

None.gif
None.gif 
None.gif
None.gif
protected override BizObject CreateBizObject(BizObjectFactory bof)
None.gif
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif{
InBlock.gif
InBlock.gif            
return new Contact(bof);
InBlock.gif
ExpandedBlockEnd.gif        }

None.gif
None.gif 
None.gif

 

 

 

取消就把Original值覆盖到当前值.

    

None.gif   public   void  CancelEdit()
None.gif
ExpandedBlockStart.gifContractedBlock.gif         
dot.gif {
InBlock.gif
InBlock.gif              CancelEditChildren();
InBlock.gif
InBlock.gif              
if ((mIsDirty)) 
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif              
dot.gif{
InBlock.gif
InBlock.gif                   RestoreLastPersistedValues();
InBlock.gif
InBlock.gif                   
this.OnBizObjectUpdatedEvent(new BizObjectUpdatedEventArgs(BizObjectUpdatedType.Changed));
InBlock.gif
ExpandedSubBlockEnd.gif              }

InBlock.gif
ExpandedBlockEnd.gif         }

None.gif
None.gif 
protected   override   void  RestoreLastPersistedValues()
None.gif
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif {
InBlock.gif
InBlock.gif            mDisplayID[AttributeValueVersion.Current] 
= mDisplayID[AttributeValueVersion.Original];
InBlock.gif
InBlock.gif            mFirstName[AttributeValueVersion.Current] 
= mFirstName[AttributeValueVersion.Original];
InBlock.gif
InBlock.gif            mLastName[AttributeValueVersion.Current] 
= mLastName[AttributeValueVersion.Original];
InBlock.gif
InBlock.gif            mDescription[AttributeValueVersion.Current] 
= mDescription[AttributeValueVersion.Original];
InBlock.gif
InBlock.gif            mCompanyName[AttributeValueVersion.Current] 
= mCompanyName[AttributeValueVersion.Original];
InBlock.gif
InBlock.gif            mContactType[AttributeValueVersion.Current].UniqueID 
= mContactType[AttributeValueVersion.Original].UniqueID;
InBlock.gif
InBlock.gif          
// mAddress[AttributeValueVersion.Current].UniqueID = mAddress[AttributeValueVersion.Original].UniqueID;
InBlock.gif

InBlock.gif            mEmailAddress[AttributeValueVersion.Current] 
= mEmailAddress[AttributeValueVersion.Original];
InBlock.gif
InBlock.gif            mWebSiteURL[AttributeValueVersion.Current] 
= mWebSiteURL[AttributeValueVersion.Original];
InBlock.gif
InBlock.gif            mNotes[AttributeValueVersion.Current] 
= mNotes[AttributeValueVersion.Original];
InBlock.gif
InBlock.gif 
InBlock.gif
InBlock.gif            
base.RestoreLastPersistedValues();
InBlock.gif
ExpandedBlockEnd.gif        }

None.gif
None.gif

 

保存就把数据更新到数据库,然后再刷新当前的实体。也许有人要问:刚才保存的为什么要刷新呀?刷新目是把RecordVersion取出来,RecordVersion是timestamp类型,每更新一次数据库,该字段就是有一个新值。在更新数据库之前会和数据库中的值比较,这是防止两个人在同时修改一个对象时引发冲突。

    

ContractedBlock.gif ExpandedBlockStart.gif
None.gifpublic virtual bool Update(string AssemblyName)
None.gif
ExpandedBlockStart.gifContractedBlock.gif         
dot.gif{
InBlock.gif
InBlock.gif            BeginEdit();
InBlock.gif
InBlock.gif              DataSet ds;
InBlock.gif
InBlock.gif              DataRow dr;
InBlock.gif
InBlock.gif              BizObject bobjClone;
InBlock.gif
InBlock.gif              
bool success = false;
InBlock.gif
InBlock.gif              
if (!mAllowEdit) 
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif              
dot.gif{
InBlock.gif
InBlock.gif                   
throw new Exception("Object marked to disallow edits");
InBlock.gif
ExpandedSubBlockEnd.gif              }

InBlock.gif
InBlock.gif              
if (!Validate()) 
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif              
dot.gif{
InBlock.gif
InBlock.gif                   
return false;
InBlock.gif
ExpandedSubBlockEnd.gif              }

InBlock.gif
InBlock.gif 
InBlock.gif
InBlock.gif              ds 
= mBOFactory.CreateDataObject();
InBlock.gif
InBlock.gif              dr 
= GetDataObjectRow(ds);
InBlock.gif
InBlock.gif       
InBlock.gif
InBlock.gif              
try 
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif              
dot.gif{
InBlock.gif
InBlock.gif                mBOFactory.Update( 
ref ds, AssemblyName);
InBlock.gif
InBlock.gif           
InBlock.gif
InBlock.gif                   success 
= !(ds.HasErrors);
InBlock.gif
InBlock.gif                   
if ((ds.HasErrors && DBUtility.HasDBConcurrencyError(ds))) 
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif                   
dot.gif{
InBlock.gif
InBlock.gif                       bobjClone 
= this.Clone(true);
InBlock.gif
InBlock.gif                       OnBizObjectConcurrencyErrorEvent(
new BizObjectConcurrencyErrorEventArgs(bobjClone));
InBlock.gif
ExpandedSubBlockEnd.gif                   }
 
InBlock.gif
InBlock.gif                   
else 
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif                   
dot.gif{
InBlock.gif
InBlock.gif                       Refresh(ds);
InBlock.gif
ExpandedSubBlockEnd.gif                   }

InBlock.gif
ExpandedSubBlockEnd.gif              }
 
InBlock.gif
InBlock.gif              
catch (CustomBizObjectException ex) 
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif              
dot.gif{
InBlock.gif
InBlock.gif                   ExceptionManager.Publish(ex);
InBlock.gif
InBlock.gif                   
throw ex;
InBlock.gif
ExpandedSubBlockEnd.gif              }
 
InBlock.gif
InBlock.gif              
catch (Exception ex) 
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif              
dot.gif{
InBlock.gif
InBlock.gif                   success 
= false;
InBlock.gif
InBlock.gif                   
this.OnBizObjectErrorEvent(new BizObjectErrorEventArgs(BizObjectErrorType.DBError, ex.Message, ""));
InBlock.gif
ExpandedSubBlockEnd.gif              }

InBlock.gif
InBlock.gif 
InBlock.gif
InBlock.gif            
this.EndEdit();
InBlock.gif
InBlock.gif              
return success;
InBlock.gif
InBlock.gif 
InBlock.gif
ExpandedBlockEnd.gif         }

None.gif
None.gif

 

Factory类中,就会调用数据层的更新方法。

  

None.gif   public   void  Update( ref  DataSet ds,  string  AssemblyName)
None.gif
ExpandedBlockStart.gifContractedBlock.gif        
dot.gif {
InBlock.gif
InBlock.gif            DataAccess da;
InBlock.gif
InBlock.gif            da 
= GetDataAccess(AssemblyName);
InBlock.gif
InBlock.gif            ds
= da.Update(ds,true);
InBlock.gif
ExpandedBlockEnd.gif        }

None.gif

刷新就是从数据库重取数据,然后更新对象属性的值。

 

 

ContractedBlock.gif ExpandedBlockStart.gif
None.gifpublic virtual void ReSelect()
None.gif
ExpandedBlockStart.gifContractedBlock.gif         
dot.gif{
InBlock.gif
InBlock.gif              
this.ReSelect(QueryFor.Complete);
InBlock.gif
ExpandedBlockEnd.gif         }

None.gif
None.gif 
None.gif
None.gif         
public virtual void ReSelect(QueryFor queryFor)
None.gif
ExpandedBlockStart.gifContractedBlock.gif         
dot.gif{
InBlock.gif
InBlock.gif              
if (this.mIsDirty) 
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif              
dot.gif{
InBlock.gif
InBlock.gif                   
throw new CustomBizObjectException("Can not ReSelect if BizObject is dirty.");
InBlock.gif
ExpandedSubBlockEnd.gif              }

InBlock.gif
InBlock.gif              
this.mBOFactory.ReSelect(this, queryFor, mDataAccessAssemblyName);
InBlock.gif
ExpandedBlockEnd.gif         }

None.gif
None.gif     
// mBOFactory 中
None.gif

None.gif     
protected internal void ReSelect(BizObject bobj, QueryFor queryFor, string DAAssemblyName)
None.gif
ExpandedBlockStart.gifContractedBlock.gif         
dot.gif{
InBlock.gif
InBlock.gif              DataSet ds;
InBlock.gif
InBlock.gif              ds 
= this.GetDataAccess(DAAssemblyName).Select(bobj.UniqueID, QueryFor.Complete);
InBlock.gif
InBlock.gif              
this.BuildBizObject(bobj.UniqueID, ds, queryFor);
InBlock.gif
ExpandedBlockEnd.gif         }

None.gif
None.gif 
None.gif
None.gif

 

转载于:https://www.cnblogs.com/mediar/archive/2006/09/27/515806.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值