/// 
///INTERFACE CLASS FOR TABLE t_node
///By wm with codesmith. 
///on 04/27/2017
/// 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DeiNiu.Utils;
namespace DeiNiu.wms.Data.Model
{
    [Serializable]
    public class Node : Node_base
    {
        public Node()
        {
        }
        public Node(int id): base(id)
        {
        }
        public Node(DataRow dr)
            : base(dr)
        {
            
        }
        protected override void getImp()
        {
            model_imp = new Node_Imp();
        }
        //begin cust db operation, query, excute sql etc.
        public DataSet QueryByName(string name)
        {
            cmdParameters[0] = name;
            return  CustQuery(100);
            
        }
      
        public int getCntByName(string name)
        { 
            int cnt = 0;
            cmdParameters[0] = name;
            DataTable dt = CustQuery(200).Tables[0];
            if (dt.Rows.Count > 0 && dt.Columns.Count > 0)
            {
                cnt = Convert.ToInt32(dt.Rows[0][0].ToString());
            };
            return cnt;
        }
        /// 
        /// for combox show
        /// 
        /// 
        public override string ToString()
        {
            return _name;
        }
        public string ToJsonString()
        {
            return Util.getJson(this);
        }
        /// 
        /// query dic that has flag
        /// used for building combox
        /// 
        /// 
        public DataTable QueryByFlags()
        { 
            return CustQuery(300).Tables[0];
        }
        /// 
        /// query dic that has flag
        /// used for building combox
        /// 
        /// 
        public DataTable QueryByFlag(int flag)
        {
            cmdParameters[0] = flag;
            return CustQuery(400).Tables[0];
        }
        public DataTable queryChildsByFlag(int flag)
        {
            cmdParameters[0] = flag;
            return CustQuery(401).Tables[0];
        }
        public DataTable QueryByFlags(int[] flags)
        {
            string tmp = "(";
            foreach (int i in flags)
            {
                tmp += i+",";
            }
            tmp = tmp.Substring(0, tmp.Length - 1);
            tmp += ")";
            cmdParameters[0] = tmp;
            return CustQuery(500).Tables[0];
        }
        
    }
}