//Created by Prasa on 17.07.2013 /// <summary> /// Adds the student mark. /// </summary> /// <param name="studentMark">The student mark.</param> /// <returns>StudentMarkId</returns> public int AddStudentMark(StudentMark studentMark) { int studentMarkId = 0; object IdentityValue = 0; using (var connection = new SqlConnection(GetConnectionString())) { using (SqlCommand cmd = connection.CreateCommand()) { connection.Open(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "[dbo].[usp_student_mark_insert]"; cmd.Parameters.Add(new SqlParameter("@roll_number", studentMark.RollNumber)); cmd.Parameters.Add(new SqlParameter("@language", studentMark.Language)); cmd.Parameters.Add(new SqlParameter("@english", studentMark.English)); cmd.Parameters.Add(new SqlParameter("@maths", studentMark.Maths)); cmd.Parameters.Add(new SqlParameter("@science", studentMark.Science)); cmd.Parameters.Add(new SqlParameter("@social", studentMark.Social)); cmd.Parameters.Add(new SqlParameter("@total", studentMark.Total)); cmd.Parameters.Add(new SqlParameter("@percentage", studentMark.Percentage)); cmd.Parameters.Add(new SqlParameter("@result", studentMark.Result)); cmd.Parameters.Add(new SqlParameter("@remarks", studentMark.Remarks)); cmd.Parameters.Add(new SqlParameter("@created_by", 1)); IdentityValue = cmd.ExecuteScalar(); } if (IdentityValue != DBNull.Value) { studentMarkId = Convert.ToInt32(IdentityValue); } } return studentMarkId; }
//Created by Vivek on 18.07.2013 /// <summary> /// Students the mark delete. /// </summary> /// <returns>StudentMark</returns> public static StudentMark StudentMarkDelete() { var markDelete = new StudentMark { RollNumber = 5, Modified_By = 2, }; return markDelete; }
//Created by Vivek on 18.07.2013 /// <summary> /// Students the mark delete. /// </summary> /// <returns></returns> public static StudentMark StudentMarkDelete() { StudentMark studentMarkDelete = new StudentMark(); var studentDelete = new StudentMark { RollNumber = 45, Modified_By = 2, }; return studentDelete; }
public ActionResult AddStudentMark(StudentMark studentMark, int id) { try { StudentRepository studentRepository = new StudentRepository(); studentMark.RollNumber = id; studentRepository.AddStudentMark(studentMark); //ViewData["Message1"] = "Student Marks Inserted Sucessfully"; //return View(); return RedirectToAction("Search", "Student"); } catch (Exception ex) { ViewData["Message2"] = "Error in Inserting"; return View(); } }
//Created by Prasana on 18.07.2013 /// <summary> /// Creates the student mark. /// </summary> /// <returns></returns> public static StudentMark CreateStudentMark() { var studentMark = new StudentMark { RollNumber = 4, Language = 100, English = 100, Maths = 100, Science = 100, Social = 100, Result = 'P', Remarks = "Outstanding", Total = 500, Percentage = 100, Created_By = 1 }; studentMark.StudentMarkId = studentDataService.AddStudentMark(studentMark); return studentMark; }
//Created by Prasanaon 18.07.2013 /// <summary> /// Creates the student mark. /// </summary> /// <returns>StudentMark</returns> public static StudentMark CreateStudentMark() { StudentRepository studentRepository = new StudentRepository(); var studentMark = new StudentMark { RollNumber = 4, Language = 90, English = 90, Maths = 100, Science = 100, Social = 100, Result = 'P', Remarks = "Good", Total = 480, Percentage = 96, Created_By = 1 }; studentMark.StudentMarkId = studentRepository.AddStudentMark(studentMark); return studentMark; }
//Created By Vivek on 17.07.2013 /// <summary> /// Students the mark update. /// </summary> /// <param name="studentMarkUpdate">The student mark update.</param> public void StudentMarkUpdate(StudentMark studentMarkUpdate) { using (var sqlcon = new SqlConnection(GetConnectionString())) { using (var sqlcmd = sqlcon.CreateCommand()) { sqlcon.Open(); sqlcmd.CommandType = CommandType.StoredProcedure; sqlcmd.CommandText = "[dbo].[usp_student_mark_update]"; sqlcmd.Parameters.Add(new SqlParameter("@student_mark_id", studentMarkUpdate.StudentMarkId)); sqlcmd.Parameters.Add(new SqlParameter("@roll_number", studentMarkUpdate.RollNumber)); sqlcmd.Parameters.Add(new SqlParameter("@language", studentMarkUpdate.Language)); sqlcmd.Parameters.Add(new SqlParameter("@english", studentMarkUpdate.English)); sqlcmd.Parameters.Add(new SqlParameter("@maths", studentMarkUpdate.Maths)); sqlcmd.Parameters.Add(new SqlParameter("@science", studentMarkUpdate.Science)); sqlcmd.Parameters.Add(new SqlParameter("@social", studentMarkUpdate.Social)); sqlcmd.Parameters.Add(new SqlParameter("@total", studentMarkUpdate.Total)); sqlcmd.Parameters.Add(new SqlParameter("@percentage", studentMarkUpdate.Percentage)); sqlcmd.Parameters.Add(new SqlParameter("@result", studentMarkUpdate.Result)); sqlcmd.Parameters.Add(new SqlParameter("@remarks", studentMarkUpdate.Remarks)); sqlcmd.Parameters.Add(new SqlParameter("@modified_by", 1)); sqlcmd.ExecuteNonQuery(); } } }
//Created By Prasana on 17.07.2013 /// <summary> /// Gets the studentmark by student mark id. /// </summary> /// <param name="studentMarkId">The student mark id.</param> /// <returns>Student Mark</returns> public StudentMark GetStudentMarkByStudentMarkId(int studentMarkId) { StudentMark studentMark = null; using (var connection = new SqlConnection(GetConnectionString())) { using (SqlCommand cmd = connection.CreateCommand()) { connection.Open(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "[dbo].[usp_get_student_mark_by_student_mark_id]"; cmd.Parameters.Add(new SqlParameter("@student_mark_id", studentMarkId)); using (SqlDataReader dataReader = cmd.ExecuteReader()) { if (dataReader.HasRows) { int rollNumberOrdinal = dataReader.GetOrdinal("roll_number"); int languageOrdinal = dataReader.GetOrdinal("language"); int englishOrdinal = dataReader.GetOrdinal("english"); int mathsOrdinal = dataReader.GetOrdinal("maths"); int scienceOrdinal = dataReader.GetOrdinal("science"); int socialOrdinal = dataReader.GetOrdinal("social"); int totalOrdinal = dataReader.GetOrdinal("total"); int percentageOrdinal = dataReader.GetOrdinal("percentage"); int resultOrdinal = dataReader.GetOrdinal("result"); int remarksOrdinal = dataReader.GetOrdinal("remarks"); while (dataReader.Read()) { studentMark = new StudentMark { RollNumber = dataReader.GetInt32(rollNumberOrdinal), Language = dataReader.GetInt32(languageOrdinal), English = dataReader.GetInt32(englishOrdinal), Maths = dataReader.GetInt32(mathsOrdinal), Science = dataReader.GetInt32(scienceOrdinal), Social = dataReader.GetInt32(socialOrdinal), Total = dataReader.GetInt32(totalOrdinal), Percentage = Convert.ToSingle(dataReader.GetValue(percentageOrdinal).ToString()), Result = Convert.ToChar(dataReader.GetValue(resultOrdinal)), Remarks = dataReader.GetString(remarksOrdinal) }; } } } } } return studentMark; }
public ActionResult EditStudentMarkUpdate(StudentMark studentMark) { studentRepository.StudentMarkUpdate(studentMark); return RedirectToAction("Search", "Student"); }
//Created by Prasana on 18.07.2013 /// <summary> /// Students the mark update. /// </summary> /// <returns></returns> public static StudentMark StudentMarkUpdate() { StudentMark studentMark = new StudentMark(); var updata = new StudentMark { StudentMarkId = 1, RollNumber = 34, Language = 50, English = 50, Maths = 50, Science = 50, Social = 50, Total = 250, Percentage = 50, Result = 'P', Remarks = "Good", Modified_By = 1, }; return updata; }
//Created by Prasana on 18.07.2013 /// <summary> /// Adds the student mark. /// </summary> /// <param name="studentMark">The student mark.</param> /// <returns>StudentMark</returns> public int AddStudentMark(StudentMark studentMark) { return studentDataService.AddStudentMark(studentMark); }
//Created by Vivek on 18.07.2013 /// <summary> /// Students the mark update. /// </summary> /// <param name="studentMarkUpdate">The student mark update.</param> public void StudentMarkUpdate(StudentMark studentMarkUpdate) { studentDataService.StudentMarkUpdate(studentMarkUpdate); }