public ActionResult Update(tb_node_model model)
 {
     return this.Visit(Core.EnumUserRole.Admin, () =>
     {
         tb_node_dal Dal = new tb_node_dal();
         model.nodecreatetime = DateTime.Now;
         model.nodelastupdatetime = DateTime.Now;
         using (DbConn PubConn = DbConfig.CreateConn(Config.TaskConnectString))
         {
             PubConn.Open();
             Dal.Update(PubConn, model);
         }
         return RedirectToAction("index");
     });
 }
 public int Update(DbConn PubConn, tb_node_model model)
 {
     return SqlHelper.Visit(ps =>
     {
         ps.Add("@nodename", model.nodename);
       
         ps.Add("@nodeip", model.nodeip);
       
         ps.Add("@id", model.id);
         ps.Add("@ifcheckstate", model.ifcheckstate);
         string updatecmd = "update tb_node set nodeip=@nodeip,nodename=@nodename,ifcheckstate=@ifcheckstate where id=@id";
         
         return PubConn.ExecuteSql(updatecmd, ps.ToParameters()) ;
     });
 }
        public int AddOrUpdate(DbConn PubConn, tb_node_model model)
        {
            return SqlHelper.Visit(ps =>
            {
                ps.Add("@nodename", model.nodename);
                ps.Add("@nodecreatetime", model.nodecreatetime);
                ps.Add("@nodeip", model.nodeip);
                ps.Add("@nodelastupdatetime", model.nodelastupdatetime);
                ps.Add("@ifcheckstate", model.ifcheckstate);
                ps.Add("@id", model.id);
                string updatecmd = "update tb_node set nodeip=@nodeip,nodelastupdatetime=@nodelastupdatetime where id=@id";
                string insertcmd = @"insert into tb_node(nodename,nodecreatetime,nodeip,ifcheckstate)
										   values(@nodename,@nodecreatetime,@nodeip,@ifcheckstate)";
                if (PubConn.ExecuteSql(updatecmd, ps.ToParameters()) <= 0)
                {
                    PubConn.ExecuteSql(insertcmd, ps.ToParameters());
                }
                return 1;
            });
        }
        public virtual bool Edit(DbConn PubConn, tb_node_model model)
        {
            List<ProcedureParameter> Par = new List<ProcedureParameter>()
            {
                    
					//
					new ProcedureParameter("@nodename",    model.nodename),
					//
					new ProcedureParameter("@nodecreatetime",    model.nodecreatetime),
					//
					new ProcedureParameter("@nodeip",    model.nodeip),
					//
					new ProcedureParameter("@nodelastupdatetime",    model.nodelastupdatetime),
					//
					new ProcedureParameter("@ifcheckstate",    model.ifcheckstate)
            };
			Par.Add(new ProcedureParameter("@id",  model.id));

            int rev = PubConn.ExecuteSql("update tb_node set nodename=@nodename,nodecreatetime=@nodecreatetime,nodeip=@nodeip,nodelastupdatetime=@nodelastupdatetime,ifcheckstate=@ifcheckstate where id=@id", Par);
            return rev == 1;

        }
        public virtual bool Add(DbConn PubConn, tb_node_model model)
        {

            List<ProcedureParameter> Par = new List<ProcedureParameter>()
                {
					
					//
					new ProcedureParameter("@nodename",    model.nodename),
					//
					new ProcedureParameter("@nodecreatetime",    model.nodecreatetime),
					//
					new ProcedureParameter("@nodeip",    model.nodeip),
					//
					new ProcedureParameter("@nodelastupdatetime",    model.nodelastupdatetime),
					//
					new ProcedureParameter("@ifcheckstate",    model.ifcheckstate)   
                };
            int rev = PubConn.ExecuteSql(@"insert into tb_node(nodename,nodecreatetime,nodeip,nodelastupdatetime,ifcheckstate)
										   values(@nodename,@nodecreatetime,@nodeip,@nodelastupdatetime,@ifcheckstate)", Par);
            return rev == 1;

        }
		public virtual tb_node_model CreateModel(DataRow dr)
        {
            var o = new tb_node_model();
			
			//
			if(dr.Table.Columns.Contains("id"))
			{
				o.id = dr["id"].Toint();
			}
			//
			if(dr.Table.Columns.Contains("nodename"))
			{
				o.nodename = dr["nodename"].Tostring();
			}
			//
			if(dr.Table.Columns.Contains("nodecreatetime"))
			{
				o.nodecreatetime = dr["nodecreatetime"].ToDateTime();
			}
			//
			if(dr.Table.Columns.Contains("nodeip"))
			{
				o.nodeip = dr["nodeip"].Tostring();
			}
			//
			if(dr.Table.Columns.Contains("nodelastupdatetime"))
			{
				o.nodelastupdatetime = dr["nodelastupdatetime"].ToDateTime();
			}
			//
			if(dr.Table.Columns.Contains("ifcheckstate"))
			{
				o.ifcheckstate = dr["ifcheckstate"].Tobool();
			}
			return o;
        }