Exemple #1
0
        public ActionResult getHBLList(ParameterModel param)
        {
            param.cidx = (int)userInfo.cidx;
            var blListDto = blService.getHBLList(param).OrderByDescending(h => h.hidx);

            return(Json(blListDto.Select(u => new { u.hidx, u.MBL.mblNo, u.midx, u.HblNo, Status = u.CODE.CDNAME, u.OnBoardDate, u.ShipperName, u.ConsigneeName, u.CreateDate, u.Weight, WeightType = u.CODE3.CDNAME }), JsonRequestBehavior.AllowGet));
        }
        public ActionResult HblExport(int midx)
        {
            var hblList = blService.getHBLList(new ParameterModel {
                searchKey = "midx", searchText = midx.ToString()
            });

            GridView gv        = new GridView();
            var      excelData = new DataTable();

            excelData.Columns.Add("No");
            excelData.Columns.Add("MAWBNo");
            excelData.Columns.Add("HAWBNo");
            excelData.Columns.Add("주문번호");
            excelData.Columns.Add("발송일");
            excelData.Columns.Add("업체코드");
            excelData.Columns.Add("발송인이름");
            excelData.Columns.Add("주소");
            excelData.Columns.Add("city");
            excelData.Columns.Add("state");
            excelData.Columns.Add("우편번호");
            excelData.Columns.Add("전화번호");
            excelData.Columns.Add("수취인이름");
            excelData.Columns.Add("수취인우편번호");
            excelData.Columns.Add("주소1");
            excelData.Columns.Add("주소2");
            excelData.Columns.Add("수취인전화번호");
            excelData.Columns.Add("휴대폰");
            excelData.Columns.Add("메모");
            excelData.Columns.Add("주민번호");
            excelData.Columns.Add("통관고유번호");
            excelData.Columns.Add("통관구분");
            excelData.Columns.Add("항목구분");
            excelData.Columns.Add("HS코드");
            excelData.Columns.Add("무게");
            excelData.Columns.Add("Carton");
            excelData.Columns.Add("품명");
            excelData.Columns.Add("URL");
            excelData.Columns.Add("수량");
            excelData.Columns.Add("단가");
            excelData.Columns.Add("합계");
            int cnt    = 0;
            int hblidx = 0;

            foreach (var hbl in hblList)
            {
                hblidx++;
                DataRow row = excelData.NewRow();
                row["No"]      = hblidx.ToString();
                row["MAWBNo"]  = hbl.MBL.mblNo;
                row["HAWBNo"]  = hbl.HblNo;
                row["주문번호"]    = "";
                row["발송일"]     = hbl.OnBoardDate;
                row["업체코드"]    = hbl.ShipperCd;
                row["발송인이름"]   = hbl.ShipperName;
                row["주소"]      = hbl.ShipperAddress;
                row["city"]    = hbl.ShipperCity;
                row["state"]   = hbl.ShipperState;
                row["우편번호"]    = hbl.ShipperZipCode;
                row["전화번호"]    = hbl.ShipperPhone;
                row["수취인이름"]   = hbl.ConsigneeName;
                row["수취인우편번호"] = hbl.ConsigneeZipCode;
                row["주소1"]     = hbl.ConsigneeZipAddress;
                row["주소2"]     = hbl.ConsigneeAddress;
                row["수취인전화번호"] = hbl.ConsigneePhone;
                row["휴대폰"]     = hbl.ConsigneeCellPhone;
                row["메모"]      = hbl.Memo;
                row["주민번호"]    = hbl.juminNo;
                row["통관고유번호"]  = "";
                row["통관구분"]    = hbl.CODE2.CD;
                row["항목구분"]    = "";
                row["HS코드"]    = "";
                row["무게"]      = hbl.Weight;
                row["Carton"]  = hbl.Carton;
                row["품명"]      = "";
                row["URL"]     = "";
                row["수량"]      = "";
                row["단가"]      = "";
                row["합계"]      = "";
                excelData.Rows.Add(row);
                int itemCnt = 0;
                foreach (var item in hbl.PRODUCTITEM)
                {
                    if (itemCnt == 0)
                    {
                        excelData.Rows[cnt]["품명"]  = item.itemName;
                        excelData.Rows[cnt]["URL"] = item.url;
                        excelData.Rows[cnt]["수량"]  = item.itemQty;
                        excelData.Rows[cnt]["단가"]  = item.itemAmt;
                        excelData.Rows[cnt]["합계"]  = item.ItemTotalAmt;
                    }
                    else
                    {
                        var itemRow = excelData.NewRow();
                        itemRow["품명"]  = item.itemName;
                        itemRow["URL"] = item.url;
                        itemRow["수량"]  = item.itemQty;
                        itemRow["단가"]  = item.itemAmt;
                        itemRow["합계"]  = item.ItemTotalAmt;
                        excelData.Rows.InsertAt(itemRow, cnt + 1);
                        cnt++;
                    }
                    itemCnt++;
                }
                cnt++;
            }
            gv.DataSource = excelData;
            gv.DataBind();

            Response.ClearContent();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", "attachment; filename=ConsoleList.xls");
            Response.ContentType     = "application/ms-excel";
            Response.Charset         = "euc-kr";
            Response.ContentEncoding = System.Text.Encoding.GetEncoding("euc-kr");
            StringWriter   sw  = new StringWriter();
            HtmlTextWriter htw = new HtmlTextWriter(sw);

            gv.RenderControl(htw);
            Response.Output.Write(sw.ToString());
            Response.Flush();
            Response.End();

            return(View());
        }
Exemple #3
0
        public ActionResult DownloadPDF(int midx)
        {
            KoreanRomanizer converter = new KoreanRomanizer();

            var param = new ParameterModel();

            param.midx       = midx;
            param.searchKey  = "midx";
            param.searchText = midx.ToString();
            var mblModel = blService.getMBL(param);
            var hblModel = blService.getHBLList(param);
            var mblTable = new DataTable();
            var hblTable = new DataTable();

            mblTable.Columns.Add("FltNo");
            mblTable.Columns.Add("mblNo");
            mblTable.Columns.Add("FltDate");
            mblTable.Columns.Add("ArrivalDate");
            mblTable.Columns.Add("DptrCd");
            mblTable.Columns.Add("DestCd");
            mblTable.Columns.Add("ShipperAddress1");
            mblTable.Columns.Add("ShipperName");
            mblTable.Columns.Add("CneeName");
            mblTable.Columns.Add("CneePhone");
            var dataRow = mblTable.NewRow();

            dataRow["FltNo"]           = mblModel.FltNo;
            dataRow["mblNo"]           = mblModel.mblNo;
            dataRow["FltDate"]         = mblModel.FltDate;
            dataRow["ArrivalDate"]     = mblModel.ArrivalDate;
            dataRow["DptrCd"]          = mblModel.DptrCd;
            dataRow["DestCd"]          = mblModel.DestCd;
            dataRow["ShipperAddress1"] = mblModel.CUSTOMER.CustFullAddress;
            dataRow["ShipperName"]     = mblModel.CUSTOMER.CustEngName;
            dataRow["CneeName"]        = mblModel.CUSTOMER1.CustEngName;
            dataRow["CneePhone"]       = mblModel.CUSTOMER1.WPhone;
            mblTable.Rows.Add(dataRow);
            //dataRow
            hblTable.Columns.Add("HblNo");
            hblTable.Columns.Add("ShipperName");
            hblTable.Columns.Add("ShipperAddress");
            hblTable.Columns.Add("ConsigneeName");
            hblTable.Columns.Add("ConsigneeAddress");
            hblTable.Columns.Add("Carton", typeof(int));
            hblTable.Columns.Add("Value", typeof(decimal));
            hblTable.Columns.Add("Weight", typeof(decimal));
            hblTable.Columns.Add("Memo");
            foreach (var item in hblModel)
            {
                var conEngName = item.ConsigneeEngName;
                if (string.IsNullOrEmpty(conEngName))
                {
                    conEngName = converter.romanize(item.ConsigneeName);
                }

                var newRow = hblTable.NewRow();
                newRow["HblNo"]            = item.HblNo;
                newRow["ShipperName"]      = item.ShipperName;
                newRow["ShipperAddress"]   = item.ShipperAddress + item.ShipperZipAddress + "\r" + ((item.ShipperZipCode ?? "").Length == 4?"0":"") + item.ShipperZipCode;
                newRow["ConsigneeName"]    = conEngName;
                newRow["ConsigneeAddress"] = item.EngAddress + item.EngZipaddress + "\r" + item.ConsigneeZipCode;
                newRow["Carton"]           = item.Carton;
                newRow["Value"]            = item.PRODUCTITEM.Sum(i => i.ItemTotalAmt);
                newRow["Weight"]           = item.Weight;
                newRow["Memo"]             = string.Join("\r", item.PRODUCTITEM.Select(i => i.itemName).Take(3)) + (item.PRODUCTITEM.Count() > 3 ? "\r..." : "");
                hblTable.Rows.Add(newRow);
            }

            ReportDocument rd = new ReportDocument();

            rd.Load(Path.Combine(Server.MapPath("~/Reports"), "Manifest.rpt"));
            //rd.SetDataSource(getHblList(param));
            rd.Database.Tables[0].SetDataSource(hblTable);
            rd.Database.Tables[1].SetDataSource(mblTable);
            Response.Buffer = false;
            Response.ClearContent();
            Response.ClearHeaders();


            try
            {
                Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                stream.Seek(0, SeekOrigin.Begin);
                return(File(stream, "application/pdf", "Manifest.pdf"));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }