WinForm应用程序框架设计之WinAction(修改数据)

我们来先看看WinAction的修改数据的流程:

具体的参考代码:

 

         public   virtual   void  EditEntityHandler( object  entity,  object  caller,  object  sender, EventArgs e)
        {
            
if  (caller  is  IDataListView)
            {
                IDataListView listForm 
=  caller  as  IDataListView;
                
if  ( null   ==  listForm.DataList  ||  (listForm.DataList  is  ICollection  &&  (listForm.DataList  as  ICollection).Count  ==   0 ))
                    
return ;
            }

            Form eForm 
=  CallEditForm(caller);
            
if  (eForm  is  IEditDataForm)
            {
                IEditDataForm mEditForm 
=  eForm  as  IEditDataForm;
                
if  (eForm.Visible)
                {
                    
if  (mEditForm.Entity  is  Entity  &&  (mEditForm.Entity  as  Entity).IsNewEntity) // 新增时进行修改
                    {
                        
if  (caller  is  IDataControlActionView)
                        {
                            
// 修改最后新增的记录
                             if  ((entity  as  Entity).IsNewEntity)
                            {
                                CommonFunctions.SetFormTop(eForm);
                                
return ;
                            }
                        }
                        
if  (caller  is  IDataControlActionView  &&  caller  is  IDataListView  &&  (caller  as  IDataListView).DataList  is  IList)
                            (caller 
as  IDataControlActionView).RemoveLastNewRow();
                        
if  (caller  is  IDataControlActionView) // 已经执行过修改
                            UnloadEditEntityEvent(caller  as  IDataControlActionView);
                    }
                    
else
                    {
                        
if  (mEditForm  is  IBindEntityAware)
                            (mEditForm 
as  IBindEntityAware).BindEntity(entity);
                        CommonFunctions.SetFormTop(eForm);
                        
return ;
                    }
                }
                LoadEditForm(EditForm);
            }
            
if  (eForm  is  IBindEntityAware)
                (eForm 
as  IBindEntityAware).BindEntity(entity);
            
if  (caller  is  IDataControlActionView)
                LoadEditEntityEvent(caller 
as  IDataControlActionView);
            
if  (eForm.Visible)
                CommonFunctions.SetFormTop(eForm);
            
else
                eForm.Show();
        }

 

原创作品出自努力偷懒,转载请说明文章出处http://blog.csdn.net/kfarvid或 http://www.cnblogs.com/kfarvid/

你可能感兴趣的:(WinForm)