Пример #1
0
        protected void Unnamed1_Click(object sender, EventArgs e)
        {
            BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();

            var usr = db.cms_user.ToList().SingleOrDefault(x => x.username == Request["userid"] && x.password == MD5Hash(Request["password"]));

            if (usr != null && usr.status == 1)
            {
                usr.date_login     = DateTime.Now;
                usr.isOnline       = true;
                Session["CMSUser"] = usr;
                db.SaveChanges();
                if (!string.IsNullOrEmpty(Request["red"]))
                {
                    Response.Redirect(Request["red"]);
                }
                else
                {
                    Response.Redirect("~/system");
                }
            }
            else
            {
                Msg.Text = @"<div class=""alert alert-danger alert-dismissable"">
                                        <i class=""fa fa-ban""></i>
                                        <b>Alert!</b> Invalid Username / Password
                                    </div>
<script>
document.addEventListener('DOMContentLoaded', function () {
  if (Notification.permission !== ""granted"")
    Notification.requestPermission();
            });

            function notifyMe() {
                if (Notification.permission !== ""granted"")
                    Notification.requestPermission();
                else
                {
                    var notification = new Notification('Error', {
      icon: 'http://maizonpub.com/images/logo-shrink.png',
      body: ""Invalid username / password please try again"",
    });

                /*notification.onclick = function() {
                    window.open("");
                };*/

            }

        }
notifyMe();
</script>
";
            }
        }
Пример #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            lang = Page.RouteData.Values["lang"].ToString();
            BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();

            if (IsPostBack)
            {
                string accCode    = Request.Form["accesscode"];
                string uname      = Request.Form["uname"];
                var    userExists = db.Students.Where(x => x.UserName == uname).Count() > 0;
                if (!userExists)
                {
                    var student = db.Students.Where(x => x.AccessCode == accCode && x.UserName == null).SingleOrDefault();
                    if (student != null)
                    {
                        student.Password = StringCipher.Encrypt(Request.Form["passwd"]);
                        student.UserName = Request.Form["uname"];
                        db.SaveChanges();
                        Session["UserId"] = student.id;
                        Response.Redirect("level-" + student.levelId);
                    }
                    else
                    {
                        if (lang == "en")
                        {
                            msg.Text = "<font color='red'>The Access Code you entered is not correct, please use another one.</font>";
                        }
                        if (lang == "ar")
                        {
                            msg.Text = "<font color='red'>Le code d'accès que vous avez entré n'est pas correct, veuillez en utiliser un autre.</font>";
                        }
                    }
                }
                else
                {
                    if (lang == "en")
                    {
                        msg.Text = "<font color='red'>Username is used. Please choose another one.</font>";
                    }
                    if (lang == "ar")
                    {
                        msg.Text = "<font color='red'>Le nom d'utilisateur est utilisé. Veuillez en choisir un autre.</font>";
                    }
                }
            }
        }
Пример #3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            int bookId = int.Parse(context.Request["bookId"]);
            BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();
            string msg = "success";

            try
            {
                int userId = (int)context.Session["UserId"];
                db.StudentLibraries.Remove(db.StudentLibraries.Where(x => x.bookId == bookId && x.studentId == userId).FirstOrDefault());
                db.SaveChanges();
            }
            catch
            {
                msg = "error";
            }
            context.Response.Write(msg);
        }
Пример #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();
         cms_user usr = (cms_user)Session["CMSUser"];
         var      u   = db.cms_user.ToList().Where(x => x.id == usr.id).SingleOrDefault();
         u.isOnline = false;
         db.SaveChanges();
         Session["CMSUser"] = null;
         if (Request["logout"] != null)
         {
             Response.Redirect("~/system/login.aspx");
         }
     }
     catch
     {
         if (Request["logout"] != null)
         {
             Response.Redirect("~/system/login.aspx");
         }
     }
 }