예제 #1
0
 public static void add_log_liaving_time(DateTime date, TimeSpan time)
 {
     SQLConnector.set_log_liaving_time(date + time);
 }
예제 #2
0
        //Возвращает массив с данными для ячеек календаря
        public static ObservableCollection <Day> get_array_days(int year, int month)
        {
            array_objects_days.Clear();
            GC.Collect();


            //Определяем кол-во дней в переданном месяце
            int day_in_now_month = DateTime.DaysInMonth(year, month);

            //Определяем с какого дня недели начинается переданный месяц
            int day_of_the_week = get_day_week(new DateTime(year, month, 1));

            //Определям предидущий месяц и в каком он был году
            int old_month = get_old_month(year, month)[0];
            int old_year  = get_old_month(year, month)[1];

            //Определям следующий месяц и в каком он был году
            int new_month = get_new_month(year, month)[0];
            int new_year  = get_new_month(year, month)[1];

            //Определяем кол-во дней в прошлом месяце
            int day_in_old_month = DateTime.DaysInMonth(old_year, old_month);

            int i = 0;
            int d = 1;

            while (i + 1 < day_of_the_week)
            {
                array_objects_days.Add(new Day(new DateTime(old_year, old_month, i + day_in_old_month - day_of_the_week + 2)));
                array_objects_days[i].day_is_now_month = false;

                array_objects_days[i].Text_block_1 = Registration.get_time_arrival_from_day(new DateTime(old_year, old_month, i + day_in_old_month - day_of_the_week + 2));
                array_objects_days[i].Text_block_2 = Registration.get_liaving_time_from_day(new DateTime(old_year, old_month, i + day_in_old_month - day_of_the_week + 2));

                if (array_objects_days[i].Data_index.Date > DateTime.Now.Date)
                {
                    array_objects_days[i].EnableContextMenu = true;
                }

                if (array_objects_days[i].Data_index.Date == DateTime.Now.Date)
                {
                    array_objects_days[i].Is_now_day = true;
                }

                if (CalculationData.is_work(new DateTime(old_year, old_month, array_objects_days[i].getDay())))
                {
                    array_objects_days[i].IsWork = true;
                }
                else
                {
                    array_objects_days[i].IsWork = false;
                }
                i++;
            }

            d = 1;
            while (d <= day_in_now_month)
            {
                if (DateTime.Now.Date == new DateTime(year, month, d) && CalculationData.is_work(new DateTime(year, month, d)) && SQLConnector.GetTypeDay(new DateTime(year, month, d)) == 0)
                {
                    nowDayObject.Data_index = new DateTime(year, month, d);
                    array_objects_days.Add(nowDayObject);
                }
                else
                {
                    array_objects_days.Add(new Day(new DateTime(year, month, d)));
                    array_objects_days[i].Text_block_1 = SQLConnector.get_log_arrival_time(new DateTime(year, month, d));
                    array_objects_days[i].Text_block_2 = SQLConnector.get_log_liaving_time(new DateTime(year, month, d));
                }

                if (array_objects_days[i].Data_index > DateTime.Now.Date)
                {
                    array_objects_days[i].EnableContextMenu = true;
                }

                array_objects_days[i].day_is_now_month = true;
                if (array_objects_days[i].Data_index.Date == DateTime.Now.Date)
                {
                    array_objects_days[i].Is_now_day = true;
                }

                if (CalculationData.is_work(new DateTime(year, month, array_objects_days[i].getDay())))
                {
                    array_objects_days[i].IsWork = true;
                }
                else
                {
                    array_objects_days[i].IsWork = false;
                }

                i++;
                d++;
            }

            d = 1;
            while (i < 42)
            {
                array_objects_days.Add(new Day(new DateTime(new_year, new_month, d)));
                array_objects_days[i].day_is_now_month = false;
                if (array_objects_days[i].Data_index.Date == DateTime.Now.Date)
                {
                    array_objects_days[i].Is_now_day = true;
                }

                if (CalculationData.is_work(new DateTime(new_year, new_month, array_objects_days[i].getDay())))
                {
                    array_objects_days[i].IsWork = true;
                }
                else
                {
                    array_objects_days[i].IsWork = false;
                }

                if (array_objects_days[i].Data_index > DateTime.Now)
                {
                    array_objects_days[i].EnableContextMenu = true;
                }

                i++;
                d++;
            }



            return(array_objects_days);
        }