Beispiel #1
0
 public int SetTimeLesson(DayLesson dayLesson, DateTime timeLesson)
 {
     try
     {
         if (ExistDay(dayLesson))
         {
             if (!ExistTime(dayLesson, timeLesson))
             {
                 return(_day_LessonDAO.SetTimeLesson(dayLesson, timeLesson));
             }
             else
             {
                 return(0);
             }
         }
         else
         {
             Add(dayLesson);
             return(_day_LessonDAO.SetTimeLesson(dayLesson, timeLesson));
         }
     }
     catch (Exception ex)
     {
         Logger.Log.Error(ex.Message);
         return(-1);
     }
 }
Beispiel #2
0
        public bool DeleteDay(DayLesson dayLesson)
        {
            string timeLessonSQL = dayLesson.Day_Lesson.Year + "-" + dayLesson.Day_Lesson.Month + "-" + dayLesson.Day_Lesson.Day + " " + "00:00:00.00";

            var query   = "DELETE FROM [table_DayLesson] WHERE Day_Lesson = \'" + timeLessonSQL + "\'";
            var command = new SqlCommand(query, _connection);

            command.ExecuteNonQuery();
            return(true);
        }
Beispiel #3
0
        public int AddDay(DayLesson dayLesson)
        {
            var query = "INSERT INTO dbo.[table_DayLesson](Day_Lesson) " +
                        "VALUES(@Day_Lesson)";
            var command = new SqlCommand(query, _connection);

            command.Parameters.AddWithValue("@Day_Lesson", dayLesson.Day_Lesson);
            var result = command.ExecuteNonQuery();

            return(result);
        }
 public bool SubscribeUser(DayLesson dayLesson, DateTime timeLesson, int ID)
 {
     try
     {
         return(_time_LessonDAO.SubscribeUser(dayLesson, timeLesson, ID));
     }
     catch (Exception ex)
     {
         Logger.Log.Error(ex.Message);
         return(false);
     }
 }
 public IEnumerable <int> GetSubscribeUsers(DayLesson dayLesson, DateTime timeLesson)
 {
     try
     {
         return(_time_LessonDAO.GetSubscribeUsers(dayLesson, timeLesson));
     }
     catch (Exception ex)
     {
         Logger.Log.Error(ex.Message);
         return(null);
     }
 }
 public bool ExistDay(DayLesson dayLesson)
 {
     try
     {
         return(_table_DayLessonDAO.ExistDay(dayLesson));
     }
     catch (Exception ex)
     {
         Logger.Log.Error(ex.Message);
         return(true);
     }
 }
Beispiel #7
0
 public bool Add(DayLesson number_day)
 {
     try
     {
         return(_day_LessonDAO.Add(number_day));
     }
     catch (Exception ex)
     {
         Logger.Log.Error(ex.Message);
         return(false);
     }
 }
Beispiel #8
0
 public bool EmptyDay(DayLesson dayLesson)
 {
     try
     {
         return(_day_LessonDAO.EmptyDay(dayLesson));
     }
     catch (Exception ex)
     {
         Logger.Log.Error(ex.Message);
         return(false);
     }
 }
Beispiel #9
0
 public bool ExistTime(DayLesson dayLesson, DateTime timeLesson)
 {
     try
     {
         return(_day_LessonDAO.ExistTime(dayLesson, timeLesson));
     }
     catch (Exception ex)
     {
         Logger.Log.Error(ex.Message);
         return(false);
     }
 }
 public bool ExistSubscribe(DayLesson dayLesson, DateTime timeLesson, int ID)
 {
     try
     {
         return(_time_LessonDAO.ExistSubscribe(dayLesson, timeLesson, ID));
     }
     catch (Exception ex)
     {
         Logger.Log.Error(ex.Message);
         return(true);
     }
 }
 public bool DeleteDay(DayLesson dayLesson)
 {
     try
     {
         return(_table_DayLessonDAO.DeleteDay(dayLesson));
     }
     catch (Exception ex)
     {
         Logger.Log.Error(ex.Message);
         return(false);
     }
 }
        /// <summary>
        /// Добавляет время для записи на указанный день
        /// </summary>
        /// <param name="dayLesson">День, в который необходимо добавить запись</param>
        /// <param name="timeLesson">Время, на которое необходимо добавить запись</param>
        public int SetTimeLesson(DayLesson dayLesson, DateTime timeLesson)
        {
            string dayLessonStr = "[" + dayLesson.Day_Lesson.Day + "_" + dayLesson.Day_Lesson.Month + "_" + dayLesson.Day_Lesson.Year + "]";

            var query = "INSERT INTO dbo." + dayLessonStr + "(Time_Lesson) " +
                        "VALUES(@Time_Lesson)";
            var command = new SqlCommand(query, _connection);

            command.Parameters.AddWithValue("@Time_Lesson", timeLesson);
            var result = command.ExecuteNonQuery();

            return(result);
        }
Beispiel #13
0
 public bool DeleteTime(DayLesson dayLesson, DateTime timeLesson)
 {
     try
     {
         _day_LessonDAO.DeleteTime(dayLesson, timeLesson);
         if (EmptyDay(dayLesson))
         {
             DeleteDay(dayLesson);
         }
         return(true);
     }
     catch (Exception ex)
     {
         Logger.Log.Error(ex.Message);
         return(false);
     }
 }
        /// <summary>
        /// Получает все записи времени на указанный день
        /// </summary>
        /// <param name="dayLesson">День, у которого необходимо получить все записи</param>
        /// <returns></returns>
        public IEnumerable <DateTime> GetTimeLesson(DayLesson dayLesson)
        {
            string dayLessonStr = "[" + dayLesson.Day_Lesson.Day + "_" + dayLesson.Day_Lesson.Month + "_" + dayLesson.Day_Lesson.Year + "]";
            var    query        = "SELECT Time_Lesson FROM " + dayLessonStr;

            var command = new SqlCommand(query, _connection);

            var reader = command.ExecuteReader();

            List <DateTime> timeLesson = new List <DateTime>();

            while (reader.Read())
            {
                timeLesson.Add((DateTime)reader["Time_Lesson"]);
            }
            reader.Close();
            return(timeLesson);
        }
        public bool DeleteDay(DayLesson dayLesson)
        {
            string dayLessonStr  = "[" + dayLesson.Day_Lesson.Day + "_" + dayLesson.Day_Lesson.Month + "_" + dayLesson.Day_Lesson.Year + "]";
            string timeLessonSQL = dayLesson.Day_Lesson.Year + "-" + dayLesson.Day_Lesson.Month + "-" + dayLesson.Day_Lesson.Day + " " + "00:00:00.00";
            var    query         = "DROP TABLE [dbo]." + dayLessonStr;
            var    command       = new SqlCommand(query, _connection);

            var result = command.ExecuteNonQuery();

            if (result > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public bool DeleteTime(DayLesson dayLesson, DateTime timeLesson)
        {
            string timeLessonSQL = dayLesson.Day_Lesson.Year + "-" + dayLesson.Day_Lesson.Month + "-" + dayLesson.Day_Lesson.Day + " " + timeLesson.Hour + ":" + timeLesson.Minute + ":00.00";
            string dayLessonStr  = "[" + dayLesson.Day_Lesson.Day + "_" + dayLesson.Day_Lesson.Month + "_" + dayLesson.Day_Lesson.Year + "]";
            var    query         = "DELETE FROM " + dayLessonStr + " WHERE Time_Lesson = \'" + timeLessonSQL + "\'";
            var    command       = new SqlCommand(query, _connection);

            var result = command.ExecuteNonQuery();

            if (result > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #17
0
        public bool ExistDay(DayLesson dayLesson)
        {
            string dayLessonSQL = dayLesson.Day_Lesson.Year + "-" + dayLesson.Day_Lesson.Month + "-" + dayLesson.Day_Lesson.Day;
            var    query        = "SELECT * FROM [table_DayLesson] WHERE Day_Lesson = \'" + dayLessonSQL + "\'";

            var command = new SqlCommand(query, _connection);
            var reader  = command.ExecuteReader();

            if (reader.HasRows)
            {
                reader.Close();
                return(true);
            }
            else
            {
                reader.Close();
                return(false);
            }
        }
Beispiel #18
0
 public IEnumerable <DateTime> GetTimeLesson(DayLesson dayLesson)
 {
     try
     {
         if (ExistDay(dayLesson))
         {
             return(_day_LessonDAO.GetTimeLesson(dayLesson));
         }
         else
         {
             return(null);
         }
     }
     catch (Exception ex)
     {
         Logger.Log.Error(ex.Message);
         return(null);
     }
 }
 public int AddDay(DayLesson dayLesson)
 {
     try
     {
         if (!ExistDay(dayLesson))
         {
             return(_table_DayLessonDAO.AddDay(dayLesson));
         }
         else
         {
             return(0);
         }
     }
     catch (Exception ex)
     {
         Logger.Log.Error(ex.Message);
         return(-1);
     }
 }
        public bool ExistDay(DayLesson dayLesson)
        {
            string dayLessonStr = "\'" + dayLesson.Day_Lesson.Day + "_" + dayLesson.Day_Lesson.Month + "_" + dayLesson.Day_Lesson.Year + "\'";
            var    query        = "SELECT * FROM Tutor.INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = " + dayLessonStr;

            var command = new SqlCommand(query, _connection);
            var reader  = command.ExecuteReader();

            if (reader.HasRows)
            {
                reader.Close();
                return(true);
            }
            else
            {
                reader.Close();
                return(false);
            }
        }
 public int Add(DayLesson dayLesson, DateTime timeLesson)
 {
     try
     {
         if (!ExistTimeTable(dayLesson, timeLesson))
         {
             return(_time_LessonDAO.Add(dayLesson, timeLesson));
         }
         else
         {
             return(0);
         }
     }
     catch (Exception ex)
     {
         Logger.Log.Error(ex.Message);
         return(-1);
     }
 }
        public bool EmptyDay(DayLesson dayLesson)
        {
            string dayLessonStr = "[" + dayLesson.Day_Lesson.Day + "_" + dayLesson.Day_Lesson.Month + "_" + dayLesson.Day_Lesson.Year + "]";
            var    query        = "SELECT * FROM " + dayLessonStr;

            var command = new SqlCommand(query, _connection);
            var reader  = command.ExecuteReader();

            if (reader.HasRows)
            {
                reader.Close();
                return(false);
            }
            else
            {
                reader.Close();
                return(true);
            }
        }
        public bool ExistTime(DayLesson dayLesson, DateTime timeLesson)
        {
            string timeLessonSQL = dayLesson.Day_Lesson.Year + "-" + dayLesson.Day_Lesson.Month + "-" + dayLesson.Day_Lesson.Day + " " + timeLesson.Hour + ":" + timeLesson.Minute + ":00.00";
            string dayLessonStr  = "[" + dayLesson.Day_Lesson.Day + "_" + dayLesson.Day_Lesson.Month + "_" + dayLesson.Day_Lesson.Year + "]";
            var    query         = "SELECT * FROM " + dayLessonStr + " WHERE Time_Lesson = \'" + timeLessonSQL + "\'";

            var command = new SqlCommand(query, _connection);
            var reader  = command.ExecuteReader();

            if (reader.HasRows)
            {
                reader.Close();
                return(true);
            }
            else
            {
                reader.Close();
                return(false);
            }
        }
        /// <summary>
        /// Создает отдельную таблицу для указанного дня
        /// </summary>
        /// <param name="number_day">День для создания таблицы</param>
        public bool Add(DayLesson number_day)
        {
            string number_dayStr = number_day.Day_Lesson.Day + "_" + number_day.Day_Lesson.Month + "_" + number_day.Day_Lesson.Year;
            var    query         = "CREATE TABLE [dbo].[" + number_dayStr + "]" +
                                   "(" +

                                   "[Id]          INT      NOT NULL IDENTITY," +
                                   "[Time_Lesson] DATETIME NOT NULL," +
                                   "PRIMARY KEY CLUSTERED ([Id] ASC)" +
                                   ")";
            var command = new SqlCommand(query, _connection);
            var result  = command.ExecuteNonQuery();

            if (result > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #25
0
        public DayCalendar(List <Webinar> webinars, DateTime dt)
        {
            InitializeComponent();

            for (int i = 0; i < 13; i++)
            {
                for (int j = 0; j < 12; j++)
                {
                    LessonsContainer.RowDefinitions.Add(new RowDefinition()
                    {
                        MinHeight = 20
                    });
                    Border b = new Border();
                    Grid.SetRow(b, j + i * 12);
                    Grid.SetColumn(b, 1);
                    b.BorderThickness = new Thickness(0, 0, 0, 1);
                    b.BorderBrush     = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#65A6D1"));
                    LessonsContainer.Children.Add(b);
                }
                Border b1 = new Border();
                Grid.SetRow(b1, i * 12);
                Grid.SetRowSpan(b1, 12);
                Grid.SetColumn(b1, 0);
                b1.BorderThickness = new Thickness(0, 0, 0, 1);
                b1.BorderBrush     = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#65A6D1"));
                b1.Background      = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#8065A6D1"));

                string time = "";
                switch (i)
                {
                case 0:
                    time = "9:00";
                    break;

                case 1:
                    time = "10:00";
                    break;

                case 2:
                    time = "11:00";
                    break;

                case 3:
                    time = "12:00";
                    break;

                case 4:
                    time = "13:00";
                    break;

                case 5:
                    time = "14:00";
                    break;

                case 6:
                    time = "15:00";
                    break;

                case 7:
                    time = "16:00";
                    break;

                case 8:
                    time = "17:00";
                    break;

                case 9:
                    time = "18:00";
                    break;

                case 10:
                    time = "19:00";
                    break;

                case 11:
                    time = "20:00";
                    break;

                case 12:
                    time = "21:00";
                    break;
                }

                b1.Child = new TextBlock()
                {
                    FontSize            = 20,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Center,
                    Foreground          = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#777777")),
                    Text = time
                };
                LessonsContainer.Children.Add(b1);
            }

            foreach (Webinar webinar in webinars)
            {
                if (webinar.StartTime.HasValue)
                {
                    if (webinar.StartTime.Value.Date == dt.Date)
                    {
                        DayLesson dl = new DayLesson(webinar);
                        Grid.SetRow(dl, (webinar.StartTime.Value.Hour - 9) * 12 + ((webinar.StartTime.Value.Minute) / 5));
                        Grid.SetRowSpan(dl, 18);
                        Grid.SetColumn(dl, 1);
                        LessonsContainer.Children.Add(dl);
                    }
                }
            }
        }