%@ CodeTemplate Language="C#" TargetLanguage="Text" Description="This template demonstrates using properties defined in external assemblies." %>
<%@ Property Name="SourceTable" Type="SchemaExplorer.TableSchema" Category="Context" Description="The table to use for this sample." %>
<%@ Assembly Name="SchemaExplorer" %>
<%@ Import Namespace="SchemaExplorer" %>
///
///LOGIC CLASS FOR TABLE <%=this.SourceTable.Name%>
///By wm with codesmith.
///on <%= DateTime.Now.ToString("MM/dd/yyyy")%>
///
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DeiNiu.wms.Data.Model;
using System.Data;
using System.Transactions;
namespace DeiNiu.wms.Logical
{
[Serializable]
public class l<%= getObjClassName() %> :lbase
{
<%= getObjClassName() %> _obj;
public l<%= getObjClassName() %>()
{
initialize();
}
public <%= getObjClassName() %> get<%= getObjClassName() %>
{
get
{
if (_obj == null)
{
_obj = new <%= getObjClassName() %>();
}
_obj.operater = operId;
return _obj;
}
}
public l<%= getObjClassName() %>(int operId)
: base(operId)
{
initialize();
}
///
/// get all data
///
public DataSet getAllData()
{
return _obj.Query();
}
///
/// get all data
///
public DataSet getAllActiveData()
{
return _obj.QueryActived();
}
///
/// get a record by id
///
public void initialize(int id)
{
_obj = id != 0 ? new <%= getObjClassName() %>(id) : new <%= getObjClassName() %>();
}
///
/// get a record by id 0
///
public void initialize()
{
initialize(0);
}
///
/// get a record by id
///
public void initialize(DataRow dr)
{
_obj = new <%= getObjClassName() %>(dr);
}
protected override DeiNiu.Data.BaseObject.BaseModel getModel()
{
return _obj;
}
//begin cust db operation, query, excute sql etc.
internal int add(<%= getObjClassName() %> obj)
{
return obj.Add();
}
///
/// update in a transaction scrop
///
public void update()
{
if (valid())
{
using (TransactionScope scope = new TransactionScope())
{
//Node tmp = new Node();
//tmp.parentid = 1;
//tmp.name = "test trans" + DateTime.Now;
//tmp.description = "this is for transTest";
//tmp.Add();
_obj.Update();
scope.Complete();
}
}
}
private bool valid()
{
return true;
}
}
}