Example #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(dbamet.Model.HomeWork model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into HomeWork(");
            strSql.Append("customId,hwId,hwName,hwPath)");
            strSql.Append(" values (");
            strSql.Append("@customId,@hwId,@hwName,@hwPath)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@customId", SqlDbType.Char,      8),
                new SqlParameter("@hwId",     SqlDbType.Char,     10),
                new SqlParameter("@hwName",   SqlDbType.VarChar, 200),
                new SqlParameter("@hwPath",   SqlDbType.VarChar, 200)
            };
            parameters[0].Value = model.customId;
            parameters[1].Value = model.hwId;
            parameters[2].Value = model.hwName;
            parameters[3].Value = model.hwPath;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(dbamet.Model.HomeWork model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update HomeWork set ");
            strSql.Append("customId=@customId,");
            strSql.Append("hwId=@hwId,");
            strSql.Append("hwName=@hwName,");
            strSql.Append("hwPath=@hwPath");
            strSql.Append(" where ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@customId", SqlDbType.Char,      8),
                new SqlParameter("@hwId",     SqlDbType.Char,     10),
                new SqlParameter("@hwName",   SqlDbType.VarChar, 200),
                new SqlParameter("@hwPath",   SqlDbType.VarChar, 200)
            };
            parameters[0].Value = model.customId;
            parameters[1].Value = model.hwId;
            parameters[2].Value = model.hwName;
            parameters[3].Value = model.hwPath;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

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

            strSql.Append("select  top 1 customId,hwId,hwName,hwPath from HomeWork ");
            strSql.Append(" where ");
            SqlParameter[] parameters =
            {
            };

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["customId"] != null && ds.Tables[0].Rows[0]["customId"].ToString() != "")
                {
                    model.customId = ds.Tables[0].Rows[0]["customId"].ToString();
                }
                if (ds.Tables[0].Rows[0]["hwId"] != null && ds.Tables[0].Rows[0]["hwId"].ToString() != "")
                {
                    model.hwId = ds.Tables[0].Rows[0]["hwId"].ToString();
                }
                if (ds.Tables[0].Rows[0]["hwName"] != null && ds.Tables[0].Rows[0]["hwName"].ToString() != "")
                {
                    model.hwName = ds.Tables[0].Rows[0]["hwName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["hwPath"] != null && ds.Tables[0].Rows[0]["hwPath"].ToString() != "")
                {
                    model.hwPath = ds.Tables[0].Rows[0]["hwPath"].ToString();
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }