Ejemplo n.º 1
0
        protected void teacherGrid_RowDelete(object sender, GridViewDeleteEventArgs e)
        {
            Session["returnToPage"] = "4";
            Label idl = teacherGrid.Rows[e.RowIndex].FindControl("lbl_ID") as Label;
            var   id  = idl.Text;

            var user = wpe.tableUsers.FirstOrDefault(u => u.ID.Equals(id));

            wpe.tableUsers.Remove(user);
            wpe.SaveChanges();
            teacherGrid.EditIndex = -1;
            FillDataTeacher();
        }
Ejemplo n.º 2
0
        protected void Register_Click(object sender, EventArgs e)
        {
            if (!isValidEmail(inputEmail.Text))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Invalid Email Address!')", true);
            }

            // invalid email

            else
            {
                String t;
                if (radio_student.Checked)
                {
                    t = "student";
                }
                else
                {
                    t = "teacher";
                }


                using (var db = new webProjectEntities())
                {
                    var newUser = new tableUsers()
                    {
                        ID               = inputid.Text,
                        Email            = inputEmail.Text,
                        Password         = inputPassword.Text,
                        Fullname         = inputFullname.Text,
                        Algebra          = "",
                        Algorithms       = "",
                        Datamining       = "",
                        WebDev           = "",
                        Calculus         = "",
                        OperatinsSystems = "",
                        type             = t
                    };

                    try
                    {
                        db.tableUsers.Add(newUser);
                        db.SaveChanges();
                        RegisteredSuccess.Visible       = true;
                        RequiredFieldValidator.Visible  = false;
                        RequiredFieldValidator1.Visible = false;
                        RequiredFieldValidator2.Visible = false;
                        gotoLogin.Visible   = true;
                        backToLogin.Visible = false;
                    }
                    catch (Exception ex)
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ID already exists')", true);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        protected void addNewStudent(object sender, EventArgs e)
        {
            Session["returnToPage"] = "6";
            toStudentTbl.Visible    = false;
            if (newStudentEmail.Text.Length == 0 || newStudentID.Text.Length == 0 || newStudentPassword.Text.Length == 0) // mandatory fields are empty
            {
                addStudent_lbl.Visible = true;
            }

            else // form is filled OK
            {
                if (!isValidEmail(newStudentEmail.Text))
                {
                    addStudent_lbl.Visible = false;
                    toStudentTbl.Visible   = false;
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Invalid Email Address!')", true);
                }
                else
                {
                    using (var db = new webProjectEntities())
                    {
                        var newUser = new tableUsers()
                        {
                            ID               = newStudentID.Text,
                            Email            = newStudentEmail.Text,
                            Password         = newStudentPassword.Text,
                            Fullname         = newStudentFullname.Text.Length == 0 ? "" : newStudentFullname.Text,
                            Algebra          = "",
                            Algorithms       = "",
                            Datamining       = "",
                            WebDev           = "",
                            Calculus         = "",
                            OperatinsSystems = "",
                            type             = "student"
                        };

                        newStudentEmail.Text    = "";
                        newStudentID.Text       = "";
                        newStudentPassword.Text = "";
                        newStudentFullname.Text = "";

                        try
                        {
                            db.tableUsers.Add(newUser);
                            db.SaveChanges();
                        }
                        catch (Exception ex)
                        {
                            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ID already exists')", true);
                            addStudent_lbl.Visible = false;
                            toStudentTbl.Visible   = false;
                            return;
                        }
                    }
                    addStudent_lbl.ForeColor = System.Drawing.Color.Green;
                    addStudent_lbl.Text      = "New Student Added Successfully";
                    addStudent_lbl.Visible   = true;
                    toStudentTbl.Attributes.Add("style", "margin-left: 25px;");
                    toStudentTbl.Visible = true;
                }
            }
        }