Beispiel #1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public TF.RunSafty.Model.TAB_Base_Jwd_Address DataRowToModel(DataRow row)
 {
     TF.RunSafty.Model.TAB_Base_Jwd_Address model = new TF.RunSafty.Model.TAB_Base_Jwd_Address();
     if (row != null)
     {
         if (row["nId"] != null && row["nId"].ToString() != "")
         {
             model.nId = int.Parse(row["nId"].ToString());
         }
         if (row["strJWDNumber"] != null)
         {
             model.strJWDNumber = row["strJWDNumber"].ToString();
         }
         if (row["strJWDName"] != null)
         {
             model.strJWDName = row["strJWDName"].ToString();
         }
         if (row["strIP"] != null)
         {
             model.strIP = row["strIP"].ToString();
         }
         if (row["nWebHtmlPort"] != null && row["nWebHtmlPort"].ToString() != "")
         {
             model.nWebHtmlPort = int.Parse(row["nWebHtmlPort"].ToString());
         }
         if (row["nWebApiPort"] != null && row["nWebApiPort"].ToString() != "")
         {
             model.nWebApiPort = int.Parse(row["nWebApiPort"].ToString());
         }
     }
     return(model);
 }
Beispiel #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(TF.RunSafty.Model.TAB_Base_Jwd_Address model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into TAB_Base_Jwd_Address(");
            strSql.Append("strJWDNumber,strJWDName,strIP,nWebHtmlPort,nWebApiPort)");
            strSql.Append(" values (");
            strSql.Append("@strJWDNumber,@strJWDName,@strIP,@nWebHtmlPort,@nWebApiPort)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@strJWDNumber", SqlDbType.VarChar, 50),
                new SqlParameter("@strJWDName",   SqlDbType.VarChar, 50),
                new SqlParameter("@strIP",        SqlDbType.VarChar, 50),
                new SqlParameter("@nWebHtmlPort", SqlDbType.Int,      4),
                new SqlParameter("@nWebApiPort",  SqlDbType.Int, 4)
            };
            parameters[0].Value = model.strJWDNumber;
            parameters[1].Value = model.strJWDName;
            parameters[2].Value = model.strIP;
            parameters[3].Value = model.nWebHtmlPort;
            parameters[4].Value = model.nWebApiPort;
            int rows = (int)SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(TF.RunSafty.Model.TAB_Base_Jwd_Address model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update TAB_Base_Jwd_Address set ");
            strSql.Append("strJWDNumber=@strJWDNumber,");
            strSql.Append("strJWDName=@strJWDName,");
            strSql.Append("strIP=@strIP,");
            strSql.Append("nWebHtmlPort=@nWebHtmlPort,");
            strSql.Append("nWebApiPort=@nWebApiPort");
            strSql.Append(" where nId=@nId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@strJWDNumber", SqlDbType.VarChar, 50),
                new SqlParameter("@strJWDName",   SqlDbType.VarChar, 50),
                new SqlParameter("@strIP",        SqlDbType.VarChar, 50),
                new SqlParameter("@nWebHtmlPort", SqlDbType.Int,      4),
                new SqlParameter("@nWebApiPort",  SqlDbType.Int,      4),
                new SqlParameter("@nId",          SqlDbType.Int, 4)
            };
            parameters[0].Value = model.strJWDNumber;
            parameters[1].Value = model.strJWDName;
            parameters[2].Value = model.strIP;
            parameters[3].Value = model.nWebHtmlPort;
            parameters[4].Value = model.nWebApiPort;
            parameters[5].Value = model.nId;

            int rows = (int)SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public TF.RunSafty.Model.TAB_Base_Jwd_Address GetModel()
        {
            //该表无主键信息,请自定义主键/条件字段
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 nId,strJWDNumber,strJWDName,strIP,nWebHtmlPort,nWebApiPort from TAB_Base_Jwd_Address ");
            strSql.Append(" where ");
            SqlParameter[] parameters =
            {
            };

            TF.RunSafty.Model.TAB_Base_Jwd_Address model = new TF.RunSafty.Model.TAB_Base_Jwd_Address();
            DataSet ds = SqlHelper.ExecuteDataset(SqlHelper.ConnString, CommandType.Text, strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }