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;
using System.IO;

public partial class rl_students_pg_JoinedClasses : 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 = "همکلاسی ها";
                int studentId = Int32.Parse(Session["iden"].ToString());
                SqlDataSource1.SelectCommand = "SELECT t_Classes.classId, t_Classes.classTitle, t_Courses.courseName, t_Teachers.fullName, t_Teachers.teacherPhotoUrl FROM t_Classes INNER JOIN t_ClassStudents ON t_Classes.classId = t_ClassStudents.classId INNER JOIN t_Courses ON t_Classes.courseId = t_Courses.courseId INNER JOIN t_Teachers ON t_Classes.teacherId = t_Teachers.teacherId WHERE (t_ClassStudents.studentId = " + studentId + ")";
                GridView1.DataBind();
            }
            
        }
        catch
        {
        }
    }

    protected string FindTeacherImageUrl(object TeacherPhotoUrl)
    {
        string url = "~/photoes/";
        string photosFolderPath = Request.PhysicalApplicationPath + @"photoes\";
        if (File.Exists(photosFolderPath + TeacherPhotoUrl))
        {
            url += TeacherPhotoUrl;
        }
        else
        {
            url += "noPersonalPhoto.gif";
        }
        return url;
    }
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        try
        {
            if (e.CommandName == "ClassStudents")
            {
                int classId = Int32.Parse(e.CommandArgument.ToString());
                Response.Redirect("pg_ClassStudents.aspx?classId=" + classId + "&returnUrl=pg_JoinedClasses.aspx");
            }
        }
        catch
        {
        }
    }
}
