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
}