public DataTable ReadFull(DataTable table, Object.Grade grade) { using (SqlConnection con = new SqlConnection(SharedMethods.getConnectionString())) { SqlCommand cmd = new SqlCommand("Select Id,Grade,ClassId,ClassName,LessonId,LessonName,OnDate,StudentInClassId,StudentName,FullTeacherName,TeacherEGN From vwGradeFull_tblGrade Where ClassId = @ClassId", con); cmd.Parameters.AddWithValue("@ClassId", grade.ClassId); con.Open(); using (SqlDataReader rdr = cmd.ExecuteReader()) { while (rdr.Read()) { DataRow row = table.NewRow(); row["Id"] = rdr["Id"]; row["Grade"] = rdr["Grade"]; row["ClassId"] = rdr["ClassId"]; row["ClassName"] = rdr["ClassName"]; row["LessonId"] = rdr["LessonId"]; row["LessonName"] = rdr["LessonName"]; row["OnDate"] = rdr["OnDate"]; row["StudentInClassId"] = rdr["StudentInClassId"]; row["StudentName"] = rdr["StudentName"]; row["FullTeacherName"] = rdr["FullTeacherName"]; row["TeacherEGN"] = rdr["TeacherEGN"]; table.Rows.Add(row); } } con.Close(); return(table); } }
public int Create(Object.Grade grade) { using (SqlConnection con = new SqlConnection(SharedMethods.getConnectionString())) { SqlCommand cmd = new SqlCommand("spAddGrade_tblGrade", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Grade", grade.grade); cmd.Parameters.AddWithValue("@ClassId", grade.ClassId); cmd.Parameters.AddWithValue("@LessonId", grade.LessonId); cmd.Parameters.AddWithValue("@StudentInClassId", grade.StudentId); cmd.Parameters.AddWithValue("@TeacherEGN", grade.TeacherEGN); SqlParameter Result = new SqlParameter("@ResultNumber", DbType.Int32); Result.Direction = ParameterDirection.Output; cmd.Parameters.Add(Result); con.Open(); cmd.ExecuteNonQuery(); con.Close(); return((int)Result.Value); } }
public DataTable ReadFull(int ClassId) { DataTable table = new DataTable(); table.Columns.Add("Id"); table.Columns.Add("Grade"); table.Columns.Add("ClassId"); table.Columns.Add("ClassName"); table.Columns.Add("LessonId"); table.Columns.Add("LessonName"); table.Columns.Add("OnDate"); table.Columns.Add("StudentInClassId"); table.Columns.Add("StudentName"); table.Columns.Add("FullTeacherName"); table.Columns.Add("TeacherEGN"); if (ClassId == 0) { return(crud.ReadFull(table)); } else { Object.Grade grade = new Object.Grade(); grade.ClassId = ClassId; return(crud.ReadFull(table, grade)); } }
public void Delete(int Id, out string Message, out System.Drawing.Color Color) { Object.Grade grade = new Object.Grade(); grade.Id = Id; int ResultNumber = crud.Delete(grade); message.Delete(ResultNumber, out Message, out Color); }
public int Delete(Object.Grade grade) { using (SqlConnection con = new SqlConnection(SharedMethods.getConnectionString())) { SqlCommand cmd = new SqlCommand("Delete From tblGrade Where Id = @Id", con); cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("@Id", grade.Id); con.Open(); return((int)cmd.ExecuteNonQuery()); } }
public void Create(int ClassId, int Grade, int LessonId, int StudentId, string TeacherEGN, out string Message, out System.Drawing.Color Color) { Object.Grade grade = new Object.Grade(); grade.ClassId = ClassId; grade.grade = Grade; grade.LessonId = LessonId; grade.StudentId = StudentId; grade.TeacherEGN = TeacherEGN; int ResultNumber = crud.Create(grade); message.Create(ResultNumber, out Message, out Color); }