using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class rl_admins_pg_Presence : System.Web.UI.Page
{
    //*****************************

    //*****************************
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (!Page.IsPostBack)
            {
                C_myClass.MenueItemsCreate(User, panelMenues);
                Label lblTitle = (Label)this.Master.FindControl("lblTitle");
                lblTitle.Text = "حضور و غیاب";
                SqlDataSource1.SelectCommand = "SELECT t_Classes.classId, t_Classes.classTitle, t_Courses.courseName, t_Teachers.fullName FROM t_Classes INNER JOIN t_Teachers ON t_Classes.teacherId = t_Teachers.teacherId INNER JOIN t_Courses ON t_Classes.courseId = t_Courses.courseId WHERE (t_Classes.status = N'جاری') AND (t_Classes.teacherId = " + Session["iden"].ToString() + ")";
                GridView1.DataBind();
            }
        }
        catch
        {
        }
        finally
        {
        }
    }
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        try
        {
            if (e.CommandName == "PresencePress")
            {
                int classId = Int32.Parse(e.CommandArgument.ToString());
                SqlDataSource2.SelectCommand = "SELECT sessionId, classId, sessionDate, sessionTime, classNumber FROM t_ClassSessions WHERE (classId = " + classId + ")";
                GridSessions.DataBind();
                mpeSessions.Show();
            }
        }
        catch
        {
        }
    }
    protected void btnStudentsCancel_Click(object sender, EventArgs e)
    {
        try
        {
            mpeSessions.Hide();
        }
        catch
        {
        }
    }
    protected void GridSessions_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        try
        {
            if (e.CommandName == "SelectPress")
            {
                int sessionId = Int32.Parse(e.CommandArgument.ToString());
                Response.Redirect("pg_PresenceClassSet.aspx?sessionId=" + sessionId + "&returnUrl=pg_Presence.aspx");
            }
        }
        catch
        {
        }
    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        try
        {
            GridView1.PageIndex = e.NewPageIndex;
            SqlDataSource1.SelectCommand = "SELECT t_Classes.classId, t_Classes.classTitle, t_Courses.courseName, t_Teachers.fullName FROM t_Classes INNER JOIN t_Teachers ON t_Classes.teacherId = t_Teachers.teacherId INNER JOIN t_Courses ON t_Classes.courseId = t_Courses.courseId WHERE (t_Classes.status = N'جاری') AND (t_Classes.teacherId = " + Session["iden"].ToString() + ")";
            GridView1.DataBind();
        }
        catch
        {
        }
    }
}
