コード例 #1
0
ファイル: UserStatistic.aspx.cs プロジェクト: Lesssnik/Labs
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserLogin"] == null || Session["UserLogin"].ToString().CompareTo("Admin") != 0)
            {
                Response.Redirect("Default.aspx");
            }

            var user = new BLL.UserComponents().GetUser(Request["user"]);
            var tempstat = new BLL.StatisticComponents().GetTestStatistic(user);

            foreach (var st in tempstat)
            {
                var test = new BLL.TestComponents().FindTest(st.TestName).First();
                stats.Add(new Tuple<string, List<Tuple<string, string>>>(test.Name, new List<Tuple<string, string>>()));
                foreach (var q in test.Questions)
                {
                    var temp = st.CorrectQuestions.Where(s => s.Correct == q.Text);
                    if (temp.Count() > 0)
                        stats[stats.Count-1].Item2.Add(new Tuple<string, string>(q.Text, "Верно"));
                    else stats[stats.Count-1].Item2.Add(new Tuple<string, string>(q.Text, "Неверно"));
                }
            }
            RepeaterStats.DataSource = stats;
            if (stats.Count == 0)
                NullText.Visible = true;
            else NullText.Visible = false;
            DataBind();
        }
コード例 #2
0
ファイル: Result.aspx.cs プロジェクト: Lesssnik/Labs
        protected void Page_Load(object sender, EventArgs e)
        {
            var bll = new BLL.UserComponents();
            var user = new Entities.User();
            if (Session["UserLogin"] != null)
                user = bll.GetUser(Session["UserLogin"].ToString());
            var test = new BLL.TestComponents().FindTest(Guid.Parse(Request["test"]));
            var blls = new BLL.StatisticComponents();
            var guid = Guid.Parse(Request["stat"]);
            var stat = new BLL.StatisticComponents().GetTestStatistics().Where(s => s.ID.CompareTo(guid) == 0).First();

            foreach (var q in test.Questions)
            {
                var temp = stat.CorrectQuestions.Where(s => s.Correct == q.Text);
                if (temp.Count() > 0)
                    stats.Add(new Tuple<string, string>(q.Text, "Верно"));
                else stats.Add(new Tuple<string, string>(q.Text, "Неверно"));
            }

            RepeaterStats.DataSource = stats;
            DataBind();

            if (Session["IsTrue"] != null)
            {
                blls.DeleteStatistic(stat);
                Session["IsTrue"] = null;
            }
        }
コード例 #3
0
ファイル: Login.aspx.cs プロジェクト: Lesssnik/Labs
 protected void Login_Click(object sender, EventArgs e)
 {
     var user = new BLL.UserComponents().GetUser(UserName.Text);
     if (user != null)
     {
         if (user.Role == Entities.Roles.User)
         {
             if (user.Password == Password.Text)
             {
                 Session["UserLogin"] = UserName.Text;
                 Response.Redirect("~/Default.aspx");
             }
         }
         else if (user.Role == Entities.Roles.Admin)
         {
             if (user.Password == Password.Text)
             {
                 Session["UserLogin"] = UserName.Text;
                 Response.Redirect("~/Admin.aspx");
             }
         }
         FailureText.Text = "Неверный пароль";
     }
     FailureText.Text = "Пользователь с таким именем не найден";
 }
コード例 #4
0
ファイル: MyTests.aspx.cs プロジェクト: Lesssnik/Labs
 protected void Page_Load(object sender, EventArgs e)
 {
     var bll = new BLL.UserComponents();
     var user = bll.GetUser(Session["UserLogin"].ToString());
     if (user != null)
     {
         var bllt = new BLL.TestComponents();
         RepeaterTests.DataSource = bllt.GetTests(user.Login);
         DataBind();
     }
 }
コード例 #5
0
ファイル: EditUserControl.ascx.cs プロジェクト: Lesssnik/Labs
 protected void Update_User(object sender, EventArgs e)
 {
     var user = new BLL.UserComponents().GetUser(Session["UserLogin"].ToString());
     if (Name != "")
         user.Name = Name;
     if (Surname != "")
         user.Surname = Surname;
     if (City != "")
         user.City = City;
     if (OldPass == user.Password)
         user.Password = NewPass;
     new BLL.UserComponents().UpdateUser(user);
     Response.Redirect("Default.aspx");
 }
コード例 #6
0
ファイル: MyStatistic.aspx.cs プロジェクト: Lesssnik/Labs
        protected void Page_Load(object sender, EventArgs e)
        {
            var bll = new BLL.UserComponents();
            var user = bll.GetUser(Session["UserLogin"].ToString());
            var blls = new BLL.StatisticComponents();
            var bllt = new BLL.TestComponents();
            var stats =  blls.GetTestStatistic(user);

            foreach (var stat in stats)
            {
                var test = bllt.FindTest(stat.TestName).First();
                TestNames.Add(new Tuple<string, int, int>(stat.TestName, stat.CorrectQuestions.Count, test.Questions.Count));
            }

            RepeaterStats.DataSource = TestNames;
            if (TestNames.Count == 0)
                NullText.Visible = true;
            else NullText.Visible = false;
            DataBind();
        }