예제 #1
0
 public ActionResult UpdateRole(string keys, string type)
 {
     if (isLogin("RoleSetting"))
     {
         try
         {
             int key = Convert.ToInt16(Models.EncryptHandler.Decrypt(keys));
             Models.BookShopEntities4 db  = new Models.BookShopEntities4();
             Models.adminRole         anr = db.adminRole.Where(e => e.sysID == key).FirstOrDefault();
             if (anr != null)
             {
                 if (type == "allow")
                 {
                     anr.isLogin = "******";
                 }
                 else
                 {
                     anr.isLogin = "******";
                 }
             }
             db.SaveChanges();
             return(Content("操作成功"));
         }
         catch
         {
             return(Content("系统错误"));
         }
     }
     else
     {
         return(Content("权限不足"));
     }
 }
예제 #2
0
 public ActionResult OrderProcessing(string toName, string toAddress, string toPhone, string userPay)
 {
     if (Session["userLogin"] != null)
     {
         string uName = Session["userLogin"].ToString();
         Models.BookShopEntities4 db = new Models.BookShopEntities4();
         Models.orderInfo         oi = new Models.orderInfo()
         {
             submitTime = System.DateTime.Now.ToString(),
             toAddress  = toAddress,
             toName     = toName,
             toPhone    = toPhone,
             buyUser    = uName,
             orderState = "等待系统处理",
             payType    = userPay
         };
         db.orderInfo.Add(oi);
         db.SaveChanges();
         var deleteQuery = db.buyCar.Where(e => e.buyUser == uName);
         // var orderId = db.buyCar.Where(e => e.buyUser == uName);
         //Models. bCar = db.buyCar.Where(b => b.booksID == id && b.buyUser == uname).FirstOrDefault();
         foreach (var item in deleteQuery)
         {
             Models.bookInfo     binfo = db.bookInfo.Where(b => b.bookID == item.booksID).FirstOrDefault();
             Models.orderDetails od    = new Models.orderDetails()
             {
                 orderId   = oi.orderId,
                 bookId    = item.booksID,
                 bookPrice = binfo.bookPrice,
                 buyNum    = item.buyNum
             };
             db.orderDetails.Add(od);
             db.buyCar.Remove(item);
         }
         db.SaveChanges();
         Response.Write("<script language='javaScript' type='text/javaScript'>window.onload=function(){layer.alert('订单提交成功',function (){location='/My/MyOrder'});}</script>");
         return(View());
     }
     else
     {
         return(RedirectToAction("otherLogin", "Login", new { m = "My", a = "Settlement" }));
     }
 }
예제 #3
0
        public ActionResult addToBuyCar(int id)
        {
            if (Session["userLogin"] != null)
            {
                string uname=Session["userLogin"].ToString();
                Models.BookShopEntities4 db = new Models.BookShopEntities4();
                Models.bookInfo bi = db.bookInfo.Where(a => a.bookID == id && a.isDel != "Y").FirstOrDefault();
                if (bi != null)
                {
                    Models.buyCar bCar = db.buyCar.Where(b => b.booksID == id && b.buyUser == uname).FirstOrDefault();
                    string output = "";
                    if (bCar == null)
                    {
                        Models.buyCar newAdd = new Models.buyCar()
                        {
                            booksID = id,
                            buyNum = 1,
                            buyUser = Session["userLogin"].ToString()
                        };
                        db.buyCar.Add(newAdd);
                        output = "加入购物车成功";
                    }
                    else
                    {
                        Models.bookInfo binfo = db.bookInfo.Where(b => b.bookID == id).FirstOrDefault();
                        if (binfo.onlyBuy != null && bCar.buyNum >= binfo.onlyBuy)
                        {
                            bCar.buyNum = binfo.onlyBuy.Value;
                            output = "该商品有限购规则,仅允许购买" + binfo.onlyBuy.Value + "个,已将购物车中该商品数量调整为最大购买数量";
                        }
                        else
                        {
                            bCar.buyNum += 1;
                            output = "购物车中已存在该商品,商品数量加1";
                        }
                    }
                    db.SaveChanges();
                    return Content(output);
                }
                else
                {
                    return Content("该商品已经下架或者商品不存在,无法加入购物车");
                }

            }
            else {
                return Content("尚未登录,无法加入购物车,请先登录");
            }
        }
예제 #4
0
 public ActionResult addToBuyCar(int id)
 {
     if (Session["userLogin"] != null)
     {
         string uname = Session["userLogin"].ToString();
         Models.BookShopEntities4 db = new Models.BookShopEntities4();
         Models.bookInfo          bi = db.bookInfo.Where(a => a.bookID == id && a.isDel != "Y").FirstOrDefault();
         if (bi != null)
         {
             Models.buyCar bCar   = db.buyCar.Where(b => b.booksID == id && b.buyUser == uname).FirstOrDefault();
             string        output = "";
             if (bCar == null)
             {
                 Models.buyCar newAdd = new Models.buyCar()
                 {
                     booksID = id,
                     buyNum  = 1,
                     buyUser = Session["userLogin"].ToString()
                 };
                 db.buyCar.Add(newAdd);
                 output = "加入购物车成功";
             }
             else
             {
                 Models.bookInfo binfo = db.bookInfo.Where(b => b.bookID == id).FirstOrDefault();
                 if (binfo.onlyBuy != null && bCar.buyNum >= binfo.onlyBuy)
                 {
                     bCar.buyNum = binfo.onlyBuy.Value;
                     output      = "该商品有限购规则,仅允许购买" + binfo.onlyBuy.Value + "个,已将购物车中该商品数量调整为最大购买数量";
                 }
                 else
                 {
                     bCar.buyNum += 1;
                     output       = "购物车中已存在该商品,商品数量加1";
                 }
             }
             db.SaveChanges();
             return(Content(output));
         }
         else
         {
             return(Content("该商品已经下架或者商品不存在,无法加入购物车"));
         }
     }
     else
     {
         return(Content("尚未登录,无法加入购物车,请先登录"));
     }
 }
예제 #5
0
        public ActionResult userReg(string userName, string userPwd, string trueName, string userMail)
        {
            Models.BookShopEntities4 db2     = new Models.BookShopEntities4();
            Models.userInfo          newAdd2 = new Models.userInfo()
            {
                userName     = userName,
                userPwd      = userPwd,
                userMail     = userMail,
                userTureName = trueName
            };
            db2.userInfo.Add(newAdd2);
            int result = db2.SaveChanges();

            if (result > 0)
            {
                Response.Write("<script language='javaScript' type='text/javaScript'>window.onload=function(){layer.msg('注册成功,6秒之后转向登录', {icon: 1,time: 6000}, function(){window.location.href = '/My/Account';})}</script>");
            }
            else
            {
                Response.Write("<script language='javaScript' type='text/javaScript'>window.onload=function(){layer.msg('注册失败,5秒之后转向首页', {icon: 1,time: 5000}, function(){window.location.href = '/Home/Index';})}</script>");
            }
            return(View());
        }
예제 #6
0
 public ActionResult changeSkin()
 {
     if (Session["adminLogin"] != null)
     {
         if (Session["adminSkin"].ToString() == "navbar navbar-default")
         {
             Session["adminSkin"] = "navbar navbar-inverse";
         }
         else
         {
             Session["adminSkin"] = "navbar navbar-default";
         }
         Models.BookShopEntities4 db = new Models.BookShopEntities4();
         string           uName      = Session["adminLogin"].ToString();
         Models.adminInfo admini     = db.adminInfo.Where(e => e.adminName == uName).FirstOrDefault();
         admini.adminSkin = Session["adminSkin"].ToString();
         db.SaveChanges();
         return(RedirectToAction("MyDesktop", "Manage"));
     }
     else
     {
         return(RedirectToAction("Index", "Manage"));
     }
 }
예제 #7
0
 public ActionResult updateCartNum(int sysID, int newNum)
 {
     if (Session["userLogin"] != null)
     {
         string uname = Session["userLogin"].ToString();
         Models.BookShopEntities4 db   = new Models.BookShopEntities4();
         Models.buyCar            bCar = db.buyCar.Where(b => b.sysID == sysID && b.buyUser == uname).FirstOrDefault();
         int             id            = bCar.booksID;
         string          output        = "okay";
         Models.bookInfo binfo         = db.bookInfo.Where(b => b.bookID == id).FirstOrDefault();
         if (binfo.isDel != "Y")
         {
             if (binfo.onlyBuy != null && newNum >= binfo.onlyBuy)
             {
                 bCar.buyNum = binfo.onlyBuy.Value;
                 output      = "该商品有限购规则,仅允许购买" + binfo.onlyBuy.Value + "个,已将购物车中该商品数量调整为最大购买数量";
             }
             else
             {
                 bCar.buyNum = newNum;
                 output      = "okay";
             }
         }
         else
         {
             bCar.buyNum = 0;
             output      = "该商品已经下架或者不存在,数量自动调整为0个";
         }
         db.SaveChanges();
         return(Content(output));
     }
     else
     {
         return(Content("会话已失效,请重新登陆后再操作"));
     }
 }
예제 #8
0
 public ActionResult OrderProcessing(string toName, string toAddress, string toPhone, string userPay)
 {
     if (Session["userLogin"] != null)
     {
         string uName = Session["userLogin"].ToString();
         Models.BookShopEntities4 db = new Models.BookShopEntities4();
         Models.orderInfo oi=new Models.orderInfo ()
         {
             submitTime=System.DateTime.Now.ToString(),
             toAddress=toAddress,
             toName=toName,
             toPhone=toPhone,
             buyUser=uName,
             orderState="等待系统处理",
             payType = userPay
         };
         db.orderInfo.Add(oi);
         db.SaveChanges();
         var deleteQuery = db.buyCar.Where(e => e.buyUser == uName);
        // var orderId = db.buyCar.Where(e => e.buyUser == uName);
         //Models. bCar = db.buyCar.Where(b => b.booksID == id && b.buyUser == uname).FirstOrDefault();
         foreach (var item in deleteQuery)
         {
             Models.bookInfo binfo = db.bookInfo.Where(b => b.bookID == item.booksID).FirstOrDefault();
             Models.orderDetails od = new Models.orderDetails()
             {
                 orderId = oi.orderId,
                 bookId=item.booksID,
                 bookPrice=binfo.bookPrice,
                 buyNum=item.buyNum
             };
             db.orderDetails.Add(od);
             db.buyCar.Remove(item);
         }
         db.SaveChanges();
         Response.Write("<script language='javaScript' type='text/javaScript'>window.onload=function(){layer.alert('订单提交成功',function (){location='/My/MyOrder'});}</script>");
         return View();
     }
     else
     {
         return RedirectToAction("otherLogin", "Login", new { m = "My", a = "Settlement" });
     }
 }
예제 #9
0
        public ActionResult userAdmin(int? offset, string typeValue, string userKEY, string newAdminName, string newAdminPwd, string keyWords,string adminNick)
        {
            if (isLogin("userAdmin"))
            {
                Models.BookShopEntities4 db = new Models.BookShopEntities4();
                var adminInfo = db.adminInfo.Where(a => a.adminName != "sysAdmin").ToList();
                switch (typeValue)
                {
                    case "search":
                        adminInfo = db.adminInfo.Where(a => a.adminName != "sysAdmin" && a.adminName.Contains(keyWords)).ToList();
                        break;
                    case "deleteUser":
                        int keys = Convert.ToInt16(MyBookShop.Models.EncryptHandler.Decrypt(userKEY));
                        MyBookShop.Models.adminInfo ai = db.adminInfo.Where(a => a.adminID == keys).FirstOrDefault();
                        string uname = ai.adminName;
                        if (ai != null)
                        {
                            db.adminInfo.Remove(ai);
                        }
                        var allData = from a in db.adminRole
                                      where a.adminId == uname
                                      select a;
                        db.adminRole.RemoveRange(allData);
                        db.SaveChanges();
                        Response.Write("<script language='javaScript' type='text/javaScript'>window.onload=function(){layer.alert('删除用户成功',function (){location='/Manage/userAdmin'});}</script>");
                        adminInfo = db.adminInfo.Where(a => a.adminName != "sysAdmin").ToList();
                        break;
                    case "addUser":
                        MyBookShop.Models.adminInfo se = db.adminInfo.Where(a => a.adminName == newAdminName).FirstOrDefault();
                        if (se != null)
                        {
                            Response.Write("<script language='javaScript' type='text/javaScript'>window.onload=function(){layer.alert('该用户名已经存在,请勿重复',function (){location='/Manage/userAdmin'});}</script>");
                        }
                        else if (adminNick == "" || newAdminName==""||newAdminPwd=="")
                        {
                            Response.Write("<script language='javaScript' type='text/javaScript'>window.onload=function(){layer.alert('相应值不能为空,请输入',function (){location='/Manage/userAdmin'});}</script>");
                        }
                        else
                        {
                            Models.adminInfo newAdd = new Models.adminInfo()
                            {
                                adminNick=adminNick,
                                adminName = newAdminName,
                                adminPwd = newAdminPwd,
                                adminSkin = "navbar navbar-default"
                            };
                            db.adminInfo.Add(newAdd);
                            string[] myMenu =
                        { "订单总览","订单审核","订单状态更新","新增动态","管理动态","商品入库","商品库存更新",
                            "商品资料修改","会员信息查看","会员信息更新","会员状态调整" ,"用户管理","用户权限设定","修改密码"};
                            string[] myMenuAction =
                        { "AllOrder","OrderAudit","UpdateStatus","NewsEditor?type=addNews","NewsAdmin","商品入库","商品库存更新",
                            "商品资料修改","会员信息查看","会员信息更新","会员状态调整" ,"userAdmin","RoleSetting","changePwd"};
                            for (int i = 0; i < myMenu.Length; i++)
                            {
                                Models.adminRole ar = new Models.adminRole()
                                {
                                    adminId = newAdminName,
                                    functionName = myMenu[i],
                                    actionName = myMenuAction[i],
                                    isLogin = "******"
                                };
                                db.adminRole.Add(ar);
                            }
                            db.SaveChanges();
                            Response.Write("<script language='javaScript' type='text/javaScript'>window.onload=function(){layer.alert('新增用户成功',function (){location='/Manage/userAdmin'});}</script>");
                            adminInfo = db.adminInfo.Where(a => a.adminName != "sysAdmin").ToList();
                        }
                        break;
                    case "resetPwd":
                        int Nkey = Convert.ToInt16(MyBookShop.Models.EncryptHandler.Decrypt(userKEY));
                        MyBookShop.Models.adminInfo newai = db.adminInfo.Where(a => a.adminID == Nkey).FirstOrDefault();
                        if (newAdminPwd == "")
                        {
                            Response.Write("<script language='javaScript' type='text/javaScript'>window.onload=function(){layer.alert('新密码不能为空',function (){location='/Manage/userAdmin'});}</script>");

                        }
                        else
                        {
                            newai.adminPwd = newAdminPwd;
                            db.SaveChanges();
                            Response.Write("<script language='javaScript' type='text/javaScript'>window.onload=function(){layer.alert('重置用户密码成功',function (){location='/Manage/userAdmin'});}</script>");

                        }
                        break;
                }
                if (offset == null)
                    offset = 1;
                //通过指定路径将查询结果返回给指定视图(指定不同控制器的路径中必须包括View文件的后缀cshtml)
                if (offset == null)
                    offset = 1;
                //通过指定路径将查询结果返回给指定视图(指定不同控制器的路径中必须包括View文件的后缀cshtml)
                if (adminInfo.Count > 0)
                {
                    //创建分页模型类对象
                    Models.BasePageModel page =
                        new Models.BasePageModel() { ControllerName = "Manage", ActionName = "userAdmin", CurrentIndex = (int)offset, TotalCount = adminInfo.Count, PageSize = 10 };
                    //获取指定页码的图书数据集合(Ship是跳过指定数量的元素,返回剩余的元素,Take是返回指定数量的连续元素
                    var bookspageList = adminInfo.Skip((page.CurrentIndex - 1) * page.PageSize).Take(page.PageSize).ToList();
                    //向视图传递分页对象
                    ViewData["pagemodel"] = page;
                    //返回视图,传递当前页图书数据
                    return View(bookspageList);
                }
                return View(adminInfo);
            }
            else
            {
                return RedirectToAction("Error", "Manage");
            }
        }
예제 #10
0
        public ActionResult processOrder(string key)
        {
            if (isLogin("UpdateStatus"))
            {
                try
                {
                    string oid = key.Substring(1, key.Length - 1);
                    Int64 passid = Convert.ToInt64(oid);
                    string type = key.Substring(0, 1);
                    string state = "";
                    switch (type)
                    {
                        case "A":
                            state = "审核通过,等待仓库发货";
                            break;
                        case "B":
                            state = "已取消(用户主动取消)";
                            break;
                        case "C":
                            state = "已取消(后台系统取消)";
                            break;
                        case "D":
                            state = "已完成";
                            break;
                        case "E":
                            state = "状态异常,等待处理";
                            break;
                        case "F":
                            state = "订单作废";
                            break;
                        case "G":
                            state = "其他,等待处理";
                            break;
                        case "H":
                            state = "等待系统处理";
                            break;
                        case "I":
                            state = "已发货,等待用户收货";
                            break;
                        case "X":
                            state = "已退货";
                            break;

                    }
                    Models.BookShopEntities4 db = new Models.BookShopEntities4();
                    Models.orderInfo oi = db.orderInfo.Where(e => e.orderId == passid).FirstOrDefault();
                    string oldState = "";
                    if (oi != null)
                    {
                        oldState = oi.orderState;
                        oi.orderState = state;
                    }
                    db.SaveChanges();
                    return Content("状态已成功从【" + oldState + "】变更为【" + state + "】");
                }
                catch
                {
                    return Content("系统错误");
                }
            }
            else if (isLogin("OrderAudit"))
            {
                try
                {
                    string oid = key.Substring(1, key.Length - 1);
                    Int64 passid = Convert.ToInt64(oid);
                    string type = key.Substring(0, 1);
                    string state = "";
                    switch (type)
                    {
                        case "A":
                            state = "审核通过,等待仓库发货";
                            break;
                        case "E":
                            state = "状态异常,等待处理";
                            break;
                    }
                    Models.BookShopEntities4 db = new Models.BookShopEntities4();
                    Models.orderInfo oi = db.orderInfo.Where(e => e.orderId == passid).FirstOrDefault();
                    string oldState = "";
                    if (oi != null)
                    {
                        oldState = oi.orderState;
                        oi.orderState = state;
                    }
                    db.SaveChanges();
                    return Content("状态已成功从【" + oldState + "】变更为【" + state + "】");
                }
                catch
                {
                    return Content("系统错误");
                }
            }
            else
            {
                return RedirectToAction("Error", "Manage");
            }
        }
예제 #11
0
 public ActionResult UpdateRole(string keys,string type)
 {
     if (isLogin("RoleSetting"))
     {
         try
         {
             int key = Convert.ToInt16(Models.EncryptHandler.Decrypt(keys));
             Models.BookShopEntities4 db = new Models.BookShopEntities4();
             Models.adminRole anr = db.adminRole.Where(e => e.sysID == key).FirstOrDefault();
             if (anr != null)
             {
                 if (type == "allow")
                 {
                     anr.isLogin = "******";
                 }
                 else
                 {
                     anr.isLogin = "******";
                 }
             }
             db.SaveChanges();
             return Content("操作成功");
         }
         catch
         {
             return Content("系统错误");
         }
     }
     else
     {
         return Content("权限不足");
     }
 }
예제 #12
0
 public ActionResult changeSkin()
 {
     if (Session["adminLogin"] != null)
     {
         if (Session["adminSkin"].ToString() == "navbar navbar-default")
         {
             Session["adminSkin"] = "navbar navbar-inverse";
         }
         else
         {
             Session["adminSkin"] = "navbar navbar-default";
         }
         Models.BookShopEntities4 db = new Models.BookShopEntities4();
         string uName = Session["adminLogin"].ToString();
         Models.adminInfo admini = db.adminInfo.Where(e => e.adminName == uName).FirstOrDefault();
         admini.adminSkin = Session["adminSkin"].ToString();
         db.SaveChanges();
         return RedirectToAction("MyDesktop", "Manage");
     }
     else
     {
         return RedirectToAction("Index", "Manage");
     }
 }
예제 #13
0
        public ActionResult NewsOperation(string type,string content,string newsTitle,int? newsID)
        {
            if (type == "addNews")
            {
                if (isLogin("NewsEditor?type=addNews"))
                {
                    Models.BookShopEntities4 db = new Models.BookShopEntities4();
                            Models.newsInfo ni = new Models.newsInfo()
                            {
                                submitId = Session["adminLogin"].ToString(),
                                submitor = Session["adminNick"].ToString(),
                                newsContent = content,
                                newsTitle = newsTitle,
                                sumitTime = DateTime.Now
                            };
                            db.newsInfo.Add(ni);
                            db.SaveChanges();
                            Response.Write("<script language='javaScript' type='text/javaScript'>window.onload=function(){layer.alert('新增动态成功,页面跳转到动态管理',function (){location='/Manage/NewsAdmin'});}</script>");
                    return View();
                }
                else
                {
                    return RedirectToAction("Error", "Manage");
                }

            }
            else
            {
                if (isLogin("NewsAdmin"))
                {
                    Models.BookShopEntities4 db = new Models.BookShopEntities4();
                    switch (type)
                    {
                        case "deleteNews":
                            try
                            {
                                var dele = db.newsInfo.Where(a => a.newsId == newsID).FirstOrDefault();
                                db.newsInfo.Remove(dele);
                                db.SaveChanges();
                                Response.Write("<script language='javaScript' type='text/javaScript'>window.onload=function(){layer.alert('删除动态成功',function (){location='/Manage/NewsAdmin'});}</script>");
                            }
                            catch
                            {

                            }
                            break;
                        case "updateNews":
                            var up = db.newsInfo.Where(a => a.newsId == newsID).FirstOrDefault();
                            up.newsTitle = newsTitle;
                            up.newsContent = content;
                            db.SaveChanges();
                            Response.Write("<script language='javaScript' type='text/javaScript'>window.onload=function(){layer.alert('动态修改成功',function (){location='/Manage/NewsAdmin'});}</script>");
                            break;
                    }
                    return View();
                }
                else
                {
                    return RedirectToAction("Error", "Manage");
                }
            }
        }
예제 #14
0
        public ActionResult NewsOperation(string type, string content, string newsTitle, int?newsID)
        {
            if (type == "addNews")
            {
                if (isLogin("NewsEditor?type=addNews"))
                {
                    Models.BookShopEntities4 db = new Models.BookShopEntities4();
                    Models.newsInfo          ni = new Models.newsInfo()
                    {
                        submitId    = Session["adminLogin"].ToString(),
                        submitor    = Session["adminNick"].ToString(),
                        newsContent = content,
                        newsTitle   = newsTitle,
                        sumitTime   = DateTime.Now
                    };
                    db.newsInfo.Add(ni);
                    db.SaveChanges();
                    Response.Write("<script language='javaScript' type='text/javaScript'>window.onload=function(){layer.alert('新增动态成功,页面跳转到动态管理',function (){location='/Manage/NewsAdmin'});}</script>");
                    return(View());
                }
                else
                {
                    return(RedirectToAction("Error", "Manage"));
                }
            }
            else
            {
                if (isLogin("NewsAdmin"))
                {
                    Models.BookShopEntities4 db = new Models.BookShopEntities4();
                    switch (type)
                    {
                    case "deleteNews":
                        try
                        {
                            var dele = db.newsInfo.Where(a => a.newsId == newsID).FirstOrDefault();
                            db.newsInfo.Remove(dele);
                            db.SaveChanges();
                            Response.Write("<script language='javaScript' type='text/javaScript'>window.onload=function(){layer.alert('删除动态成功',function (){location='/Manage/NewsAdmin'});}</script>");
                        }
                        catch
                        {
                        }
                        break;

                    case "updateNews":
                        var up = db.newsInfo.Where(a => a.newsId == newsID).FirstOrDefault();
                        up.newsTitle   = newsTitle;
                        up.newsContent = content;
                        db.SaveChanges();
                        Response.Write("<script language='javaScript' type='text/javaScript'>window.onload=function(){layer.alert('动态修改成功',function (){location='/Manage/NewsAdmin'});}</script>");
                        break;
                    }
                    return(View());
                }
                else
                {
                    return(RedirectToAction("Error", "Manage"));
                }
            }
        }
예제 #15
0
 public ActionResult userReg(string userName, string userPwd, string trueName, string userMail)
 {
     Models.BookShopEntities4 db2 = new Models.BookShopEntities4();
     Models.userInfo newAdd2 = new Models.userInfo()
     {
         userName=userName,
         userPwd=userPwd,
         userMail=userMail,
         userTureName=trueName
     };
     db2.userInfo.Add(newAdd2);
     int result =db2.SaveChanges();
     if (result > 0)
     {
         Response.Write("<script language='javaScript' type='text/javaScript'>window.onload=function(){layer.msg('注册成功,6秒之后转向登录', {icon: 1,time: 6000}, function(){window.location.href = '/My/Account';})}</script>");
     }
     else
     {
         Response.Write("<script language='javaScript' type='text/javaScript'>window.onload=function(){layer.msg('注册失败,5秒之后转向首页', {icon: 1,time: 5000}, function(){window.location.href = '/Home/Index';})}</script>");
     }
     return View();
 }
예제 #16
0
        public ActionResult processOrder(string key)
        {
            if (isLogin("UpdateStatus"))
            {
                try
                {
                    string oid    = key.Substring(1, key.Length - 1);
                    Int64  passid = Convert.ToInt64(oid);
                    string type   = key.Substring(0, 1);
                    string state  = "";
                    switch (type)
                    {
                    case "A":
                        state = "审核通过,等待仓库发货";
                        break;

                    case "B":
                        state = "已取消(用户主动取消)";
                        break;

                    case "C":
                        state = "已取消(后台系统取消)";
                        break;

                    case "D":
                        state = "已完成";
                        break;

                    case "E":
                        state = "状态异常,等待处理";
                        break;

                    case "F":
                        state = "订单作废";
                        break;

                    case "G":
                        state = "其他,等待处理";
                        break;

                    case "H":
                        state = "等待系统处理";
                        break;

                    case "I":
                        state = "已发货,等待用户收货";
                        break;

                    case "X":
                        state = "已退货";
                        break;
                    }
                    Models.BookShopEntities4 db = new Models.BookShopEntities4();
                    Models.orderInfo         oi = db.orderInfo.Where(e => e.orderId == passid).FirstOrDefault();
                    string oldState             = "";
                    if (oi != null)
                    {
                        oldState      = oi.orderState;
                        oi.orderState = state;
                    }
                    db.SaveChanges();
                    return(Content("状态已成功从【" + oldState + "】变更为【" + state + "】"));
                }
                catch
                {
                    return(Content("系统错误"));
                }
            }
            else if (isLogin("OrderAudit"))
            {
                try
                {
                    string oid    = key.Substring(1, key.Length - 1);
                    Int64  passid = Convert.ToInt64(oid);
                    string type   = key.Substring(0, 1);
                    string state  = "";
                    switch (type)
                    {
                    case "A":
                        state = "审核通过,等待仓库发货";
                        break;

                    case "E":
                        state = "状态异常,等待处理";
                        break;
                    }
                    Models.BookShopEntities4 db = new Models.BookShopEntities4();
                    Models.orderInfo         oi = db.orderInfo.Where(e => e.orderId == passid).FirstOrDefault();
                    string oldState             = "";
                    if (oi != null)
                    {
                        oldState      = oi.orderState;
                        oi.orderState = state;
                    }
                    db.SaveChanges();
                    return(Content("状态已成功从【" + oldState + "】变更为【" + state + "】"));
                }
                catch
                {
                    return(Content("系统错误"));
                }
            }
            else
            {
                return(RedirectToAction("Error", "Manage"));
            }
        }
예제 #17
0
        public ActionResult userAdmin(int?offset, string typeValue, string userKEY, string newAdminName, string newAdminPwd, string keyWords, string adminNick)
        {
            if (isLogin("userAdmin"))
            {
                Models.BookShopEntities4 db = new Models.BookShopEntities4();
                var adminInfo = db.adminInfo.Where(a => a.adminName != "sysAdmin").ToList();
                switch (typeValue)
                {
                case "search":
                    adminInfo = db.adminInfo.Where(a => a.adminName != "sysAdmin" && a.adminName.Contains(keyWords)).ToList();
                    break;

                case "deleteUser":
                    int keys = Convert.ToInt16(MyBookShop.Models.EncryptHandler.Decrypt(userKEY));
                    MyBookShop.Models.adminInfo ai = db.adminInfo.Where(a => a.adminID == keys).FirstOrDefault();
                    string uname = ai.adminName;
                    if (ai != null)
                    {
                        db.adminInfo.Remove(ai);
                    }
                    var allData = from a in db.adminRole
                                  where a.adminId == uname
                                  select a;
                    db.adminRole.RemoveRange(allData);
                    db.SaveChanges();
                    Response.Write("<script language='javaScript' type='text/javaScript'>window.onload=function(){layer.alert('删除用户成功',function (){location='/Manage/userAdmin'});}</script>");
                    adminInfo = db.adminInfo.Where(a => a.adminName != "sysAdmin").ToList();
                    break;

                case "addUser":
                    MyBookShop.Models.adminInfo se = db.adminInfo.Where(a => a.adminName == newAdminName).FirstOrDefault();
                    if (se != null)
                    {
                        Response.Write("<script language='javaScript' type='text/javaScript'>window.onload=function(){layer.alert('该用户名已经存在,请勿重复',function (){location='/Manage/userAdmin'});}</script>");
                    }
                    else if (adminNick == "" || newAdminName == "" || newAdminPwd == "")
                    {
                        Response.Write("<script language='javaScript' type='text/javaScript'>window.onload=function(){layer.alert('相应值不能为空,请输入',function (){location='/Manage/userAdmin'});}</script>");
                    }
                    else
                    {
                        Models.adminInfo newAdd = new Models.adminInfo()
                        {
                            adminNick = adminNick,
                            adminName = newAdminName,
                            adminPwd  = newAdminPwd,
                            adminSkin = "navbar navbar-default"
                        };
                        db.adminInfo.Add(newAdd);
                        string[] myMenu =
                        { "订单总览",   "订单审核",   "订单状态更新", "新增动态",   "管理动态", "商品入库",   "商品库存更新",
                          "商品资料修改", "会员信息查看", "会员信息更新", "会员状态调整", "用户管理", "用户权限设定", "修改密码" };
                        string[] myMenuAction =
                        { "AllOrder", "OrderAudit", "UpdateStatus", "NewsEditor?type=addNews", "NewsAdmin", "商品入库",        "商品库存更新",
                          "商品资料修改",   "会员信息查看",     "会员信息更新",       "会员状态调整",                  "userAdmin", "RoleSetting", "changePwd" };
                        for (int i = 0; i < myMenu.Length; i++)
                        {
                            Models.adminRole ar = new Models.adminRole()
                            {
                                adminId      = newAdminName,
                                functionName = myMenu[i],
                                actionName   = myMenuAction[i],
                                isLogin      = "******"
                            };
                            db.adminRole.Add(ar);
                        }
                        db.SaveChanges();
                        Response.Write("<script language='javaScript' type='text/javaScript'>window.onload=function(){layer.alert('新增用户成功',function (){location='/Manage/userAdmin'});}</script>");
                        adminInfo = db.adminInfo.Where(a => a.adminName != "sysAdmin").ToList();
                    }
                    break;

                case "resetPwd":
                    int Nkey = Convert.ToInt16(MyBookShop.Models.EncryptHandler.Decrypt(userKEY));
                    MyBookShop.Models.adminInfo newai = db.adminInfo.Where(a => a.adminID == Nkey).FirstOrDefault();
                    if (newAdminPwd == "")
                    {
                        Response.Write("<script language='javaScript' type='text/javaScript'>window.onload=function(){layer.alert('新密码不能为空',function (){location='/Manage/userAdmin'});}</script>");
                    }
                    else
                    {
                        newai.adminPwd = newAdminPwd;
                        db.SaveChanges();
                        Response.Write("<script language='javaScript' type='text/javaScript'>window.onload=function(){layer.alert('重置用户密码成功',function (){location='/Manage/userAdmin'});}</script>");
                    }
                    break;
                }
                if (offset == null)
                {
                    offset = 1;
                }
                //通过指定路径将查询结果返回给指定视图(指定不同控制器的路径中必须包括View文件的后缀cshtml)
                if (offset == null)
                {
                    offset = 1;
                }
                //通过指定路径将查询结果返回给指定视图(指定不同控制器的路径中必须包括View文件的后缀cshtml)
                if (adminInfo.Count > 0)
                {
                    //创建分页模型类对象
                    Models.BasePageModel page =
                        new Models.BasePageModel()
                    {
                        ControllerName = "Manage", ActionName = "userAdmin", CurrentIndex = (int)offset, TotalCount = adminInfo.Count, PageSize = 10
                    };
                    //获取指定页码的图书数据集合(Ship是跳过指定数量的元素,返回剩余的元素,Take是返回指定数量的连续元素
                    var bookspageList = adminInfo.Skip((page.CurrentIndex - 1) * page.PageSize).Take(page.PageSize).ToList();
                    //向视图传递分页对象
                    ViewData["pagemodel"] = page;
                    //返回视图,传递当前页图书数据
                    return(View(bookspageList));
                }
                return(View(adminInfo));
            }
            else
            {
                return(RedirectToAction("Error", "Manage"));
            }
        }
예제 #18
0
 public ActionResult updateCartNum(int sysID,int newNum)
 {
     if (Session["userLogin"] != null)
     {
         string uname = Session["userLogin"].ToString();
         Models.BookShopEntities4 db = new Models.BookShopEntities4();
         Models.buyCar bCar = db.buyCar.Where(b => b.sysID == sysID && b.buyUser == uname).FirstOrDefault();
         int id = bCar.booksID;
         string output = "okay";
         Models.bookInfo binfo = db.bookInfo.Where(b => b.bookID == id).FirstOrDefault();
         if (binfo.isDel != "Y")
         {
             if (binfo.onlyBuy != null && newNum >= binfo.onlyBuy)
             {
                 bCar.buyNum = binfo.onlyBuy.Value;
                 output = "该商品有限购规则,仅允许购买" + binfo.onlyBuy.Value + "个,已将购物车中该商品数量调整为最大购买数量";
             }
             else
             {
                 bCar.buyNum = newNum;
                 output = "okay";
             }
         }
         else
         {
             bCar.buyNum = 0;
             output = "该商品已经下架或者不存在,数量自动调整为0个";
         }
         db.SaveChanges();
         return Content(output);
     }
     else
     {
         return Content("会话已失效,请重新登陆后再操作");
     }
 }