public async Task <int> Update(int id, GarmentCoverLetterViewModel viewModel) { viewModel.order = viewModel.order ?? new Buyer(); viewModel.forwarder = viewModel.forwarder ?? new Forwarder(); viewModel.shippingStaff = viewModel.shippingStaff ?? new ShippingStaff(); viewModel.emkl = viewModel.emkl ?? new EMKL(); GarmentShippingCoverLetterModel model = new GarmentShippingCoverLetterModel(viewModel.packingListId, viewModel.invoiceId, viewModel.invoiceNo, viewModel.date.GetValueOrDefault(), viewModel.emkl.Id, viewModel.emkl.Code, viewModel.emkl.Name, viewModel.destination, viewModel.address, viewModel.pic, viewModel.attn, viewModel.phone, viewModel.bookingDate.GetValueOrDefault(), viewModel.order.Id, viewModel.order.Code, viewModel.order.Name, viewModel.pcsQuantity, viewModel.setsQuantity, viewModel.packQuantity, viewModel.cartoonQuantity, viewModel.forwarder.id, viewModel.forwarder.code, viewModel.forwarder.name, viewModel.truck, viewModel.plateNumber, viewModel.driver, viewModel.containerNo, viewModel.freight, viewModel.shippingSeal, viewModel.dlSeal, viewModel.emklSeal, viewModel.exportEstimationDate.GetValueOrDefault(), viewModel.unit, viewModel.shippingStaff.id, viewModel.shippingStaff.name); return(await _repository.UpdateAsync(id, model)); }
public async Task <int> Create(GarmentCoverLetterViewModel viewModel) { viewModel.order = viewModel.order ?? new Buyer(); viewModel.forwarder = viewModel.forwarder ?? new Forwarder(); viewModel.shippingStaff = viewModel.shippingStaff ?? new ShippingStaff(); viewModel.emkl = viewModel.emkl ?? new EMKL(); GarmentShippingCoverLetterModel model = new GarmentShippingCoverLetterModel(viewModel.packingListId, viewModel.invoiceId, viewModel.invoiceNo, viewModel.date.GetValueOrDefault(), viewModel.emkl.Id, viewModel.emkl.Code, viewModel.emkl.Name, viewModel.destination, viewModel.address, viewModel.pic, viewModel.attn, viewModel.phone, viewModel.bookingDate.GetValueOrDefault(), viewModel.order.Id, viewModel.order.Code, viewModel.order.Name, viewModel.pcsQuantity, viewModel.setsQuantity, viewModel.packQuantity, viewModel.cartoonQuantity, viewModel.forwarder.id, viewModel.forwarder.code, viewModel.forwarder.name, viewModel.truck, viewModel.plateNumber, viewModel.driver, viewModel.containerNo, viewModel.freight, viewModel.shippingSeal, viewModel.dlSeal, viewModel.emklSeal, viewModel.exportEstimationDate.GetValueOrDefault(), viewModel.unit, viewModel.shippingStaff.id, viewModel.shippingStaff.name); var packingList = _packingListrepository.Query.SingleOrDefault(s => s.Id == model.PackingListId); var status = GarmentPackingListStatusEnum.DELIVERED; //&& packingList.Status != status if (packingList != null) { packingList.SetStatus(status, _identityProvider.Username, UserAgent); packingList.StatusActivities.Add(new GarmentPackingListStatusActivityModel(_identityProvider.Username, UserAgent, status)); } else { throw new Exception("Packing List " + model.PackingListId + " not found"); } return(await _repository.InsertAsync(model)); }
private GarmentCoverLetterViewModel MapToViewModel(GarmentShippingCoverLetterModel model) { GarmentCoverLetterViewModel viewModel = new GarmentCoverLetterViewModel { Active = model.Active, Id = model.Id, CreatedAgent = model.CreatedAgent, CreatedBy = model.CreatedBy, CreatedUtc = model.CreatedUtc, DeletedAgent = model.DeletedAgent, DeletedBy = model.DeletedBy, DeletedUtc = model.DeletedUtc, IsDeleted = model.IsDeleted, LastModifiedAgent = model.LastModifiedAgent, LastModifiedBy = model.LastModifiedBy, LastModifiedUtc = model.LastModifiedUtc, packingListId = model.PackingListId, invoiceId = model.InvoiceId, invoiceNo = model.InvoiceNo, date = model.Date, emkl = new EMKL { Name = model.Name, Id = model.EMKLId, Code = model.EMKLCode, //attn=model.ATTN, //address=model.Address, //phone=model.Phone }, destination = model.Destination, address = model.Address, pic = model.PIC, attn = model.ATTN, phone = model.Phone, bookingDate = model.BookingDate, order = new Buyer { Id = model.OrderId, Code = model.OrderCode, Name = model.OrderName }, pcsQuantity = model.PCSQuantity, setsQuantity = model.SETSQuantity, packQuantity = model.PACKQuantity, cartoonQuantity = model.CartoonQuantity, forwarder = new Forwarder { id = model.ForwarderId, code = model.ForwarderCode, name = model.ForwarderName, }, truck = model.Truck, plateNumber = model.PlateNumber, driver = model.Driver, containerNo = model.ContainerNo, freight = model.Freight, shippingSeal = model.ShippingSeal, dlSeal = model.DLSeal, emklSeal = model.EMKLSeal, exportEstimationDate = model.ExportEstimationDate, unit = model.Unit, shippingStaff = new ShippingStaff { id = model.ShippingStaffId, name = model.ShippingStaffName } }; return(viewModel); }
public MemoryStream GeneratePdfTemplate(GarmentCoverLetterViewModel viewModel, GarmentPackingListViewModel pl, Buyer buyer, int timeoffset) { const int MARGIN = 20; Font header_font_bold = FontFactory.GetFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 12); Font header_font = FontFactory.GetFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 11); Font normal_font = FontFactory.GetFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 8); Font normal_font_underlined = FontFactory.GetFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 8, Font.UNDERLINE); Font bold_font = FontFactory.GetFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 8); Font small_font = FontFactory.GetFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 5); //Font body_bold_font = FontFactory.GetFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 8); Document document = new Document(PageSize.A4, MARGIN, MARGIN, 140, MARGIN); MemoryStream stream = new MemoryStream(); PdfWriter writer = PdfWriter.GetInstance(document, stream); writer.PageEvent = new GarmentCoverLetterPdfTemplatePageEvent(); document.Open(); PdfPTable tableTitle = new PdfPTable(3); tableTitle.WidthPercentage = 100; tableTitle.SetWidths(new float[] { 2f, 2f, 2f }); PdfPCell cellTitle = new PdfPCell() { MinimumHeight = 15, Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_CENTER }; cellTitle.Phrase = new Phrase("Ref No. : FM-00-SP-24-008", header_font); tableTitle.AddCell(cellTitle); cellTitle.Phrase = new Phrase("SURAT PENGANTAR", header_font_bold); tableTitle.AddCell(cellTitle); cellTitle.Phrase = new Phrase(viewModel.invoiceNo, header_font); tableTitle.AddCell(cellTitle); tableTitle.SpacingAfter = 10; document.Add(tableTitle); #region header PdfPTable tableHeader = new PdfPTable(3); tableHeader.WidthPercentage = 100; tableHeader.SetWidths(new float[] { 3f, 1.5f, 2f }); PdfPCell cellHeaderLeft = new PdfPCell() { MinimumHeight = 15, Border = Rectangle.BOTTOM_BORDER | Rectangle.LEFT_BORDER | Rectangle.RIGHT_BORDER | Rectangle.TOP_BORDER, HorizontalAlignment = Element.ALIGN_LEFT }; cellHeaderLeft.Phrase = new Phrase("Kepada Yth.\n\n" + //$"{viewModel.emkl.Name} \n\n" + $"{viewModel.destination} \n" + $"{viewModel.address} \n" + $"PIC : {viewModel.pic} \n\n" + $"Forwarder : {viewModel.forwarder.name} \n\n" + $"ATTN : {viewModel.attn} \n" + $"PHONE : {viewModel.phone}", normal_font); cellHeaderLeft.Rowspan = 7; tableHeader.AddCell(cellHeaderLeft); cellHeaderLeft.Phrase = new Phrase("Tanggal", normal_font); cellHeaderLeft.Rowspan = 1; tableHeader.AddCell(cellHeaderLeft); cellHeaderLeft.Phrase = new Phrase(viewModel.date.GetValueOrDefault().ToOffset(new TimeSpan(timeoffset, 0, 0)).ToString("dd MMMM yyyy", new System.Globalization.CultureInfo("en-EN")), normal_font); tableHeader.AddCell(cellHeaderLeft); cellHeaderLeft.Phrase = new Phrase("Order ", normal_font); tableHeader.AddCell(cellHeaderLeft); cellHeaderLeft.Phrase = new Phrase(viewModel.order.Name, normal_font); tableHeader.AddCell(cellHeaderLeft); cellHeaderLeft.Phrase = new Phrase("Jumlah Pcs ", normal_font); tableHeader.AddCell(cellHeaderLeft); cellHeaderLeft.Phrase = new Phrase(viewModel.pcsQuantity == 0 ? "-" : $"{ string.Format("{0:n0}", viewModel.pcsQuantity)} PCS", normal_font); tableHeader.AddCell(cellHeaderLeft); cellHeaderLeft.Phrase = new Phrase("Jumlah Sets", normal_font); tableHeader.AddCell(cellHeaderLeft); cellHeaderLeft.Phrase = new Phrase(viewModel.setsQuantity == 0 ? "-" : $"{ string.Format("{0:n0}", viewModel.setsQuantity)} SETS", normal_font); tableHeader.AddCell(cellHeaderLeft); cellHeaderLeft.Phrase = new Phrase("Jumlah Packs", normal_font); tableHeader.AddCell(cellHeaderLeft); cellHeaderLeft.Phrase = new Phrase(viewModel.packQuantity == 0 ? "-" : $"{ string.Format("{0:n0}", viewModel.packQuantity)} PACKS", normal_font); tableHeader.AddCell(cellHeaderLeft); cellHeaderLeft.Phrase = new Phrase("Jumlah Collie", normal_font); tableHeader.AddCell(cellHeaderLeft); cellHeaderLeft.Phrase = new Phrase($"{ string.Format("{0:n0}", viewModel.cartoonQuantity)} COLLIE", normal_font); tableHeader.AddCell(cellHeaderLeft); cellHeaderLeft.Phrase = new Phrase("Invoice No.", normal_font); tableHeader.AddCell(cellHeaderLeft); cellHeaderLeft.Phrase = new Phrase(viewModel.invoiceNo, normal_font); tableHeader.AddCell(cellHeaderLeft); tableHeader.SpacingAfter = 10; document.Add(tableHeader); #endregion document.Add(new Paragraph("Dengan hormat,", normal_font)); document.Add(new Paragraph("\n", normal_font)); document.Add(new Paragraph(" Bersama ini kami kirimkan kepada Bapak sejumlah barang dengan", normal_font)); document.Add(new Paragraph("\n", normal_font)); document.Add(new Paragraph("\n", normal_font)); #region detail PdfPTable tableDetail = new PdfPTable(6); tableDetail.WidthPercentage = 100; tableDetail.SetWidths(new float[] { 1f, 1f, 1f, 1f, 1f, 1f }); PdfPCell cellDetail = new PdfPCell() { MinimumHeight = 15, Border = Rectangle.BOTTOM_BORDER | Rectangle.LEFT_BORDER | Rectangle.RIGHT_BORDER | Rectangle.TOP_BORDER, HorizontalAlignment = Element.ALIGN_LEFT }; double cbmtotal = 0; if (pl.Measurements.Count > 0) { foreach (var m in pl.Measurements) { double cbm = (m.Length * m.Width * m.Height * m.CartonsQuantity) / 1000000; cbmtotal += cbm; } } cellDetail.Phrase = new Phrase("Truck", normal_font); tableDetail.AddCell(cellDetail); cellDetail.Phrase = new Phrase("Nomor Polisi", normal_font); tableDetail.AddCell(cellDetail); cellDetail.Phrase = new Phrase("Pengemudi", normal_font); tableDetail.AddCell(cellDetail); cellDetail.Phrase = new Phrase("Seal Pelayaran", normal_font); tableDetail.AddCell(cellDetail); cellDetail.Phrase = new Phrase("Seal Dan Liris", normal_font); tableDetail.AddCell(cellDetail); cellDetail.Phrase = new Phrase("Jumlah Muatan", normal_font); tableDetail.AddCell(cellDetail); Paragraph Truck = new Paragraph($"EMKL : {viewModel.emkl.Name} \n\n" + $"Truk : {viewModel.truck}", normal_font); cellDetail.Phrase = Truck; cellDetail.VerticalAlignment = Element.ALIGN_TOP; tableDetail.AddCell(cellDetail); cellDetail.Phrase = new Phrase(viewModel.plateNumber, normal_font); tableDetail.AddCell(cellDetail); cellDetail.Phrase = new Phrase(viewModel.driver, normal_font); tableDetail.AddCell(cellDetail); cellDetail.Phrase = new Phrase(viewModel.shippingSeal, normal_font); tableDetail.AddCell(cellDetail); cellDetail.Phrase = new Phrase(viewModel.dlSeal, normal_font); tableDetail.AddCell(cellDetail); Paragraph weight = new Paragraph($"GW : {string.Format("{0:n2}", pl.GrossWeight)} KGS \n\n" + $"NW : {string.Format("{0:n2}", pl.NettWeight)} KGS \n\n" + $"Volume : {string.Format("{0:n2}", Math.Round(cbmtotal, 2))} m", normal_font); Chunk chunk = new Chunk("3", small_font); chunk.SetTextRise(2); Paragraph m2 = new Paragraph(chunk); m2.Alignment = Element.ALIGN_TOP; weight.Add(m2); cellDetail.Phrase = weight; cellDetail.VerticalAlignment = Element.ALIGN_TOP; tableDetail.AddCell(cellDetail); tableDetail.SpacingAfter = 10; document.Add(tableDetail); #endregion #region marks PdfPTable tableMark = new PdfPTable(4); tableMark.WidthPercentage = 100; tableMark.SetWidths(new float[] { 1f, 3f, 1f, 3f }); PdfPCell cellMark = new PdfPCell() { MinimumHeight = 15, Border = Rectangle.BOTTOM_BORDER, HorizontalAlignment = Element.ALIGN_LEFT }; cellMark.Phrase = new Phrase("Shippig Mark :", normal_font); cellMark.Rowspan = 2; tableMark.AddCell(cellMark); cellMark.Phrase = new Phrase(pl.ShippingMark, normal_font); tableMark.AddCell(cellMark); string sealType = ""; string seal = ""; if (!string.IsNullOrEmpty(viewModel.shippingSeal)) { sealType += "Seal Pelayaran \n"; seal += ": " + viewModel.shippingSeal + "\n"; } if (!string.IsNullOrEmpty(viewModel.dlSeal)) { sealType += "Seal DL \n"; seal += ": " + viewModel.dlSeal + "\n"; } if (!string.IsNullOrEmpty(viewModel.emklSeal)) { sealType += "Seal EMKL \n"; seal += ": " + viewModel.emklSeal + "\n"; } cellMark.Phrase = new Phrase(sealType, normal_font); cellMark.Rowspan = 1; cellMark.Border = Rectangle.NO_BORDER; cellMark.HorizontalAlignment = Element.ALIGN_LEFT; tableMark.AddCell(cellMark); cellMark.Phrase = new Phrase(seal, normal_font); cellMark.Rowspan = 1; cellMark.Border = Rectangle.NO_BORDER; cellMark.HorizontalAlignment = Element.ALIGN_LEFT; tableMark.AddCell(cellMark); //cellMark.Phrase = new Phrase("SEND TO :", normal_font); //cellMark.Colspan = 1; //cellMark.HorizontalAlignment = Element.ALIGN_RIGHT; //cellMark.Border = Rectangle.BOTTOM_BORDER; //tableMark.AddCell(cellMark); //cellMark.Phrase = new Phrase($"{buyer.Name} \n" + // $"{buyer.Address} \n", normal_font); //cellMark.HorizontalAlignment = Element.ALIGN_LEFT; //tableMark.AddCell(cellMark); //tableMark.SpacingAfter = 15; //document.Add(tableMark); #endregion document.Add(new Paragraph("Demikian harap diterima dengan baik dan terima kasih.", normal_font)); document.Add(new Paragraph("\n", normal_font)); document.Add(new Paragraph("\n", normal_font)); #region sign PdfPTable tableSign = new PdfPTable(5); tableSign.WidthPercentage = 100; tableSign.SetWidths(new float[] { 1f, 1f, 1f, 1f, 1f }); PdfPCell cellSign = new PdfPCell() { MinimumHeight = 15, Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_CENTER }; cellSign.Phrase = new Phrase("Pengemudi Truck, \n\n\n\n\n\n", normal_font); cellSign.Colspan = 1; tableSign.AddCell(cellSign); cellSign.Phrase = new Phrase("Mengetahui, \n\n\n\n\n\n", normal_font); cellSign.Colspan = 2; tableSign.AddCell(cellSign); cellSign.Phrase = new Phrase(" Hormat Kami, \n\n\n\n\n\n", normal_font); cellSign.Colspan = 1; tableSign.AddCell(cellSign); cellSign.Phrase = new Phrase(" \n\n\n\n\n\n", normal_font); cellSign.Colspan = 1; tableSign.AddCell(cellSign); cellSign.Phrase = new Phrase("__________________", normal_font); tableSign.AddCell(cellSign); cellSign.Phrase = new Phrase("__________________", normal_font); tableSign.AddCell(cellSign); cellSign.Phrase = new Phrase("__________________", normal_font); tableSign.AddCell(cellSign); cellSign.Phrase = new Phrase("__________________", normal_font); tableSign.AddCell(cellSign); cellSign.Phrase = new Phrase("( " + viewModel.shippingStaff.name + " )", normal_font); tableSign.AddCell(cellSign); cellSign.Phrase = new Phrase("", normal_font); tableSign.AddCell(cellSign); cellSign.Phrase = new Phrase("Pembukuan DL", normal_font); tableSign.AddCell(cellSign); cellSign.Phrase = new Phrase("Sat Pam", normal_font); tableSign.AddCell(cellSign); cellSign.Phrase = new Phrase("Konfeksi " + $"{viewModel.unit}", normal_font); tableSign.AddCell(cellSign); cellSign.Phrase = new Phrase("Shipping Staff", normal_font); tableSign.AddCell(cellSign); cellSign.Phrase = new Phrase("\n\n\n\n\n\n\n\n\n\n\n\n\n", normal_font); tableSign.AddCell(cellSign); cellSign.Phrase = new Phrase("\n\n\n\n\n\n\n\n\n\n\n\n\n", normal_font); tableSign.AddCell(cellSign); cellSign.Phrase = new Phrase("\n\n\n\n\n\n\n\n\n\n\n\n\n", normal_font); tableSign.AddCell(cellSign); cellSign.Phrase = new Phrase("\n\n\n\n\n\n\n\n\n\n\n\n\n", normal_font); tableSign.AddCell(cellSign); cellSign.Phrase = new Phrase("\n\n\n\n\n\n\n\n\n\n\n\n\n", normal_font); tableSign.AddCell(cellSign); cellSign.Phrase = new Phrase("JAM MASUK : ______", normal_font); tableSign.AddCell(cellSign); cellSign.Phrase = new Phrase(" ", normal_font); tableSign.AddCell(cellSign); cellSign.Phrase = new Phrase(" ", normal_font); tableSign.AddCell(cellSign); cellSign.Phrase = new Phrase(" ", normal_font); tableSign.AddCell(cellSign); cellSign.Phrase = new Phrase(" ", normal_font); tableSign.AddCell(cellSign); cellSign.Phrase = new Phrase("JAM KELUAR : ______", normal_font); tableSign.AddCell(cellSign); cellSign.Phrase = new Phrase(" ", normal_font); tableSign.AddCell(cellSign); cellSign.Phrase = new Phrase(" ", normal_font); tableSign.AddCell(cellSign); cellSign.Phrase = new Phrase(" ", normal_font); tableSign.AddCell(cellSign); cellSign.Phrase = new Phrase(" ", normal_font); tableSign.AddCell(cellSign); cellSign.Phrase = new Phrase("\n\n", normal_font); tableSign.AddCell(cellSign); cellSign.Phrase = new Phrase("\n\n", normal_font); tableSign.AddCell(cellSign); cellSign.Phrase = new Phrase("\n\n", normal_font); tableSign.AddCell(cellSign); cellSign.Phrase = new Phrase("\n\n", normal_font); tableSign.AddCell(cellSign); cellSign.Phrase = new Phrase("\n\n", normal_font); tableSign.AddCell(cellSign); cellSign.Phrase = new Phrase("CATATAN : \n" + "1. Mohon bisa dikirim kembali Pengantar ini apabila barang sudah diterima \n" + "2. ....................................................", normal_font); cellSign.Colspan = 3; cellSign.HorizontalAlignment = Element.ALIGN_LEFT; tableSign.AddCell(cellSign); cellSign.Phrase = new Phrase("Diterima, \n\n\n\n\n\n", normal_font); cellSign.Rowspan = 1; cellSign.HorizontalAlignment = Element.ALIGN_CENTER; tableSign.AddCell(cellSign); cellSign.Phrase = new Phrase("", normal_font); cellSign.Colspan = 3; cellSign.HorizontalAlignment = Element.ALIGN_LEFT; tableSign.AddCell(cellSign); cellSign.Phrase = new Phrase(" (__________________)", normal_font); cellSign.Rowspan = 1; tableSign.AddCell(cellSign); cellSign.Phrase = new Phrase(" ", normal_font); cellSign.Colspan = 3; cellSign.HorizontalAlignment = Element.ALIGN_LEFT; tableSign.AddCell(cellSign); cellSign.Phrase = new Phrase(" JAM DITERIMA : ______", normal_font); cellSign.Rowspan = 1; tableSign.AddCell(cellSign); document.Add(tableSign); #endregion document.Close(); byte[] byteInfo = stream.ToArray(); stream.Write(byteInfo, 0, byteInfo.Length); stream.Position = 0; return(stream); }