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.Data.SqlClient;

public partial class rl_admins_pg_ClassSessionDefine : System.Web.UI.Page
{
    //******************************
    SqlConnection con;
    SqlCommand cmd;
    //******************************
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            C_myClass.MenueItemsCreate(User, panelMenues);
            Label lblTitle = (Label)this.Master.FindControl("lblTitle");
            lblTitle.Text = "تعریف جلسه";

        }
        catch
        {
        }
        finally
        {
        }
    }
    protected void btnBack_Click(object sender, EventArgs e)
    {
        try
        {
            int classId = Int32.Parse(Request.QueryString["classId"].ToString());
            string returnUrl = Request.QueryString["returnUrl"].ToString();
            Response.Redirect(returnUrl + "?classId=" + classId + "&returnUrl=pg_ClassSessionsEdit.aspx");
        }
        catch
        {
        }
    }
    protected void btnOk_Click(object sender, EventArgs e)
    {
        try
        {
            System.Threading.Thread.Sleep(2000);
            string weekDay = (cmbDayOfWeek.SelectedIndex > 0 ? cmbDayOfWeek.SelectedItem.ToString() : "");
            string day = (cmbDay.SelectedIndex > 0 ? cmbDay.SelectedItem.ToString() : "");
            string month = (cmbMonth.SelectedIndex > 0 ? cmbMonth.SelectedItem.ToString() : "");
            string year = (cmbYear.SelectedIndex > 0 ? cmbYear.SelectedItem.ToString() : "");
            string sessionTime = tbSessionTime.Text;
            string classNumber = tbClassNumber.Text;
            string sessionDate = weekDay + " " + day + " " + month + " " + year;
            int classId = Int32.Parse(Request.QueryString["classId"].ToString());
            //lblMessage.Text = classId.ToString() + "<br />" + sessionDate + "<br />" + sessionTime + "<br />" + classNumber + "<br />";
            string conString = RamanConnectionString.LocalConnectionString();
            con = new SqlConnection(conString);
            cmd = con.CreateCommand();
            try
            {
                con.Open();
                cmd.CommandText = "insert into t_ClassSessions (classId, sessionDate, sessionTime, classNumber) values(" +
                    classId + " , N'" +
                    sessionDate + "', N'" +
                    sessionTime + "', N'" +
                    classNumber + "')";
                cmd.ExecuteNonQuery();
                lblMessage.ForeColor = System.Drawing.Color.Green;
                lblMessage.Text = "با موفقیت ذخیره شد.";
            }
            catch
            {

            }
            finally
            {
                if (con.State != ConnectionState.Closed)
                    con.Close();
            }
        }
        catch
        {
        }
    }
}
