示例#1
0
        public void ProcessRequest(HttpContext context)
        {
            // -999
            context.Response.ContentType = "text/plain";
            HttpPostedFile file = context.Request.Files["FileData"];

            string tid = HttpUtility.HtmlEncode(context.Request.QueryString["pid"]);

            if (file != null)
            {
                string path  = context.Request["folder"] + "/Porduct/" + string.Format("{0:yyyyMMdd}", DateTime.Now) + "/";
                string apath = context.Request["folder"] + "/" + string.Format("{0:yyyyMMdd}", DateTime.Now) + "/";
                string uploadpath;
                if (tid == "-999")
                {
                    uploadpath = context.Server.MapPath(apath);
                }
                else
                {
                    uploadpath = context.Server.MapPath(path);
                }
                if (!Directory.Exists(uploadpath))
                {
                    Directory.CreateDirectory(uploadpath);
                }
                string fileNew = CreateRandomCode(22) + file.FileName.Substring(file.FileName.LastIndexOf("."));//  file.FileName;

                if (tid == "-999")
                {
                    DAO.ActiveImg img = new DAO.ActiveImg();
                    img.ActiveID   = -1;
                    img.ImgPath    = apath + fileNew;
                    img.Status     = 1;
                    img.UploadDate = DateTime.Now;
                    abll.AddActiveImg(img);
                }
                else
                {
                    DAO.ImgStock img = new DAO.ImgStock();
                    img.ImgPath    = path + fileNew;
                    img.PartID     = int.Parse(tid);
                    img.UploadDate = DateTime.Now;
                    bll.Add(img);
                }
                //DownRes upfiles = new DownRes();
                //upfiles.DT = Convert.ToInt32(tid);
                //upfiles.FileName = fileNew;
                //upfiles.FileSize = GetSize(file.ContentLength) ;
                //upfiles.UpDate = DateTime.Now;
                //upfiles.Add();
                file.SaveAs(uploadpath + fileNew);

                context.Response.Write("1");
            }
            else
            {
                context.Response.Write("0");
            }
        }
示例#2
0
        /// <summary>
        /// 获取购物车数据
        /// </summary>
        /// <param name="id"></param>
        /// <param name="AttID"></param>
        /// <returns></returns>
        public CarProductDetail GetProDetail(int id, int AttID, string atID = "-1")
        {
            CarProductDetail proDetail = new CarProductDetail();
            string           sql       = "select a.ID,a.CategoryID,a.PartName,a.PartModel,a.PartSuppyNo,a.Price,b.BrandName  from Parts a left join PartBrand b on a.PartBrand=b.ID where a.ID={0} ";
            CarProDetail     model     = db.Database.SqlQuery <CarProDetail>(string.Format(sql, id)).FirstOrDefault();

            if (model != null)
            {
                string       imgSql = " select * from ImgStock where PartID={0} ";
                DAO.ImgStock img    = db.Database.SqlQuery <DAO.ImgStock>(string.Format(imgSql, id)).FirstOrDefault();
                proDetail.imgStock = img;
                string            CSql = " select * from PartsCategory where ID={0} and IsShow=1 ";
                DAO.PartsCategory pc   = db.Database.SqlQuery <DAO.PartsCategory>(string.Format(CSql, model.CategoryID)).FirstOrDefault();
                proDetail.partCate = pc;

                PartExtendBll          extBll = new PartExtendBll();
                List <DAO.PartsExtend> att    = extBll.GetCarItems(id, AttID);
                proDetail.partExt = att;
                if (att.Count > 0)
                {
                    if (atID != "-1" && atID != null)
                    {
                        int            aid = int.Parse(atID);
                        DAO.ActiveAttr a   = db.ActiveAttr.Where(o => o.AProID == id && o.AtrrID == AttID && o.ActiveID == aid).FirstOrDefault();
                        if (a != null)
                        {
                            model.Price       = a.NewPrice;
                            proDetail.activeM = db.Active.Where(o => o.ID == aid).FirstOrDefault();
                        }
                    }
                    else
                    {
                        model.Price = att.Last().AttrPrice;
                    }
                }
                else
                {
                    if (atID != "-1" && atID != null)
                    {
                        int            aid = int.Parse(atID);
                        DAO.ActivePros p   = db.ActivePros.Where(o => o.ActiveID == aid && o.ProID == id).FirstOrDefault();
                        if (p != null)
                        {
                            model.Price       = p.NewPrice;
                            proDetail.activeM = db.Active.Where(o => o.ID == aid).FirstOrDefault();
                        }
                    }
                }

                proDetail.proDetail = model;
                return(proDetail);
            }
            else
            {
                return(null);
            }
        }