Exemple #1
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            DepartmentCourses nd = new DepartmentCourses(txtIdCourse.Text);

            if (nd.CheckCourseNull())
            {
                Lecture l = new Lecture(Session["ID_Lecture"].ToString());
                if (l.checkIfLectureExsist())
                {
                    LectureOfCourse lec = new LectureOfCourse(txtIdCourse.Text, Session["ID_Lecture"].ToString());
                    if (lec.insertCourseForLecture())
                    {
                        lblMsn.Visible = true;
                        lblMsn.Text    = "Has Been Added";
                        DepartmentCourses dd = new DepartmentCourses(Session["ID_Lecture"].ToString(), Session["Lecture"].ToString(), txtIdCourse.Text, Session["DepartmentLecture"].ToString());
                        //dd.UpdateRegisteringLecture();
                        dd.updateLectureName();
                        dd.UdpateLectureId();
                    }
                    else
                    {
                        lblMsn.Visible = true;
                        lblMsn.Text    = "Already Exsist!";
                    }
                }
                else
                {
                    lblMsn.Visible = true;
                    lblMsn.Text    = "Lecture is not exsist";
                }
            }
            else
            {
                lblMsn.Visible = true;
                lblMsn.Text    = "the course is unavailable ";
            }

            string    sql = "select * from DepartmentCourses where Department='" + Session["DepartmentLecture"].ToString() + "' and Lecture='null' and LectureName='null'";
            DataTable d   = DBFunctions.SelectFromTable(sql);

            GridViewlist.DataSource = d;
            DataBind();
        }
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            DataTable dt1 = null;
            string    sql = "select * from DepartmentCourses where Department='" + Session["DepartmentLecture"] + "'and Lecture='null' and LectureName='null'";
            DataTable dt  = DBFunctions.SelectFromTable(sql);

            GridViewRegistering.DataSource = dt;



            if (((CheckBox)GridViewRegistering.Rows[0].FindControl("CheckBox2")).Checked == true)
            {
                string          s    = dt.Rows[0]["IdCourse"].ToString();
                string          sql1 = "select * from DepartmentCourses where IdCourse='" + s + "'";
                LectureOfCourse l    = new LectureOfCourse(s, Session["ID_Lecture"].ToString());
                if (l.insertCourseForLecture())
                {
                    DepartmentCourses d = new DepartmentCourses(Session["ID_Lecture"].ToString(), Session["Lecture"].ToString(), s, Session["DepartmentLecture"].ToString());
                    d.UpdateRegisteringLecture();
                    lblMsn.Visible = true;
                    lblMsn.Text    = "Has Been Added";
                }
                else
                {
                    lblMsn.Visible = true;
                    lblMsn.Text    = "Error!";
                }
                dt1 = DBFunctions.SelectFromTable(sql1);
            }

            for (int i = 1; i < dt.Rows.Count; i++)
            {
                if (((CheckBox)GridViewRegistering.Rows[i].FindControl("CheckBox2")).Checked == true)
                {
                    string s = dt.Rows[i]["IdCourse"].ToString();
                    // string sql1 = "select * from DeaprtmentCourses where IdCourse='" + s + "'";
                    LectureOfCourse l = new LectureOfCourse(s, Session["ID_Lecture"].ToString());
                    if (l.insertCourseForLecture())
                    {
                        DepartmentCourses d = new DepartmentCourses(Session["ID_Lecture"].ToString(), Session["Lecture"].ToString(), s, Session["DepartmentLecture"].ToString());
                        d.UpdateRegisteringLecture();
                        lblMsn.Visible = true;
                        lblMsn.Text    = "Has Been Added";
                    }
                    else
                    {
                        lblMsn.Visible = true;
                        lblMsn.Text    = "Error!";
                    }
                    string    sql2 = "select * from [DepartmentCourses] where IdCourse= '" + s + "'";
                    DataTable dt2  = DBFunctions.SelectFromTable(sql2);
                    if (dt1 == null)
                    {
                        dt1 = dt2;
                    }
                    else
                    {
                        dt1.Merge(dt2);
                    }
                }
            }
            GridViewPrint.DataSource = dt1;
            DataBind();
        }