Esempio n. 1
0
        public JsonResult Delete()
        {
            JsonResult res = new JsonResult();
            JsonMessage message = new JsonMessage() { Status = "ok" };
            res.Data = message;
            User currentUser = (User)Session["User"];
            if (currentUser == null)
            {
                message.Status = "failed";
                message.Message = "没有登录不能删除图片";
                return res;
            }
            AccountManager accountMgr=new AccountManager();
            ShopManager shopMgr = new ShopManager(currentUser);
            Permission permission = shopMgr.Permission;
            if (permission.DELETE_PDT_IMAGE == 0)
            {
                message.Status = "failed";
                message.Message = "没有权限删除图片";
                return res;
            }

            int imgId = 0;
            int.TryParse(Request["image_id"],out imgId);
            if (shopMgr.DeleteImage(imgId, Request.PhysicalApplicationPath))
            {
                message.Status = "ok";
            }

            return res;
        }
Esempio n. 2
0
        public JsonResult CancelTrade()
        {
            JsonResult res = new JsonResult();
            JsonMessage message = new JsonMessage();
            User user = (User)Session["User"];
            res.Data = message;
            int trade_id = 0;
            int.TryParse(Request["trade_id"],out trade_id);
            try
            {
                AccountManager manager = new AccountManager();
                manager.CancelTrade(trade_id, user.ID);
                message.Status = "ok";
            }
            catch (Exception ex)
            {
                message.Status = "failed";
                message.Message = ex.Message;
            }
            finally
            {

            }
            return res;
        }
Esempio n. 3
0
 public ActionResult AddressBook()
 {
     AccountManager accManager = new AccountManager();
     User user = (User)Session["User"];
     List<BAddress> addresses = accManager.GetAddresses(user.ID);
     List<Common_district> provinces = accManager.GetCommonDistricts();
     ViewData["province"] = provinces;
     return View(addresses);
 }
Esempio n. 4
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            AccountManager account = new AccountManager();
            base.OnActionExecuting(filterContext);
            string url = filterContext.HttpContext.Request.Url.AbsoluteUri;
            if (filterContext.HttpContext.Session["User"] == null)
            {
                filterContext.HttpContext.Response.Redirect("/Account/Login?returnURL=" + HttpUtility.HtmlEncode(url));
            }

            User user=(User)filterContext.HttpContext.Session["User"];

            if (!account.IsAdmin(user.ID))
            {
                filterContext.HttpContext.Response.Redirect("/Account/Login?message="+HttpUtility.HtmlEncode("您不是管理员,不能访问管理员界面")+"&returnURL=" + HttpUtility.HtmlEncode(url));
            }
        }
Esempio n. 5
0
 public JsonResult CheckNick()
 {
     JsonResult res = new JsonResult();
     JsonMessage message = new JsonMessage();
     string nickName = Request["nickName"];
     AccountManager am = new AccountManager();
     User user = (User)Session["User"];
     if (!string.IsNullOrEmpty(nickName))
     {
         bool existed = am.CheckNickIsUsed(nickName,user.ID);
         if (existed)
         {
             message.Status = "failed";
             message.Message = "此昵称已经被使用";
         }
         else
         {
             message.Status = "ok";
         }
     }
     res.Data = message;
     return res;
 }
Esempio n. 6
0
        public ActionResult DoLogin()
        {
            string email = Request["email"];
            string password = Request["password"];
            string url = Request["returnURL"];
            if (string.IsNullOrEmpty(email))
            {
                return RedirectToAction("Login", new { message="邮箱地址不能为空"});
            }

            if (string.IsNullOrEmpty(password))
            {
                return RedirectToAction("Login", new { message = "密码不能为空" });
            }

            AccountManager accountManager = new AccountManager();
            User user = null;
            try
            {
                user = accountManager.Login(email, password);

            }
            catch (Exception ex)
            {
                return RedirectToAction("Login", new { message = ex.Message });
            }

            Session["User"] = user;
            if (!string.IsNullOrEmpty(url))
            {
                return Redirect(HttpUtility.HtmlDecode(url));
            }
            return Redirect("/Home/Index");
        }
Esempio n. 7
0
        public JsonResult UpdatePassword()
        {
            JsonResult res = new JsonResult();
            JsonMessage message = new JsonMessage();
            res.Data = message;
            string password=Request["password"];
            User user = (User)Session["User"];
            if (user == null)
            {
                message.Status = "failed";
                message.Message = "更新失败";
                return res;
            }
            user.Password = anan.web.Util.Encrypt.MD5(password);
            AccountManager manager = new AccountManager();

            if (manager.UpdateUser(user))
            {
                message.Status = "ok";
            }
            else
            {
                message.Status = "failed";
                message.Message = "更新失败";
            }
            res.Data = message;

            return res;
        }
Esempio n. 8
0
        public JsonResult UpdateUser()
        {
            JsonResult res = new JsonResult();
            string nick = Request["nickName"];
            string birthday = Request["birthday"];
            string gendar = Request["gendar"];
            string pid = Request["province"];
            string cid = Request["city"];
            string did = Request["district"];
            int province = 0;
            int city = 0;
            int district = 0;
            int.TryParse(pid, out province);
            int.TryParse(cid, out city);
            int.TryParse(did, out district);

            User user = (User)Session["User"];
            user.NickName = nick;
            user.Gendar = short.Parse(gendar);
            user.Birthday = birthday;
            user.ProvinceID = province;
            user.CityID = city;
            user.DistrictID = district;
            AccountManager manager = new AccountManager();
            JsonMessage message = new JsonMessage();
            if (manager.UpdateUser(user))
            {
                message.Status = "ok";
            }
            else
            {
                message.Status="failed";
                message.Message = "更新失败";
            }
            res.Data = message;
            return res;
        }
Esempio n. 9
0
 public ActionResult Pay()
 {
     AccountManager accManager = new AccountManager();
     User user = (User)Session["User"];
     List<BAddress> addresses = accManager.GetAddresses(user.ID);
     List<Common_district> provinces = accManager.GetCommonDistricts();
     ViewData["province"] = provinces;
     ViewData["address"] = addresses;
     List<Product> products = (List<Product>)Session["cart"];
     return View(products);
 }
Esempio n. 10
0
        public JsonResult SubmitOrder()
        {
            JsonResult res = new JsonResult();
            JsonMessage message = new JsonMessage();
            res.Data = message;

            int addressId = 0;
            int.TryParse(Request["address"],out addressId);
            string description = "";
            if (!string.IsNullOrEmpty(Request["description"])) {
                description = Request["description"];
            }

            List<Product> products = (List<Product>)Session["cart"];

            User user = (User)Session["User"];
            AccountManager manager = new AccountManager();
            if (manager.SubmitOrder(user.ID, addressId, products, description))
            {
                message.Status="ok";
                Session["cart"] = null;
            }else
            {
                message.Status="failed";
            }

            return res;
        }
Esempio n. 11
0
        public ActionResult Index()
        {
            User user = (User)Session["User"];
            AccountManager manager = new AccountManager();
            List<Common_district> provinces = manager.GetCommonDistricts(0);
            List<Common_district> cities = null;
            List<Common_district> districts = null;
            if (user.ProvinceID > 0)
            {
                //direct city
                if (user.CityID == user.ProvinceID)
                {
                    districts = manager.GetCommonDistricts((int)user.ProvinceID);
                }
                else
                {
                    cities = manager.GetCommonDistricts((int)user.ProvinceID);
                }
            }

            if (user.CityID > 0 && user.CityID!=user.ProvinceID)
            {
                districts = manager.GetCommonDistricts((int)user.CityID);
            }

            ViewData["province"] = provinces;
            ViewData["city"] = cities;
            ViewData["district"] = districts;

            return View();
        }
Esempio n. 12
0
 public ActionResult Order()
 {
     User user = (User)Session["User"];
     AccountManager manager = new AccountManager();
     int total = 0;
     List<Trade> trades = manager.GetTrades(0, 0, 0, 0, out total);
     return View(trades);
 }
Esempio n. 13
0
 //
 // GET: /Order/
 public ActionResult Detail(int id)
 {
     AccountManager manager = new AccountManager();
     BTrade trade = manager.GetBTrade(id);
     return View(trade);
 }
Esempio n. 14
0
        public JsonResult GetCommonDistrict()
        {
            JsonResult res = new JsonResult();
            JsonMessage message = new JsonMessage();
            res.Data = message;
            AccountManager manager = new AccountManager();

            int pid = 0;
            int.TryParse(Request["pid"],out pid);

            List<Common_district> diss = manager.GetCommonDistricts(pid);
            message.Status = "ok";
            message.Item = diss;
            return res;
        }
Esempio n. 15
0
        public JsonResult Upload()
        {
            JsonResult res = new JsonResult();
            JsonMessage message = new JsonMessage() { Status="ok"};
            int len = Request.Files["Filedata"].ContentLength;
            string name = Request.Files["Filedata"].FileName;
            string uid = Request["authid"];
            int user_id = 0;
            int.TryParse(uid,out user_id);

            if (user_id <= 0) {
                message.Status = "failed";
                message.Message = "未登录用户不能上传图片";
                res.Data = message;
                return res;
            }

            int size = len / (1024);

            if (size > 2 * 1024)
            {
                message.Status = "failed";
                message.Message = "上传的文件大小不能超过3M";
            }
            else
            {
                AccountManager accountMgr = new AccountManager();
                User user = accountMgr.GetUser(user_id);
                ShopManager shopMgr = new ShopManager(user);

                string fileName = Path.GetFileName(name);
                string fileExt = Path.GetExtension(name);
                string newFileName = DateTime.Now.ToString("yyyyMMddHHmmss_ffff", DateTimeFormatInfo.InvariantInfo) + fileExt;
                string dir1 = DateTime.Now.ToString("yyyy");
                string dir2 = DateTime.Now.ToString("MM");
                string dir3 = DateTime.Now.ToString("dd");
                string dir4 = DateTime.Now.Hour.ToString();
                string rootPath=Request.PhysicalApplicationPath+@"Content\Uploads\Images";
                string absPath=@"/Content/Uploads/Images";
                string location = Path.Combine(rootPath, dir1, dir2, dir3, dir4);
                absPath = absPath + "/" + dir1 + "/" + dir2 + "/" + dir3 + "/" + dir4;
                if (!Directory.Exists(location))
                {
                    Directory.CreateDirectory(location);
                }

                Image img = new Image();
                img.UserID = user_id;
                img.ProductID = 0;
                img.Path = "";
                img.Created = DateTimeUtil.ConvertDateTimeToInt(DateTime.Now);
                img.FileName = name;
                shopMgr.CreateImage(img);

                System.Drawing.Image image = System.Drawing.Image.FromStream(Request.Files["Filedata"].InputStream);
                //if(image.Width>600){
                //    ImageUtil.ThumbPic(Request.Files["Filedata"].InputStream, 600, 0, location, fileName, true);
                //}

                ImageUtil.CutForCustom(Request.Files["Filedata"].InputStream, Path.Combine(location, newFileName), 600, 700, 80);

                if (System.IO.File.Exists(Path.Combine(location, newFileName)))
                {
                    img.Path = absPath + "/" + newFileName;
                }
                message.Status = "ok";
                message.Message = "succeed";
                shopMgr.UpdateImage(img);
                message.Item = img;
            }

            res.Data = message;
            return res;
        }
Esempio n. 16
0
        public JsonResult DeleteAddress()
        {
            JsonResult res = new JsonResult();
            JsonMessage message = new JsonMessage();
            res.Data = message;
            AccountManager manager = new AccountManager();
            User user = (User)Session["User"];
            int id = 0;

            int.TryParse(Request["id"], out id);

            if (manager.DeleteAddress(id,user.ID))
            {
                message.Status = "ok";
            }
            else
            {
                message.Status = "failed";
                message.Message = "地址删除失败";
            }

            return res;
        }
Esempio n. 17
0
        public ActionResult Order(int page)
        {
            User user = (User)Session["User"];
            AccountManager manager = new AccountManager();
            ShopManager shop = new ShopManager(user);
            int total = 0;
            int pageSize = 30;
            if (page <= 0)
            {
                page = 1;
            }
            List<Trade> trades = manager.GetTrades(0,0,0,0,out total,page,pageSize);
            ViewBag.page = page;
            ViewBag.pageSize = pageSize;
            ViewBag.total = total;

            List<Trade_Status> status = shop.GetStatus();
            ViewData["tstatus"] = status;
            return View(trades);
        }
Esempio n. 18
0
        public JsonResult CreateAddress()
        {
            JsonResult res = new JsonResult();
            JsonMessage message = new JsonMessage();
            res.Data = message;

            int pid = 0;
            int cid = 0;
            int did = 0;
            string address = Request["address"];
            string person = Request["person"];
            string phone = Request["phone"];
            int.TryParse(Request["province"], out pid);
            int.TryParse(Request["city"], out cid);
            int.TryParse(Request["district"], out did);

            AccountManager manager = new AccountManager();
            User user =(User)Session["User"];

            if (manager.CreateAddress(user.ID, pid, cid, did, address, person, phone))
            {
                message.Status = "ok";
            }
            else {
                message.Status = "failed";
                message.Message = "地址创建失败";
            }

            return res;
        }
Esempio n. 19
0
 public JsonResult CheckRegisterEmail()
 {
     JsonResult res = new JsonResult();
     string email=Request["email"];
     JsonMessage message = new JsonMessage();
     AccountManager am=new AccountManager();
     if (!string.IsNullOrEmpty(email))
     {
         bool existed = am.CheckEmailIsRegistered(email);
         if (existed)
         {
             message.Status = "failed";
             message.Message = "此邮件地址已经被注册";
         }
         else
         {
             message.Status = "ok";
         }
     }
     res.Data = message;
     return res;
 }
Esempio n. 20
0
 private void GetPermission()
 {
     AccountManager accMgr = new AccountManager();
     this.Permission = accMgr.GetUserPermission(this.CurrentUser.ID);
 }
Esempio n. 21
0
        public ActionResult DoRegister()
        {
            string email=Request["email"];
            string nick = Request["nickName"];
            string password = Request["password"];
            string gendar = Request["gendar"];
            User user = new User();
            user.Email = email;
            user.NickName = nick;
            user.Password =  password;
            user.Gendar = short.Parse(gendar);
            user.ProvinceID = 0;
            user.CityID = 0;
            user.DistrictID = 0;
            AccountManager accountManager = new AccountManager();
            accountManager.LocalRegisterUser(user);
            User currentUser=accountManager.Login(user.Email,user.Password);
            if (currentUser != null)
            {
                Session["User"] = currentUser;
            }
            else {
                return Redirect("/Home/Index");
            }

            return RedirectToAction("Index");
        }