Exemple #1
0
    public void LoadTraining()
    {
        string Profilname  = Request.QueryString["Nume"];
        int    UserId      = GetUserId(Profilname);
        bool   OtherProfil = IsOtherProfil();

        SqlDataReader reader = GetTraining(UserId);
        TableRow      row1   = TabelCursuri.Rows[0];

        TabelCursuri.Rows.Clear();
        TabelCursuri.Rows.Add(row1);

        while (reader.Read())
        {
            TableRow row = new TableRow();

            TableCell  TrainingCell = new TableCell();
            LinkButton Curs         = new LinkButton();
            Curs.Text   = (string)reader["NumeCurs"];
            Curs.Click += new EventHandler(ViewCurs);
            TrainingCell.Controls.Add(Curs);
            row.Cells.Add(TrainingCell);

            if (OtherProfil == false)
            {
                TableCell      DeleteTrainingCell = new TableCell();
                ButtonTraining Delete             = new ButtonTraining();
                Delete.Text     = "Sterge";
                Delete.Training = (string)reader["NumeCurs"];
                Delete.Click   += new EventHandler(StergeCursul);
                DeleteTrainingCell.Controls.Add(Delete);
                row.Cells.Add(DeleteTrainingCell);
            }

            TabelCursuri.Rows.Add(row);
        }
        reader.Close();
        if (ProfilProfesor())
        {
            if (!VerifyNota(GetUserId(username), UserId))
            {
                if (ApartineProfesorului())
                {
                    LoadRating();
                }
                else
                {
                    TextBox1.Visible = false;
                    Button4.Visible  = false;
                }
            }
        }
    }
Exemple #2
0
    public void StergeCursul(object sender, EventArgs e)
    {
        ButtonTraining Delete = (ButtonTraining)sender;

        try
        {
            con = DbConnection.GetSqlConnection();
            con.Open();
            SqlCommand cmd = new SqlCommand("delete from Cursuri where NumeCurs ='" + Delete.Training + "'", con);
            cmd.ExecuteNonQuery();
        }
        catch { }
        finally
        {
            con.Close();
        }
        Response.Redirect(Request.RawUrl);
    }
Exemple #3
0
    public void deleteMeFromThisCourse(object sender, EventArgs e)
    {
        ButtonTraining Delete = (ButtonTraining)sender;

        string[] courseAndUserIds = Delete.Training.Split('*');

        SqlConnection conn = DbConnection.GetSqlConnection();

        conn.Open();
        SqlCommand c = new SqlCommand("DELETE FROM Participanti WHERE IdCurs=@idCurs AND IdUser=@idUser", conn);

        c.Parameters.Add(new SqlParameter("@idCurs", TypeCode.Int32));
        c.Parameters["@idCurs"].Value = Int32.Parse(courseAndUserIds[0]);
        c.Parameters.Add(new SqlParameter("@idUser", TypeCode.Int32));
        c.Parameters["@idUser"].Value = Int32.Parse(courseAndUserIds[1]);
        c.ExecuteReader();

        conn.Close();

        Response.Redirect(Request.RawUrl);
    }
Exemple #4
0
    public void goToDeletePage(object sender, EventArgs e)
    {
        ButtonTraining Delete = (ButtonTraining)sender;

        Response.Redirect(Delete.Training);
    }
Exemple #5
0
    public void LoadPeopleEnrolledToMyCourses()
    {
        string     Profilname         = Request["Nume"];
        int        UserId             = GetUserId(Profilname);
        bool       isTeacher          = esteProfesor(Profilname);
        bool       OtherProfil        = IsOtherProfil();
        List <int> teacherCoursesList = new List <int>();

        SqlCommand    c;
        SqlDataReader r, s;
        string        numeCurs = null;

        if (OtherProfil == false && isTeacher == true)
        {
            c = new SqlCommand("SELECT * FROM Cursuri WHERE Profesor=@IdProfesor", con);
            c.Parameters.Add(new SqlParameter("@IdProfesor", TypeCode.Int32));
            c.Parameters["@IdProfesor"].Value = UserId;
            r = c.ExecuteReader();

            while (r.Read())
            {
                teacherCoursesList.Add(Int32.Parse(r["Id"].ToString()));
            }
            int[] teacherCoursesArray = teacherCoursesList.ToArray();

            c = new SqlCommand("SELECT * FROM Participanti WHERE IdCurs IN (" + string.Join(",", teacherCoursesArray) + ")", con);
            r = c.ExecuteReader();

            TableHeaderRow headerRow = new TableHeaderRow();
            headerRow.BackColor = System.Drawing.ColorTranslator.FromHtml("Aqua");

            TableCell CourseNameCell = new TableCell();
            CourseNameCell.Text = "Nume curs";
            headerRow.Cells.Add(CourseNameCell);

            TableCell UserNameCell = new TableCell();
            UserNameCell.Text = "Nume user";
            headerRow.Cells.Add(UserNameCell);

            TableCell ActionCell = new TableCell();
            ActionCell.Text = "Actiuni";
            headerRow.Cells.Add(ActionCell);

            oameniInscrisiLaCursurileMele.Rows.Add(headerRow);

            if (r.HasRows)
            {
                while (r.Read())
                {
                    TableRow row = new TableRow();

                    TableCell  TrainingCell = new TableCell();
                    LinkButton Curs         = new LinkButton();
                    Curs.Text   = getCourseNameById(r["IdCurs"].ToString());
                    Curs.Click += new EventHandler(ViewCurs);
                    TrainingCell.Controls.Add(Curs);
                    row.Cells.Add(TrainingCell);

                    TableCell UserCell = new TableCell();
                    UserCell.Text = getUsernameById(r["IdUser"].ToString());
                    row.Cells.Add(UserCell);

                    TableCell      DeleteCell = new TableCell();
                    ButtonTraining Delete     = new ButtonTraining();
                    if (r["Status"].ToString() == "ACTIVE")
                    {
                        Delete.Text = "Sterge";
                    }
                    else if (r["Status"].ToString() == "PENDING")
                    {
                        Delete.Text = "Anuleaza cererea primita de la utilizator";
                    }
                    Delete.Training = "/WebForms/DeclineCourseRegistrationPage.aspx?idDoritor=" + r["IdUser"].ToString() + "&idCurs=" + r["idCurs"];
                    Delete.Click   += new EventHandler(goToDeletePage);
                    DeleteCell.Controls.Add(Delete);
                    row.Cells.Add(DeleteCell);

                    oameniInscrisiLaCursurileMele.Rows.Add(row);
                }
            }
            else
            {
                TableRow row = new TableRow();

                TableCell notRegisteredToAnyCourse = new TableCell();
                notRegisteredToAnyCourse.Text = "Nu aveti nici o persoana inregistrata la vreun curs!";
                row.Cells.Add(notRegisteredToAnyCourse);

                oameniInscrisiLaCursurileMele.Rows.Add(row);
            }
        }
    }
Exemple #6
0
    public void LoadCursuriLaCareSuntInscris()
    {
        string Profilname  = Request["Nume"];
        int    UserId      = GetUserId(Profilname);
        bool   OtherProfil = IsOtherProfil();

        SqlCommand    c;
        SqlDataReader r;
        string        numeCurs = null;

        if (OtherProfil == false)
        {
            c = new SqlCommand("SELECT * FROM Participanti WHERE IdUser=@IdUser AND Status IN ('ACTIVE', 'PENDING')", con);
            c.Parameters.Add(new SqlParameter("@idUser", TypeCode.Int32));
            c.Parameters["@idUser"].Value = UserId;
            r = c.ExecuteReader();

            if (r.HasRows)
            {
                while (r.Read())
                {
                    numeCurs = getCourseNameById(r["idCurs"].ToString());

                    TableRow row = new TableRow();

                    TableCell  TrainingCell = new TableCell();
                    LinkButton Curs         = new LinkButton();
                    Curs.Text   = numeCurs;
                    Curs.Click += new EventHandler(ViewCurs);
                    TrainingCell.Controls.Add(Curs);
                    row.Cells.Add(TrainingCell);

                    TableCell      DeleteTrainingCell = new TableCell();
                    ButtonTraining Delete             = new ButtonTraining();
                    if (r["Status"].ToString() == "ACTIVE")
                    {
                        Delete.Text = "Sterge-ma de la acest curs";
                    }
                    else
                    {
                        Delete.Text = "Cerere trimisa. Anuleaza cererea";
                    }
                    Delete.Training = r["IdCurs"] + "*" + UserId.ToString();
                    Delete.Click   += new EventHandler(deleteMeFromThisCourse);
                    DeleteTrainingCell.Controls.Add(Delete);
                    row.Cells.Add(DeleteTrainingCell);

                    TabelCursuriLaCareSuntInscris.Rows.Add(row);
                }
            }
            else
            {
                TableRow row = new TableRow();

                TableCell notRegisteredToAnyCourse = new TableCell();
                notRegisteredToAnyCourse.Text = "Nu sunteti inregistrat la nici un curs!";
                row.Cells.Add(notRegisteredToAnyCourse);

                TabelCursuriLaCareSuntInscris.Rows.Add(row);
            }
        }
    }