/// <summary> /// 添加学员 /// </summary> /// <param name="student"></param> /// <returns>返回学员编号</returns> public int AddNewStudent(Students student) { //string sql = "insert into Students(StudentName, Gender, Birthday, StudentIdNo, CardNo, StuImage, Age, PhoneNumber, StudentAddress, ClassId)"; //sql += " values('{0}','{1}','{2}',{3},'{4}','{5}',{6},'{7}','{8}',{9});"; //sql += "select @@identity"; //sql = string.Format(sql, student.StudentName, student.Gender, student.Birthday, student.StudentIdNo, student.CardNo, // student.StuImage, student.Age, student.PhoneNumber, student.StudentAddress, student.ClassId); ////SqlParameter[] sqlParameters = new SqlParameter[] ////{ //// new SqlParameter("@StudentName",student.StudentName), //// new SqlParameter("@Gender",student.Gender), //// new SqlParameter("@Birthday",student.Birthday.ToString("yyyyMMdd")), //// new SqlParameter("@StudentIdNo",student.StudentIdNo), //// new SqlParameter("@CardNo",student.CardNo), //// new SqlParameter("@StuImage",student.StuImage), //// new SqlParameter("@Age",student.Age), //// new SqlParameter("@PhoneNumber",student.PhoneNumber), //// new SqlParameter("@StudentAddress",student.StudentAddress), //// new SqlParameter("@ClassId",student.ClassId), ////}; //try //{ // //返回学号 // return Convert.ToInt32(SQLHelper.GetSignalResult(sql)); //} //catch (Exception ex) //{ // throw new Exception("添加学员时数据库访问异常!" + ex.Message); //} return(db.AddModel(student)); }