Пример #1
0
        public JsonResult AddPdfBypic(string CoANo, string path, string CASNo)
        {
            string serverFilepath = Server.MapPath(string.Format("/Storage/PDF/{0}/ ", base.CurrentUser.Id));

            if (!System.IO.Directory.Exists(serverFilepath))
            {
                System.IO.Directory.CreateDirectory(serverFilepath);
            }
            string serverFileName = "CoAReports" + DateTime.Now.ToString("yyyyMMddHHmmssffff") + ".pdf";
            string pdfpath        = serverFilepath + serverFileName;

            string[] list = path.Split(';');
            Result   res  = new Result();

            res.success = ExportDataIntoPDF(pdfpath, list.ToList <string>());
            if (res.success)
            {
                string  str = ImgHelper.PostImg(pdfpath, "coapic");
                COAList cr  = new COAList()
                {
                    Addtime     = DateTime.Now,
                    CoANo       = CoANo,
                    URL         = str,
                    UserId      = base.CurrentUser.Id,
                    AddUserType = 2,
                    CASNo       = CASNo
                };
                ServiceHelper.Create <ICOAListService>().AddCoAReportInfo(cr);
            }

            return(Json(res));
        }
Пример #2
0
        public ActionResult Detail(long id)
        {
            OrderInfo order = ServiceHelper.Create <IOrderService>().GetOrder(id);

            ViewBag.Coupon = 0;
            foreach (var r in order.OrderItemInfo)
            {
                r.ImagePath     = ServiceHelper.Create <IProductService>().GetProduct(r.ProductId) == null ? "" : (ServiceHelper.Create <IProductService>().GetProduct(r.ProductId).ImagePath == null ? "" : ServiceHelper.Create <IProductService>().GetProduct(r.ProductId).ImagePath);
                r.ThumbnailsUrl = ServiceHelper.Create <IProductService>().GetProduct(r.ProductId) == null ? "" : (ServiceHelper.Create <IProductService>().GetProduct(r.ProductId).STRUCTURE_2D == null ? "" : ServiceHelper.Create <IProductService>().GetProduct(r.ProductId).STRUCTURE_2D);
            }

            ViewBag.COA = "";
            if (ServiceHelper.Create <IChemCloud_OrderWithCoaService>().GetChemCloud_OrderWithCoaByOrderid(id) != null)
            {
                string strcoa = ServiceHelper.Create <IChemCloud_OrderWithCoaService>().GetChemCloud_OrderWithCoaByOrderid(id).CoaNo;
                if (!string.IsNullOrEmpty(strcoa))
                {
                    COAList Coa = ServiceHelper.Create <ICOAListService>().GetCoAReportInfo(strcoa);
                    if (Coa != null)
                    {
                        string coaurl = ChemCloud.Core.Common.GetRootUrl("") + "/search/Search_COA?key=" + Coa.CoANo;
                        ViewBag.COA = coaurl;
                    }
                }
            }

            return(View(order));
        }
Пример #3
0
 public void AddCoAReportInfo(COAList cr)
 {
     if (cr == null)
     {
         return;
     }
     context.COAList.Add(cr);
     context.SaveChanges();
 }
Пример #4
0
        public ActionResult Search_COA(string key)
        {
            COAList Coa = ServiceHelper.Create <ICOAListService>().GetCoAReportInfo(key);

            if (Coa != null)
            {
                ViewBag.Url = Coa.URL;
            }
            return(View());
        }
Пример #5
0
        public void DeleteCoAReportInfo(long id)
        {
            COAList cr = context.COAList.FindById <COAList>(id);

            if (cr.Id == 0 || cr == null)
            {
                return;
            }
            context.COAList.Remove(cr);
            context.SaveChanges();
        }
Пример #6
0
        public JsonResult AddPdf(string CoANo, string filename, string CASNo)
        {
            COAList cr = new COAList()
            {
                Addtime     = DateTime.Now,
                CoANo       = CoANo,
                URL         = filename,
                UserId      = base.CurrentUser.Id,
                AddUserType = 2,
                CASNo       = CASNo
            };

            ServiceHelper.Create <ICOAListService>().AddCoAReportInfo(cr);
            Result res = new Result();

            res.success = true;
            return(Json(res));
        }
Пример #7
0
        public ActionResult Detail(long id)
        {
            OrderInfo          order = ServiceHelper.Create <IOrderService>().GetOrder(id, base.CurrentUser.Id);
            IEnumerable <long> nums  = (
                from d in order.OrderItemInfo
                select d.ProductId).AsEnumerable <long>();
            var list = (
                from d in ServiceHelper.Create <IProductService>().GetProductByIds(nums)
                select new { Id = d.Id, ProductCode = d.ProductCode }).ToList();

            foreach (OrderItemInfo orderItemInfo in order.OrderItemInfo)
            {
                var variable = list.Find((d) => d.Id == orderItemInfo.ProductId);
                if (variable == null)
                {
                    continue;
                }
                orderItemInfo.ProductCode = variable.ProductCode;
                orderItemInfo.Pub_CID     = ServiceHelper.Create <IProductService>().GetProduct(orderItemInfo.ProductId) == null ? 0 :
                                            (ServiceHelper.Create <IProductService>().GetProduct(orderItemInfo.ProductId).Pub_CID == null ? 0 : ServiceHelper.Create <IProductService>().GetProduct(orderItemInfo.ProductId).Pub_CID);
            }
            ViewBag.COA = "";
            if (ServiceHelper.Create <IChemCloud_OrderWithCoaService>().GetChemCloud_OrderWithCoaByOrderid(id) != null)
            {
                string strcoa = ServiceHelper.Create <IChemCloud_OrderWithCoaService>().GetChemCloud_OrderWithCoaByOrderid(id).CoaNo;
                if (!string.IsNullOrEmpty(strcoa))
                {
                    COAList Coa = ServiceHelper.Create <ICOAListService>().GetCoAReportInfo(strcoa);
                    if (Coa != null)
                    {
                        string coaurl = ChemCloud.Core.Common.GetRootUrl("") + "/search/Search_COA?key=" + Coa.CoANo;
                        ViewBag.COA = coaurl;
                    }
                }
            }


            ViewBag.ShopName = order.ShopName == null ? "" : order.ShopName;

            return(View(order));
        }
Пример #8
0
        //private Cell CreateCell(int cellID, Row row)
        //{
        //    Cell cell = row.GetCell(cellID) ?? row.CreateCell(cellID);
        //    return cell;
        //}

        //private Row CreateRow(int rowID, HSSFSheet excelSheet)
        //{
        //    Row row = excelSheet.GetRow(rowID) ?? excelSheet.CreateRow(rowID);
        //    return row;
        //}

        public ActionResult Detail(long id, bool updatePrice = false)
        {
            OrderInfo order = ServiceHelper.Create <IOrderService>().GetOrder(id);

            if (order == null || order.ShopId != base.CurrentSellerManager.ShopId)
            {
                throw new HimallException("订单已被删除,或者不属于该供应商!");
            }
            ViewBag.UpdatePrice = updatePrice;

            ViewBag.COA = "";
            if (ServiceHelper.Create <IChemCloud_OrderWithCoaService>().GetChemCloud_OrderWithCoaByOrderid(id) != null)
            {
                string strcoa = ServiceHelper.Create <IChemCloud_OrderWithCoaService>().GetChemCloud_OrderWithCoaByOrderid(id).CoaNo;
                if (!string.IsNullOrEmpty(strcoa))
                {
                    COAList Coa = ServiceHelper.Create <ICOAListService>().GetCoAReportInfo(strcoa);
                    if (Coa != null)
                    {
                        string coaurl = ChemCloud.Core.Common.GetRootUrl("") + "/search/Search_COA?key=" + Coa.CoANo;
                        ViewBag.COA = coaurl;
                    }
                }
            }

            foreach (var r in order.OrderItemInfo)
            {
                /*订单查看时候,加载cas#产品图片*/
                r.Id    = r.Id;
                r.CASNo = ServiceHelper.Create <ChemCloud.IServices.IProductService>().GetProduct(r.ProductId) != null?ServiceHelper.Create <ChemCloud.IServices.IProductService>().GetProduct(r.ProductId).CASNo : "";

                r.MolecularFormula = ServiceHelper.Create <ChemCloud.IServices.IProductService>().GetProduct(r.ProductId) != null?ServiceHelper.Create <ChemCloud.IServices.IProductService>().GetProduct(r.ProductId).MolecularFormula : "";

                r.Pub_CID = ServiceHelper.Create <IProductService>().GetProduct(r.ProductId) == null ? 0 : (ServiceHelper.Create <IProductService>().GetProduct(r.ProductId).Pub_CID == null ? 0 : ServiceHelper.Create <IProductService>().GetProduct(r.ProductId).Pub_CID);
            }
            return(View(order));
        }
Пример #9
0
        public JsonResult AddPdfByHtml(string CoANo, string Html, string titles, string CASNo, string Specification)
        {
            titles        = titles.Substring(0, titles.Length - 1);
            Specification = Specification.Substring(0, Specification.Length - 1);
            ChemCloud_COA model             = Newtonsoft.Json.JsonConvert.DeserializeObject <ChemCloud_COA>(Html);
            List <string> titlelist         = titles.Split(';').ToList <string>();
            List <string> SpecificationList = Specification.Split(';').ToList <string>();
            string        serverFilepath    = Server.MapPath(string.Format("/Storage/PDF/{0}/ ", base.CurrentUser.Id));

            if (!System.IO.Directory.Exists(serverFilepath))
            {
                System.IO.Directory.CreateDirectory(serverFilepath);
            }
            string serverFileName = "CoAReports" + DateTime.Now.ToString("yyyyMMddHHmmssffff") + ".pdf";
            Result res            = new Result();

            iTextSharp.text.Document document = new iTextSharp.text.Document(PageSize.A4);
            try
            {
                iTextSharp.text.pdf.PdfWriter.GetInstance(document, new FileStream(serverFilepath + serverFileName, FileMode.Create));
                document.Open();
                iTextSharp.text.pdf.BaseFont bfChinese     = iTextSharp.text.pdf.BaseFont.CreateFont("C:\\WINDOWS\\Fonts\\simsun.ttc,1", iTextSharp.text.pdf.BaseFont.IDENTITY_H, iTextSharp.text.pdf.BaseFont.NOT_EMBEDDED);
                iTextSharp.text.Font         Titlefont     = new iTextSharp.text.Font(bfChinese, 16, iTextSharp.text.Font.BOLD);
                iTextSharp.text.Font         titleDetial   = new iTextSharp.text.Font(bfChinese, 11, iTextSharp.text.Font.BOLD);
                iTextSharp.text.Font         normall       = new iTextSharp.text.Font(bfChinese, 11, iTextSharp.text.Font.NORMAL);
                iTextSharp.text.Font         newtable      = new iTextSharp.text.Font(bfChinese, 12, iTextSharp.text.Font.BOLD);
                iTextSharp.text.Font         newtableInner = new iTextSharp.text.Font(bfChinese, 12, iTextSharp.text.Font.NORMAL);
                Paragraph p = new Paragraph("CERTIFICATE OF ANALYSIS" + "\n\n", Titlefont);
                p.Alignment = iTextSharp.text.Element.ALIGN_CENTER;
                document.Add(p);
                PdfPTable table = new PdfPTable(4);
                table.DefaultCell.MinimumHeight = 30;
                table.SetWidths(new int[] { 35, 15, 35, 15 });
                PdfPCell cell;
                cell = new PdfPCell();
                Paragraph pCell;
                pCell = new Paragraph("CertificateNumber", titleDetial);
                table.AddCell(pCell);
                pCell = new Paragraph(model.CertificateNumber, normall);
                table.AddCell(pCell);
                pCell = new Paragraph("Suppiler", titleDetial);
                table.AddCell(pCell);
                pCell = new Paragraph(ServiceHelper.Create <IShopService>().GetShopName(base.CurrentSellerManager.ShopId), normall);
                table.AddCell(pCell);
                cell  = new PdfPCell();
                pCell = new Paragraph("Product Code", titleDetial);
                table.AddCell(pCell);
                pCell = new Paragraph(model.ProductCode, normall);
                table.AddCell(pCell);
                pCell = new Paragraph("Manufacturer's Batch #", titleDetial);
                table.AddCell(pCell);
                pCell = new Paragraph(model.ManufacturersBatchNo, normall);
                table.AddCell(pCell);
                cell  = new PdfPCell();
                pCell = new Paragraph("Product", titleDetial);
                table.AddCell(pCell);
                pCell = new Paragraph(model.ProductName, normall);
                table.AddCell(pCell);
                pCell = new Paragraph("Sydco's Lab.Batch #", titleDetial);
                table.AddCell(pCell);
                pCell = new Paragraph(model.SydcosLabBatchNo, normall);
                table.AddCell(pCell);
                cell  = new PdfPCell();
                pCell = new Paragraph("Date of Manufacture", titleDetial);
                table.AddCell(pCell);
                pCell = new Paragraph(model.DateofManufacture.ToShortDateString(), normall);
                table.AddCell(pCell);
                pCell = new Paragraph("ExpiryDate", titleDetial);
                table.AddCell(pCell);
                pCell = new Paragraph(model.ExpiryDate.ToShortDateString(), normall);
                table.AddCell(pCell);
                document.Add(table);
                Paragraph pfoot = new Paragraph("\n           The undersigned hereby certifies the following data to be true specification" + "\n\n\n\n\n", titleDetial);
                p.Alignment = iTextSharp.text.Element.ALIGN_CENTER;
                document.Add(pfoot);
                foreach (ChemCloud_COADetails item in model.ChemCloud_COADetails)
                {
                    PdfPTable table1 = new PdfPTable(3);
                    table1.DefaultCell.MinimumHeight = 30;
                    table1.SetWidths(new int[] { 40, 20, 35 });
                    pCell = new Paragraph("Tests", newtable);

                    table1.AddCell(pCell);
                    pCell = new Paragraph("Results", newtable);
                    table1.AddCell(pCell);
                    pCell = new Paragraph("Specifications(BP)", newtable);
                    table1.AddCell(pCell);
                    pCell = new Paragraph(titlelist[0], newtableInner);
                    table1.AddCell(pCell);
                    pCell = new Paragraph(item.Appearance, newtableInner);
                    table1.AddCell(pCell);
                    pCell = new Paragraph(SpecificationList[0], newtableInner);
                    table1.AddCell(pCell);
                    pCell = new Paragraph(titlelist[1], newtableInner);
                    table1.AddCell(pCell);
                    pCell = new Paragraph(item.IIdentity, newtableInner);
                    table1.AddCell(pCell);
                    pCell = new Paragraph(SpecificationList[1], newtableInner);
                    table1.AddCell(pCell);
                    pCell = new Paragraph(titlelist[2], newtableInner);
                    table1.AddCell(pCell);
                    pCell = new Paragraph(item.Carbonates, newtableInner);
                    table1.AddCell(pCell);
                    pCell = new Paragraph(SpecificationList[2], newtableInner);
                    table1.AddCell(pCell);
                    pCell = new Paragraph(titlelist[3], newtableInner);
                    table1.AddCell(pCell);
                    pCell = new Paragraph(item.Solubility, newtableInner);
                    table1.AddCell(pCell);
                    pCell = new Paragraph(SpecificationList[3], newtableInner);
                    table1.AddCell(pCell);
                    pCell = new Paragraph(titlelist[4], newtableInner);
                    table1.AddCell(pCell);
                    pCell = new Paragraph(item.Ammonium, newtableInner);
                    table1.AddCell(pCell);
                    pCell = new Paragraph(SpecificationList[4], newtableInner);
                    table1.AddCell(pCell);
                    pCell = new Paragraph(titlelist[5], newtableInner);
                    table1.AddCell(pCell);
                    pCell = new Paragraph(item.Calcium, newtableInner);
                    table1.AddCell(pCell);
                    pCell = new Paragraph(SpecificationList[5], newtableInner);
                    table1.AddCell(pCell);
                    pCell = new Paragraph(titlelist[6], newtableInner);
                    table1.AddCell(pCell);
                    pCell = new Paragraph(item.Arsenic, newtableInner);
                    table1.AddCell(pCell);
                    pCell = new Paragraph(SpecificationList[6], newtableInner);
                    table1.AddCell(pCell);
                    pCell = new Paragraph(titlelist[7], newtableInner);
                    table1.AddCell(pCell);
                    pCell = new Paragraph(item.HeavyMetals, newtableInner);
                    table1.AddCell(pCell);
                    pCell = new Paragraph(SpecificationList[7], newtableInner);
                    table1.AddCell(pCell);
                    pCell = new Paragraph(titlelist[8], newtableInner);
                    table1.AddCell(pCell);
                    pCell = new Paragraph(item.Iron, newtableInner);
                    table1.AddCell(pCell);
                    pCell = new Paragraph(SpecificationList[8], newtableInner);
                    table1.AddCell(pCell);
                    pCell = new Paragraph(titlelist[9], newtableInner);
                    table1.AddCell(pCell);
                    pCell = new Paragraph(item.Sulphates, newtableInner);
                    table1.AddCell(pCell);
                    pCell = new Paragraph(SpecificationList[9], newtableInner);
                    table1.AddCell(pCell);
                    pCell = new Paragraph(titlelist[10], newtableInner);
                    table1.AddCell(pCell);
                    pCell = new Paragraph(item.Chlorides, newtableInner);
                    table1.AddCell(pCell);
                    pCell = new Paragraph(SpecificationList[10], newtableInner);
                    table1.AddCell(pCell);
                    pCell = new Paragraph(titlelist[11], newtableInner);
                    table1.AddCell(pCell);
                    pCell = new Paragraph(item.Appearanceofsolution, newtableInner);
                    table1.AddCell(pCell);
                    pCell = new Paragraph(SpecificationList[11], newtableInner);
                    table1.AddCell(pCell);
                    pCell = new Paragraph(titlelist[12], newtableInner);
                    table1.AddCell(pCell);
                    pCell = new Paragraph(item.MicroStatus, newtableInner);
                    table1.AddCell(pCell);
                    pCell = new Paragraph(SpecificationList[12], newtableInner);
                    table1.AddCell(pCell);
                    document.Add(table1);
                    Paragraph ppp = new Paragraph("\n\n\n\n\n\n", titleDetial);
                    ppp.Alignment = iTextSharp.text.Element.ALIGN_CENTER;
                    document.Add(ppp);
                }
            }

            catch (Exception de)
            {
                res.success = false;
                return(Json(res));
            }
            document.Close();
            res.success = true;
            //string pdfpath1 = string.Format("/Storage/PDF/{0}/", base.CurrentUser.Id);
            string  str = ImgHelper.PostImg(serverFilepath + serverFileName, "coapic");
            COAList cr  = new COAList()
            {
                Addtime     = DateTime.Now,
                CoANo       = CoANo,
                URL         = str,
                UserId      = base.CurrentUser.Id,
                AddUserType = 2,
                CASNo       = CASNo
            };

            ServiceHelper.Create <ICOAListService>().AddCoAReportInfo(cr);
            return(Json(res));
        }