Ejemplo n.º 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(TFXK.Model.Link model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tb_Link(");
            strSql.Append("title,linkUrl,logo,isPictureOn,orderId,parentId)");
            strSql.Append(" values (");
            strSql.Append("@title,@linkUrl,@logo,@isPictureOn,@orderId,@parentId)");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@title",       OleDbType.VarChar, 100),
                new OleDbParameter("@linkUrl",     OleDbType.VarChar, 100),
                new OleDbParameter("@logo",        OleDbType.VarChar,  50),
                new OleDbParameter("@isPictureOn", OleDbType.VarChar,  10),
                new OleDbParameter("@orderId",     OleDbType.Integer,   4),
                new OleDbParameter("@parentId",    OleDbType.Integer, 4)
            };
            parameters[0].Value = model.title;
            parameters[1].Value = model.linkUrl;
            parameters[2].Value = model.logo;
            parameters[3].Value = model.isPictureOn;
            parameters[4].Value = model.orderId;
            parameters[5].Value = model.parentId;

            object obj = DbHelperOleDb.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(TFXK.Model.Link model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tb_Link set ");
            strSql.Append("title=@title,");
            strSql.Append("linkUrl=@linkUrl,");
            strSql.Append("logo=@logo,");
            strSql.Append("isPictureOn=@isPictureOn,");
            strSql.Append("orderId=@orderId,");
            strSql.Append("parentId=@parentId");
            strSql.Append(" where id=@id ");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@title",       OleDbType.VarChar, 100),
                new OleDbParameter("@linkUrl",     OleDbType.VarChar, 100),
                new OleDbParameter("@logo",        OleDbType.VarChar, 100),
                new OleDbParameter("@isPictureOn", OleDbType.VarChar,  10),
                new OleDbParameter("@orderId",     OleDbType.Integer,   4),
                new OleDbParameter("@parentId",    OleDbType.Integer,   4),
                new OleDbParameter("@id",          OleDbType.Integer, 4)
            };
            parameters[0].Value = model.title;
            parameters[1].Value = model.linkUrl;
            parameters[2].Value = model.logo;
            parameters[3].Value = model.isPictureOn;
            parameters[4].Value = model.orderId;
            parameters[5].Value = model.parentId;
            parameters[6].Value = model.id;

            DbHelperOleDb.ExecuteSql(strSql.ToString(), parameters);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public TFXK.Model.Link GetModel(int id)
        {
            //该表无主键信息,请自定义主键/条件字段
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id,title,linkUrl,logo,isPictureOn,orderId,parentId,description from tb_Link ");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            TFXK.Model.Link model = new TFXK.Model.Link();
            DataSet         ds    = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                model.title       = ds.Tables[0].Rows[0]["title"].ToString();
                model.linkUrl     = ds.Tables[0].Rows[0]["linkUrl"].ToString();
                model.logo        = ds.Tables[0].Rows[0]["logo"].ToString();
                model.isPictureOn = ds.Tables[0].Rows[0]["isPictureOn"].ToString();
                if (ds.Tables[0].Rows[0]["orderId"].ToString() != "")
                {
                    model.orderId = int.Parse(ds.Tables[0].Rows[0]["orderId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["parentId"].ToString() != "")
                {
                    model.parentId = int.Parse(ds.Tables[0].Rows[0]["parentId"].ToString());
                }
                model.description = ds.Tables[0].Rows[0]["description"].ToString();



                return(model);
            }
            else
            {
                return(null);
            }
        }