protected void btnConfirmNew_Click(object sender, EventArgs e)
        {
            UserDataClassesDataContext us = new UserDataClassesDataContext();
            Security sec = new Security();

            //user ev = us.users.FirstOrDefault(x => x.email == (txtEmail.Text));
            //ev.password = sec.EncryptString(txtNewConfirm.Text);
            ////us.users.InsertOnSubmit(ev);
            //us.SubmitChanges();



            (from f in us.users
             where f.email.Equals(txtEmail.Text)
             select f).FirstOrDefault().password = sec.EncryptString(txtNewConfirm.Text);

            us.SubmitChanges();

            //(from f in us.users
            //where f.email.Equals(txtEmail.Text)
            //select f)
            //       .FirstOrDefault().password = sec.EncryptString(txtNewConfirm.Text);

            //us.SubmitChanges();


            lblChanged.Visible = true;
        }
Exemplo n.º 2
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            Security sec = new Security();
            //string enc = sec.EncryptString(txtpass.Text);
            UserDataClassesDataContext us = new UserDataClassesDataContext();

            if (us.users.Any(x => x.username == txtuser.Text))// && us.users.Any(xy => xy.password == enc)))
            {
                user ev = us.users.FirstOrDefault(x => x.username == (txtuser.Text));
                if (sec.DecryptString(ev.password) == txtpass.Text)
                {
                    currentUser = txtuser.Text;
                    Response.Redirect("UserPage.aspx");
                }
                else if (sec.DecryptString(ev.password) != txtpass.Text)
                {
                    Label1.Visible = true;
                    Label1.Text    = "Invalid Username or Password";
                }
            }
            else
            {
                Label1.Visible = true;
                Label1.Text    = "Invalid Username or Password";
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            UserDataClassesDataContext us = new UserDataClassesDataContext();
            user eo = (from f in us.users where f.username == Login.currentUser select f).SingleOrDefault();

            /*if (eo.role == "Admin")
             * {
             *  btnAdmins.Visible = true;
             * }*/
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            UserDataClassesDataContext us = new UserDataClassesDataContext();

            //Gather Correct Answers
            int count = 0;

            for (int i = 1; i < 21; i++)
            {
                var correctanswer = us.quizanswers.Where((a => a.quizid == quizid && a.qcount == i)).Select(a => a.correctanswer).FirstOrDefault();
                if (correctanswer == true)
                {
                    var anum = us.quizanswers.Where((a => a.quizid == quizid && a.qcount == i)).Select(a => a.anum).FirstOrDefault();
                    correctanswers[count] = anum;
                    count++;
                }
            }

            //    //Gather user answers
            //    useranswers[0] = RadioButtonList1.SelectedIndex;
            //    useranswers[1] = RadioButtonList2.SelectedIndex;
            //    useranswers[2] = RadioButtonList3.SelectedIndex;
            //    useranswers[3] = RadioButtonList4.SelectedIndex;
            //    useranswers[4] = RadioButtonList5.SelectedIndex;

            //    //Compare Answers
            //    for (int i = 0; i < 5; i++)
            //    {
            //        if (useranswers[i] == correctanswers[i])
            //        {
            //            score++;
            //        }
            //    }

            //    //Display Score
            //    scoreLabel.Visible = true;
            //    scoreLabel.Text = score + "/" + total;
            //    Button1.Enabled = false;
            //}

            //private void EnableViewState(bool v)
            //{

            //}

            //protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
            //{
            //    int index = 0;
            //    index = RadioButtonList1.SelectedIndex;
            //    RadioButtonList1.SelectedIndex = index;
            //}

            //protected void RadioButtonList5_SelectedIndexChanged(object sender, EventArgs e)
            //{
        }
        private void Search(string searchText)
        {
            UserDataClassesDataContext us = new UserDataClassesDataContext();
            var search = (from c in us.Classes
                          where (c.Id.ToString().StartsWith(searchText) ||
                                 c.professorName.ToString().StartsWith(searchText) || c.description.ToString().StartsWith(searchText))
                          select c).FirstOrDefault();

            var result = search.Id + " " + search.description;

            //btnNav.Visible = true;
            CoursePage.course        = search.Id;
            lblSearchResults.Text    = result;
            lblSearchResults.Visible = true;
        }
        protected void btnSend_Click(object sender, EventArgs e)
        {
            Random yuh = new Random();
            UserDataClassesDataContext us = new UserDataClassesDataContext();

            if (us.users.Any(x => x.email == txtEmail.Text))
            {
                Random y = new Random();
                recov = yuh.Next(10000, 99999);
                string email = txtEmail.Text;
                try
                {
                    using (MailMessage mail = new MailMessage())
                    {
                        mail.From = new MailAddress("*****@*****.**");
                        mail.To.Add(email);
                        mail.Subject    = "Password Recovery";
                        mail.Body       = "<h1>Your Recovery number is: " + recov + "</h1>";
                        mail.IsBodyHtml = true;
                        using (SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587))
                        {
                            //SmtpClient.UseDefaultCredentials = false;
                            smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "testing123!");
                            smtp.EnableSsl   = true;
                            smtp.Send(mail);
                            Label1.Visible     = true;
                            Label1.ForeColor   = System.Drawing.Color.Green;
                            Label1.Text        = "Recovery # Sent";
                            lblConfirm.Visible = true;
                            txtConfirm.Visible = true;
                            btnComfirm.Visible = true;
                            Label1.Visible     = false;
                        }
                    }
                }
                catch (Exception ex)
                {
                    Label1.Text = ex.Message;
                }
            }
            else
            {
                Label1.Visible = true;
                Label1.Text    = "Email Incorrect";
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            UserDataClassesDataContext us = new UserDataClassesDataContext();

            var video_id = us.Classes.Where(a => a.Id == course).Select(a => a.videourl).FirstOrDefault();

            // Gets the video url from the database
            var videoframe = new Literal();

            video_id        = video_id.Split('=')[1];
            video_id        = "https://www.youtube.com/embed/" + video_id;
            videoframe.Text = String.Format(@"<iframe width=""628"" height=""374"" src=""{0}"" frameborder=""0"" allowfullscreen></iframe>", video_id);
            test.Controls.Add(videoframe);

            var desc = us.Classes.Where(a => a.Id == course).Select(a => a.description).FirstOrDefault();

            courseDescription.Text = desc;
        }
Exemplo n.º 8
0
        protected void btnCreate_Click(object sender, EventArgs e)
        {
            UserDataClassesDataContext us = new UserDataClassesDataContext();
            Security sec = new Security();
            string   enc = sec.EncryptString(txtPassword.Text);

            if (!us.users.Any(x => x.username == txtUsername.Text))
            {
                if (con == true)
                {
                    user u = new user
                    {
                        username     = txtUsername.Text,
                        password     = enc,
                        first_name   = txtFirstname.Text,
                        last_name    = txtLastname.Text,
                        phone_number = txtPhone.Text,
                        role         = dropRole.SelectedValue,
                        organization = DropDownList3.SelectedValue,
                        degree       = DropDownList2.SelectedValue,
                        email        = txtEmail.Text,
                    };

                    us.users.InsertOnSubmit(u);
                    us.SubmitChanges();
                    Response.Redirect("Login.aspx");
                }
                else if (con == false)
                {
                    lblFail.Visible = true;
                }
            }
            else if (us.users.Any(x => x.username == txtUsername.Text))
            {
                lblUnique.Visible   = true;
                lblUnique.Text      = "Username Already Taken";
                lblUnique.ForeColor = System.Drawing.Color.Red;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            UserDataClassesDataContext us = new UserDataClassesDataContext();

            var video_id = us.Classes.Where(a => a.Id == course).Select(a => a.videourl).FirstOrDefault();

            // Gets the video url from the database
            var videoframe = new Literal();

            video_id        = video_id.Split('=')[1];
            video_id        = "https://www.youtube.com/embed/" + video_id;
            videoframe.Text = String.Format(@"<iframe width=""628"" height=""374"" src=""{0}"" frameborder=""0"" allowfullscreen></iframe>", video_id);
            test.Controls.Add(videoframe);


            var currentclass = us.Classes.Where(a => a.Id == course).FirstOrDefault();

            lblCourse.Text = currentclass.Id + " " + currentclass.courseTitle;

            var zoom            = us.Classes.Where(a => a.Id == course).Select(a => a.zoomLink).FirstOrDefault();
            var descrip         = us.Classes.Where(a => a.Id == course).Select(a => a.description).FirstOrDefault();
            var announcemessage = us.Classes.Where(a => a.Id == course).Select(a => a.announcementMessage).FirstOrDefault();
            var teacher         = us.Classes.Where(a => a.Id == course).Select(a => a.professorName).FirstOrDefault();

            announceLabel.Text    = announcemessage;
            descriptionLabel.Text = descrip;
            if (zoom == null)
            {
                zoomLabel.Text = "This course does not have a Zoom meeting scheduled. Check back later";
            }
            else
            {
                zoomLabel.Text = zoom;
            }
            teachLabel.Text = teacher;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                UserDataClassesDataContext us = new UserDataClassesDataContext();
                var quizID       = 0;
                var quizidresult = us.quizzes.Where(a => a.courseid == course).Select(a => a.quizid).FirstOrDefault();
                quizid = quizidresult;


                var coursetitle = us.quizzes.Where(a => a.courseid == course).Select(a => a.quiztitle).FirstOrDefault();
                quizTitle.Text = coursetitle;


                //Load Questions
                var question = us.quizquestions.Where((a => a.quizid == quizid && a.qid == 1)).Select(a => a.question).FirstOrDefault();
                Question_1.Text = question;
                question        = us.quizquestions.Where((a => a.quizid == quizid && a.qid == 2)).Select(a => a.question).FirstOrDefault();
                Question_2.Text = question;
                question        = us.quizquestions.Where((a => a.quizid == quizid && a.qid == 3)).Select(a => a.question).FirstOrDefault();
                Question_3.Text = question;
                question        = us.quizquestions.Where((a => a.quizid == quizid && a.qid == 4)).Select(a => a.question).FirstOrDefault();
                Question_4.Text = question;
                question        = us.quizquestions.Where((a => a.quizid == quizid && a.qid == 5)).Select(a => a.question).FirstOrDefault();
                Question_5.Text = question;

                //        //Question 1 Load Answers
                //        RadioButtonList1.Items.Clear();



                var answer = us.quizanswers.Where((a => a.quizid == quizid && a.qqid == 1 && a.qcount == 1)).Select(a => a.answer).FirstOrDefault();
                RadioButtonList1.Items.Add(answer);
                answer = us.quizanswers.Where((a => a.quizid == quizid && a.qqid == 1 && a.qcount == 2)).Select(a => a.answer).FirstOrDefault();
                RadioButtonList1.Items.Add(answer);
                answer = us.quizanswers.Where((a => a.quizid == quizid && a.qqid == 1 && a.qcount == 3)).Select(a => a.answer).FirstOrDefault();
                RadioButtonList1.Items.Add(answer);
                answer = us.quizanswers.Where((a => a.quizid == quizid && a.qqid == 1 && a.qcount == 4)).Select(a => a.answer).FirstOrDefault();
                RadioButtonList1.Items.Add(answer);

                //Questions 2 Load Answers
                RadioButtonList2.Items.Clear();
                answer = us.quizanswers.Where((a => a.quizid == quizid && a.qqid == 2 && a.qcount == 5)).Select(a => a.answer).FirstOrDefault();
                RadioButtonList2.Items.Add(answer);
                answer = us.quizanswers.Where((a => a.quizid == quizid && a.qqid == 2 && a.qcount == 6)).Select(a => a.answer).FirstOrDefault();
                RadioButtonList2.Items.Add(answer);
                answer = us.quizanswers.Where((a => a.quizid == quizid && a.qqid == 2 && a.qcount == 7)).Select(a => a.answer).FirstOrDefault();
                RadioButtonList2.Items.Add(answer);
                answer = us.quizanswers.Where((a => a.quizid == quizid && a.qqid == 2 && a.qcount == 8)).Select(a => a.answer).FirstOrDefault();
                RadioButtonList2.Items.Add(answer);

                //Question 3 Load Answers
                RadioButtonList3.Items.Clear();
                answer = us.quizanswers.Where((a => a.quizid == quizid && a.qqid == 3 && a.qcount == 9)).Select(a => a.answer).FirstOrDefault();
                RadioButtonList3.Items.Add(answer);
                answer = us.quizanswers.Where((a => a.quizid == quizid && a.qqid == 3 && a.qcount == 10)).Select(a => a.answer).FirstOrDefault();
                RadioButtonList3.Items.Add(answer);
                answer = us.quizanswers.Where((a => a.quizid == quizid && a.qqid == 3 && a.qcount == 11)).Select(a => a.answer).FirstOrDefault();
                RadioButtonList3.Items.Add(answer);
                answer = us.quizanswers.Where((a => a.quizid == quizid && a.qqid == 3 && a.qcount == 12)).Select(a => a.answer).FirstOrDefault();
                RadioButtonList3.Items.Add(answer);

                //Question 4 Load Answers
                RadioButtonList4.Items.Clear();
                answer = us.quizanswers.Where((a => a.quizid == quizid && a.qqid == 4 && a.qcount == 13)).Select(a => a.answer).FirstOrDefault();
                RadioButtonList4.Items.Add(answer);
                answer = us.quizanswers.Where((a => a.quizid == quizid && a.qqid == 4 && a.qcount == 14)).Select(a => a.answer).FirstOrDefault();
                RadioButtonList4.Items.Add(answer);
                answer = us.quizanswers.Where((a => a.quizid == quizid && a.qqid == 4 && a.qcount == 15)).Select(a => a.answer).FirstOrDefault();
                RadioButtonList4.Items.Add(answer);
                answer = us.quizanswers.Where((a => a.quizid == quizid && a.qqid == 4 && a.qcount == 16)).Select(a => a.answer).FirstOrDefault();
                RadioButtonList4.Items.Add(answer);

                //Question 5 Load Answers
                RadioButtonList5.Items.Clear();
                answer = us.quizanswers.Where((a => a.quizid == quizid && a.qqid == 5 && a.qcount == 17)).Select(a => a.answer).FirstOrDefault();
                RadioButtonList5.Items.Add(answer);
                answer = us.quizanswers.Where((a => a.quizid == quizid && a.qqid == 5 && a.qcount == 18)).Select(a => a.answer).FirstOrDefault();
                RadioButtonList5.Items.Add(answer);
                answer = us.quizanswers.Where((a => a.quizid == quizid && a.qqid == 5 && a.qcount == 19)).Select(a => a.answer).FirstOrDefault();
                RadioButtonList5.Items.Add(answer);
                answer = us.quizanswers.Where((a => a.quizid == quizid && a.qqid == 5 && a.qcount == 20)).Select(a => a.answer).FirstOrDefault();
                RadioButtonList5.Items.Add(answer);
            }
            else
            {
                int index = 0;
                index = RadioButtonList1.SelectedIndex;
                RadioButtonList1.SelectedIndex = index;
                index = RadioButtonList2.SelectedIndex;
                RadioButtonList2.SelectedIndex = index;
                index = RadioButtonList3.SelectedIndex;
                RadioButtonList3.SelectedIndex = index;
                index = RadioButtonList4.SelectedIndex;
                RadioButtonList4.SelectedIndex = index;
                index = RadioButtonList5.SelectedIndex;
                RadioButtonList5.SelectedIndex = index;
            }
        }