public static int Add(ExamTypes examtypes) { int retvalue = -1; try { db.cmd.CommandType = CommandType.StoredProcedure; db.cmd.CommandText = "procExamTypes_ExamTypes"; db.cmd.Parameters.AddWithValue("@ExamTypeName", examtypes.ExamTypeName); db.cmd.Parameters.Add("@Id", SqlDbType.Int); db.cmd.Parameters["@Id"].Direction = ParameterDirection.Output; db.con.Open(); db.cmd.ExecuteNonQuery(); db.con.Close(); retvalue = Convert.ToInt32(db.cmd.Parameters["@Id"].Value); } catch (SqlException sqlex) { SqlExceptionErrorHandling rh = new SqlExceptionErrorHandling(); rh.GetError(sqlex); } finally { db.CloseDb(db.con, db.cmd); } return(retvalue); }
private static List <ExamTypes> _GetExamTypes() { List <ExamTypes> ExamTypes = new List <ExamTypes>(); try { Command = "select * from tblExamTypes"; db.cmd.CommandText = Command; db.con.Open(); SqlDataReader rdr = db.cmd.ExecuteReader(); while (rdr.Read()) { ExamTypes singleExamTypes = new ExamTypes(); singleExamTypes.Id = (int)rdr[0]; singleExamTypes.ExamTypeName = rdr[1].ToString(); ExamTypes.Add(singleExamTypes); } } catch (SqlException sqlex) { SqlExceptionErrorHandling rh = new SqlExceptionErrorHandling(); rh.GetError(sqlex); } finally { db.con.Close(); } return(ExamTypes); }
public static int Add(Exams exams, ExamTypes examTypes) { int retvalue = -1; exams.ExamTypesId = ExamTypes.Add(examTypes); retvalue = Exams.Add(exams); return(retvalue); }
private static List <Exams> _GetExams() { List <Exams> Exams = new List <Exams>(); try { Command = "select * from tblExams"; db.cmd.CommandText = Command; db.con.Open(); SqlDataReader rdr = db.cmd.ExecuteReader(); while (rdr.Read()) { Exams singleExams = new Exams(); singleExams.Id = (int)rdr[0]; singleExams.TotalMarks = Convert.ToSingle(rdr[1]); singleExams.ObtainedMarks = Convert.ToSingle(rdr[2]); singleExams.DateTime = rdr[3].ToString(); singleExams.StudentsId = (int)rdr[4]; singleExams.SubjectsId = (int)rdr[5]; singleExams.ExamTypesId = (int)rdr[6]; var students = new Students(); singleExams.Students = Students.ListOfStudents.SingleOrDefault(s => s.Id == singleExams.StudentsId); var subject = new Subjects(); singleExams.Subjects = Subjects.ListOfSubjects.SingleOrDefault(s => s.Id == singleExams.SubjectsId); var examtype = new ExamTypes(); singleExams.ExamTypes = ExamTypes.ListOfExamTypes.SingleOrDefault(e => e.Id == singleExams.ExamTypesId); Exams.Add(singleExams); } } catch (SqlException sqlex) { SqlExceptionErrorHandling rh = new SqlExceptionErrorHandling(); rh.GetError(sqlex); } finally { db.con.Close(); } return(Exams); }
public static void Update(int id, ExamTypes examtypes) { try { db.cmd.CommandText = "update tblExamTypes set ExamTypeName = @ExamTypeName where Id=@id"; db.cmd.Parameters.AddWithValue("@ExamTypename", examtypes.ExamTypeName); db.cmd.Parameters.AddWithValue("@id", id); db.con.Open(); db.cmd.ExecuteNonQuery(); } catch (SqlException sqlex) { SqlExceptionErrorHandling rh = new SqlExceptionErrorHandling(); rh.GetError(sqlex); } finally { db.CloseDb(db.con, db.cmd); } }
public Exams() { Students = new Students(); Subjects = new Subjects(); ExamTypes = new ExamTypes(); }
public static void Update(int Id, Exams exams, ExamTypes examtype) { exams.ExamTypesId = ExamTypes.Add(examtype); Exams.Update(Id, exams); }