Example #1
0
        protected void btnLogin_OnClick(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(tbxAccount.Text))
            {
                WebUtil.Alert("用户名不能为空!");
                return;
            }
            if (string.IsNullOrWhiteSpace(tbxPassword.Text))
            {
                WebUtil.Alert("密码不能为空!");
                return;
            }
            var shop = ShopBll.Login(tbxAccount.Text.Trim(), DESUtil.Encrypt(tbxPassword.Text));

            if (shop != null)
            {
                Session["YeShopId"] = shop.ShopID;
                Cache["Ye_Shop"]    = shop;
                Response.Redirect("Default.aspx", true);
            }
            else
            {
                WebUtil.AlertAndRedirect("用户名或密码不正确!", "Login.aspx");
            }
        }
Example #2
0
        /// <summary>
        /// 登录页面
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnLogin_OnClick(object sender, EventArgs e)
        {
            var user = UserBll.Login(tbxUserName.Text.Trim(), DESUtil.Encrypt(tbxPwd.Text.Trim()));

            if (user == null)
            {
                WebUtil.Alert("Email,mobile or password is incorrect!");
            }
            else
            {
                UserBll.UpdateUserLastLoginTime(user.UserID);
                if (Request.Cookies["location"] == null)
                {
                    var cookie = new HttpCookie("location", user.Address);
                    cookie.Expires = DateTime.MaxValue;
                    Response.Cookies.Add(cookie);
                }
                else
                {
                    Response.Cookies["location"].Value = user.Address;
                }
                if (Request.Cookies["username"] == null)
                {
                    var cookie = new HttpCookie("username", user.UserName);
                    cookie.Expires = DateTime.MaxValue;
                    Response.Cookies.Add(cookie);
                }
                else
                {
                    Response.Cookies["username"].Value = user.UserName;
                }
                Session["YeUser"] = user;
                Response.Redirect("Home.aspx");//登录后跳转
            }
        }
Example #3
0
 protected void btnOK_OnClick(object sender, EventArgs e)
 {
     if (YeAdministrator.Password != DESUtil.Encrypt(tbxOldPwd.Text))
     {
         WebUtil.Alert("您输入的当期登录密码不正确!");
         tbxOldPwd.Focus();
     }
     else
     {
         var newPwd = DESUtil.Encrypt(tbxNewPwd1.Text.Trim());
         if (AdministratorBll.ChangePassword(YeAdministratorId, newPwd))
         {
             AdministratorBll.AddAdminLog(new Ye_AdminLog()
             {
                 AdminID     = YeAdministratorId,
                 LogTypeName = LogType.修改密码.ToString(),
                 CreateTime  = DateTime.Now
             });
             WebUtil.Alert("密码修改成功!");
             YeAdministrator.Password = newPwd;
         }
         else
         {
             WebUtil.Alert("密码修改失败!");
         }
     }
 }
Example #4
0
        protected void btnLogin_OnClick(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(tbxAccount.Text))
            {
                WebUtil.Alert("用户名不能为空!");
                return;
            }
            if (string.IsNullOrWhiteSpace(tbxPassword.Text))
            {
                WebUtil.Alert("密码不能为空!");
                return;
            }
            var admin = AdministratorBll.Login(tbxAccount.Text.Trim(), DESUtil.Encrypt(tbxPassword.Text));

            if (admin != null)
            {
                AdministratorBll.AddAdminLog(new Ye_AdminLog()
                {
                    AdminID     = admin.AdministratorID,
                    LogTypeName = LogType.登录系统.ToString(),
                    CreateTime  = DateTime.Now
                });
                Session["YeAdministratorId"] = admin.AdministratorID;
                Cache["YeAdministrator"]     = admin;
                Response.Redirect("~/YellEatAdmin/Default.aspx", true);
            }
            else
            {
                WebUtil.AlertAndRedirect("用户名或密码不正确!", "Login.aspx");
            }
        }
Example #5
0
 protected void btnOK_OnClick(object sender, EventArgs e)
 {
     if (AdministratorBll.GetAdministrators().SingleOrDefault(a => a.Account == tbxAccount.Text) != null)
     {
         WebUtil.Alert("该用户名已存在!");
         return;
     }
     else
     {
         if (AdministratorBll.AddAdministrator(new Ye_Administrator()
         {
             Account = tbxAccount.Text.Trim(),
             Password = DESUtil.Encrypt(tbxPwd1.Text.Trim()),
             CreateTime = DateTime.Now,
             LastLoginTime = DateTime.Now
         }))
         {
             AdministratorBll.AddAdminLog(new Ye_AdminLog()
             {
                 AdminID     = YeAdministratorId,
                 LogTypeName = LogType.添加管理员.ToString(),
                 CreateTime  = DateTime.Now
             });
             WebUtil.AlertAndReload("成功添加管理员!");
         }
         else
         {
             WebUtil.Alert("创建新管理员时出错!");
         }
     }
 }
Example #6
0
    void Encry()
    {
        Stopwatch sw = new Stopwatch();

        sw.Start();
        var text = DESUtil.Encrypt(toEncry, key, iv);

        sw.Stop();
        Debug.Log(sw.ElapsedMilliseconds);
        Debug.Log(text);
    }
Example #7
0
        //protected void btnSendSMS_OnClick(object sender, EventArgs e)
        //{

        //}
        protected void btnRegister_OnClick(object sender, EventArgs e)
        {
            var user = new Ye_User()
            {
                Address       = tbxAddress.Text.Trim(),
                UserName      = tbxName.Text.Trim(),
                Zip           = tbxZip.Text.Trim(),
                AptSuite      = tbxAptSuite.Text.Trim(),
                Mobile        = tbxPhone.Text.Trim(),
                Password      = DESUtil.Encrypt(tbxPassword.Text.Trim()),
                Email         = tbxEmail.Text.Trim(),
                FaceBookID    = "",
                QQ            = "",
                WxID          = "",
                Status        = 0,
                LastLoginTime = DateTime.Now,
                RegisterTime  = DateTime.Now
            };

            if (UserBll.GetUsers().SingleOrDefault(u => u.UserName == user.UserName) != null)
            {
                WebUtil.Alert("The username is used,please change a new username.");//当前用户已经存在!请使用其他用户名注册!
                return;
            }
            if (UserBll.AddUser(user))
            {
                Session["YeUser"] = UserBll.Login(user.UserName, user.Password);
                if (Request.Cookies["location"] == null)
                {
                    var cookie = new HttpCookie("location", user.Address);
                    cookie.Expires = DateTime.MaxValue;
                    Response.Cookies.Add(cookie);
                }
                else
                {
                    Response.Cookies["location"].Value = user.Address;
                }
                if (Request.Cookies["username"] == null)
                {
                    var cookie = new HttpCookie("username", user.UserName);
                    cookie.Expires = DateTime.MaxValue;
                    Response.Cookies.Add(cookie);
                }
                else
                {
                    Request.Cookies["username"].Value = user.UserName;
                }
                WebUtil.AlertAndRedirect("Register successfully", "Home.aspx");
            }
            else
            {
                WebUtil.Alert("Failed to register.");
            }
        }
        /// <summary>
        /// 点击加密按钮
        /// </summary>
        /// <param name="sender">引发对象</param>
        /// <param name="e">事件参数</param>
        private void btnEncrypt_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtPlaintext.Text))
            {
                MessageBox.Show("请输入明文");
                return;
            }

            try
            {
                txtCiphertext.Text = DESUtil.Encrypt(txtPlaintext.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #9
0
        protected void btnRegister_OnClick(object sender, EventArgs e)
        {
            var shop = new Ye_Shop()
            {
                ShopAccount        = tbxUserName.Text.Trim(),
                ShopPassword       = DESUtil.Encrypt(tbxUserPwd.Text.Trim()),
                RegisterTime       = DateTime.Now,
                LastLoginTime      = DateTime.Now,
                ShopName           = tbxShopName.Text,
                ShopAddress        = tbxAddr.Text,
                ShopMobile         = tbxShopMobile.Text,
                ShopEmail          = tbxShopEmail.Text,
                ShopFax            = tbxShopFax.Text,
                ShopZip            = tbxShopZip.Text,
                ShopDesc           = "",
                ShopLogoImg        = "",
                ShopMainImg        = "",
                ShopQQ             = "",
                ShopQRCodeImg      = "",
                Longitude          = 0,
                Latitude           = 0,
                DeliveryTime       = "",
                DeliveryMinPrice   = 0,
                RecommendLevel     = 0,
                IsChecked          = false,
                OpeningBeginMinute = 0,
                OpeningEndMinute   = 0,
                Rank   = 3,
                Clicks = 0,
            };

            if (ShopBll.AddShop(shop))
            {
                WebUtil.AlertAndRedirect("您的餐馆已成功注册,请耐心等待审核!", "Login.aspx");
            }
            else
            {
                WebUtil.Alert("餐馆注册失败!");
            }
        }
Example #10
0
 protected void btnOK_OnClick(object sender, EventArgs e)
 {
     if (YeShop.ShopPassword != DESUtil.Encrypt(tbxOldPwd.Text))
     {
         WebUtil.Alert("您输入的当期登录密码不正确!");
         tbxOldPwd.Focus();
         return;
     }
     else
     {
         var newPwd = DESUtil.Encrypt(tbxNewPwd1.Text.Trim());
         if (ShopBll.ChangePassword(YeShopId, newPwd))
         {
             WebUtil.Alert("密码修改成功!");
             YeShop.ShopPassword = newPwd;
         }
         else
         {
             WebUtil.Alert("密码修改失败!");
         }
     }
 }
Example #11
0
        protected void imgBtn_OnClick(object sender, ImageClickEventArgs e)
        {
            var user = new Ye_User()
            {
                Address  = tbxAddress.Text.Trim(),
                UserName = tbxFirstName.Text.Trim() + " " + tbxLastName.Text.Trim(),
                //Zip =  tbxZip.Text.Trim(),
                //Aptsuite = tbxAptSuite.Text.Trim(),
                Mobile        = tbxMobile.Text.Trim(),
                Password      = DESUtil.Encrypt(tbxPwd1.Text.Trim()),
                Email         = tbxEmail.Text.Trim(),
                FaceBookID    = "",
                QQ            = "",
                WxID          = "",
                Status        = 0,
                Zip           = "",
                AptSuite      = "",
                LastLoginTime = DateTime.Now,
                RegisterTime  = DateTime.Now
            };

            if (UserBll.GetUsers().SingleOrDefault(u => u.UserName == user.UserName) != null)
            {
                WebUtil.Alert("当前用户已经存在!请使用其他用户名注册!");
                return;
            }
            if (UserBll.AddUser(user))
            {
                Session["YeUser"] = UserBll.Login(user.UserName, user.Password);
                Response.Redirect("Home.aspx");
            }
            else
            {
                WebUtil.Alert("注册失败!");
            }
        }
Example #12
0
 public static string EncryptDES(this string str)
 {
     return(DESUtil.Encrypt(str));
 }
Example #13
0
 public bool Login(string username, string password)
 {
     return(AdministratorBll.Login(username, DESUtil.Encrypt(password)) != null);
 }