public async Task <IActionResult> Put([FromRoute] int id, [FromBody] VbWithPORequestViewModel viewModel) { try { VerifyUser(); _validateService.Validate(viewModel); if (id != viewModel.Id) { var result = new ResultFormatter(ApiVersion, General.BAD_REQUEST_STATUS_CODE, General.BAD_REQUEST_MESSAGE).Fail(); return(BadRequest(result)); } var model = _mapper.Map <VbRequestModel>(viewModel); await _service.UpdateAsync(id, viewModel); return(NoContent()); } catch (ServiceValidationException e) { var result = new ResultFormatter(ApiVersion, General.BAD_REQUEST_STATUS_CODE, General.BAD_REQUEST_MESSAGE).Fail(e); return(BadRequest(result)); } catch (Exception e) { var result = new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message).Fail(); return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, result)); } }
public async Task <ActionResult> Post([FromBody] VbWithPORequestViewModel viewModel) { try { VerifyUser(); _validateService.Validate(viewModel); var model = _mapper.Map <VbRequestModel>(viewModel); await _service.CreateAsync(model, viewModel); await _service.MappingData(viewModel); var result = new ResultFormatter(ApiVersion, General.CREATED_STATUS_CODE, General.OK_MESSAGE).Ok(); return(Created(String.Concat(Request.Path, "/", 0), result)); } catch (ServiceValidationException e) { var result = new ResultFormatter(ApiVersion, General.BAD_REQUEST_STATUS_CODE, General.BAD_REQUEST_MESSAGE).Fail(e); return(BadRequest(result)); } catch (Exception e) { var result = new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message) .Fail(); return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, result)); } }
public Task <int> MappingData(VbWithPORequestViewModel viewmodel) { var result = new List <VbRequestDetailModel>(); int value = int.Parse(_DbSet.OrderByDescending(p => p.Id) .Select(r => r.Id) .First().ToString()); string VbNo = _DbSet.OrderByDescending(p => p.Id) .Select(r => r.VBNo) .First().ToString(); foreach (var itm1 in viewmodel.Items) { foreach (var itm2 in itm1.Details) { var item = new VbRequestDetailModel() { VBNo = VbNo, PONo = itm1.no, //POId = itm1._id.GetValueOrDefault(), UnitName = itm1.unit.Name, VBId = value, ProductId = itm2.product._id, ProductCode = itm2.product.code, ProductName = itm2.product.name, DefaultQuantity = itm2.defaultQuantity, DefaultUOMId = itm2.defaultUom._id, DefaultUOMUnit = itm2.defaultUom.unit, DealQuantity = itm2.dealQuantity, DealUOMId = itm2.dealUom._id, DealUOMUnit = itm2.dealUom.unit, Conversion = itm2.Conversion, Price = itm2.priceBeforeTax, ProductRemark = itm2.productRemark, IsUseVat = itm2.includePpn, POExtUseVat = itm2.useVat, POId = itm1._id.GetValueOrDefault(), UnitId = itm1.unit.Id }; EntityExtension.FlagForCreate(item, _identityService.Username, UserAgent); _dbContext.VbRequestsDetails.Add(item); } } return(_dbContext.SaveChangesAsync()); }
public Task <int> UpdateAsync(int id, VbWithPORequestViewModel viewmodel) { var model = MappingData2(id, viewmodel); EntityExtension.FlagForUpdate(model, _identityService.Username, UserAgent); var itemIds = _dbContext.VbRequestsDetails.Where(entity => entity.VBId == id).Select(entity => entity.Id).ToList(); foreach (var itemId in itemIds) { var item = model.VbRequestDetail.FirstOrDefault(element => element.Id == itemId); //if (item == null) //{ var itemToDelete = _dbContext.VbRequestsDetails.FirstOrDefault(entity => entity.Id == itemId); EntityExtension.FlagForDelete(itemToDelete, _identityService.Username, UserAgent); _dbContext.VbRequestsDetails.Update(itemToDelete); //} //else //{ // EntityExtension.FlagForUpdate(item, _identityService.Username, UserAgent); // _dbContext.VbRequestsDetails.Update(item); //} } foreach (var item in model.VbRequestDetail) { if (item.Id <= 0) { EntityExtension.FlagForCreate(item, _identityService.Username, UserAgent); _dbContext.VbRequestsDetails.Add(item); } } _dbContext.VbRequests.Update(model); return(_dbContext.SaveChangesAsync()); }
public async Task <IActionResult> GetVbNonPORequestPDF([FromRoute] int Id) { try { var indexAcceptPdf = Request.Headers["Accept"].ToList().IndexOf("application/pdf"); int timeoffsset = Convert.ToInt32(Request.Headers["x-timezone-offset"]); //VbRequestModel model = await _service.ReadByIdAsync(Id); VbWithPORequestViewModel viewModel = await _service.ReadByIdAsync2(Id); if (viewModel == null) { Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.NOT_FOUND_STATUS_CODE, General.NOT_FOUND_MESSAGE) .Fail(); return(NotFound(Result)); } else { /*_mapper.Map<VbWithPORequestViewModel>(model);*/ VbWithPORequestPDFTemplate PdfTemplate = new VbWithPORequestPDFTemplate(); MemoryStream stream = PdfTemplate.GeneratePdfTemplate(viewModel, timeoffsset); return(new FileStreamResult(stream, "application/pdf") { FileDownloadName = "Permohonan VB dengan PO - " + viewModel.VBNo + ".pdf" }); } } catch (Exception e) { Dictionary <string, object> Result = new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message) .Fail(); return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result)); } }
public MemoryStream GeneratePdfTemplate(VbWithPORequestViewModel viewModel, int clientTimeZoneOffset) { const int MARGIN = 20; Font header_font = FontFactory.GetFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 18); Font normal_font = FontFactory.GetFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 11); Font bold_font = FontFactory.GetFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 11); Font note_font = FontFactory.GetFont(BaseFont.HELVETICA_OBLIQUE, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 8); Font bold_italic_font = FontFactory.GetFont(BaseFont.HELVETICA_BOLDOBLIQUE, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 12); Font Title_bold_font = FontFactory.GetFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 13); Document document = new Document(PageSize.A5.Rotate(), MARGIN, MARGIN, MARGIN, MARGIN); MemoryStream stream = new MemoryStream(); PdfWriter writer = PdfWriter.GetInstance(document, stream); document.Open(); #region Header PdfPTable headerTable_A = new PdfPTable(2); PdfPTable headerTable_B = new PdfPTable(1); PdfPTable headerTable_C = new PdfPTable(1); PdfPTable headerTable1 = new PdfPTable(1); PdfPTable headerTable2 = new PdfPTable(1); PdfPTable headerTable3 = new PdfPTable(3); PdfPTable headerTable3a = new PdfPTable(10); PdfPTable headerTable4 = new PdfPTable(2); headerTable_A.SetWidths(new float[] { 10f, 10f }); headerTable_A.WidthPercentage = 100; headerTable3.SetWidths(new float[] { 40f, 4f, 100f }); headerTable3.WidthPercentage = 100; headerTable3a.SetWidths(new float[] { 3f, 10f, 3f, 10f, 3f, 10f, 3f, 10f, 3f, 10f }); headerTable3a.WidthPercentage = 100; headerTable4.SetWidths(new float[] { 10f, 40f }); headerTable4.WidthPercentage = 100; PdfPCell cellHeader1 = new PdfPCell() { Border = Rectangle.NO_BORDER }; PdfPCell cellHeader2 = new PdfPCell() { Border = Rectangle.NO_BORDER }; PdfPCell cellHeader3 = new PdfPCell() { Border = Rectangle.NO_BORDER }; PdfPCell cellHeader4 = new PdfPCell() { Border = Rectangle.NO_BORDER }; PdfPCell cellHeader3a = new PdfPCell() { Border = Rectangle.NO_BORDER }; PdfPCell cellHeaderBody = new PdfPCell() { Border = Rectangle.NO_BORDER }; PdfPCell cellHeaderBody2 = new PdfPCell() { Border = Rectangle.NO_BORDER }; PdfPCell cellHeaderBody3 = new PdfPCell() { Border = Rectangle.NO_BORDER }; cellHeaderBody.Phrase = new Phrase("Kepada Yth.......", normal_font); headerTable1.AddCell(cellHeaderBody); cellHeaderBody.Phrase = new Phrase("Kasir PT. Danliris", normal_font); headerTable1.AddCell(cellHeaderBody); cellHeaderBody.Phrase = new Phrase("Di tempat", normal_font); headerTable1.AddCell(cellHeaderBody); cellHeader1.AddElement(headerTable1); headerTable_A.AddCell(cellHeader1); cellHeader2.AddElement(headerTable2); headerTable_A.AddCell(cellHeader2); document.Add(headerTable_A); cellHeaderBody.HorizontalAlignment = Element.ALIGN_LEFT; cellHeaderBody2.HorizontalAlignment = Element.ALIGN_CENTER; cellHeaderBody3.HorizontalAlignment = Element.ALIGN_RIGHT; cellHeaderBody2.Colspan = 3; cellHeaderBody2.Phrase = new Phrase("PERMOHONAN VB DENGAN PO", bold_font); headerTable3.AddCell(cellHeaderBody2); //cellHeaderBody.Phrase = new Phrase(" ", normal_font); //headerTable3.AddCell(cellHeaderBody); //cellHeaderBody.Phrase = new Phrase(" ", normal_font); //headerTable3.AddCell(cellHeaderBody); //cellHeaderBody.Phrase = new Phrase(" ", normal_font); //headerTable3.AddCell(cellHeaderBody); cellHeaderBody3.Colspan = 3; cellHeaderBody3.Phrase = new Phrase($"No : {viewModel.VBNo}", normal_font); headerTable3.AddCell(cellHeaderBody3); cellHeaderBody3.Colspan = 3; cellHeaderBody3.Phrase = new Phrase($"Tanggal : {viewModel.Date?.AddHours(clientTimeZoneOffset).ToString("dd/MM/yyyy")}", normal_font); headerTable3.AddCell(cellHeaderBody3); //cellHeaderBody.Phrase = new Phrase(" ", normal_font); //headerTable3.AddCell(cellHeaderBody); //cellHeaderBody.Phrase = new Phrase(" ", normal_font); //headerTable3.AddCell(cellHeaderBody); //cellHeaderBody.Phrase = new Phrase(" ", normal_font); //headerTable3.AddCell(cellHeaderBody); cellHeaderBody.Phrase = new Phrase("VB Uang", normal_font); headerTable3.AddCell(cellHeaderBody); cellHeaderBody.Phrase = new Phrase(":", normal_font); headerTable3.AddCell(cellHeaderBody); decimal convertCurrency = 0; string Usage = ""; string PoNumber = ""; foreach (var itm1 in viewModel.Items) { PoNumber += itm1.no + ", "; foreach (var itm2 in itm1.Details) { var price = itm2.priceBeforeTax * itm2.dealQuantity; if (itm2.useVat && !itm2.includePpn) { price += price * (decimal)0.1; } convertCurrency += price; Usage += itm2.product.name + ", "; } } Usage = Usage.Remove(Usage.Length - 2); PoNumber = PoNumber.Remove(PoNumber.Length - 2); cellHeaderBody.Phrase = new Phrase($"{viewModel.Currency.Code} " + viewModel.VBMoney.ToString("#,##0.00", new CultureInfo("id-ID")), normal_font); headerTable3.AddCell(cellHeaderBody); cellHeaderBody.Phrase = new Phrase("Terbilang", normal_font); headerTable3.AddCell(cellHeaderBody); cellHeaderBody.Phrase = new Phrase(":", normal_font); headerTable3.AddCell(cellHeaderBody); string TotalPaidString; string CurrencySay; if (viewModel.Currency.Code == "IDR") { TotalPaidString = NumberToTextIDN.terbilang((double)viewModel.VBMoney); CurrencySay = "Rupiah"; } else { TotalPaidString = NumberToTextIDN.terbilang((double)viewModel.VBMoney); CurrencySay = viewModel.Currency.Description; CurrencySay = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(CurrencySay.ToLower()); } cellHeaderBody.Phrase = new Phrase(TotalPaidString + " " + CurrencySay, normal_font); headerTable3.AddCell(cellHeaderBody); cellHeaderBody.Phrase = new Phrase("No PO", normal_font); headerTable3.AddCell(cellHeaderBody); cellHeaderBody.Phrase = new Phrase(":", normal_font); headerTable3.AddCell(cellHeaderBody); cellHeaderBody.Phrase = new Phrase(PoNumber, normal_font); headerTable3.AddCell(cellHeaderBody); cellHeaderBody.Phrase = new Phrase("Total Harga PO", normal_font); headerTable3.AddCell(cellHeaderBody); cellHeaderBody.Phrase = new Phrase(":", normal_font); headerTable3.AddCell(cellHeaderBody); cellHeaderBody.Phrase = new Phrase($"{viewModel.Currency.Code} " + convertCurrency.ToString("#,##0.00", new CultureInfo("id-ID")), normal_font); headerTable3.AddCell(cellHeaderBody); cellHeaderBody.Phrase = new Phrase("Kegunaan", normal_font); headerTable3.AddCell(cellHeaderBody); cellHeaderBody.Phrase = new Phrase(":", normal_font); headerTable3.AddCell(cellHeaderBody); cellHeaderBody.Phrase = new Phrase(viewModel.Usage, normal_font); headerTable3.AddCell(cellHeaderBody); //cellHeaderBody.Phrase = new Phrase(" ", normal_font); //headerTable3.AddCell(cellHeaderBody); //cellHeaderBody.Phrase = new Phrase(" ", normal_font); //headerTable3.AddCell(cellHeaderBody); //cellHeaderBody.Phrase = new Phrase(" ", normal_font); //headerTable3.AddCell(cellHeaderBody); cellHeaderBody.Phrase = new Phrase("Beban Unit :", normal_font); headerTable3.AddCell(cellHeaderBody); cellHeaderBody.Phrase = new Phrase(" ", normal_font); headerTable3.AddCell(cellHeaderBody); cellHeaderBody.Phrase = new Phrase(" ", normal_font); headerTable3.AddCell(cellHeaderBody); cellHeader3.AddElement(headerTable3); headerTable_B.AddCell(cellHeader3); cellHeader4.AddElement(headerTable4); headerTable_B.AddCell(cellHeader4); document.Add(headerTable_B); //writer.AddAnnotation(_checkGroup); #endregion Header #region CheckBox string unit = ""; foreach (var itm in viewModel.Items) { unit += itm.unit.Name + ","; } unit = unit.Remove(unit.Length - 1); var items = unit.Split(","); string lastitem = items[items.Length - 1]; lastitem = lastitem.Trim(); cellHeaderBody.Phrase = new Phrase("", normal_font); //Create_Box(writer,headerTable3a); PdfPCell cellform = new PdfPCell() { Border = Rectangle.NO_BORDER }; cellform.FixedHeight = 5f; //initiate form checkbox PdfFormField _checkGroup = PdfFormField.CreateEmpty(writer); RadioCheckField _radioG; PdfFormField _radioField1; Rectangle kotak = new Rectangle(100, 100); _radioG = new RadioCheckField(writer, kotak, "abc", "Yes"); _radioG.CheckType = RadioCheckField.TYPE_CHECK; _radioG.BorderStyle = PdfBorderDictionary.STYLE_SOLID; _radioG.BorderColor = BaseColor.Black; _radioG.BorderWidth = BaseField.BORDER_WIDTH_MEDIUM; if (unit.ToUpper().Contains("SPINNING 1")) { _radioG.Checked = true; } else { _radioG.Checked = false; } _radioG.Rotation = 90; _radioG.Options = TextField.READ_ONLY; _radioField1 = _radioG.CheckField; cellform.CellEvent = new BebanUnitEvent(_checkGroup, _radioField1, 1); headerTable3a.AddCell(cellform); cellHeaderBody.Phrase = new Phrase("Spinning 1", normal_font); headerTable3a.AddCell(cellHeaderBody); cellHeaderBody.Phrase = new Phrase("", normal_font); PdfPCell cellform1 = new PdfPCell() { Border = Rectangle.NO_BORDER }; cellform1.FixedHeight = 5f; //initiate form checkbox PdfFormField _checkGroup1 = PdfFormField.CreateEmpty(writer); RadioCheckField _radioG1; PdfFormField _radioField11; Rectangle kotak1 = new Rectangle(100, 100); _radioG1 = new RadioCheckField(writer, kotak1, "abc", "Yes"); _radioG1.CheckType = RadioCheckField.TYPE_CHECK; _radioG1.BorderStyle = PdfBorderDictionary.STYLE_SOLID; _radioG1.BorderColor = BaseColor.Black; _radioG1.BorderWidth = BaseField.BORDER_WIDTH_MEDIUM; if (unit.ToUpper().Contains("WEAVING 1")) { _radioG1.Checked = true; } else { _radioG1.Checked = false; } _radioG1.Rotation = 90; _radioG1.Options = TextField.READ_ONLY; _radioField11 = _radioG1.CheckField; cellform1.CellEvent = new BebanUnitEvent(_checkGroup1, _radioField11, 1); headerTable3a.AddCell(cellform1); cellHeaderBody.Phrase = new Phrase("Weaving 1", normal_font); headerTable3a.AddCell(cellHeaderBody); cellHeaderBody.Phrase = new Phrase("", normal_font); PdfPCell cellform2 = new PdfPCell() { Border = Rectangle.NO_BORDER }; cellform2.FixedHeight = 5f; //initiate form checkbox PdfFormField _checkGroup2 = PdfFormField.CreateEmpty(writer); RadioCheckField _radioG2; PdfFormField _radioField12; Rectangle kotak2 = new Rectangle(100, 100); _radioG2 = new RadioCheckField(writer, kotak2, "abc", "Yes"); _radioG2.CheckType = RadioCheckField.TYPE_CHECK; _radioG2.BorderStyle = PdfBorderDictionary.STYLE_SOLID; _radioG2.BorderColor = BaseColor.Black; _radioG2.BorderWidth = BaseField.BORDER_WIDTH_MEDIUM; if (unit.ToUpper().Contains("FINISHING")) { _radioG2.Checked = true; } else { _radioG2.Checked = false; } _radioG2.Rotation = 90; _radioG2.Options = TextField.READ_ONLY; _radioField12 = _radioG2.CheckField; cellform2.CellEvent = new BebanUnitEvent(_checkGroup2, _radioField12, 1); headerTable3a.AddCell(cellform2); cellHeaderBody.Phrase = new Phrase("Finishing", normal_font); headerTable3a.AddCell(cellHeaderBody); cellHeaderBody.Phrase = new Phrase("", normal_font); PdfPCell cellform3 = new PdfPCell() { Border = Rectangle.NO_BORDER }; cellform3.FixedHeight = 5f; //initiate form checkbox PdfFormField _checkGroup3 = PdfFormField.CreateEmpty(writer); RadioCheckField _radioG3; PdfFormField _radioField13; Rectangle kotak3 = new Rectangle(100, 100); _radioG3 = new RadioCheckField(writer, kotak3, "abc", "Yes"); _radioG3.CheckType = RadioCheckField.TYPE_CHECK; _radioG3.BorderStyle = PdfBorderDictionary.STYLE_SOLID; _radioG3.BorderColor = BaseColor.Black; _radioG3.BorderWidth = BaseField.BORDER_WIDTH_MEDIUM; if (unit.ToUpper().Contains("KONFEKSI 2A")) { _radioG3.Checked = true; } else { _radioG3.Checked = false; } _radioG3.Rotation = 90; _radioG3.Options = TextField.READ_ONLY; _radioField13 = _radioG3.CheckField; cellform3.CellEvent = new BebanUnitEvent(_checkGroup3, _radioField13, 1); headerTable3a.AddCell(cellform3); cellHeaderBody.Phrase = new Phrase("Konfeksi 2 A", normal_font); headerTable3a.AddCell(cellHeaderBody); cellHeaderBody.Phrase = new Phrase("", normal_font); PdfPCell cellform4 = new PdfPCell() { Border = Rectangle.NO_BORDER }; cellform4.FixedHeight = 5f; //initiate form checkbox PdfFormField _checkGroup4 = PdfFormField.CreateEmpty(writer); RadioCheckField _radioG4; PdfFormField _radioField14; Rectangle kotak4 = new Rectangle(100, 100); _radioG4 = new RadioCheckField(writer, kotak4, "abc", "Yes"); _radioG4.CheckType = RadioCheckField.TYPE_CHECK; _radioG4.BorderStyle = PdfBorderDictionary.STYLE_SOLID; _radioG4.BorderColor = BaseColor.Black; _radioG4.BorderWidth = BaseField.BORDER_WIDTH_MEDIUM; if (unit.ToUpper().Contains("UMUM")) { _radioG4.Checked = true; } else { _radioG4.Checked = false; } _radioG4.Rotation = 90; _radioG4.Options = TextField.READ_ONLY; _radioField14 = _radioG4.CheckField; cellform4.CellEvent = new BebanUnitEvent(_checkGroup4, _radioField14, 1); headerTable3a.AddCell(cellform4); cellHeaderBody.Phrase = new Phrase("Umum", normal_font); headerTable3a.AddCell(cellHeaderBody); //================================================ cellHeaderBody.Phrase = new Phrase("", normal_font); PdfPCell cellform5 = new PdfPCell() { Border = Rectangle.NO_BORDER }; cellform5.FixedHeight = 5f; //initiate form checkbox PdfFormField _checkGroup5 = PdfFormField.CreateEmpty(writer); RadioCheckField _radioG5; PdfFormField _radioField15; Rectangle kotak5 = new Rectangle(100, 100); _radioG5 = new RadioCheckField(writer, kotak5, "abc", "Yes"); _radioG5.CheckType = RadioCheckField.TYPE_CHECK; _radioG5.BorderStyle = PdfBorderDictionary.STYLE_SOLID; _radioG5.BorderColor = BaseColor.Black; _radioG5.BorderWidth = BaseField.BORDER_WIDTH_MEDIUM; if (unit.ToUpper().Contains("SPINNING 2")) { _radioG5.Checked = true; } else { _radioG5.Checked = false; } _radioG5.Rotation = 90; _radioG5.Options = TextField.READ_ONLY; _radioField15 = _radioG5.CheckField; cellform5.CellEvent = new BebanUnitEvent(_checkGroup5, _radioField15, 1); headerTable3a.AddCell(cellform5); cellHeaderBody.Phrase = new Phrase("Spinning 2", normal_font); headerTable3a.AddCell(cellHeaderBody); cellHeaderBody.Phrase = new Phrase("", normal_font); PdfPCell cellform6 = new PdfPCell() { Border = Rectangle.NO_BORDER }; cellform6.FixedHeight = 5f; //initiate form checkbox PdfFormField _checkGroup6 = PdfFormField.CreateEmpty(writer); RadioCheckField _radioG6; PdfFormField _radioField16; Rectangle kotak6 = new Rectangle(100, 100); _radioG6 = new RadioCheckField(writer, kotak6, "abc", "Yes"); _radioG6.CheckType = RadioCheckField.TYPE_CHECK; _radioG6.BorderStyle = PdfBorderDictionary.STYLE_SOLID; _radioG6.BorderColor = BaseColor.Black; _radioG6.BorderWidth = BaseField.BORDER_WIDTH_MEDIUM; if (unit.ToUpper().Contains("WEAVING 2")) { _radioG6.Checked = true; } else { _radioG6.Checked = false; } _radioG6.Rotation = 90; _radioG6.Options = TextField.READ_ONLY; _radioField16 = _radioG6.CheckField; cellform6.CellEvent = new BebanUnitEvent(_checkGroup6, _radioField16, 1); headerTable3a.AddCell(cellform6); cellHeaderBody.Phrase = new Phrase("Weaving 2", normal_font); headerTable3a.AddCell(cellHeaderBody); cellHeaderBody.Phrase = new Phrase("", normal_font); PdfPCell cellform7 = new PdfPCell() { Border = Rectangle.NO_BORDER }; cellform7.FixedHeight = 5f; //initiate form checkbox PdfFormField _checkGroup7 = PdfFormField.CreateEmpty(writer); RadioCheckField _radioG7; PdfFormField _radioField17; Rectangle kotak7 = new Rectangle(100, 100); _radioG7 = new RadioCheckField(writer, kotak7, "abc", "Yes"); _radioG7.CheckType = RadioCheckField.TYPE_CHECK; _radioG7.BorderStyle = PdfBorderDictionary.STYLE_SOLID; _radioG7.BorderColor = BaseColor.Black; _radioG7.BorderWidth = BaseField.BORDER_WIDTH_MEDIUM; if (unit.ToUpper().Contains("KONFEKSI 1A")) { _radioG7.Checked = true; } else { _radioG7.Checked = false; } _radioG7.Rotation = 90; _radioG7.Options = TextField.READ_ONLY; _radioField17 = _radioG7.CheckField; cellform7.CellEvent = new BebanUnitEvent(_checkGroup7, _radioField17, 1); headerTable3a.AddCell(cellform7); cellHeaderBody.Phrase = new Phrase("Konfeksi 1A", normal_font); headerTable3a.AddCell(cellHeaderBody); cellHeaderBody.Phrase = new Phrase("", normal_font); PdfPCell cellform8 = new PdfPCell() { Border = Rectangle.NO_BORDER }; cellform8.FixedHeight = 5f; //initiate form checkbox PdfFormField _checkGroup8 = PdfFormField.CreateEmpty(writer); RadioCheckField _radioG8; PdfFormField _radioField18; Rectangle kotak8 = new Rectangle(100, 100); _radioG8 = new RadioCheckField(writer, kotak8, "abc", "Yes"); _radioG8.CheckType = RadioCheckField.TYPE_CHECK; _radioG8.BorderStyle = PdfBorderDictionary.STYLE_SOLID; _radioG8.BorderColor = BaseColor.Black; _radioG8.BorderWidth = BaseField.BORDER_WIDTH_MEDIUM; if (unit.ToUpper().Contains("KONFEKSI 2B")) { _radioG8.Checked = true; } else { _radioG8.Checked = false; } _radioG8.Rotation = 90; _radioG8.Options = TextField.READ_ONLY; _radioField18 = _radioG8.CheckField; cellform8.CellEvent = new BebanUnitEvent(_checkGroup8, _radioField18, 1); headerTable3a.AddCell(cellform8); cellHeaderBody.Phrase = new Phrase("Konfeksi 2 B", normal_font); headerTable3a.AddCell(cellHeaderBody); cellHeaderBody.Phrase = new Phrase("", normal_font); PdfPCell cellform9 = new PdfPCell() { Border = Rectangle.NO_BORDER }; cellform9.FixedHeight = 5f; //initiate form checkbox PdfFormField _checkGroup9 = PdfFormField.CreateEmpty(writer); RadioCheckField _radioG9; PdfFormField _radioField19; Rectangle kotak9 = new Rectangle(100, 100); _radioG9 = new RadioCheckField(writer, kotak9, "abc", "Yes"); _radioG9.CheckType = RadioCheckField.TYPE_CHECK; _radioG9.BorderStyle = PdfBorderDictionary.STYLE_SOLID; _radioG9.BorderColor = BaseColor.Black; _radioG9.BorderWidth = BaseField.BORDER_WIDTH_MEDIUM; string res; if (lastitem.ToUpper() == "SPINNING 1" || lastitem.ToUpper() == "SPINNING 2" || lastitem.ToUpper() == "SPINNING 3" || lastitem.ToUpper() == "WEAVING 1" || lastitem.ToUpper() == "WEAVING 2" || lastitem.ToUpper() == "PRINTING" || lastitem.ToUpper() == "FINISHING" || lastitem.ToUpper() == "KONFEKSI 1A" || lastitem.ToUpper() == "KONFEKSI 1B" || lastitem.ToUpper() == "KONFEKSI 2A" || lastitem.ToUpper() == "KONFEKSI 2B" || lastitem.ToUpper() == "KONFEKSI 2C" || lastitem.ToUpper() == "UMUM") { _radioG9.Checked = false; res = "......."; } else { _radioG9.Checked = true; res = lastitem; } _radioG9.Rotation = 90; _radioG9.Options = TextField.READ_ONLY; _radioField19 = _radioG9.CheckField; cellform9.CellEvent = new BebanUnitEvent(_checkGroup9, _radioField19, 1); headerTable3a.AddCell(cellform9); cellHeaderBody.Phrase = new Phrase(res, normal_font); headerTable3a.AddCell(cellHeaderBody); //================================================ cellHeaderBody.Phrase = new Phrase("", normal_font); PdfPCell cellform10 = new PdfPCell() { Border = Rectangle.NO_BORDER }; cellform10.FixedHeight = 5f; //initiate form checkbox PdfFormField _checkGroup10 = PdfFormField.CreateEmpty(writer); RadioCheckField _radioG10; PdfFormField _radioField110; Rectangle kotak10 = new Rectangle(100, 100); _radioG10 = new RadioCheckField(writer, kotak10, "abc", "Yes"); _radioG10.CheckType = RadioCheckField.TYPE_CHECK; _radioG10.BorderStyle = PdfBorderDictionary.STYLE_SOLID; _radioG10.BorderColor = BaseColor.Black; _radioG10.BorderWidth = BaseField.BORDER_WIDTH_MEDIUM; if (unit.ToUpper().Contains("SPINNING 3")) { _radioG10.Checked = true; } else { _radioG10.Checked = false; } _radioG10.Rotation = 90; _radioG10.Options = TextField.READ_ONLY; _radioField110 = _radioG10.CheckField; cellform10.CellEvent = new BebanUnitEvent(_checkGroup10, _radioField110, 1); headerTable3a.AddCell(cellform10); cellHeaderBody.Phrase = new Phrase("Spinning 3", normal_font); headerTable3a.AddCell(cellHeaderBody); cellHeaderBody.Phrase = new Phrase("", normal_font); PdfPCell cellform11 = new PdfPCell() { Border = Rectangle.NO_BORDER }; cellform11.FixedHeight = 5f; //initiate form checkbox PdfFormField _checkGroup11 = PdfFormField.CreateEmpty(writer); RadioCheckField _radioG11; PdfFormField _radioField111; Rectangle kotak11 = new Rectangle(100, 100); _radioG11 = new RadioCheckField(writer, kotak11, "abc", "Yes"); _radioG11.CheckType = RadioCheckField.TYPE_CHECK; _radioG11.BorderStyle = PdfBorderDictionary.STYLE_SOLID; _radioG11.BorderColor = BaseColor.Black; _radioG11.BorderWidth = BaseField.BORDER_WIDTH_MEDIUM; if (unit.ToUpper().Contains("PRINTING")) { _radioG11.Checked = true; } else { _radioG11.Checked = false; } _radioG11.Rotation = 90; _radioG11.Options = TextField.READ_ONLY; _radioField111 = _radioG11.CheckField; cellform11.CellEvent = new BebanUnitEvent(_checkGroup11, _radioField111, 1); headerTable3a.AddCell(cellform11); cellHeaderBody.Phrase = new Phrase("Printing", normal_font); headerTable3a.AddCell(cellHeaderBody); cellHeaderBody.Phrase = new Phrase("", normal_font); PdfPCell cellform12 = new PdfPCell() { Border = Rectangle.NO_BORDER }; cellform12.FixedHeight = 5f; //initiate form checkbox PdfFormField _checkGroup12 = PdfFormField.CreateEmpty(writer); RadioCheckField _radioG12; PdfFormField _radioField112; Rectangle kotak12 = new Rectangle(100, 100); _radioG12 = new RadioCheckField(writer, kotak12, "abc", "Yes"); _radioG12.CheckType = RadioCheckField.TYPE_CHECK; _radioG12.BorderStyle = PdfBorderDictionary.STYLE_SOLID; _radioG12.BorderColor = BaseColor.Black; _radioG12.BorderWidth = BaseField.BORDER_WIDTH_MEDIUM; if (unit.ToUpper().Contains("KONFEKSI 1B")) { _radioG12.Checked = true; } else { _radioG12.Checked = false; } _radioG12.Rotation = 90; _radioG12.Options = TextField.READ_ONLY; _radioField112 = _radioG12.CheckField; cellform12.CellEvent = new BebanUnitEvent(_checkGroup12, _radioField112, 1); headerTable3a.AddCell(cellform12); cellHeaderBody.Phrase = new Phrase("Konfeksi 1B", normal_font); headerTable3a.AddCell(cellHeaderBody); cellHeaderBody.Phrase = new Phrase("", normal_font); PdfPCell cellform13 = new PdfPCell() { Border = Rectangle.NO_BORDER }; cellform13.FixedHeight = 5f; //initiate form checkbox PdfFormField _checkGroup13 = PdfFormField.CreateEmpty(writer); RadioCheckField _radioG13; PdfFormField _radioField113; Rectangle kotak13 = new Rectangle(100, 100); _radioG13 = new RadioCheckField(writer, kotak13, "abc", "Yes"); _radioG13.CheckType = RadioCheckField.TYPE_CHECK; _radioG13.BorderStyle = PdfBorderDictionary.STYLE_SOLID; _radioG13.BorderColor = BaseColor.Black; _radioG13.BorderWidth = BaseField.BORDER_WIDTH_MEDIUM; if (unit.ToUpper().Contains("KONFEKSI 2C")) { _radioG13.Checked = true; } else { _radioG13.Checked = false; } _radioG13.Rotation = 90; _radioG13.Options = TextField.READ_ONLY; _radioField113 = _radioG13.CheckField; cellform13.CellEvent = new BebanUnitEvent(_checkGroup13, _radioField113, 1); headerTable3a.AddCell(cellform13); cellHeaderBody.Phrase = new Phrase("Konfeksi 2C", normal_font); headerTable3a.AddCell(cellHeaderBody); cellHeaderBody.Phrase = new Phrase(" ", normal_font); headerTable3a.AddCell(cellHeaderBody); cellHeaderBody.Phrase = new Phrase(" ", normal_font); headerTable3a.AddCell(cellHeaderBody); cellHeader3a.AddElement(headerTable3a); headerTable_C.AddCell(cellHeader3a); document.Add(headerTable_C); writer.AddAnnotation(_checkGroup); writer.AddAnnotation(_checkGroup1); writer.AddAnnotation(_checkGroup2); writer.AddAnnotation(_checkGroup3); writer.AddAnnotation(_checkGroup4); writer.AddAnnotation(_checkGroup5); writer.AddAnnotation(_checkGroup6); writer.AddAnnotation(_checkGroup7); writer.AddAnnotation(_checkGroup8); writer.AddAnnotation(_checkGroup9); writer.AddAnnotation(_checkGroup10); writer.AddAnnotation(_checkGroup11); writer.AddAnnotation(_checkGroup12); writer.AddAnnotation(_checkGroup13); #endregion #region Footer PdfPTable table = new PdfPTable(4) { WidthPercentage = 100 }; float[] widths = new float[] { 1f, 1f, 1f, 1f }; table.SetWidths(widths); PdfPCell cell = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE, }; PdfPCell cellLeft = new PdfPCell() { HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, }; PdfPCell cellColspan = new PdfPCell() { Colspan = 4, Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, }; cell.Phrase = new Phrase("", normal_font); table.AddCell(cell); cell.Phrase = new Phrase("", normal_font); table.AddCell(cell); cell.Phrase = new Phrase("", normal_font); table.AddCell(cell); cell.Phrase = new Phrase("", normal_font); table.AddCell(cell); cell.Phrase = new Phrase("Menyetujui,", normal_font); table.AddCell(cell); cell.Phrase = new Phrase("", normal_font); table.AddCell(cell); cell.Phrase = new Phrase("Mengetahui,", normal_font); table.AddCell(cell); cell.Phrase = new Phrase("Diminta Oleh,", normal_font); table.AddCell(cell); for (var i = 0; i < 11; i++) { cell.Phrase = new Phrase("", normal_font); table.AddCell(cell); cell.Phrase = new Phrase("", normal_font); table.AddCell(cell); cell.Phrase = new Phrase("", normal_font); table.AddCell(cell); cell.Phrase = new Phrase("", normal_font); table.AddCell(cell); } cell.Phrase = new Phrase("(..................)", normal_font); table.AddCell(cell); cell.Phrase = new Phrase("(..................)", normal_font); table.AddCell(cell); cell.Phrase = new Phrase("(..................)", normal_font); table.AddCell(cell); cell.Phrase = new Phrase($"({viewModel.CreatedBy})", normal_font); table.AddCell(cell); cell.Phrase = new Phrase("Kasir", normal_font); table.AddCell(cell); cell.Phrase = new Phrase("Anggaran", normal_font); table.AddCell(cell); cell.Phrase = new Phrase("..................", normal_font); table.AddCell(cell); cell.Phrase = new Phrase($"Bag. {viewModel.Unit.Name}", normal_font); table.AddCell(cell); document.Add(table); #endregion Footer document.Close(); byte[] byteInfo = stream.ToArray(); stream.Write(byteInfo, 0, byteInfo.Length); stream.Position = 0; return(stream); }
public void Should_Success_Validate_All_Null_Data() { var viewModel = new VbWithPORequestViewModel(); Assert.True(viewModel.Validate(null).Count() > 0); }
public VbRequestModel MappingData2(int id, VbWithPORequestViewModel viewModel) { var listDetail = new List <VbRequestDetailModel>(); foreach (var itm1 in viewModel.Items) { foreach (var itm2 in itm1.Details) { var item = new VbRequestDetailModel() { //Id = itm2.Id, VBId = id, POId = itm1._id.GetValueOrDefault(), PONo = itm1.no, VBNo = viewModel.VBNo, UnitName = itm1.unit.Name, UnitId = itm1.unit.Id, Conversion = itm2.Conversion, DealQuantity = itm2.dealQuantity, DealUOMId = itm2.dealUom._id, DealUOMUnit = itm2.dealUom.unit, DefaultQuantity = itm2.defaultQuantity, DefaultUOMId = itm2.defaultUom._id, DefaultUOMUnit = itm2.defaultUom.unit, Price = itm2.priceBeforeTax, ProductCode = itm2.product.code, ProductId = itm2.product._id, ProductName = itm2.product.name, ProductRemark = itm2.productRemark, LastModifiedBy = viewModel.LastModifiedBy, LastModifiedAgent = viewModel.LastModifiedAgent, DeletedBy = "", DeletedAgent = "", CreatedBy = viewModel.CreatedBy, CreatedAgent = viewModel.CreatedAgent, IsUseVat = itm2.includePpn, }; listDetail.Add(item); } } string IncomeTaxBy = ""; string IncomeTaxId = ""; string IncomeTaxName = ""; string IncomeTaxRate = ""; string temp = ""; decimal Amount = 0; foreach (var itm in viewModel.Items) { if (string.IsNullOrEmpty(itm.IncomeTax._id)) { IncomeTaxId = ""; } else { IncomeTaxId = itm.IncomeTax._id; } if (string.IsNullOrEmpty(itm.IncomeTax.Name)) { IncomeTaxName = ""; } else { IncomeTaxName = itm.IncomeTax.Name; } if (string.IsNullOrEmpty(itm.IncomeTax.Rate)) { IncomeTaxRate = ""; } else { IncomeTaxRate = itm.IncomeTax.Rate; } if (string.IsNullOrEmpty(itm.IncomeTaxBy)) { IncomeTaxBy = ""; } else { IncomeTaxBy = itm.IncomeTaxBy; } foreach (var itm2 in itm.Details) { Amount += itm2.priceBeforeTax * itm2.dealQuantity; } IncomeTaxBy = itm.IncomeTaxBy; IncomeTaxId = itm.IncomeTax._id; IncomeTaxName = itm.IncomeTax.Name; IncomeTaxRate = itm.IncomeTax.Rate; temp += itm.unit.Name + ", "; temp = temp.Remove(temp.Length - 2); } var result = new VbRequestModel() { VbRequestDetail = listDetail, Active = viewModel.Active, Id = viewModel.Id, Date = (DateTimeOffset)viewModel.Date, DateEstimate = (DateTimeOffset)viewModel.DateEstimate, UnitId = viewModel.Unit.Id, UnitCode = viewModel.Unit.Code, UnitName = viewModel.Unit.Name, VBNo = viewModel.VBNo, CreatedUtc = viewModel.CreatedUtc, CreatedBy = viewModel.CreatedBy, CreatedAgent = viewModel.CreatedAgent, LastModifiedUtc = DateTime.Now, LastModifiedAgent = viewModel.LastModifiedAgent, LastModifiedBy = viewModel.LastModifiedBy, VBMoney = viewModel.VBMoney, Usage_Input = viewModel.Usage, CurrencyId = viewModel.Currency.Id, CurrencyCode = viewModel.Currency.Code, CurrencyRate = viewModel.Currency.Rate, CurrencySymbol = viewModel.Currency.Symbol, CurrencyDescription = viewModel.Currency.Symbol, Amount = Amount, UnitDivisionId = viewModel.Division.Id, UnitDivisionName = viewModel.Division.Name, IncomeTaxBy = IncomeTaxBy, IncomeTaxId = IncomeTaxId, IncomeTaxName = IncomeTaxName, IncomeTaxRate = IncomeTaxRate, UnitLoad = temp, VBRequestCategory = "PO", Apporve_Status = false, Complete_Status = false }; return(result); }
public Task <int> CreateAsync(VbRequestModel model, VbWithPORequestViewModel viewmodel) { decimal Amt = 0; model.VBNo = GetVbNonPoNo(model); model.VBRequestCategory = "PO"; model.Apporve_Status = false; model.Complete_Status = false; model.Usage_Input = viewmodel.Usage; string temp = ""; foreach (var itm in viewmodel.Items) { temp += itm.unit.Name + ", "; temp = temp.Remove(temp.Length - 2); if (string.IsNullOrEmpty(itm.IncomeTax._id)) { model.IncomeTaxId = ""; } else { model.IncomeTaxId = itm.IncomeTax._id; } if (string.IsNullOrEmpty(itm.IncomeTax.Name)) { model.IncomeTaxName = ""; } else { model.IncomeTaxName = itm.IncomeTax.Name; } if (string.IsNullOrEmpty(itm.IncomeTax.Rate)) { model.IncomeTaxRate = ""; } else { model.IncomeTaxRate = itm.IncomeTax.Rate; } if (string.IsNullOrEmpty(itm.IncomeTaxBy)) { model.IncomeTaxBy = ""; } else { model.IncomeTaxBy = itm.IncomeTaxBy; } foreach (var itm2 in itm.Details) { var price = itm2.priceBeforeTax * itm2.dealQuantity; if (!itm2.includePpn && itm2.useVat) { price += price * (decimal)0.1; } Amt += price; } } model.Amount = Amt; model.UnitLoad = temp; EntityExtension.FlagForCreate(model, _identityService.Username, UserAgent); _dbContext.VbRequests.Add(model); //foreach (var itm1 in viewmodel.Items) //{ // var updateModel = new POExternalUpdateModel() // { // IsCreateOnVBRequest = true // }; // UpdateToPOExternal(itm1.no, updateModel); //} return(_dbContext.SaveChangesAsync()); }