/// 
///LOGIC CLASS FOR TABLE t_erp_bussinessDoc
///By wm with codesmith. 
///on 05/13/2020
/// 
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 lErp_bussinessDoc   :lbase
    {
        Erp_bussinessDoc _obj;
        public lErp_bussinessDoc()
        {
             initialize();
        }
 
        public  Erp_bussinessDoc getErp_bussinessDoc
        {
            get
            {
             if (_obj == null)
                {
                    _obj = new Erp_bussinessDoc();
                   
                } 
                _obj.operater = operId;
                return _obj;
            }
        }
        
       public lErp_bussinessDoc(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 Erp_bussinessDoc(id) : new Erp_bussinessDoc();
		}
        /// 
		/// get a record by id 0
		/// 
        public void initialize()
        {
            initialize(0);
        }
         /// 
        /// get a record by id
        /// 
        public void initialize(DataRow dr)
        {
            _obj =   new Erp_bussinessDoc(dr);
        }
        
        protected override DeiNiu.Data.BaseObject.BaseModel getModel()
        {
            return _obj;
        }
 
        //begin cust db operation, query, excute sql etc.
     
        internal int add(Erp_bussinessDoc 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;
        }
        
  
    }
    
    
}