示例#1
0
        public int AddNew(StuClassModel model)
        {
            object obj = SqlHelper.ExecuteScalar("insert into T_StuClass(id,StuId,ClassId) values(@id,@StuId,@ClassId )",
                                                 new MySqlParameter("id", model.id.ToString()),
                                                 new MySqlParameter("StuId", model.StuId.ToString()),
                                                 new MySqlParameter("ClassId", model.ClassId.ToString()));

            return(Convert.ToInt32(obj));
        }
示例#2
0
        public int Update(StuClassModel model)
        {
            object obj = SqlHelper.ExecuteScalar("update T_StuClass set StuId=@StuId,ClassId=@ClassId where id=@id",
                                                 new MySqlParameter("StuId", model.StuId.ToString()),
                                                 new MySqlParameter("ClassId", model.ClassId.ToString()),
                                                 new MySqlParameter("id", model.id.ToString()));

            return(Convert.ToInt32(obj));
        }
示例#3
0
        public IEnumerable <StuClassModel> GetAll()
        {
            DataTable            dt   = SqlHelper.ExecuteDataTable("select * from T_StuClass");
            List <StuClassModel> list = new List <StuClassModel>();

            foreach (DataRow row in dt.Rows)
            {
                StuClassModel model = new StuClassModel();
                model.id      = new Guid(row["id"].ToString());
                model.StuId   = new Guid(row["StuId"].ToString());
                model.ClassId = new Guid(row["ClassId"].ToString());
                list.Add(model);
            }
            return(list);
        }
示例#4
0
        public StuClassModel Get(Guid id)
        {
            DataTable dt = SqlHelper.ExecuteDataTable("select * from T_StuClass where id=@id",
                                                      new MySqlParameter("id", id));

            if (dt.Rows.Count <= 0)
            {
                return(null);
            }
            else if (dt.Rows.Count == 1)
            {
                StuClassModel model = new StuClassModel();
                DataRow       row   = dt.Rows[0];
                model.id      = new Guid(row["id"].ToString());
                model.StuId   = new Guid(row["StuId"].ToString());
                model.ClassId = new Guid(row["ClassId"].ToString());
                return(model);
            }
            else
            {
                throw new Exception("出现多条数据!");
            }
        }
示例#5
0
 public int AddNew(StuClassModel model)
 {
     return(new StuClassDAL().AddNew(model));
 }
示例#6
0
 public int Update(StuClassModel model)
 {
     return(new StuClassDAL().Update(model));
 }