Exemple #1
0
        public ActionResult ExportInBondExBondRawMaterialReport(int?SearchBonderID, Nullable <System.DateTime> SearchFromDate, Nullable <System.DateTime> SearchToDate)
        {
            if (null != SearchBonderID && null != SearchFromDate && null != SearchToDate)
            {
                List <INBOND> inbondList = getInbondList(SearchBonderID, SearchFromDate, SearchToDate);

                List <BonderInfo> bonderInfoList = new List <BonderInfo>();
                BonderInfo        bonderInfo     = null;

                foreach (var inbondInfo in inbondList)
                {
                    bonderInfo            = new BonderInfo();
                    bonderInfo.BonderName = inbondInfo.BONDER.BONDERNAME;
                    bonderInfo.BonderLCNo = inbondInfo.LCNUMBER;

                    for (int i = 0; i < inbondInfo.INBONDRAWMATERIALs.Count; i++)
                    {
                        RawMaterialInfo rw = new RawMaterialInfo();
                        rw.BonderID        = (short)inbondInfo.BONDERID;
                        rw.RawMaterialName = inbondInfo.INBONDRAWMATERIALs[i].MATERIAL.MHSCODE;
                        rw.HSCode          = inbondInfo.INBONDRAWMATERIALs[i].MATERIAL.MHSCODE;

                        bonderInfo.RawMaterialInfoList.Add(rw);
                    }

                    bonderInfoList.Add(bonderInfo);
                }


                ReportDocument rd = new ReportDocument();
                rd.Load(Path.Combine(Server.MapPath("~/Report/Crystal"), "InBondExBondRawMaterialStatus_1.rpt"));

                rd.SetDataSource(DataSourceUtil.ToDataSet(bonderInfoList));

                rd.SetDatabaseLogon("", "", "", "");


                Response.Buffer = false;
                Response.ClearContent();
                Response.ClearHeaders();


                //rd.SetDatabaseLogon("", "", "192.168.40.55:1521/orcl", "");
                try
                {
                    Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                    stream.Seek(0, SeekOrigin.Begin);
                    return(File(stream, "application/pdf", "InBondRawMaterial.pdf"));
                }
                catch (Exception e)
                {
                    System.Diagnostics.Debug.WriteLine("ExportInBondExBondRawMaterialReport: Time-" + DateTime.Now + " Exception = " + e.ToString());
                    ViewBag.ErrorMsg = "Export InBondExBond Rawmaterial Report Development is On going";
                    throw e;
                }
            }
            //return Redirect(ControllerContext.HttpContext.Request.UrlReferrer.ToString());
            ViewBag.BonderID = new SelectList(db.BONDERs, "BONDERSLNO", "BONDERNAME");
            return(View("InbondExbondRawMaterialStatus"));
        }