关闭

Websharp使用说明(3)

466人阅读 评论(0) 收藏 举报

如果要表示一对多的对象结构,我们可以采用如下的方式(表明了一个入库单的结构,这个入库单包含了入库单头和相关明细):

public class Form  : PersistenceCapable

     {

         private EntityData form;

         private FormDetail formDetail;

 

         #region 构造函数

         public Form()  : this(true)

         {}

 

         public Form(bool AutoInit)

         {

              form=EntityPrototypeManager.GetEmptyEntity("Form");

              if(AutoInit)

                   form.NewRecord("Form");

         }

        

         public Form(EntityData entity)

         {

              form=entity;

         }

         #endregion

 

         #region 属性

         public string FormID

         {

              get{return form["FormID","Form"].ToString();}

              set{form["FormID","Form"]=value;}

         }

 

         public DateTime FormTime

         {

              get{return form.GetDateTime("FormTime","Form");}

              set{form["FormTime","Form"]=value;}

         }

 

         public FormDetail FormDetail

         {

              get

              {

                   if(formDetail==null)

                   {

                       formDetail=new FormDetail(form);

                   }

                   return formDetail;

              }

         }

         #endregion

 

         #region PersistenceCapable 成员

 

         public int ObjectCount

         {

              get

              {

                   return form.EntityCount;

              }

         }

 

         public EntityData EntityData

         {

              get

              {

                   return form;

              }

              set

              {

                   form=value;

              }

         }

 

         public bool Next()

         {

              return form.Next("Form");

         }

 

         public void First()

         {

              form.First("Form");

         }

 

         public void AddNew()

         {

              form.NewRecord("Form");

         }

 

         #endregion

     }

 

     public class FormDetail : PersistenceCapable

     {

         private EntityData form;

         #region 构造函数

         public FormDetail()  : this(true)

         {}

 

         public FormDetail(bool AutoInit)

         {

              form=EntityPrototypeManager.GetEmptyEntity("Form");

              if(AutoInit)

                   form.NewRecord("FormDetail");

         }

        

         public FormDetail(EntityData entity)

         {

              form=entity;

         }

         #endregion

 

         #region 属性

         public string FormDetailID

         {

              get{return form["FormDetailID","FormDetail"].ToString();}

              set{form["FormDetailID","FormDetail"]=value;}

         }

         public string FormID

         {

              get{return form["FormID","FormDetail"].ToString();}

              set{form["FormID","FormDetail"]=value;}

         }

         public string ProductID

         {

              get{return form["ProductID","FormDetail"].ToString();}

              set{form["ProductID","FormDetail"]=value;}

         }

         public decimal InCount

         {

              get{return form.GetDecimal("InCount","FormDetail");}

              set{form["InCount","FormDetail"]=value;}

         }

         #endregion

 

         #region PersistenceCapable 成员

         public int ObjectCount

         {

              get

              {

                   return form.Tables["FormDetail"].Rows.Count;

              }

         }

 

         public EntityData EntityData

         {

              get

              {

                   return form;

              }

              set

              {

                   form=value;

              }

         }

 

         public bool Next()

         {

              return form.Next("FormDetail");

         }

 

         public void First()

         {

              form.First("FormDetail");

         }

 

         public void AddNew()

         {

              form.NewRecord("FormDetail");

         }

 

         #endregion

     }

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:55007次
    • 积分:714
    • 等级:
    • 排名:千里之外
    • 原创:0篇
    • 转载:59篇
    • 译文:0篇
    • 评论:3条
    文章存档