Exemplo n.º 1
0
        /// <summary>
        /// 更新学生个人信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool Update(Model.student model)
        {
            StringBuilder sqlstr = new StringBuilder();

            sqlstr.Append("update t_student set");
            sqlstr.Append(" xuehao=@xuehao,");
            sqlstr.Append(" name=@name,");
            sqlstr.Append(" age=@age,");
            sqlstr.Append(" hobby=@hobby,");
            sqlstr.Append(" zhuanye=@zhuanye,");
            sqlstr.Append(" xueli=@xueli");
            sqlstr.Append(" where xuehao=@xuehao");
            SqlParameter[] parameters =
            {
                new SqlParameter("@xuehao",  SqlDbType.VarChar, 50),
                new SqlParameter("@name",    SqlDbType.VarChar, 50),
                new SqlParameter("@age",     SqlDbType.VarChar, 50),
                new SqlParameter("@hobby",   SqlDbType.VarChar, 50),
                new SqlParameter("@zhuanye", SqlDbType.VarChar, 50),
                new SqlParameter("@xueli",   SqlDbType.VarChar, 50),
            };
            parameters[0].Value = model.xuehao;
            parameters[1].Value = model.name;
            parameters[2].Value = model.age;
            parameters[3].Value = model.hobby;
            parameters[4].Value = model.zhuanye;
            parameters[5].Value = model.xueli;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 添加一条记录
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int Add(Model.student model)
        {
            StringBuilder sqlstr = new StringBuilder();

            sqlstr.Append("insert into t_student (");
            sqlstr.Append(" xuehao,name,age,hobby,zhuanye,xueli) ");
            sqlstr.Append(" values (");
            sqlstr.Append(" @xuehao,@name,@age,@hobby,@zhuanye,@xueli )");
            sqlstr.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@xuehao",  SqlDbType.VarChar, 50),
                new SqlParameter("@name",    SqlDbType.VarChar, 50),
                new SqlParameter("@age",     SqlDbType.VarChar, 50),
                new SqlParameter("@hobby",   SqlDbType.VarChar, 50),
                new SqlParameter("@zhuanye", SqlDbType.VarChar, 50),
                new SqlParameter("@xueli",   SqlDbType.VarChar, 50)
            };
            parameters[0].Value = model.xuehao;
            parameters[1].Value = model.name;
            parameters[2].Value = model.age;
            parameters[3].Value = model.hobby;
            parameters[4].Value = model.zhuanye;
            parameters[5].Value = model.xueli;

            int obj = DbHelperSQL.ExecuteSql(sqlstr.ToString(), parameters);

            if (obj < 1)
            {
                return(0);
            }
            else
            {
                return(obj);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 添加一条记录
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Add(Model.student model)
 {
     return(dal2.Add(model));
 }
Exemplo n.º 4
0
 /// <summary>
 /// 更新学生个人信息
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool Update(Model.student model)
 {
     return(dal2.Update(model));
 }