Ejemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            this.Master.name.Text = Session["User"].ToString();
        }
        catch (Exception ex)
        {
            Response.Redirect("index.aspx");
        }
        int sid = Convert.ToInt32(Session["Feedback_Key"]);

//        DataSet ds = cd.getOfferedCourse(sid);

        ComposeDAL sdal = new ComposeDAL();



        ListItemCollection lic = new ListItemCollection();
        int       id           = Convert.ToInt32(Session["Feedback_Key"]);
        int       count        = sdal.getMultiple(id);
        DataTable dt2          = new DataTable();

        dt2.Columns.Add(new DataColumn("Course Id", typeof(int)));
        dt2.Columns.Add(new DataColumn("Course", typeof(string)));
        dt2.Columns.Add(new DataColumn("Instructor Name", typeof(string)));
        if (count > 0)
        {
            for (int i = 1; i < 1000; i++)
            {
                DataSet   ds = cd.getOfferedCourse(id, i);
                DataTable dt = ds.Tables[0];
                try
                {
                    DataRow dr = dt.Rows[0];
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        DataRow dr3 = dt2.NewRow();
                        dr3["Course id"]       = Convert.ToInt32(dr["Course id"]);
                        dr3["Course"]          = dr["Course"].ToString();
                        dr3["Instructor Name"] = dr["Instructor Name"].ToString();
                        dt2.Rows.Add(dr3);
                    }
                }
                catch (Exception ex)
                {
                    continue;
                }
            }
        }


        gvCourse.DataSource = dt2;
        gvCourse.DataBind();
    }
Ejemplo n.º 2
0
    protected void ddPerson_SelectedIndexChanged(object sender, EventArgs e)
    {
        ComposeDAL sdal = new ComposeDAL();

        if (ddPerson.SelectedValue == "-1")
        {
            ddReciever.Items.Clear();
        }

        else if (ddPerson.SelectedValue == "-2")
        {
            ListItemCollection lic = new ListItemCollection();
            int id    = Convert.ToInt32(Session["Feedback_Key"]);
            int count = sdal.getMultiple(id);
            if (count > 1)
            {
                int j = 0;
                int k = -1;
                for (int i = 1; i < 1000; i++)
                {
                    DataSet   ds = sdal.Check(id, i);
                    DataTable dt = ds.Tables[0];
                    try
                    {
                        DataRow dr = dt.Rows[0];
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            int       course_id = Convert.ToInt32(dr["course_id"]);
                            DataSet   ds2       = sdal.GetInstructorName(course_id);
                            DataTable dt2       = ds2.Tables[0];
                            DataRow   dr2       = dt2.Rows[0];
                            string    name      = dr2["Instructor Name"].ToString();
                            string    temp      = k.ToString();
                            lic.Insert(j, new ListItem(name, temp));
                            j++;
                            k--;
                        }
                    }
                    catch (Exception ex)
                    {
                        continue;
                    }
                }
                ddReciever.DataSource     = lic;
                ddReciever.DataTextField  = "Text";
                ddReciever.DataValueField = "Text";
                ddReciever.DataBind();
            }
            else
            {
                ddReciever.DataSource     = sdal.GetInstructorName();
                ddReciever.DataTextField  = "Instructor Name";
                ddReciever.DataValueField = "Instructor Name";
                ddReciever.DataBind();
            }
        }
        else if (ddPerson.SelectedValue == "-3")
        {
            ddReciever.DataSource = sdal.GetStudentName();

            ddReciever.DataTextField  = "Student Name";
            ddReciever.DataValueField = "Student Name";
            ddReciever.DataBind();
        }
        else
        {
            //label error here
        }
    }