Пример #1
0
        public DataTable ReadTodayLesson(DataTable table, Object.Lesson lesson, Object.Programme programme)
        {
            using (SqlConnection con = new SqlConnection(SharedMethods.getConnectionString()))
            {
                SqlCommand cmd = new SqlCommand("Select a.Id,LessonName from tblLesson a Left Join tblProgramme b On a.ProgrammeId = b.Id Where DateDiff(day,OnDate,@OnDate) = 0 And ClassId = @ClassId", con);

                cmd.Parameters.AddWithValue("@OnDate", lesson.OnDate);
                cmd.Parameters.AddWithValue("@ClassId", programme.ClassId);

                con.Open();
                using (SqlDataReader rdr = cmd.ExecuteReader())
                {
                    while (rdr.Read())
                    {
                        DataRow row = table.NewRow();

                        row["Id"]         = rdr["Id"];
                        row["LessonName"] = rdr["LessonName"];

                        table.Rows.Add(row);
                    }
                }
                con.Close();
                return(table);
            }
        }
Пример #2
0
        public int Update(Object.Lesson lesson)
        {
            using (SqlConnection con = new SqlConnection(SharedMethods.getConnectionString()))
            {
                SqlCommand cmd = new SqlCommand("spUpdateLesson_tblLesson", con);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@Id", lesson.Id);
                cmd.Parameters.AddWithValue("@ProgrammeId", lesson.ProgrammeId);
                cmd.Parameters.AddWithValue("@LessonName", lesson.LessonName);
                cmd.Parameters.AddWithValue("@OnDate", lesson.OnDate);
                cmd.Parameters.AddWithValue("@TeacherEGN", lesson.TeacherEGN);
                cmd.Parameters.AddWithValue("@MissingStudentId", lesson.MissingStudentId);
                cmd.Parameters.AddWithValue("@LateStudentId", lesson.LateStudentId);

                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);
            }
        }
Пример #3
0
        public void Delete(int Id, int ClassId, out string Message, out System.Drawing.Color Color)
        {
            Object.Lesson lesson = new Object.Lesson();
            lesson.Id = Id;

            Object.Programme programme = new Object.Programme();
            programme.ClassId = ClassId;

            int ResultNumber = crud.Delete(lesson, programme);

            message.Delete(ResultNumber, out Message, out Color);
        }
Пример #4
0
        public DataTable ReadTodayLesson(int ClassId)
        {
            DataTable table = new DataTable();

            table.Columns.Add("Id");
            table.Columns.Add("LessonName");

            Object.Lesson lesson = new Object.Lesson();
            lesson.OnDate = DateTime.Now;

            Object.Programme programme = new Object.Programme();
            programme.ClassId = ClassId;

            return(crud.ReadTodayLesson(table, lesson, programme));
        }
Пример #5
0
        public void Update(int Id, int ProgrammeId, string LessonName, DateTime OnDate, string TeacherEGN, string MissingStudentId
                           , string LateStudentId, out string Message, out System.Drawing.Color Color)
        {
            Object.Lesson lesson = new Object.Lesson();
            lesson.Id               = Id;
            lesson.ProgrammeId      = ProgrammeId;
            lesson.LessonName       = LessonName;
            lesson.OnDate           = OnDate;
            lesson.TeacherEGN       = TeacherEGN;
            lesson.MissingStudentId = MissingStudentId;
            lesson.LateStudentId    = LateStudentId;

            int ResultNumber = crud.Update(lesson);

            message.Update(ResultNumber, out Message, out Color);
        }
Пример #6
0
        public int Delete(Object.Lesson lesson, Object.Programme programme)
        {
            using (SqlConnection con = new SqlConnection(SharedMethods.getConnectionString()))
            {
                SqlCommand cmd = new SqlCommand("spDeleteLesson_tblLesson", con);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@Id", lesson.Id);
                cmd.Parameters.AddWithValue("@ClassId", programme.ClassId);

                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);
            }
        }