Imports System.Data
Imports AppCommon

Partial Class Calendar
    Inherits System.Web.UI.Page

#Region "********************** メンバ変数 **********************"

    Private 項目 As DataView

#End Region

#Region "******************** ページイベント ********************"

    Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        ''ログインチェック
        'If IsNothing(Session("UserCD")) Or IsNothing(Session("UserNO")) Then
        '    Response.Redirect("~/login.aspx")
        '    Return
        'End If

        '---------------------------------------------------------------
        'HTMLタグを追加
        '---------------------------------------------------------------
        Dim ctl As Control = Page.FindControl("page_header")
        'ファビコン
        SetTagFavicon(ctl)

        Dim 年 As String
        Dim 月 As String
        年 = DateTime.Now.Year
        月 = DateTime.Now.Month
        If Me.年.Text = "" Then
            Me.年.Text = 年
        End If
        If Me.月.Text = "" Then
            Me.月.Text = 月
        End If
        Session("年") = Me.年.Text
        Session("月") = Me.月.Text

        Me.年月表示.Text = Session("年") & "年" & Session("月") & "月"

        ' SqlDataSource からすべての担当地域を DataView にロードします。
        項目 = CType(sql_カレンダ項目.Select(DataSourceSelectArguments.Empty), DataView)
    End Sub

#End Region

#Region "***************** コントロールイベント *****************"

    Sub SPカレンダ_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles GridView1.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow Then
            Dim GV2 As GridView = CType(e.Row.FindControl("GridView2"), GridView)
            GV2.Height = "130"
            Dim t2 As String
            Dim STR2() As String = {"企業CD", "拠点CD", "求人年度", "枝NO"}
            Dim BT2 As HyperLinkField
            BT2 = New HyperLinkField
            BT2.DataNavigateUrlFormatString = "JobInfo.aspx?CD={0}&CD2={1}&Year={2}&No={3}"
            BT2.DataNavigateUrlFields = STR2
            BT2.HeaderText = CType(e.Row.DataItem, DataRowView)("日日").ToString()
            BT2.DataTextField = "名前"
            BT2.HeaderStyle.Height = "20"
            BT2.HeaderStyle.BorderWidth = "0"
            BT2.ItemStyle.Width = "150"
            BT2.ItemStyle.BorderWidth = "0"
            BT2.HeaderStyle.ForeColor = System.Drawing.Color.FromArgb(255, 0, 0)
            GV2.Columns.Add(BT2)
            t2 = CType(e.Row.DataItem, DataRowView)("日年").ToString() & "-" & CType(e.Row.DataItem, DataRowView)("日月").ToString() & "-" & CType(e.Row.DataItem, DataRowView)("日日").ToString()
            項目.RowFilter = "実施日 = " & "#" & Date.Parse(t2) & "#"
            GV2.DataSource = 項目
            GV2.DataBind()
            Dim GV3 As GridView = CType(e.Row.FindControl("GridView3"), GridView)
            GV3.Height = "130"
            Dim t3 As String
            Dim BT3 As HyperLinkField
            Dim STR3() As String = {"企業CD", "拠点CD", "求人年度", "枝NO"}
            BT3 = New HyperLinkField
            BT3.DataNavigateUrlFormatString = "JobInfo.aspx?CD={0}&CD2={1}&Year={2}&No={3}"
            BT3.DataNavigateUrlFields = STR3
            BT3.HeaderText = CType(e.Row.DataItem, DataRowView)("月日").ToString()
            BT3.DataTextField = "名前"
            BT3.HeaderStyle.Height = "20"
            BT3.HeaderStyle.BorderWidth = "0"
            BT3.ItemStyle.Width = "150"
            BT3.ItemStyle.BorderWidth = "0"
            GV3.Columns.Add(BT3)
            t3 = CType(e.Row.DataItem, DataRowView)("月年").ToString() & "-" & CType(e.Row.DataItem, DataRowView)("月月").ToString() & "-" & CType(e.Row.DataItem, DataRowView)("月日").ToString()
            項目.RowFilter = "実施日 = " & "#" & Date.Parse(t3) & "#"
            GV3.DataSource = 項目
            GV3.DataBind()
            Dim GV4 As GridView = CType(e.Row.FindControl("GridView4"), GridView)
            GV4.Height = "130"
            Dim t4 As String
            Dim BT4 As HyperLinkField
            Dim STR4() As String = {"企業CD", "拠点CD", "求人年度", "枝NO"}
            BT4 = New HyperLinkField
            BT4.DataNavigateUrlFormatString = "JobInfo.aspx?CD={0}&CD2={1}&Year={2}&No={3}"
            BT4.DataNavigateUrlFields = STR4
            BT4.HeaderText = CType(e.Row.DataItem, DataRowView)("火日").ToString()
            BT4.DataTextField = "名前"
            BT4.HeaderStyle.Height = "20"
            BT4.HeaderStyle.BorderWidth = "0"
            BT4.ItemStyle.Width = "150"
            BT4.ItemStyle.BorderWidth = "0"
            GV4.Columns.Add(BT4)
            t4 = CType(e.Row.DataItem, DataRowView)("火年").ToString() & "-" & CType(e.Row.DataItem, DataRowView)("火月").ToString() & "-" & CType(e.Row.DataItem, DataRowView)("火日").ToString()
            項目.RowFilter = "実施日 = " & "#" & Date.Parse(t4) & "#"
            GV4.DataSource = 項目
            GV4.DataBind()
            Dim GV5 As GridView = CType(e.Row.FindControl("GridView5"), GridView)
            GV5.Height = "130"
            Dim t5 As String
            Dim BT5 As HyperLinkField
            Dim STR5() As String = {"企業CD", "拠点CD", "求人年度", "枝NO"}
            BT5 = New HyperLinkField
            BT5.DataNavigateUrlFormatString = "JobInfo.aspx?CD={0}&CD2={1}&Year={2}&No={3}"
            BT5.DataNavigateUrlFields = STR5
            BT5.HeaderText = CType(e.Row.DataItem, DataRowView)("水日").ToString()
            BT5.DataTextField = "名前"
            BT5.HeaderStyle.Height = "20"
            BT5.HeaderStyle.BorderWidth = "0"
            BT5.ItemStyle.Width = "150"
            BT5.ItemStyle.BorderWidth = "0"
            GV5.Columns.Add(BT5)
            t5 = CType(e.Row.DataItem, DataRowView)("水年").ToString() & "-" & CType(e.Row.DataItem, DataRowView)("水月").ToString() & "-" & CType(e.Row.DataItem, DataRowView)("水日").ToString()
            項目.RowFilter = "実施日 = " & "#" & Date.Parse(t5) & "#"
            GV5.DataSource = 項目
            GV5.DataBind()
            Dim GV6 As GridView = CType(e.Row.FindControl("GridView6"), GridView)
            GV6.Height = "130"
            Dim t6 As String
            Dim BT6 As HyperLinkField
            Dim STR6() As String = {"企業CD", "拠点CD", "求人年度", "枝NO"}
            BT6 = New HyperLinkField
            BT6.DataNavigateUrlFormatString = "JobInfo.aspx?CD={0}&CD2={1}&Year={2}&No={3}"
            BT6.DataNavigateUrlFields = STR6
            BT6.HeaderText = CType(e.Row.DataItem, DataRowView)("木日").ToString()
            BT6.DataTextField = "名前"
            BT6.HeaderStyle.Height = "20"
            BT6.HeaderStyle.BorderWidth = "0"
            BT6.ItemStyle.Width = "150"
            BT6.ItemStyle.BorderWidth = "0"
            GV6.Columns.Add(BT6)
            t6 = CType(e.Row.DataItem, DataRowView)("木年").ToString() & "-" & CType(e.Row.DataItem, DataRowView)("木月").ToString() & "-" & CType(e.Row.DataItem, DataRowView)("木日").ToString()
            項目.RowFilter = "実施日 = " & "#" & Date.Parse(t6) & "#"
            GV6.DataSource = 項目
            GV6.DataBind()
            Dim GV7 As GridView = CType(e.Row.FindControl("GridView7"), GridView)
            GV7.Height = "130"
            Dim t7 As String
            Dim BT7 As HyperLinkField
            Dim STR7() As String = {"企業CD", "拠点CD", "求人年度", "枝NO"}
            BT7 = New HyperLinkField
            BT7.DataNavigateUrlFormatString = "JobInfo.aspx?CD={0}&CD2={1}&Year={2}&No={3}"
            BT7.DataNavigateUrlFields = STR7
            BT7.HeaderText = CType(e.Row.DataItem, DataRowView)("金日").ToString()
            BT7.DataTextField = "名前"
            BT7.HeaderStyle.Height = "20"
            BT7.HeaderStyle.BorderWidth = "0"
            BT7.ItemStyle.Width = "150"
            BT7.ItemStyle.BorderWidth = "0"
            GV7.Columns.Add(BT7)
            t7 = CType(e.Row.DataItem, DataRowView)("金年").ToString() & "-" & CType(e.Row.DataItem, DataRowView)("金月").ToString() & "-" & CType(e.Row.DataItem, DataRowView)("金日").ToString()
            項目.RowFilter = "実施日 = " & "#" & Date.Parse(t7) & "#"
            GV7.DataSource = 項目
            GV7.DataBind()
            Dim GV8 As GridView = CType(e.Row.FindControl("GridView8"), GridView)
            GV8.Height = "130"
            Dim t8 As String
            Dim BT8 As HyperLinkField
            Dim STR8() As String = {"企業CD", "拠点CD", "求人年度", "枝NO"}
            BT8 = New HyperLinkField
            BT8.DataNavigateUrlFormatString = "JobInfo.aspx?CD={0}&CD2={1}&Year={2}&No={3}"
            BT8.DataNavigateUrlFields = STR8
            BT8.HeaderText = CType(e.Row.DataItem, DataRowView)("土日").ToString()
            BT8.DataTextField = "名前"
            BT8.HeaderStyle.Height = "20"
            BT8.HeaderStyle.BorderWidth = "0"
            BT8.ItemStyle.Width = "150"
            BT8.ItemStyle.BorderWidth = "0"
            BT8.HeaderStyle.ForeColor = System.Drawing.Color.FromArgb(0, 0, 255)
            GV8.Columns.Add(BT8)
            t8 = CType(e.Row.DataItem, DataRowView)("土年").ToString() & "-" & CType(e.Row.DataItem, DataRowView)("土月").ToString() & "-" & CType(e.Row.DataItem, DataRowView)("土日").ToString()
            項目.RowFilter = "実施日 = " & "#" & Date.Parse(t8) & "#"
            GV8.DataSource = 項目
            GV8.DataBind()
        End If
    End Sub

    Protected Sub last_month_Click(ByVal sender As Object, ByVal e As EventArgs) Handles 前月.Click
        If Me.月.Text = 1 Then
            Me.月.Text = 12
            Me.年.Text = (Convert.ToInt32(Me.年.Text) - 1).ToString
        Else
            Me.月.Text = (Convert.ToInt32(Me.月.Text) - 1).ToString
        End If
        Session("年") = Me.年.Text
        Session("月") = Me.月.Text
        項目 = CType(sql_カレンダ項目.Select(DataSourceSelectArguments.Empty), DataView)
        Me.年月表示.Text = Session("年") & "年" & Session("月") & "月"
    End Sub

    Protected Sub current_month_Click(ByVal sender As Object, ByVal e As EventArgs) Handles 今月.Click
        Me.年.Text = (DateTime.Now().Year).ToString
        Me.月.Text = (DateTime.Now().Month).ToString
        Session("年") = Me.年.Text
        Session("月") = Me.月.Text
        項目 = CType(sql_カレンダ項目.Select(DataSourceSelectArguments.Empty), DataView)
        Me.年月表示.Text = Session("年") & "年" & Session("月") & "月"
    End Sub

    Protected Sub next_month_Click(ByVal sender As Object, ByVal e As EventArgs) Handles 来月.Click
        If Me.月.Text = 12 Then
            Me.月.Text = 1
            Me.年.Text = (Convert.ToInt32(Me.年.Text) + 1).ToString
        Else
            Me.月.Text = (Convert.ToInt32(Me.月.Text) + 1).ToString
        End If
        Session("年") = Me.年.Text
        Session("月") = Me.月.Text
        項目 = CType(sql_カレンダ項目.Select(DataSourceSelectArguments.Empty), DataView)
        Me.年月表示.Text = Session("年") & "年" & Session("月") & "月"
    End Sub

#End Region

End Class
