Websharp使用說明(3)
2024-07-21 02:17:17
供稿:網友
本文來源于網頁設計愛好者web開發社區http://www.html.org.cn收集整理,歡迎訪問。如果要表示一對多的對象結構,我們可以采用如下的方式(表明了一個入庫單的結構,這個入庫單包含了入庫單頭和相關明細):
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
}