示例#1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(TF.RunSafty.Model.TAB_NoticeType model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update TAB_NoticeType set ");

            strSql.Append(" strTypeGUID = @strTypeGUID , ");
            strSql.Append(" strTypeName = @strTypeName  ");
            strSql.Append(" where nid=@nid ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@nid",         SqlDbType.Int,      4),
                new SqlParameter("@strTypeGUID", SqlDbType.VarChar, 50),
                new SqlParameter("@strTypeName", SqlDbType.VarChar, 50)
            };

            parameters[0].Value = model.nid;
            parameters[1].Value = model.strTypeGUID;
            parameters[2].Value = model.strTypeName;
            int rows = (int)SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(TF.RunSafty.Model.TAB_NoticeType model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into TAB_NoticeType(");
            strSql.Append("strTypeGUID,strTypeName");
            strSql.Append(") values (");
            strSql.Append("@strTypeGUID,@strTypeName");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@strTypeGUID", SqlDbType.VarChar, 50),
                new SqlParameter("@strTypeName", SqlDbType.VarChar, 50)
            };

            parameters[0].Value = model.strTypeGUID;
            parameters[1].Value = model.strTypeName;

            object obj = SqlHelper.ExecuteScalar(SqlHelper.ConnString, CommandType.Text, strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
示例#3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public TF.RunSafty.Model.TAB_NoticeType GetModel(int nid)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select nid, strTypeGUID, strTypeName  ");
            strSql.Append("  from TAB_NoticeType ");
            strSql.Append(" where nid=@nid");
            SqlParameter[] parameters =
            {
                new SqlParameter("@nid", SqlDbType.Int, 4)
            };
            parameters[0].Value = nid;


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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["nid"].ToString() != "")
                {
                    model.nid = int.Parse(ds.Tables[0].Rows[0]["nid"].ToString());
                }
                model.strTypeName = ds.Tables[0].Rows[0]["strTypeName"].ToString();

                return(model);
            }
            else
            {
                return(null);
            }
        }
示例#4
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <TF.RunSafty.Model.TAB_NoticeType> DataTableToList(DataTable dt)
        {
            List <TF.RunSafty.Model.TAB_NoticeType> modelList = new List <TF.RunSafty.Model.TAB_NoticeType>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                TF.RunSafty.Model.TAB_NoticeType model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new TF.RunSafty.Model.TAB_NoticeType();
                    if (dt.Rows[n]["nid"].ToString() != "")
                    {
                        model.nid = int.Parse(dt.Rows[n]["nid"].ToString());
                    }
                    model.strTypeGUID = dt.Rows[n]["strTypeGUID"].ToString();
                    model.strTypeName = dt.Rows[n]["strTypeName"].ToString();


                    modelList.Add(model);
                }
            }
            return(modelList);
        }
示例#5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(TF.RunSafty.Model.TAB_NoticeType model)
 {
     return(dal.Update(model));
 }
示例#6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(TF.RunSafty.Model.TAB_NoticeType model)
 {
     return(dal.Add(model));
 }