示例#1
0
 public bool  EditStudent(int studentId, Student student)
 {
     using (_entity = new StudentModal())
     {
         return(_entity.EditStudent(studentId, student));
     }
 }
示例#2
0
        } //List Method

        public int Update(StudentModal student)
        {
            int rowsAffected = 0;

            using (SqlConnection connection = new SqlConnection(_connectionString))
            {
                connection.Open();

                SqlCommand command = new SqlCommand("spUpdateStudent", connection);

                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@Id", student.Id);
                command.Parameters.AddWithValue("@SessionId", student.SessionId);
                command.Parameters.AddWithValue("@SemesterId", student.SemesterId);
                command.Parameters.AddWithValue("@SectionId", student.SectionId);
                command.Parameters.AddWithValue("@RollNumber", student.RollNumber);
                command.Parameters.AddWithValue("@Name", student.Name);
                command.Parameters.AddWithValue("@FatherName", student.FatherName);
                command.Parameters.AddWithValue("@Password", student.Password);


                try
                {
                    rowsAffected = command.ExecuteNonQuery();
                }
                catch (Exception e)
                {
                    return(0);
                }

                return(rowsAffected);
            }
        }
示例#3
0
 public bool AddStudent(Student student)
 {
     using (_entity = new StudentModal())
     {
         return(_entity.AddStudent(student));
     }
 }
示例#4
0
 public List <Student> GetStudentByClass(string selectedClass)
 {
     using (_entity = new StudentModal())
     {
         return(_entity.GetStudentByClass(selectedClass));
     }
 }
示例#5
0
 public Student GetStudentByEnrollmentNumber(int enrollmentNumber)
 {
     using (_entity = new StudentModal())
     {
         return(_entity.GetStudentByEnrollmentNumber(enrollmentNumber));
     }
 }
示例#6
0
 public List <Student> GetAllStudent()
 {
     using (_entity = new StudentModal())
     {
         return(_entity.GetAllStudent());
     }
 }
示例#7
0
        public int Insert(StudentModal student)
        {
            student.RollNumber = student.RollNumber.Trim();
            student.Name       = student.Name.Trim();
            student.FatherName = student.FatherName.Trim();
            student.Password   = student.Password.Trim();

            bool isDuplicate = CheckPrimaryKeyViolation(student.SemesterId, student.SessionId, student.SectionId, student.RollNumber);

            if (isDuplicate)
            {
                return(0);
            }


            int noOfRowsAffected = 0;

            using (SqlConnection connection = new SqlConnection(_connectionString))
            {
                connection.Open();

                SqlCommand command = new SqlCommand("spInsertStudent", connection);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@SessionId", student.SessionId);
                command.Parameters.AddWithValue("@SemesterId", student.SemesterId);
                command.Parameters.AddWithValue("@SectionId", student.SectionId);
                command.Parameters.AddWithValue("@RollNumber", student.RollNumber);
                command.Parameters.AddWithValue("@Name", student.Name);
                command.Parameters.AddWithValue("@FatherName", student.FatherName);
                command.Parameters.AddWithValue("@Password", student.Password);
                try
                {
                    noOfRowsAffected = command.ExecuteNonQuery();
                }
                catch (SqlException ex)
                {
                    if (ex.Number == 2627)
                    {
                        return(0);
                    }
                }
            }

            return(noOfRowsAffected);
        } // Insert Method
 public JsonResult Insert(StudentModal student)
 {
     return(Json(_databaseConnection.Insert(student), JsonRequestBehavior.AllowGet));
 }
 public JsonResult Update(StudentModal studentOject)
 {
     return(Json(_databaseConnection.Update(studentOject), JsonRequestBehavior.AllowGet));
 }