Beispiel #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(university.Model.CCOM.Student model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Student set ");
            strSql.Append("User_id=@User_id,");
            strSql.Append("Period_id=@Period_id");
            strSql.Append(" where Student_id=@Student_id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@User_id",    SqlDbType.BigInt, 8),
                new SqlParameter("@Period_id",  SqlDbType.Int,    4),
                new SqlParameter("@Student_id", SqlDbType.BigInt, 8)
            };
            parameters[0].Value = model.User_id;
            parameters[1].Value = model.Period_id;
            parameters[2].Value = model.Student_id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public long Add(university.Model.CCOM.Student model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Student(");
            strSql.Append("User_id,Period_id)");
            strSql.Append(" values (");
            strSql.Append("@User_id,@Period_id)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@User_id",   SqlDbType.BigInt, 8),
                new SqlParameter("@Period_id", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.User_id;
            parameters[1].Value = model.Period_id;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt64(obj));
            }
        }
Beispiel #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public university.Model.CCOM.Student DataRowToModel(DataRow row)
 {
     university.Model.CCOM.Student model = new university.Model.CCOM.Student();
     if (row != null)
     {
         if (row["Student_id"] != null && row["Student_id"].ToString() != "")
         {
             model.Student_id = long.Parse(row["Student_id"].ToString());
         }
         if (row["User_id"] != null && row["User_id"].ToString() != "")
         {
             model.User_id = long.Parse(row["User_id"].ToString());
         }
         if (row["Period_id"] != null && row["Period_id"].ToString() != "")
         {
             model.Period_id = int.Parse(row["Period_id"].ToString());
         }
     }
     return(model);
 }
Beispiel #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public university.Model.CCOM.Student GetModel(long Student_id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Student_id,User_id,Period_id from Student ");
            strSql.Append(" where Student_id=@Student_id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Student_id", SqlDbType.BigInt)
            };
            parameters[0].Value = Student_id;

            university.Model.CCOM.Student model = new university.Model.CCOM.Student();
            DataSet ds = DBSQL.Query(strSql.ToString(), parameters);

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