Imports System
Imports System.Data
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls

Partial Class CreateArchive
    Inherits System.Web.UI.Page
    Protected Sub grdFill()
        Dim db As New FirstClass()
        Dim dt As New DataTable()

        dt = db.dbOut("SELECT TOP 100 PERCENT NewsID, NewsTitle, DateOfAdding, ArchivedBit FROM tblNews WHERE (ArchivedBit = 0) ORDER BY NewsID")

        GridView1.DataSource = dt

        GridView1.DataBind()
    End Sub

    Protected Sub GridView1_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles GridView1.PageIndexChanging
        GridView1.PageIndex = e.NewPageIndex
        grdFill()
    End Sub

    Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged
        Dim db As New FirstClass()
        Dim nwsEdtKey As String = GridView1.SelectedValue.ToString()

        db.cmd.Parameters.Add("@NewsID", SqlDbType.Int).Value = Integer.Parse(nwsEdtKey)
        db.cmd.Parameters.Add("@ArchivedBit", SqlDbType.Bit).Value = 1
        db.cmd.Parameters.Add("@ArchivedDate", SqlDbType.NVarChar).Value = db.dtShamsi()

        db.exeCommand("sp_tblNews_Update4")
        Response.Redirect("CreateArchive.aspx?")

        'grdFill()
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Session("UserTypeID") Is Nothing Then
            Response.Redirect("Default.aspx?ID=NotHavePermission&NextID=" & DateTime.Now.Ticks.ToString())
        Else
            If Integer.Parse(Session("UserTypeID").ToString()) = 3 OrElse Integer.Parse(Session("UserTypeID").ToString()) = 2 Then
                Response.Redirect("Default.aspx?ID=NotHavePermission&NextID=" & DateTime.Now.Ticks.ToString())
            Else
                If Not IsPostBack Then
                    grdFill()
                End If
            End If
        End If
    End Sub
End Class
