Example #1
0
    /// <summary>
    /// Delete a ch_students_lessons record
    /// </summary>
    /// <param name="stu_les1">the ch_students_lessons record to delete</param>
    public static void DeleteStudentLesson(ch_students_lessons stu_les1)
    {
        string strSql = "DELETE * FROM ch_students_lessons WHERE les_id=" + stu_les1.les_Id + " AND usr_id=" + stu_les1.usr_Id;

        Connect.DoAction(strSql, "ch_students_lessons");
    }
Example #2
0
    protected void btnAddLesson_Click(object sender, EventArgs e)
    {
        if (ValidatePage())
        {
            //if teacher is checked
            bool selected = false;
            foreach (ListItem li in ckliTeachers.Items)
            {
                if (li.Selected)
                {
                    selected = true;
                }
            }

            if (selected)
            {
                int    selected_prof  = Convert.ToInt32(ddlProf.SelectedValue);
                string selected_layer = ddlLayers.SelectedItem.Text;
                string les_name       = txtLes_name.Text.Trim();

                ch_lessons newLes = new ch_lessons();
                newLes.pro_Id   = selected_prof;
                newLes.les_Name = les_name + " - " + selected_layer;

                ch_lessonsSvc.AddLesson(newLes);

                int lastLesson_id = ch_lessonsSvc.GetLastInsertId();

                //add teachers
                foreach (ListItem li in ckliTeachers.Items)
                {
                    if (li.Selected)
                    {
                        ch_teachers_lessons newTchLes = new ch_teachers_lessons();
                        newTchLes.les_Id = lastLesson_id;
                        newTchLes.usr_Id = Convert.ToInt32(li.Value);

                        ch_teachers_lessonsSvc.AddTeachersLesson(newTchLes);
                    }
                }

                //add students
                foreach (Hashtable htItem in htAllSelectedStudents.Values)
                {
                    foreach (string usr_id in htItem.Keys)
                    {
                        ch_students_lessons newStuLes = new ch_students_lessons();
                        newStuLes.les_Id = lastLesson_id;
                        newStuLes.usr_Id = Convert.ToInt32(usr_id);

                        ch_students_lessonsSvc.AddStudentLesson(newStuLes);
                    }
                }
                Response.Redirect("LessonsData.aspx");
            }
            else
            {
                lblError.Text = "לא נבחרו מורים";
            }
        }

        foreach (ListItem li in ckliTeachers.Items)
        {
            if (li.Selected)
            {
                Panel pnlName = new Panel();
                pnlName.ID       = "pnlName_" + li.Value;
                pnlName.CssClass = "pnlName";
                pnlTeachers.Controls.Add(pnlName);

                Label lblName = new Label();
                lblName.Text = li.Text;
                pnlName.Controls.Add(lblName);
            }
        }

        //show
        foreach (Hashtable htItem in htAllSelectedStudents.Values)
        {
            foreach (string student in htItem.Values)
            {
                Panel pnlName = new Panel();
                pnlName.CssClass = "pnlName";
                pnlStudents.Controls.Add(pnlName);

                Label lblName = new Label();
                lblName.Text = student;
                pnlName.Controls.Add(lblName);
            }
        }
        update_pnlStudents.Update();
    }
Example #3
0
    /// <summary>
    /// Add a new ch_students_lessons record to the database
    /// </summary>
    /// <param name="stu_les1">a new ch_students_lessons you want to add</param>
    public static void AddStudentLesson(ch_students_lessons stu_les1)
    {
        string strSql = "INSERT INTO ch_students_lessons(les_id, usr_id) VALUES(" + stu_les1.les_Id + ", " + stu_les1.usr_Id + ")";

        Connect.DoAction(strSql, "ch_students_lessons");
    }
Example #4
0
    protected void btnUpdateLesson_Click(object sender, EventArgs e)
    {
        if (ValidatePage())
        {
            //if teacher is checked
            bool selected = false;
            foreach (ListItem li in ckliTeachers.Items)
            {
                if (li.Selected)
                {
                    selected = true;
                }
            }

            if (selected)
            {
                int    selected_prof  = Convert.ToInt32(ddlProf.SelectedValue);
                string selected_layer = ddlLayers.SelectedItem.Text;
                string les_name       = txtLes_name.Text.Trim();

                ch_lessons newLes = new ch_lessons();
                newLes.pro_Id   = selected_prof;
                newLes.les_Name = les_name + " - " + selected_layer;

                ch_lessonsSvc.UpdateLesson(Convert.ToInt32(Request.QueryString["les_id"].ToString()), newLes);

                //update teachers
                ch_teachers_lessonsSvc.DeleteAllTeachersLesson(Convert.ToInt32(Request.QueryString["les_id"].ToString()));
                foreach (ListItem li in ckliTeachers.Items)
                {
                    if (li.Selected)
                    {
                        ch_teachers_lessons newTchLes = new ch_teachers_lessons();
                        newTchLes.les_Id = Convert.ToInt32(Request.QueryString["les_id"].ToString());
                        newTchLes.usr_Id = Convert.ToInt32(li.Value);

                        ch_teachers_lessonsSvc.AddTeachersLesson(newTchLes);
                    }
                }

                //update students
                ch_students_lessonsSvc.DeleteAllStudentsLesson(Convert.ToInt32(Request.QueryString["les_id"].ToString()));

                foreach (Hashtable htItem in htAllSelectedStudents.Values)
                {
                    foreach (string usr_id in htItem.Keys)
                    {
                        ch_students_lessons newStuLes = new ch_students_lessons();
                        newStuLes.les_Id = Convert.ToInt32(Request.QueryString["les_id"].ToString());
                        newStuLes.usr_Id = Convert.ToInt32(usr_id);

                        ch_students_lessonsSvc.AddStudentLesson(newStuLes);
                    }
                }
                Response.Redirect("LessonsData.aspx");
            }
        }
        //----reenter Choices----
        int les_id = Convert.ToInt32(Request.QueryString["les_id"].ToString());

        DataRow drLesson = ch_lessonsSvc.GetLesson(les_id);

        ddlProf.SelectedValue       = drLesson["pro_id"].ToString();                                                                                                                                                                  //מתמטיקה
        ddlLayers.SelectedItem.Text = drLesson["les_name"].ToString().Substring(drLesson["les_name"].ToString().LastIndexOf('-') + 2, drLesson["les_name"].ToString().Length - drLesson["les_name"].ToString().LastIndexOf('-') - 2); // יב
        txtLes_name.Text            = drLesson["les_name"].ToString().Substring(0, drLesson["les_name"].ToString().LastIndexOf('-') - 1);                                                                                             // שם השיעור

        DataSet teachers = ch_teachers_lessonsSvc.GetTeachersLesson(les_id);

        lblEmpty_tch.Visible = (teachers.Tables[0].Rows.Count > 0) ? false : true;
        //show
        foreach (DataRow dr in teachers.Tables[0].Rows)
        {
            Panel pnlName = new Panel();
            pnlName.ID       = "pnlName_" + dr["usr_id"].ToString();
            pnlName.CssClass = "pnlName";
            pnlTeachers.Controls.Add(pnlName);

            Label lblName = new Label();
            lblName.Text = dr["usr_fullname"].ToString();
            pnlName.Controls.Add(lblName);
        }

        //checkboxes
        ckliTeachers.Items.Clear();
        DataSet dsTeachersProfessions = ch_teachers_professionsSvc.GetTeachersByPro(Convert.ToInt32(ddlProf.SelectedValue));

        for (int i = 0; i < dsTeachersProfessions.Tables[0].Rows.Count; i++)
        {
            int      usr_id = Convert.ToInt32(dsTeachersProfessions.Tables[0].Rows[i]["tch_pro.usr_id"].ToString());
            ListItem li     = new ListItem();
            li.Value = usr_id.ToString();
            li.Text  = ch_usersSvc.GetUserFullname(usr_id);

            foreach (DataRow dr in teachers.Tables[0].Rows)
            {
                if (usr_id == Convert.ToInt32(dr["usr_id"].ToString()))
                {
                    li.Selected = true;
                }
            }


            ckliTeachers.Items.Add(li);
        }

        foreach (Hashtable htItem in htAllSelectedStudents.Values)
        {
            ((Hashtable)htItem).Clear();
        }

        DataSet students = ch_students_lessonsSvc.GetStudentsLesson(les_id);

        foreach (DataRow dr in students.Tables[0].Rows)
        {
            ((Hashtable)htAllSelectedStudents[dr["rm_id"].ToString()]).Add(dr["usr_id"].ToString(), dr["usr_fullname"].ToString());
        }

        //show
        foreach (Hashtable htItem in htAllSelectedStudents.Values)
        {
            foreach (string student in htItem.Values)
            {
                Panel pnlName = new Panel();
                pnlName.CssClass = "pnlName";
                pnlStudents.Controls.Add(pnlName);

                Label lblName = new Label();
                lblName.Text = student;
                pnlName.Controls.Add(lblName);
            }
        }

        update_ckliStudentsByClass.Update();
        update_ckliTeachers.Update();
        update_pnlStudents.Update();
        update_pnlTeachers.Update();
    }