Beispiel #1
0
        public ActionResult SetSelectProductInfo(Product Product, string ImgPath)
        {
            Product tmpProduct = db.Products.FirstOrDefault(r => r.PID == Product.PID);

            tmpProduct.Title       = Product.Title;
            tmpProduct.MarketPrice = Product.MarketPrice;
            tmpProduct.Price       = Product.Price;
            tmpProduct.Discount    = Product.Discount;
            tmpProduct.Sale        = Product.Sale;
            tmpProduct.Stock       = Product.Stock;
            tmpProduct.PVCount     = Product.PVCount;
            tmpProduct.Date        = Product.Date;
            if (!string.IsNullOrEmpty(ImgPath))
            {
                string[] tmpArr = tmpProduct.ImgPathArr;
                tmpProduct.ImgPath = ImgPath + ";";
                for (int i = 1; i < tmpArr.Length; i++)
                {
                    tmpProduct.ImgPath += tmpArr[i] + ";";
                }
            }
            db.SaveChanges();
            if (Request.IsAjaxRequest())
            {
                string jsonStr = PubFunction.BuildResult("OK");
                return(Content(jsonStr));
            }
            else
            {
                return(View());
            }
        }
Beispiel #2
0
        //
        // GET: /CustomOrder/
        public ActionResult GetEnableCountry()
        {
            if (GlobalTemp.ForeignSupplyCountryHS == null)
            {
                GlobalTemp.ForeignSupplyCountryHS = new HashSet <string>();
                List <string> ReLST = (from re in db.ReUserRoles
                                       where re.RID == (int)Role.RoleTypeID.RT_FOREIGNSUPPLIER
                                       select re.Reserve).ToList();

                foreach (string tmpStr in ReLST)
                {
                    try
                    {
                        Hashtable tmpHT       = (Hashtable)JsonConvert.DeserializeObject(tmpStr, typeof(Hashtable));
                        string    countryName = tmpHT["Country"].ToString();
                        GlobalTemp.ForeignSupplyCountryHS.Add(countryName);
                    }
                    catch
                    {
                    }
                }
            }


            if (Request.IsAjaxRequest())
            {
                string jsonStr = PubFunction.BuildResult(GlobalTemp.ForeignSupplyCountryHS);
                return(Content(jsonStr));
            }
            else
            {
                return(View());
            }
        }
Beispiel #3
0
 public ActionResult submitEvaluation(Evaluation evaluation)
 {
     if (HttpContext.User.Identity.IsAuthenticated)
     {
         MyUser user = HttpContext.User as MyUser;
         if (user != null)
         {
             evaluation.UID = user.UID;
         }
         evaluation.DataTime = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
         db.Evaluations.Add(evaluation);
         db.SaveChanges();
         evaluation.User  = db.Users.FirstOrDefault(r => r.UID == evaluation.UID);
         evaluation.Order = db.Orders.FirstOrDefault(r => r.OID == evaluation.OID);
         EvaluationVM tmpEVM = new EvaluationVM(evaluation);
         if (Request.IsAjaxRequest())
         {
             string jsonStr = PubFunction.BuildResult(tmpEVM);
             return(Content(jsonStr));
         }
         else
         {
             return(View(tmpEVM));
         }
     }
     else
     {
         string jsonStr = PubFunction.BuildResult("Err");
         return(Content(jsonStr));
     }
 }
Beispiel #4
0
        public ActionResult SaveEditDetail(Product product, List <ShamOrderData> ShamOrderDataArr)
        {
            Product tmpProduct = db.Products.FirstOrDefault(r => r.PID == product.PID);

            tmpProduct.Title = product.Title;
            tmpProduct.EvaluationStarCount = product.EvaluationStarCount;
            tmpProduct.Price       = product.Price;
            tmpProduct.MarketPrice = product.MarketPrice;
            tmpProduct.Sale        = product.Sale;
            tmpProduct.Chose       = product.Chose;
            tmpProduct.Descript    = product.Descript;
            tmpProduct.ImgPath     = product.ImgPath;

            if (ShamOrderDataArr != null)
            {
                foreach (ShamOrderData item in ShamOrderDataArr)
                {
                    db.ShamOrderDatas.Add(item);
                }
            }
            db.SaveChanges();

            if (Request.IsAjaxRequest())
            {
                string jsonStr = PubFunction.BuildResult("OK");
                return(Content(jsonStr));
            }
            else
            {
                return(View());
            }
        }
Beispiel #5
0
        public ActionResult SaveAddDetail(Product product, List <ShamOrderData> ShamOrderDataArr)
        {
            Product tmpProduct = new Product();

            tmpProduct.Title = product.Title;
            tmpProduct.EvaluationStarCount = product.EvaluationStarCount;
            tmpProduct.Price       = product.Price;
            tmpProduct.MarketPrice = product.MarketPrice;
            tmpProduct.Sale        = product.Sale;
            tmpProduct.Chose       = product.Chose;
            tmpProduct.Descript    = product.Descript;
            tmpProduct.ImgPath     = product.ImgPath;
            //设置为其他
            Brand tmpBrand = db.Brands.FirstOrDefault(r => r.NameStr == "未知");

            if (tmpBrand == null)
            {
                tmpBrand             = new Brand();
                tmpBrand.CountryCode = 0;
                tmpBrand.Img         = "";
                tmpBrand.Important   = 0;
                tmpBrand.Name2       = "未知";
                tmpBrand.NameStr     = "未知";
                tmpBrand.Tag         = 999;
                db.Brands.Add(tmpBrand);
            }
            tmpProduct.Brand = tmpBrand;
            //设置为首页
            Category tmpCategory = db.Categorys.FirstOrDefault(r => r.NameStr == "未知");

            if (tmpCategory == null)
            {
                tmpCategory         = new Category();
                tmpCategory.NameStr = "未知";
                tmpCategory.Parent  = tmpCategory;
                tmpCategory.Tag     = 999;
                db.Categorys.Add(tmpCategory);
            }
            tmpProduct.Category = tmpCategory;
            db.Products.Add(tmpProduct);

            if (ShamOrderDataArr != null)
            {
                foreach (ShamOrderData item in ShamOrderDataArr)
                {
                    db.ShamOrderDatas.Add(item);
                }
            }
            db.SaveChanges();

            if (Request.IsAjaxRequest())
            {
                string jsonStr = PubFunction.BuildResult("OK");
                return(Content(jsonStr));
            }
            else
            {
                return(View());
            }
        }
Beispiel #6
0
        public ActionResult CancelOrder(int id)
        {
            //删除Cookie
            bool hasCookie = Request.Cookies.AllKeys.Contains("Order");

            if (hasCookie)
            {
                Response.Cookies["Order"].Expires = DateTime.MinValue;
            }

            //修改数据库Order的状态
            Order order = db.Orders.FirstOrDefault(r => r.OID == id);

            if (order != null)
            {
                db.Entry(order).State = EntityState.Deleted;
                db.SaveChanges();
            }
            if (Request.IsAjaxRequest())
            {
                string jsonStr = PubFunction.BuildResult("OK");
                return(Content(jsonStr));
            }
            else
            {
                return(View());
            }
        }
Beispiel #7
0
        public ActionResult ProductManager(int Tag, string Par, int BeginIndex, int GetCount, string OrderStr, string WhereStr)
        {
            int totalCount = db.Products.Count();

            GetCount = Math.Min(totalCount - BeginIndex, GetCount);
            StringBuilder SQLStr = new StringBuilder("SELECT TOP(");

            SQLStr.Append(GetCount);
            SQLStr.Append(") * FROM (SELECT TOP(");
            SQLStr.Append(totalCount - (BeginIndex + GetCount - 1));
            SQLStr.Append(") * FROM Products");
            if (!string.IsNullOrEmpty(WhereStr))
            {
                SQLStr.Append(" WHERE " + WhereStr);
            }
            string tmpOB1 = "", tmpOB2 = "";

            if (!string.IsNullOrEmpty(OrderStr))
            {
                SQLStr.Append(" ORDER BY ");
                string[] OrderArr = OrderStr.Split(new char[] { ';' });
                foreach (string itemArr in OrderArr)
                {
                    string[] itemStr = itemArr.Split(new char[] { ',' });
                    tmpOB1 = itemStr[0] + " " + (itemStr[1].ToUpper().CompareTo("DESC") == 0 ? "ASC" : "DESC");
                    tmpOB2 = itemStr[0] + " " + itemStr[1].ToUpper();
                }
                SQLStr.Append(tmpOB1);
            }
            SQLStr.Append(") as TEMPTB");

            if (!string.IsNullOrEmpty(OrderStr))
            {
                SQLStr.Append(" ORDER BY ");
                SQLStr.Append(tmpOB2);
            }
            List <Product> result = db.m_objcontext.ExecuteStoreQuery <Product>(SQLStr.ToString(), null).ToList();

            foreach (Product item in result)
            {
                item.REProColLST = (from rcp in db.ReColumnProducts
                                    where rcp.ProductID == item.PID
                                    select rcp).ToList();
            }
            if (Request.IsAjaxRequest())
            {
                string jsonStr = PubFunction.BuildResult(result);
                return(Content(jsonStr));
            }
            else
            {
                return(View(result));
            }
        }
Beispiel #8
0
        public ActionResult Login(string userID, string PSW, string checkCode)
        {
            //防止暴力破解
            //设置COOKIE过期
            if (Response.Cookies.AllKeys.Contains(FormsAuthentication.FormsCookieName))
            {
                Response.Cookies[FormsAuthentication.FormsCookieName].Expires = DateTime.MinValue;
            }

            if (userID == null || PSW == null)
            {
                return(RedirectToAction("Login", "Home"));
            }
            User user = null;

            if (Session["LPTAG"] != null && int.Parse(Session["LPTAG"].ToString()) == -1 &&
                (Session["Validate_code"] == null || (Session["Validate_code"] != null && checkCode != (Session["Validate_code"].ToString()))))
            {
                //ViewBag.LoginFail = -2;
                string jsonStr = PubFunction.BuildResult(user, Session["LPTAG"].ToString(), false, -2, "验证码错误");
                return(Content(jsonStr));
            }
            else if (Session["LPTAG"] != null && int.Parse(Session["LPTAG"].ToString()) == -2)
            {
                //ViewBag.LoginFail = -3;
                string tmpLOCK = new TimeSpan(0, 0, int.Parse(Session["LOGINLOCK"].ToString())).ToString();
                string jsonStr = PubFunction.BuildResult(user, Session["LPTAG"].ToString() + ",\"LOCK\":\"" + tmpLOCK + "\"", false, -3, "登陆异常");
                return(Content(jsonStr));
            }
            else
            {
                user = db.Users.FirstOrDefault(r => (r.LoginID == userID && r.LoginPSW == PSW));
                if (user != null)
                {
                    LoginSuccess(user);
                }
                else
                {
                    //ViewBag.LoginFail = -1;
                    string tmpStr  = Session["LPTAG"] != null ? Session["LPTAG"].ToString() : null;
                    string jsonStr = PubFunction.BuildResult(user, tmpStr, false, -1, "用户名或密码错误");
                    return(Content(jsonStr));
                }
            }
            if (Request.IsAjaxRequest())
            {
                string jsonStr = PubFunction.BuildResult(user);
                return(Content(jsonStr));
            }
            else
            {
                return(View(user));
            }
        }
Beispiel #9
0
        public ActionResult SearchResource(string searchText, int pageIndex)
        {
            if (pageIndex <= 1)
            {
                try
                {
                    SearchLog tmpLog = new SearchLog();
                    tmpLog.IPAddress   = Request.UserHostAddress;
                    tmpLog.LogDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    tmpLog.SearchStr   = searchText;
                    db.SearchLogs.Add(tmpLog);
                    db.SaveChanges();
                }
                catch
                {
                }
            }

            SearchResult result = new SearchResult();

            result.PageIndex = pageIndex;

            string htmlStr = HtmlReader.OpenSync(string.Format(SEARCHHTMLFORMAT, searchText, pageIndex));

            if (!string.IsNullOrEmpty(htmlStr))
            {
                HtmlAnalyser analyser             = new HtmlAnalyser(htmlStr);
                HtmlAnalyser.MagnetResult[] tmpMC = analyser.GetResult();
                result.Items = new List <ResourceItem>();
                foreach (HtmlAnalyser.MagnetResult item in tmpMC)
                {
                    ResourceItem resourceItem = new ResourceItem();
                    resourceItem.ResourceName = item.Description;
                    resourceItem.MagnetLink   = item.MargnetLink;
                    resourceItem.Date         = item.Date;
                    resourceItem.Size         = item.Size;
                    resourceItem.SeedLink     = item.SeedLink;
                    resourceItem.DetailUrl    = HOMEPAGEURL + item.DetailLink;
                    result.Items.Add(resourceItem);
                }
                result.PageCount = analyser.GetPageCount();
            }

            if (Request.IsAjaxRequest())
            {
                string jsonStr = PubFunction.BuildResult(result);
                return(Content(jsonStr));
            }
            else
            {
                return(View(result));
            }
        }
Beispiel #10
0
 public ActionResult GetTreeNodes()
 {
     if (Request.IsAjaxRequest())
     {
         //string jsonStr = Newtonsoft.Json.JsonConvert.SerializeObject(tmpVM);
         string jsonStr = PubFunction.BuildResult(db.Categorys);
         return(Content(jsonStr));
     }
     else
     {
         return(View(db.Categorys));
     }
 }
Beispiel #11
0
        public ActionResult getEvaluationByPID(int ID)
        {
            //获得销售记录
            int[] NCStatus = new int[] { (int)Order.EOrderStatus.OS_Init };
            List <OrderPacket> tmpOPLST  = db.OrderPackets.Where(r => r.PID == ID && !NCStatus.Contains(r.Order.Status)).ToList();
            List <int>         tmpOIDArr = (from opl in tmpOPLST
                                            select opl.Order.OID).Distinct().ToList();
            //只取前20条
            List <Evaluation> tmpELST = db.Evaluations.Where(r => tmpOIDArr.Contains(r.OID)).Take(20).ToList();

            if (Request.IsAjaxRequest())
            {
                string customStr = "";
                if (HttpContext.User.Identity.IsAuthenticated)
                {
                    MyUser tmpUser = HttpContext.User as MyUser;
                    //查找该用户是否有购买该产品并未提交评价的
                    OrderPacket tmpOP = db.OrderPackets.OrderByDescending(r => r.Order.OrderDate).FirstOrDefault(r => r.PID == ID && r.Order.UID == tmpUser.UID);
                    string      tmpME = "null";
                    if (tmpOP != null)
                    {
                        //已购买
                        Evaluation tmpEva = db.Evaluations.FirstOrDefault(r => r.PID == ID && r.OID == tmpOP.OID);
                        if (tmpEva != null)
                        {
                            //已评价
                            EvaluationVM tmpEVModel = new EvaluationVM(tmpEva);
                            tmpME = Newtonsoft.Json.JsonConvert.SerializeObject(tmpEVModel);
                        }
                    }
                    customStr = string.Format("{{\"buyedOID\":{0},\"myEvaluation\":{1}}}", tmpOP == null ? -1 : tmpOP.OID, tmpME);
                }
                List <EvaluationVM> tmpEVM = new List <EvaluationVM>(tmpELST.Count);
                foreach (Evaluation tmpE in tmpELST)
                {
                    tmpEVM.Add(new EvaluationVM(tmpE));
                }
                List <ShamOrderData> shamLST = db.ShamOrderDatas.Where(r => r.ProductID == ID).Take(20).ToList();
                foreach (ShamOrderData sham in shamLST)
                {
                    tmpEVM.Add(new EvaluationVM(sham));
                }
                tmpEVM.Sort((a, b) => b.DataTime.CompareTo(a.DataTime));
                string jsonStr = PubFunction.BuildResult(tmpEVM, customStr);
                return(Content(jsonStr));
            }
            else
            {
                return(View(tmpELST));
            }
        }
Beispiel #12
0
 public ActionResult DelShamEvaluation(int EID)
 {
     db.ShamOrderDatas.Remove(db.ShamOrderDatas.FirstOrDefault(r => r.SOID == EID));
     db.SaveChanges();
     if (Request.IsAjaxRequest())
     {
         string jsonStr = PubFunction.BuildResult("OK");
         return(Content(jsonStr));
     }
     else
     {
         return(View());
     }
 }
Beispiel #13
0
 public ActionResult SaveBannerManager(List <BannerItem> AddArr, List <BannerItem> EditArr, List <BannerItem> DelArr)
 {
     if (AddArr != null)
     {
         foreach (BannerItem item in AddArr)
         {
             BannerItem tmpObj = item;
             PubFunction.NotNullObj(ref tmpObj);
             db.BannerItems.Add(tmpObj);
         }
     }
     if (EditArr != null)
     {
         foreach (BannerItem item in EditArr)
         {
             BannerItem tmpObj = item;
             //奇怪,传进来的明明是""但是在后台获取就是null,只能做转换了
             PubFunction.NotNullObj(ref tmpObj);
             BannerItem tmpItem = db.BannerItems.FirstOrDefault(r => r.BIID == tmpObj.BIID);
             //tmpItem.Description = tmpObj.Description;
             //tmpItem.HrefPath = tmpObj.HrefPath;
             //tmpItem.ImgPath = tmpObj.ImgPath;
             //tmpItem.Index = tmpObj.Index;
             //tmpItem.Title = tmpObj.Title;
             PubFunction.CopyObj(tmpObj, ref tmpItem);
         }
     }
     if (DelArr != null)
     {
         foreach (BannerItem item in DelArr)
         {
             BannerItem tmpItem = db.BannerItems.FirstOrDefault(r => r.BIID == item.BIID);
             if (tmpItem != null)
             {
                 db.BannerItems.Remove(tmpItem);
             }
         }
     }
     db.SaveChanges();
     if (Request.IsAjaxRequest())
     {
         string jsonStr = PubFunction.BuildResult("OK");
         return(Content(jsonStr));
     }
     else
     {
         return(View());
     }
 }
Beispiel #14
0
        public ActionResult Save(CustomOrder customOrder)
        {
            db.CustomOrders.Add(customOrder);
            db.SaveChanges();

            if (Request.IsAjaxRequest())
            {
                string jsonStr = PubFunction.BuildResult("OK");
                return(Content(jsonStr));
            }
            else
            {
                return(View());
            }
        }
Beispiel #15
0
        public ActionResult getSaleLogByPID(int ID)
        {
            //获得销售记录
            string DTFormat = "yyyy-MM-dd hh:mm:ss";
            string DTF      = "M月d日";

            int[]              NCStatus = new int[] { (int)Order.EOrderStatus.OS_Init };
            string             DTStr    = DateTime.Now.AddMonths(-1).ToString(DTFormat);
            List <OrderPacket> tmpOPLST = db.OrderPackets.Where(r => r.PID == ID && !NCStatus.Contains(r.Order.Status) && r.Order.OrderDate.CompareTo(DTStr) > 0).ToList();
            DateTime           tmpDT    = DateTime.Now;
            string             EDTStr   = tmpDT.ToString(DTF);
            string             BDTStr;
            string             BDT, EDT = tmpDT.ToString(DTFormat);
            SaleLogVM          tmpSLVM = new SaleLogVM();

            tmpSLVM.DTStrArr     = new List <string>();
            tmpSLVM.CountArr     = new List <int>();
            tmpSLVM.BDTStrArr    = new List <string>();
            tmpSLVM.EDTStrArr    = new List <string>();
            tmpSLVM.ShamCountArr = new List <int>();
            for (int i = 0; i < 4; i++)
            {
                tmpDT  = tmpDT.AddDays(-7);
                BDT    = tmpDT.ToString(DTFormat);
                BDTStr = tmpDT.ToString(DTF);
                var opArr = from op in tmpOPLST
                            where op.Order.OrderDate.CompareTo(BDT) > 0 && op.Order.OrderDate.CompareTo(EDT) <= 0
                            select op;
                int shamCount = db.ShamOrderDatas.Count(r => r.Product.PID == ID && r.DateTime.CompareTo(BDT) > 0 && r.DateTime.CompareTo(EDT) <= 0);
                tmpSLVM.BDTStrArr.Insert(0, BDT);
                tmpSLVM.EDTStrArr.Insert(0, EDT);
                string tmpDTStr = string.Format("\"{0}\" 至 \"{1}\"", BDTStr, EDTStr);
                tmpSLVM.DTStrArr.Insert(0, tmpDTStr);
                tmpSLVM.CountArr.Insert(0, opArr.Sum(r => r.Count));
                tmpSLVM.ShamCountArr.Insert(0, shamCount);
                EDT    = BDT;
                EDTStr = BDTStr;
            }
            if (Request.IsAjaxRequest())
            {
                string jsonStr = PubFunction.BuildResult(tmpSLVM);
                return(Content(jsonStr));
            }
            else
            {
                return(View());
            }
        }
Beispiel #16
0
        public ActionResult GetSelectProductInColum(int id)
        {
            List <Product> productLST = (from recp in db.ReColumnProducts
                                         where recp.ColumnID == id
                                         select recp.Product).ToList();

            if (Request.IsAjaxRequest())
            {
                string jsonStr = PubFunction.BuildResult(productLST);
                return(Content(jsonStr));
            }
            else
            {
                return(View());
            }
        }
Beispiel #17
0
        public ActionResult DeletePacket(string id)
        {
            string[] tmpIDArr = id.Split(new char[] { ',' });
            int      OID      = int.Parse(tmpIDArr[0]);
            Order    tmpOrder = db.Orders.FirstOrDefault(r => r.OID == OID);

            if (tmpOrder != null)
            {
                string tmpStr = "";
                for (int i = 1; i < tmpIDArr.Length; i++)
                {
                    tmpStr = tmpIDArr[i];
                    int PID = int.Parse(tmpStr);
                    tmpOrder.Packets.RemoveAll(r => r.PacketID == PID);
                }
                db.SaveChanges();
                //添加到cookie里
                bool       hasCookie = Request.Cookies.AllKeys.Contains("Order");
                HttpCookie cookie    = null;
                if (!hasCookie)
                {
                    cookie         = new HttpCookie("Order");
                    cookie.Expires = DateTime.Now.AddMonths(1);
                }
                else
                {
                    cookie = Request.Cookies["Order"];
                }
                tmpStr = tmpOrder.OID.ToString() + ",";
                foreach (OrderPacket op in tmpOrder.Packets)
                {
                    tmpStr = op.Product.PID + "," + op.Count.ToString() + "," + op.Product.Title.Substring(0, Math.Min(20, op.Product.Title.Length)) + "," + op.Product.ImgPathArr[0] + ",";
                }
                cookie.Value = Server.UrlEncode(tmpStr);
                Response.Cookies.Add(cookie);
            }
            if (Request.IsAjaxRequest())
            {
                string jsonStr = PubFunction.BuildResult("OK");
                return(Content(jsonStr));
            }
            else
            {
                return(View());
            }
        }
Beispiel #18
0
        public ActionResult GetProductBrand(int id)
        {
            Product tmpProduct = db.Products.FirstOrDefault(r => r.PID == id);

            if (Request.IsAjaxRequest())
            {
                string jsonStr = PubFunction.BuildResult(new List <Brand>()
                {
                    tmpProduct.Brand
                });
                return(Content(jsonStr));
            }
            else
            {
                return(View());
            }
        }
Beispiel #19
0
 public ActionResult SetSelectBrandsInColum(int id, List <ReColumnBrand> Par)
 {
     db.m_objcontext.ExecuteStoreCommand("DELETE ReColumnBrands WHERE ColumnID = " + id);
     foreach (ReColumnBrand item in Par)
     {
         db.ReColumnBrands.Add(item);
     }
     db.SaveChanges();
     if (Request.IsAjaxRequest())
     {
         string jsonStr = PubFunction.BuildResult("OK");
         return(Content(jsonStr));
     }
     else
     {
         return(View());
     }
 }
Beispiel #20
0
        public ActionResult LoginByQQ(string openID, string accessToken)
        {
            //判断该QQ是否已有账号关联
            User user = db.Users.FirstOrDefault(r => r.QQOpenID == openID);

            if (user != null)
            {
                LoginSuccess(user);
            }
            if (Request.IsAjaxRequest())
            {
                string jsonStr = PubFunction.BuildResult(user);
                return(Content(jsonStr));
            }
            else
            {
                return(View());
            }
        }
Beispiel #21
0
        public ActionResult LoginByWB(string wbId)
        {
            //判断该微博号是否已有账号关联
            User user = db.Users.FirstOrDefault(r => r.WBID == wbId);

            if (user != null)
            {
                LoginSuccess(user);
            }
            if (Request.IsAjaxRequest())
            {
                string jsonStr = PubFunction.BuildResult(user);
                return(Content(jsonStr));
            }
            else
            {
                return(View());
            }
        }
Beispiel #22
0
 public ActionResult SaveColumnManager(List <Column> AddArr, List <Column> EditArr, List <Column> DelArr)
 {
     if (AddArr != null)
     {
         foreach (Column item in AddArr)
         {
             Column tmpObj = item;
             PubFunction.NotNullObj(ref tmpObj);
             db.Columns.Add(tmpObj);
         }
     }
     if (EditArr != null)
     {
         foreach (Column item in EditArr)
         {
             Column tmpObj = item;
             PubFunction.NotNullObj(ref tmpObj);
             Column tmpItem = db.Columns.FirstOrDefault(r => r.ColumnID == tmpObj.ColumnID);
             PubFunction.CopyObj(tmpObj, ref tmpItem);
         }
     }
     if (DelArr != null)
     {
         foreach (Column item in DelArr)
         {
             Column tmpItem = db.Columns.FirstOrDefault(r => r.ColumnID == item.ColumnID);
             if (tmpItem != null)
             {
                 db.Columns.Remove(tmpItem);
             }
         }
     }
     db.SaveChanges();
     if (Request.IsAjaxRequest())
     {
         string jsonStr = PubFunction.BuildResult("OK");
         return(Content(jsonStr));
     }
     else
     {
         return(View());
     }
 }
Beispiel #23
0
        public ActionResult DelProductsByCIDArr(int[] CIDArr)
        {
            string CIDArrStr = "";

            foreach (int CID in CIDArr)
            {
                CIDArrStr += CID + ",";
            }
            CIDArrStr = CIDArrStr.TrimEnd(new char[] { ',' });
            db.m_objcontext.ExecuteStoreCommand("DELETE Products WHERE CID IN (" + CIDArrStr + ")");
            if (Request.IsAjaxRequest())
            {
                string jsonStr = PubFunction.BuildResult("OK");
                return(Content(jsonStr));
            }
            else
            {
                return(View());
            }
        }
Beispiel #24
0
        public ActionResult SetProductBrand(int PID, int BID)
        {
            Product tmpProduct = db.Products.FirstOrDefault(r => r.PID == PID);

            if (tmpProduct != null)
            {
                tmpProduct.BID = BID;
                db.SaveChanges();
            }

            if (Request.IsAjaxRequest())
            {
                string jsonStr = PubFunction.BuildResult("OK");
                return(Content(jsonStr));
            }
            else
            {
                return(View());
            }
        }
Beispiel #25
0
        public ActionResult ShowProductsByPIDArr(int[] PIDArr, int ShowTag)
        {
            string PIDArrStr = "";

            foreach (int PID in PIDArr)
            {
                PIDArrStr += PID + ",";
            }
            PIDArrStr = PIDArrStr.TrimEnd(new char[] { ',' });
            db.m_objcontext.ExecuteStoreCommand("UPDATE Products SET ShowTag = " + ShowTag + " WHERE PID IN (" + PIDArrStr + ")");
            if (Request.IsAjaxRequest())
            {
                string jsonStr = PubFunction.BuildResult("OK");
                return(Content(jsonStr));
            }
            else
            {
                return(View());
            }
        }
Beispiel #26
0
        public ActionResult SubmitOrder(int OrderID, int SendType, PacketObj[] packets)
        {
            string tmpResult = "OK";

            try
            {
                //提交订单
                MyUser tmpUser = HttpContext.User as MyUser;
                if (tmpUser != null)
                {
                    Order order = db.Orders.FirstOrDefault(r => r.OID == OrderID && r.UID == tmpUser.UID);
                    if (order != null)
                    {
                        order.SendType = SendType;
                        foreach (OrderPacket packet in order.Packets)
                        {
                            PacketObj tmpPacket = packets.FirstOrDefault(r => r.PacketID == packet.PacketID);
                            if (tmpPacket == null)
                            {
                                throw new Exception("Order Packet is different!");
                            }
                            packet.Count = tmpPacket.Count;
                        }
                        db.SaveChanges();
                    }
                }
            }
            catch
            {
                tmpResult = "Err";
            }
            if (Request.IsAjaxRequest())
            {
                string jsonStr = PubFunction.BuildResult(tmpResult);
                return(Content(jsonStr));
            }
            else
            {
                return(View());
            }
        }
Beispiel #27
0
        public ActionResult SelectDefaultAddress(int id)
        {
            //修改用户默认地址
            MyUser user = HttpContext.User as MyUser;

            if (HttpContext.User.Identity.IsAuthenticated && user != null)
            {
                User client = db.Users.FirstOrDefault(r => r.UID == user.UID);
                client.DefaultAddrID = id;
                db.SaveChanges();
            }
            if (Request.IsAjaxRequest())
            {
                string jsonStr = PubFunction.BuildResult("OK");
                return(Content(jsonStr));
            }
            else
            {
                return(View());
            }
        }
Beispiel #28
0
        //
        // GET: /Common/

        public ActionResult GetProvinceArr()
        {
            StringBuilder   jsonStr     = new StringBuilder("{\"ProvinceArr\":[");
            List <Province> ProvinceArr = db.Province.ToList();

            foreach (Province province in ProvinceArr)
            {
                jsonStr.AppendFormat("{{\"PID\":\"{0}\",\"PName\":\"{1}\"}},", province.ProvinceID, province.Name);
            }
            jsonStr.Remove(jsonStr.Length - 1, 1);
            jsonStr.Append("]}");
            if (Request.IsAjaxRequest())
            {
                string resultStr = PubFunction.BuildResult("OK", jsonStr.ToString());
                return(Content(resultStr));
            }
            else
            {
                return(View());
            }
        }
Beispiel #29
0
        public ActionResult GetBrandsInColumn(int id)
        {
            List <Brand> brands = (from recb in db.ReColumnBrands
                                   where recb.ColumnID == id
                                   select recb.Brand).ToList();

            //if (brands.Count == 0)
            //{
            //    brands.AddRange((from recp in db.ReColumnProducts
            //                     where recp.ColumnID == id
            //                     select recp.Product.Brand).Distinct().Take(5 - brands.Count));
            //}
            if (Request.IsAjaxRequest())
            {
                string jsonStr = PubFunction.BuildResult(brands);
                return(Content(jsonStr));
            }
            else
            {
                return(View());
            }
        }
Beispiel #30
0
        public ActionResult AddAddress(Address address)
        {
            db.Addresses.Add(address);
            MyUser tmpUser = HttpContext.User as MyUser;
            User   user    = null;

            if (tmpUser != null)
            {
                user = db.Users.Find(new object[] { tmpUser.UID });
            }
            user.DefaultAddress = address;
            user.Addresses.Add(address);
            db.SaveChanges();
            if (Request.IsAjaxRequest())
            {
                string jsonStr = PubFunction.BuildResult(address);
                return(Content(jsonStr));
            }
            else
            {
                return(View());
            }
        }