コード例 #1
0
        //*******************************************************************
        /// <summary>カレンダー選択された日付が変更された時</summary>
        /// <param name="sender">源</param>
        /// <param name="e">マウスイベント</param>
        //*******************************************************************
        private void monthCalendarDate_Select(object sender, DateRangeEventArgs e)
        {
            for (DateTime operation_date = e.Start; operation_date <= e.End; operation_date = operation_date.AddDays(1))
            {
                decimal   operating_date = ConvertUtil.ConverDate2IntYYYYMMDD(operation_date);
                DataRow[] rows           = CalendarDetailTable.Select("operating_date='" + operating_date + "'");
                // カレンダー稼働日テーブルから削除
                if (rows != null && rows.Count() > 0)
                {
                    rows[0].Delete();
                }
                else
                {
                    DataRow row = CalendarDetailTable.NewRow();
                    //ジョブネットID
                    row["calendar_id"] = _calendarId;
                    // 稼働日
                    row["operating_date"] = operating_date;
                    // 更新日
                    row["update_date"] = _tmpUpdDate;

                    CalendarDetailTable.Rows.Add(row);
                }
            }
        }
コード例 #2
0
        //*******************************************************************
        /// <summary>稼働日かどうかチェック</summary>
        //*******************************************************************
        private bool isOperatingDay(decimal theDay)
        {
            string condition = "operating_date = " + theDay;

            DataRow[] rows = CalendarDetailTable.Select(condition);
            if (rows.Length > 0)
            {
                return(true);
            }
            return(false);
        }
コード例 #3
0
        //*******************************************************************
        /// <summary>初回、矢印遷移の場合稼働日セット</summary>
        /// <param name="year">年</param>
        //*******************************************************************
        public void SetYearCalendarDetail(String year)
        {
            if (year != null)
            {
                textBox_year.Text = year;
            }
            else
            {
                year = textBox_year.Text;
            }

            DataRow[] rows = CalendarDetailTable.Select();
            monthCalendar.ViewStart = new DateTime(GetCurrentYear(), 1, 1);
            monthCalendar.SelectionRanges.Clear();
            SetSelectedDates(rows);
            DataRow[] maxRows = CalendarDetailTable.Select("operating_date = MAX(operating_date)");
            if (maxRows.Length > 0)
            {
                last_operation_day_value.Text = ConvertUtil.ConverIntYYYYMMDD2Date((Int32)maxRows[0]["operating_date"]).ToShortDateString();
            }
            this.winForm.Child = monthCalendar;
        }
コード例 #4
0
        //*******************************************************************
        /// <summary>カレンダー内容変更</summary>
        //*******************************************************************
        private bool refreshMonthCalendar()
        {
            int baseYear = GetCurrentYear();

            monthCalendar.Enabled = true;
            // 初期表示時
            if (CalendarDetailTable == null)
            {
                monthCalendar.Enabled = false;
                return(false);
            }
            monthCalendar.SelectionRanges.Clear();
            if (tbDesignatedDay.IsEnabled == true && tbDesignatedDay.Text == "")
            {
                monthCalendar.Enabled = false;
                return(false);
            }

            decimal[] targetDate = new decimal[14];
            try {
                int shiftDay = Convert.ToInt16(cmbShiftDay.SelectedItem);
                int month    = -1;
                int year     = -1;
                for (int i = 0; i < targetDate.Length; i++)
                {
                    if (i == 0)
                    {
                        year  = baseYear - 1;
                        month = 12;
                    }
                    else if (i == (targetDate.Length - 1))
                    {
                        year  = baseYear + 1;
                        month = 1;
                    }
                    else
                    {
                        year  = baseYear;
                        month = i;
                    }
                    if (rbFirstDay.IsChecked == true)
                    {
                        targetDate[i] = ConvertUtil.ConverDate2IntYYYYMMDD(new DateTime(year, month, 1));
                    }
                    else if (rbLastDay.IsChecked == true)
                    {
                        targetDate[i] = ConvertUtil.ConverDate2IntYYYYMMDD(new DateTime(year, month, DateTime.DaysInMonth(year, month)));
                    }
                    else
                    {
                        int designatedDay = Convert.ToInt16(tbDesignatedDay.Text);
                        if (tbDesignatedDay.Text != null)
                        {
                            StringBuilder yyyymmdd = new StringBuilder();
                            yyyymmdd.Append(year.ToString("D4"));
                            yyyymmdd.Append(month.ToString("D2"));
                            yyyymmdd.Append(designatedDay.ToString("D2"));
                            targetDate[i] = Convert.ToDecimal(yyyymmdd.ToString());
                        }
                    }
                    if (isOperatingDay(targetDate[i]))
                    {
                        // 稼働日移動しない
                        SetSelectDate(ConvertUtil.ConverIntYYYYMMDD2Date(targetDate[i]));
                    }
                    else
                    {
                        // 非稼働日

                        /* added by YAMA 2014/12/05    V2.1.0 No28 対応 */
                        string   stDate = Regex.Replace(targetDate[i].ToString(), @"(\d{4})(\d{2})(\d{2})", @"$1/$2/$3");
                        DateTime dtDate = DateTime.Parse(stDate);

                        if (shiftDay > 0)
                        {
                            /* added by YAMA 2014/12/05    V2.1.0 No28 対応 */
                            // string condition = "operating_date > " + targetDate[i];
                            dtDate = dtDate.AddDays(29);    // 29日加算する
                            decimal afterDate = Convert.ToDecimal(dtDate.ToString("yyyyMMdd"));
                            string  condition = "operating_date >= " + targetDate[i] + " and operating_date <= " + afterDate;

                            string    sortExpression = "operating_date asc";
                            DataRow[] rows           = CalendarDetailTable.Select(condition, sortExpression);

                            /* added by YAMA 2014/12/05    V2.1.0 No28 対応 */
                            // if (rows.Length > 0){
                            if ((0 < rows.Length) && (Math.Abs(shiftDay) - 1 < rows.Length))
                            {
                                DateTime shifted = ConvertUtil.ConverIntYYYYMMDD2Date(Convert.ToDecimal(rows[shiftDay - 1]["operating_date"]));
                                SetSelectDate(shifted);
                            }
                        }
                        else if (shiftDay < 0)
                        {
                            /* added by YAMA 2014/12/05    V2.1.0 No28 対応 */
                            //string condition = "operating_date < " + targetDate[i];
                            dtDate = dtDate.AddDays(-29);    // 29日減算する
                            decimal beforeDate = Convert.ToDecimal(dtDate.ToString("yyyyMMdd"));
                            string  condition  = "operating_date <= " + targetDate[i] + " and operating_date >= " + beforeDate;

                            string    sortExpression = "operating_date desc";
                            DataRow[] rows           = CalendarDetailTable.Select(condition, sortExpression);

                            /* added by YAMA 2014/12/05    V2.1.0 No28 対応 */
                            //if (rows.Length > 0){
                            if ((0 < rows.Length) && (Math.Abs(shiftDay) - 1 < rows.Length))
                            {
                                DateTime shifted = ConvertUtil.ConverIntYYYYMMDD2Date(Convert.ToDecimal(rows[-1 - shiftDay]["operating_date"]));
                                SetSelectDate(shifted);
                            }
                        }
                        else
                        {
                            string    condition = "operating_date = " + targetDate[i];
                            DataRow[] rows      = CalendarDetailTable.Select(condition);
                            if (rows.Length > 0)
                            {
                                DateTime shifted = ConvertUtil.ConverIntYYYYMMDD2Date(Convert.ToDecimal(rows[0]["operating_date"]));
                                SetSelectDate(shifted);
                            }
                        }
                    }
                }
            }
            catch (FormatException e) {
                monthCalendar.Enabled = false;
                return(false);
            }
            catch (Exception e) {
                //System.Windows.MessageBox.Show(e.ToString());
                monthCalendar.Enabled = false;
                return(false);
            }
            monthCalendar.Enabled = false;
            return(true);
        }
コード例 #5
0
        //*******************************************************************
        /// <summary>フィルター選択時のカレンダー表示</summary>
        //*******************************************************************
        public void SetFilterCalendarDetail()
        {
            int baseYear = GetCurrentYear();

            monthCalendar.Enabled = true;
            monthCalendar.SelectionRanges.Clear();
            monthCalendar.ViewStart = new DateTime(baseYear, 1, 1);
            DataRow row = FilterControlTable.Rows[0];

            if (row == null)
            {
                monthCalendar.Enabled = false;
                return;
            }
            int baseDate = Convert.ToInt16(row["base_date_flag"]);
            int shiftDay = Convert.ToInt16(row["shift_day"]);

            decimal [] targetDate = new decimal[14];
            try {
                int month = -1;
                int year  = -1;
                for (int i = 0; i < targetDate.Length; i++)
                {
                    if (i == 0)
                    {
                        year  = baseYear - 1;
                        month = 12;
                    }
                    else if (i == (targetDate.Length - 1))
                    {
                        year  = baseYear + 1;
                        month = 1;
                    }
                    else
                    {
                        year  = baseYear;
                        month = i;
                    }
                    if (baseDate == 0)
                    {
                        targetDate[i] = ConvertUtil.ConverDate2IntYYYYMMDD(new DateTime(year, month, 1));
                    }
                    else if (baseDate == 1)
                    {
                        targetDate[i] = ConvertUtil.ConverDate2IntYYYYMMDD(new DateTime(year, month, DateTime.DaysInMonth(year, month)));
                    }
                    else if (baseDate == 2)
                    {
                        int           designatedDay = Convert.ToInt16(row["designated_day"]);
                        StringBuilder yyyymmdd      = new StringBuilder();
                        yyyymmdd.Append(year.ToString("D4"));
                        yyyymmdd.Append(month.ToString("D2"));
                        yyyymmdd.Append(designatedDay.ToString("D2"));
                        targetDate[i] = Convert.ToDecimal(yyyymmdd.ToString());
                    }
                    else
                    {
                        monthCalendar.Enabled = false;
                        return;
                    }
                    if (isOperatingDay(targetDate[i]))
                    {
                        // 稼働日移動しない
                        SetSelectDate(ConvertUtil.ConverIntYYYYMMDD2Date(targetDate[i]));
                    }
                    else
                    {
                        // 非稼働日
                        if (shiftDay > 0)
                        {
                            string    condition      = "operating_date > " + targetDate[i];
                            string    sortExpression = "operating_date asc";
                            DataRow[] rows           = CalendarDetailTable.Select(condition, sortExpression);
                            if (rows.Length > 0)
                            {
                                DateTime shifted = ConvertUtil.ConverIntYYYYMMDD2Date(Convert.ToDecimal(rows[shiftDay - 1]["operating_date"]));
                                SetSelectDate(shifted);
                            }
                        }
                        else if (shiftDay < 0)
                        {
                            string    condition      = "operating_date < " + targetDate[i];
                            string    sortExpression = "operating_date desc";
                            DataRow[] rows           = CalendarDetailTable.Select(condition, sortExpression);
                            if (rows.Length > 0)
                            {
                                DateTime shifted = ConvertUtil.ConverIntYYYYMMDD2Date(Convert.ToDecimal(rows[-1 - shiftDay]["operating_date"]));
                                SetSelectDate(shifted);
                            }
                        }
                        else
                        {
                            string    condition = "operating_date = " + targetDate[i];
                            DataRow[] rows      = CalendarDetailTable.Select(condition);
                            if (rows.Length > 0)
                            {
                                DateTime shifted = ConvertUtil.ConverIntYYYYMMDD2Date(Convert.ToDecimal(rows[0]["operating_date"]));
                                SetSelectDate(shifted);
                            }
                        }
                    }
                }
            }
            catch (Exception e) {
                //log error msg
                monthCalendar.Enabled = false;
                return;
            }
            monthCalendar.Enabled = false;
        }