private int AddGroup(CreateGroupModel group) { string expressSql = "createStudyGroup"; using (SqlConnection connection = new SqlConnection(connectionString)) { connection.Open(); SqlCommand command = new SqlCommand(expressSql, connection) { CommandType = System.Data.CommandType.StoredProcedure }; SqlParameter namePar = new SqlParameter // parameter for enter name { ParameterName = "@nameSG", Value = group.NameStudyGroup }; command.Parameters.Add(namePar); // add SqlParameter idTeacherPar = new SqlParameter // parameter for id { ParameterName = "@IdTeach", Value = group.IdTeacher }; command.Parameters.Add(idTeacherPar); int result = (int)command.ExecuteScalar(); return(result); } }
public ActionResult CreateStudent(CreateStudentModel student) { string expressSql = "addStudent2"; using (SqlConnection connection = new SqlConnection(connectionString)) { connection.Open(); SqlCommand command = new SqlCommand(expressSql, connection) { CommandType = System.Data.CommandType.StoredProcedure }; SqlParameter namePar = new SqlParameter // parameter for enter name { ParameterName = "@idGroup", Value = student.IdStudyGroup }; command.Parameters.Add(namePar); // add SqlParameter idStudPar = new SqlParameter // parameter for id { ParameterName = "@idEmpl", Value = student.IdEmployee }; command.Parameters.Add(idStudPar); var result = command.ExecuteNonQuery(); } return(RedirectToAction("Edit", new { id = student.IdStudyGroup })); }