Esempio n. 1
0
        public static SupplierViewModel ToViewModel(this Supplier supplier)
        {
            var isAccountActivated = true;
            if (!string.IsNullOrEmpty(supplier.AspNetUserId))
            {

                var context = ServiceLocator.Current.Resolve<IApplicationDbContext>();
                var userManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(context as ApplicationDbContext));
                isAccountActivated = userManager.IsInRole(supplier.AspNetUserId, Role.Supplier.ToString());
            }

            var vm = new SupplierViewModel
            {
                Id = supplier.Id,
                Name = supplier.Name,
                Address = supplier.Address,
                VATStatus = supplier.VATStatus,
                RC = supplier.RC,
                Email = supplier.Email,
                IsActive = supplier.IsActive,
                IsAcceptingPayment = supplier.IsAcceptingPayment,
                Iban = supplier.Iban,
                Bank = supplier.Bank,
                Fax = supplier.Fax,
                Company = supplier.Company,
                PostalCode = supplier.PostalCode,
                CIF = supplier.CIF,
                BrandLogo = supplier.BrandLogo,
                BrandText = supplier.BrandText,
                AspNetUserId = supplier.AspNetUserId,
                IsAccountActivated = isAccountActivated
            };

            if (supplier.IsNew)
            {
                vm.Contact = new ContactViewModel() { Type = ContactType.Contact };
                vm.Admin = new ContactViewModel() { Type = ContactType.Admin };
                vm.ActivityPackages = new List<ActivityPackageViewModel>();
            }
            else
            {
                vm.Contact = (supplier.Contact ?? new Domain.Contact()).ToViewModel();
                vm.Contact.Type = ContactType.Contact;
                vm.Admin = (supplier.Admin ?? new Domain.Contact()).ToViewModel();
                vm.Admin.Type = ContactType.Admin;
                vm.ActivityPackages = new List<ActivityPackageViewModel>(supplier.ActivityPackages.ToViewModel());
            }

            return vm;
        }
Esempio n. 2
0
        public ActionResult Create(SupplierViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var contact = vm.Contact.ToModel();
                var admin = vm.Admin.ToModel();
                _contacts.Save(contact);
                _contacts.Save(admin);
                var supplier = vm.ToModel();
                supplier.AdminId = admin.Id;
                supplier.ContactId = contact.Id;
                _suppliers.Save(supplier);
                return RedirectToAction("Index");
            }

            return View(vm);
        }
Esempio n. 3
0
 public SupplierListing()
 {
     InitializeComponent();
     _SVM             = new SupplierViewModel();
     this.DataContext = _SVM;
 }
Esempio n. 4
0
 public PartialViewResult Supplier(SupplierViewModel model)
 {
     //Update logic
     return(PartialView("Supplier", model));
 }
Esempio n. 5
0
        public MaterialDistributionNoteViewModel MapToViewModel(MaterialDistributionNote model)
        {
            MaterialDistributionNoteViewModel viewModel = new MaterialDistributionNoteViewModel();

            PropertyCopier <MaterialDistributionNote, MaterialDistributionNoteViewModel> .Copy(model, viewModel);

            UnitViewModel Unit = new UnitViewModel()
            {
                Id   = model.UnitId,
                Code = model.UnitCode,
                Name = model.UnitName
            };

            viewModel.Unit = Unit;

            viewModel.MaterialDistributionNoteItems = new List <MaterialDistributionNoteItemViewModel>();
            if (model.MaterialDistributionNoteItems != null)
            {
                foreach (MaterialDistributionNoteItem mdni in model.MaterialDistributionNoteItems)
                {
                    MaterialDistributionNoteItemViewModel materialDistributionNoteItemViewModel = new MaterialDistributionNoteItemViewModel();
                    PropertyCopier <MaterialDistributionNoteItem, MaterialDistributionNoteItemViewModel> .Copy(mdni, materialDistributionNoteItemViewModel);

                    materialDistributionNoteItemViewModel.MaterialDistributionNoteDetails = new List <MaterialDistributionNoteDetailViewModel>();
                    foreach (MaterialDistributionNoteDetail mdnd in mdni.MaterialDistributionNoteDetails)
                    {
                        MaterialDistributionNoteDetailViewModel materialDistributionNoteDetailViewModel = new MaterialDistributionNoteDetailViewModel();
                        PropertyCopier <MaterialDistributionNoteDetail, MaterialDistributionNoteDetailViewModel> .Copy(mdnd, materialDistributionNoteDetailViewModel);

                        ProductionOrderViewModel productionOrder = new ProductionOrderViewModel
                        {
                            Id          = mdnd.ProductionOrderId,
                            OrderNo     = mdnd.ProductionOrderNo,
                            IsCompleted = mdnd.ProductionOrderIsCompleted,
                        };

                        ProductViewModel product = new ProductViewModel
                        {
                            Id   = mdnd.ProductId,
                            Code = mdnd.ProductCode,
                            Name = mdnd.ProductName
                        };

                        SupplierViewModel supplier = new SupplierViewModel
                        {
                            _id  = mdnd.SupplierId,
                            code = mdnd.SupplierCode,
                            name = mdnd.SupplierName
                        };

                        materialDistributionNoteDetailViewModel.ProductionOrder = productionOrder;
                        materialDistributionNoteDetailViewModel.Product         = product;
                        materialDistributionNoteDetailViewModel.Supplier        = supplier;

                        materialDistributionNoteItemViewModel.MaterialDistributionNoteDetails.Add(materialDistributionNoteDetailViewModel);
                    }

                    viewModel.MaterialDistributionNoteItems.Add(materialDistributionNoteItemViewModel);
                }
            }

            return(viewModel);
        }
Esempio n. 6
0
 public string IsExistSupplier(SupplierViewModel supplierViewModel)
 {
     return(_supplierRepository.IsExistSupplier(supplierViewModel));
 }
 public SupplierView()
 {
     InitializeComponent();
     DataContext = new SupplierViewModel();
 }
Esempio n. 8
0
        private JsonResult CreateResultJson(SupplierViewModel model)
        {
            if (_service.ExistedName(model.Supplier.vSupplierName))
            {
                return Json(new { result = Constants.Duplicate });
            }

            try
            {
                model.Supplier.iEnable = true;
                model.Supplier.iCreated = model.LoginId;
                model.Supplier.dCreated = DateTime.Now;
                _service.Insert(model.Supplier, model.ListProducts);

                return Json(new { result = Constants.Success });
            }
            catch (Exception e)
            {
                Log.Error("Create New Supplier!", e);
                return Json(new { result = Constants.UnSuccess });
            }
        }
Esempio n. 9
0
        public ActionResult Index()
        {
            var userName = System.Web.HttpContext.Current.User.Identity.Name;
            var user = _systemService.GetUserAndRole(0, userName);
            if (user == null)
            {
                return RedirectToAction("Index", "Login");
            }

            if (user.UserR == 0)
            {
                return RedirectToAction("Index", "Home");
            }

            var model = new SupplierViewModel
                            {
                                Stores = new SelectList(_systemService.StoreList(), "Id", "Name"),
                                Countries = new SelectList(_systemService.CountryList(), "Id", "Name"),
                                Types = new SelectList(_systemService.SupplierTypeList(), "Id", "Name"),
                                Suppliers = new SelectList(_systemService.SupplierList(), "Id", "Name"),
                                UserLogin = user
                            };

            return View(model);
        }
Esempio n. 10
0
 public SupplierView(ObservableCollection <Supplier> supplierCollection)
 {
     InitializeComponent();
     DataContext = new SupplierViewModel(supplierCollection);
 }
        public ActionResult Create(int?id)
        {
            var userName = System.Web.HttpContext.Current.User.Identity.Name;
            var user     = _systemService.GetUserAndRole(0, userName);

            if (user == null)
            {
                return(RedirectToAction("Index", "Login"));
            }
            if (user.SupplierR == 0)
            {
                return(RedirectToAction("Index", "Home"));
            }

            var item = new WAMS_SUPPLIER();

            if (id.HasValue)
            {
                item = _service.GetByKey(id.Value);
            }

            var model = new SupplierViewModel
            {
                Id              = item.bSupplierID,
                vSupplierName   = item.vSupplierName,
                vAddress        = item.vAddress,
                vCity           = item.vCity,
                Telephone1      = item.vPhone1,
                Telephone2      = item.vPhone2,
                Mobile          = item.vMobile,
                vFax            = item.vFax,
                Email           = item.vEmail,
                vContactPerson  = item.vContactPerson,
                fTotalMoney     = item.fTotalMoney,
                bSupplierTypeID = item.bSupplierTypeID,
                iEnable         = item.iEnable,
                iService        = item.iService,
                dDateCreate     = item.dDateCreate,
                CountryId       = item.CountryId,
                iMarket         = item.iMarket,
                iStore          = item.iStore,
                iPayment        = item.iPayment,
                dCreated        = item.dCreated,
                dModified       = item.dModified,
                iCreated        = item.iCreated,
                iModified       = item.iModified,
                Timestamp       = item.Timestamp,
                Stores          = new SelectList(_systemService.StoreList(), "Id", "Name"),
                Types           = new SelectList(_systemService.SupplierTypeList(), "Id", "Name"),
                Countries       = new SelectList(_systemService.CountryList(), "Id", "Name"),
                UserLogin       = user
            };

            if (!id.HasValue)
            {
                return(View(model));
            }
            var temp = _service.ListConditionDetail(id.Value, "1");

            model.GetProductDetails = temp;
            model.TotalRecords      = temp.Count;

            // FUNCTION
            return(View(model));
        }
        public async Task <IActionResult> Update([FromBody] SupplierViewModel supplierViewModel)
        {
            var data = await _supplierAppService.UpdateSupplier(supplierViewModel);

            return(Ok(data));
        }
Esempio n. 13
0
 public ActionResult Edit(SupplierViewModel model)
 {
     return(CreateEdit(model));
 }
 public Result(SupplierViewModel supplier)
 {
     Suppliers.Add(supplier);
 }
        public async Task <ActionResult> Post([FromBody] SupplierViewModel vm)
        {
            var response = await _supplierService.SaveSupplier(vm);

            return(Ok(response));
        }
Esempio n. 16
0
        public SupplierView()
        {
            InitializeComponent();

            supplierViewModel = DataContext as SupplierViewModel;
        }
Esempio n. 17
0
        public IActionResult GetSupplierDetails(int id)
        {
            SupplierViewModel model = generateAPIResponse.SupplierViewRepo.GetByID("supplier", id).Result;

            return(Ok(model));
        }
Esempio n. 18
0
        public string Insert(SupplierViewModel Model)
        {
            try
            {
                string sql = "";
                db = new SqlConnection(ConfigurationManager.ConnectionStrings["cn"].ConnectionString);

                if (Model.Supplier.ID == 0)
                {
                    sql = " INSERT INTO tblSupplier(SupplierCode,User_id,NameCompany,Emirates,Address,POBox,Owner, " +
                          " EmailAddress, Phone1, Phone2, Mobile, Fax, TradelicenseNo,IssuingAuthority,TradelicenseExpiryDate," +
                          "BankName,BankAddress,BeneficiaryName,IBANNumber,SwiftCode,VATClassification,VATRegistrationNo) " +
                          " VALUES (@SupplierCode,@User_id,@NameCompany,@Emirates,@Address,@POBox,@Owner," +
                          "@EmailAddress, @Phone1, @Phone2, @Mobile, @Fax,@TradelicenseNo, @IssuingAuthority,@TradelicenseExpiryDate," +
                          "@BankName,@BankAddress,@BeneficiaryName,@IBANNumber,@SwiftCode,@VATClassification,@VATRegistrationNo)" +
                          "Select Cast(SCOPE_IDENTITY() AS int)";

                    try
                    {
                        int ID = db.Query <int>(sql, new
                        {
                            Model.Supplier.SupplierCode,
                            Model.Supplier.User_id,
                            Model.Supplier.NameCompany,
                            Model.Supplier.Emirates,
                            Model.Supplier.Address,
                            Model.Supplier.POBox,
                            Model.Supplier.Owner,
                            Model.Supplier.EmailAddress,
                            Model.Supplier.Phone1,
                            Model.Supplier.Phone2,
                            Model.Supplier.Mobile,
                            Model.Supplier.Fax,
                            Model.Supplier.TradelicenseNo,
                            Model.Supplier.IssuingAuthority,
                            Model.Supplier.TradelicenseExpiryDate,
                            Model.Supplier.BankName,
                            Model.Supplier.BankAddress,
                            Model.Supplier.BeneficiaryName,
                            Model.Supplier.IBANNumber,
                            Model.Supplier.SwiftCode,
                            Model.Supplier.VATClassification,
                            Model.Supplier.VATRegistrationNo
                        }).SingleOrDefault();

                        if (ID > 0)
                        {
                            Model.Supplier.ID = ID;
                            lSendEmail        = true;
                            for (var i = 0; i < Model.DealWith.Count(); i++)// if none is selected then return error
                            {
                                if (Model.DealWith[i].Checked == true)
                                {
                                    sql = " INSERT INTO tblSupplierDealWith(SupplierCode,DealWithId)" +
                                          " VALUES (@SupplierCode,@Id)";

                                    db.Execute(sql, new
                                    {
                                        Model.Supplier.SupplierCode,
                                        Model.DealWith[i].Id
                                    });
                                }
                            }
                        }

                        db.Close();
                    }//try catch
                    catch (Exception e)
                    {
                        if (e.Message.IndexOf("IX_tblSupplier-Code") > 0)
                        {
                            ErrorMsg = "Supplier Code Already Exist....";
                        }
                        else
                        {
                            ErrorMsg = e.Message;
                        }
                        db.Close();
                    }
                }
                else //UPDATE
                {
                    sql = " Update tblSupplier Set NameCompany=@NameCompany," +
                          " Emirates=@Emirates,Address=@Address,POBox=@POBox,EmailAddress=@EmailAddress," +
                          " Phone1=@Phone1,Phone2=@Phone2,Mobile=@Mobile,Fax=@Fax,TradelicenseNo=@TradelicenseNo," +
                          " IssuingAuthority=@IssuingAuthority,TradelicenseExpiryDate=@TradelicenseExpiryDate," +
                          " BankName=@BankName,BankAddress=@BankAddress,BeneficiaryName=@BeneficiaryName," +
                          " IBANNumber=@IBANNumber,SwiftCode=@SwiftCode,VATClassification=@VATClassification,VATRegistrationNo=@VATRegistrationNo" +
                          " Where ID=@ID";
                    try
                    {
                        db.Execute(sql, new
                        {
                            Model.Supplier.NameCompany,
                            Model.Supplier.Emirates,
                            Model.Supplier.Address,
                            Model.Supplier.POBox,
                            Model.Supplier.Owner,
                            Model.Supplier.EmailAddress,
                            Model.Supplier.Phone1,
                            Model.Supplier.Phone2,
                            Model.Supplier.Mobile,
                            Model.Supplier.Fax,
                            Model.Supplier.TradelicenseNo,
                            Model.Supplier.IssuingAuthority,
                            Model.Supplier.TradelicenseExpiryDate,
                            Model.Supplier.BankName,
                            Model.Supplier.BankAddress,
                            Model.Supplier.BeneficiaryName,
                            Model.Supplier.IBANNumber,
                            Model.Supplier.SwiftCode,
                            Model.Supplier.VATClassification,
                            Model.Supplier.VATRegistrationNo,
                            Model.Supplier.ID
                        });
                        db.Close();
                    }
                    catch (Exception e)
                    {
                        ErrorMsg = e.Message;
                        db.Close();
                    }
                }
                UploadDocuments(Model);
            }//Main
            catch (Exception e)
            {
                ErrorMsg = e.Message;
                db.Close();
            }

            return(ErrorMsg);
        }
Esempio n. 19
0
        public ActionResult LoadProductDetail(int id, string enable)
        {
            var detailList = _service.ListConditionDetail(id, enable);
            var model = new SupplierViewModel
            {
                GetProductDetails = detailList,
                TotalRecords = detailList.Count()
            };

            return PartialView("_SupplierDetailPartial", model);
        }
Esempio n. 20
0
        private string GenerateEmailBody(SupplierViewModel Model)
        {
            string SelectedDeal = "";
            string strMailBody  = "";
            string msg          = "<table border='1' cellpadding='2' cellspacing='5'  style='text-align:left;'>";

            msg += "<tr><td>Supplier Code </td> <td><b>" + Model.Supplier.SupplierCode + "</b></td>";
            msg += "<td>Name of Company </td> <td><b>" + Model.Supplier.NameCompany + "</b></td></tr>";


            for (var i = 0; i < Model.DealWith.Count(); i++)
            {
                if (Model.DealWith[i].Checked == true)
                {
                    SelectedDeal += Model.DealWith[i].Name;
                }
            }

            msg += "<tr><td colspan='4'>Deal With</td>";
            msg += "<tr><td colspan='4'>" + SelectedDeal + "</td></tr>";

            msg += "<tr><td>Emirates </td> <td>" + Model.Supplier.Emirates + "</td>";
            msg += "<td>Address </td> <td>" + Model.Supplier.Address + "</td></tr>";


            msg += "<tr><td>P.O.BOX </td> <td>" + Model.Supplier.POBox + "</td>";
            msg += "<td>Owner </td> <td>" + Model.Supplier.Owner + "</td></tr>";

            msg += "<tr><td>Email Address </td> <td>" + Model.Supplier.EmailAddress + "</td>";
            msg += "<td>Phone1 </td> <td>" + Model.Supplier.Phone1 + "</td></tr>";

            msg += "<tr><td>Phone2 </td> <td>" + Model.Supplier.Phone2 + "</td>";
            msg += "<td>Mobile </td> <td>" + Model.Supplier.Mobile + "</td></tr>";

            msg += "<tr><td>Trade License No </td> <td>" + Model.Supplier.TradelicenseNo + "</td>";
            msg += "<td>Issuing Authority </td> <td>" + Model.Supplier.IssuingAuthority + "</td></tr>";

            msg += "<tr><td>Bank Name </td> <td>" + Model.Supplier.BankName + "</td>";
            msg += "<td>Bank Address </td> <td>" + Model.Supplier.BankAddress + "</td></tr>";



            string Classification = "";

            if (Model.Supplier.VATClassification == "R")
            {
                Classification = "Local Vendor (Registered)";
            }
            else if (Model.Supplier.VATClassification == "N")
            {
                Classification = "Local Vendor (Non-Registered)";
            }

            else if (Model.Supplier.VATClassification == "F")
            {
                Classification = "Freezone (Registered)";
            }

            msg += "<tr><td>VAT Clssification </td> <td>" + Classification + "</td>";
            msg += "<td>VAT Registration No </td> <td>" + Model.Supplier.VATRegistrationNo + "</td></tr>";

            msg += "</table>";

            strMailBody = msg;

            return(strMailBody);
        }
Esempio n. 21
0
        public IActionResult Update([FromBody] SupplierViewModel model)
        {
            var result = _supplier.Update(model);

            return(Ok(result));
        }
Esempio n. 22
0
        public IActionResult Add([FromBody] SupplierViewModel model)
        {
            var result = supplier.Add(model);

            return(Created("", result));
        }
Esempio n. 23
0
 public PrevCommand(SupplierViewModel viewModel)
 {
     _supplierVM = viewModel;
 }
Esempio n. 24
0
        public IActionResult Edit([FromBody] SupplierViewModel model)
        {
            var result = supplier.Edit(model);

            return(Ok(result));
        }
Esempio n. 25
0
 public List <Supplier> SearchSupplier(SupplierViewModel supplierViewModel)
 {
     return(_supplierRepository.SearchSupplier(supplierViewModel));
 }
Esempio n. 26
0
 private void LoadEdit(SupplierViewModel supplierViewModel)
 {
     this.DataContext = supplierViewModel;
 }
        public MemoryStream Generate(UnitPaymentOrder model, IUnitPaymentOrderFacade facade, SupplierViewModel supplier, int clientTimeZoneOffset = 7, string userName = null)
        {
            Font header_font = FontFactory.GetFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 12);
            Font normal_font = FontFactory.GetFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 7);
            Font bold_font   = FontFactory.GetFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 7);

            Document     document = new Document(PageSize.A5.Rotate(), 15, 15, 15, 15);
            MemoryStream stream   = new MemoryStream();
            PdfWriter    writer   = PdfWriter.GetInstance(document, stream);

            document.Open();

            PdfPCell cellLeftNoBorder = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT
            };
            PdfPCell cellCenterNoBorder = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_CENTER
            };
            PdfPCell cellCenterTopNoBorder = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_TOP
            };
            PdfPCell cellRightNoBorder = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_RIGHT
            };
            PdfPCell cellJustifyNoBorder = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_JUSTIFIED
            };
            PdfPCell cellJustifyAllNoBorder = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_JUSTIFIED_ALL
            };

            PdfPCell cellCenter = new PdfPCell()
            {
                Border = Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE, Padding = 5
            };
            PdfPCell cellRight = new PdfPCell()
            {
                Border = Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_RIGHT, VerticalAlignment = Element.ALIGN_MIDDLE, Padding = 5
            };
            PdfPCell cellLeft = new PdfPCell()
            {
                Border = Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, Padding = 5
            };

            PdfPCell cellRightMerge = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER | Rectangle.NO_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_RIGHT, VerticalAlignment = Element.ALIGN_TOP, Padding = 5
            };
            PdfPCell cellLeftMerge = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER | Rectangle.LEFT_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_TOP, Padding = 5
            };

            #region Header

            PdfPTable tableHeader = new PdfPTable(3);
            tableHeader.SetWidths(new float[] { 1f, 1f, 1f });

            PdfPCell cellHeaderContentLeft = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER
            };
            cellHeaderContentLeft.AddElement(new Phrase("PT DAN LIRIS", header_font));
            cellHeaderContentLeft.AddElement(new Phrase("BANARAN, GROGOL, SUKOHARJO", normal_font));
            tableHeader.AddCell(cellHeaderContentLeft);

            PdfPCell cellHeaderContentCenter = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER
            };
            cellHeaderContentCenter.AddElement(new Paragraph("NOTA KREDIT", header_font)
            {
                Alignment = Element.ALIGN_CENTER
            });
            cellHeaderContentCenter.AddElement(new Paragraph(model.PaymentMethod.ToUpper().Trim().Equals("KREDIT") ? "" : model.PaymentMethod, normal_font)
            {
                Alignment = Element.ALIGN_CENTER
            });
            tableHeader.AddCell(cellHeaderContentCenter);

            PdfPCell cellHeaderContentRight = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER
            };
            cellHeaderContentRight.AddElement(new Phrase("FM-PB-00-06-014/R2", normal_font));
            cellHeaderContentRight.AddElement(new Phrase($"SUKOHARJO, {model.Date.ToOffset(new TimeSpan(clientTimeZoneOffset, 0, 0)).ToString("dd MMMM yyyy", new CultureInfo("id-ID"))}", normal_font));
            cellHeaderContentRight.AddElement(new Phrase($"( {model.SupplierCode} ) {model.SupplierName}", normal_font));
            cellHeaderContentRight.AddElement(new Phrase(model.SupplierAddress, normal_font));
            /* tambahan */
            if (supplier.npwp == "" || supplier.npwp == null)
            {
                supplier.npwp = "00.000.000.0-000.000";
                //cellHeaderContentRight.AddElement(new Phrase("NPWP / NIK : 00.000.000.0-000.000", normal_font));
            }
            //else
            //{
            cellHeaderContentRight.AddElement(new Phrase($"NPWP / NIK : {supplier.npwp}", normal_font));
            //}
            /* tambahan */
            tableHeader.AddCell(cellHeaderContentRight);

            PdfPCell cellHeader = new PdfPCell(tableHeader);
            tableHeader.ExtendLastRow = false;
            tableHeader.SpacingAfter  = 15f;
            document.Add(tableHeader);

            #endregion

            #region Identity

            PdfPTable tableIdentity = new PdfPTable(3);
            tableIdentity.SetWidths(new float[] { 1.5f, 4.5f, 3f });

            cellLeftNoBorder.Phrase = new Phrase("Nota Pembelian", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Phrase = new Phrase($":   {model.CategoryName}", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Phrase = new Phrase($"Nomor   {model.UPONo}", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Phrase = new Phrase("Untuk", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Phrase = new Phrase($":   {model.DivisionName}", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);
            cellLeftNoBorder.Phrase = new Phrase("", normal_font);
            tableIdentity.AddCell(cellLeftNoBorder);

            PdfPCell cellIdentity = new PdfPCell(tableIdentity);
            tableIdentity.ExtendLastRow = false;
            tableIdentity.SpacingAfter  = 15f;
            document.Add(tableIdentity);

            #endregion

            #region TableContent

            PdfPTable tableContent = new PdfPTable(10);
            tableContent.SetWidths(new float[] { 1.3f, 5f, 3f, 1.5f, 3.5f, 1.5f, 3.5f, 4f, 4f, 3f });

            cellCenter.Phrase = new Phrase("No.", bold_font);
            tableContent.AddCell(cellCenter);
            cellCenter.Phrase = new Phrase("Nama Barang", bold_font);
            tableContent.AddCell(cellCenter);
            cellCenter.Phrase = new Phrase("Jumlah", bold_font);
            tableContent.AddCell(cellCenter);
            cellCenter.Phrase  = new Phrase("Harga Satuan", bold_font);
            cellCenter.Colspan = 2;
            tableContent.AddCell(cellCenter);
            cellCenter.Phrase  = new Phrase("Harga Total", bold_font);
            cellCenter.Colspan = 2;
            tableContent.AddCell(cellCenter);
            cellCenter.Phrase  = new Phrase("Nomor Order", bold_font);
            cellCenter.Colspan = 0;
            tableContent.AddCell(cellCenter);
            cellCenter.Phrase = new Phrase("Nomor Bon Unit", bold_font);
            tableContent.AddCell(cellCenter);
            cellCenter.Phrase = new Phrase("Unit", bold_font);
            tableContent.AddCell(cellCenter);

            int    no     = 0;
            double jumlah = 0;

            List <DateTimeOffset> DueDates = new List <DateTimeOffset>()
            {
                model.DueDate
            };
            List <DateTimeOffset> UnitReceiptNoteDates = new List <DateTimeOffset>()
            {
                DateTimeOffset.MinValue
            };

            //foreach (var f in new float[15])
            foreach (var item in model.Items)
            {
                var unitReceiptNote     = facade.GetUnitReceiptNote(item.URNId);
                var unitReceiptNoteDate = unitReceiptNote.ReceiptDate;
                UnitReceiptNoteDates.Add(unitReceiptNoteDate);

                //var UnitName = unitReceiptNote.UnitId == "50" ? "WEAVING" : unitReceiptNote.UnitName;
                var UnitName = "";
                var unitId   = unitReceiptNote.UnitId;
                if (unitId == "50")
                {
                    UnitName = "WEAVING";
                }
                else if (unitId == "35")
                {
                    UnitName = "SPINNING 1";
                }
                else
                {
                    UnitName = unitReceiptNote.UnitName;
                }

                foreach (var detail in item.Details)
                {
                    var PaymentDueDays = facade.GetExternalPurchaseOrder(detail.EPONo).PaymentDueDays;
                    DueDates.Add(unitReceiptNoteDate.AddDays(Double.Parse(PaymentDueDays ?? "0")));

                    cellCenter.Phrase = new Phrase($"{++no}", normal_font);
                    tableContent.AddCell(cellCenter);

                    cellLeft.Phrase = new Phrase(detail.ProductName, normal_font);
                    tableContent.AddCell(cellLeft);

                    cellCenter.Phrase = new Phrase(string.Format("{0:n2}", detail.ReceiptQuantity) + $" {detail.UomUnit}", normal_font);
                    tableContent.AddCell(cellCenter);

                    cellLeftMerge.Phrase = new Phrase($"{model.CurrencyCode}", normal_font);
                    tableContent.AddCell(cellLeftMerge);

                    cellRightMerge.Phrase = new Phrase(string.Format("{0:n4}", detail.PricePerDealUnit), normal_font);
                    tableContent.AddCell(cellRightMerge);

                    cellLeftMerge.Phrase = new Phrase($"{model.CurrencyCode}", normal_font);
                    tableContent.AddCell(cellLeftMerge);

                    cellRightMerge.Phrase = new Phrase(string.Format("{0:n2}", detail.PriceTotal), normal_font);
                    tableContent.AddCell(cellRightMerge);

                    cellCenter.Phrase = new Phrase($"{detail.PRNo}", normal_font);
                    tableContent.AddCell(cellCenter);

                    cellCenter.Phrase = new Phrase($"{item.URNNo}", normal_font);
                    tableContent.AddCell(cellCenter);

                    cellCenter.Phrase = new Phrase($"{UnitName}", normal_font);
                    tableContent.AddCell(cellCenter);

                    jumlah += detail.PriceTotal;
                }
            }

            PdfPCell cellContent = new PdfPCell(tableContent);
            tableContent.ExtendLastRow = false;
            tableContent.SpacingAfter  = 10f;
            document.Add(tableContent);

            #endregion

            #region Tax

            PdfPTable tableTax = new PdfPTable(3);
            tableTax.SetWidths(new float[] { 1f, 0.3f, 1f });

            var ppn          = jumlah * (model.VatRate / 100);
            var total        = jumlah + (model.UseVat ? ppn : 0);
            var pph          = jumlah * model.IncomeTaxRate / 100;
            var totalWithPph = total - pph;

            var withoutIncomeTax = true;


            if (model.UseIncomeTax && model.IncomeTaxBy == "Supplier")
            {
                withoutIncomeTax = false;
            }

            if (withoutIncomeTax)
            {
                tableTax.AddCell(new PdfPCell()
                {
                    Border = Rectangle.NO_BORDER
                });
            }
            else
            {
                PdfPTable tableIncomeTax = new PdfPTable(3);
                tableIncomeTax.SetWidths(new float[] { 5f, 2f, 3f });

                tableIncomeTax.AddCell(new PdfPCell(new Phrase(" ", normal_font))
                {
                    Border = Rectangle.NO_BORDER, Colspan = 3
                });

                cellLeftNoBorder.Phrase = new Phrase($"PPh {model.IncomeTaxName} {model.IncomeTaxRate} %", normal_font);
                tableIncomeTax.AddCell(cellLeftNoBorder);

                cellLeftNoBorder.Phrase = new Phrase($":   {model.CurrencyCode}", normal_font);
                tableIncomeTax.AddCell(cellLeftNoBorder);

                cellRightNoBorder.Phrase = new Phrase($"{pph.ToString("n", new CultureInfo("id-ID"))}", normal_font);
                tableIncomeTax.AddCell(cellRightNoBorder);

                cellLeftNoBorder.Phrase = new Phrase("Jumlah dibayar Ke Supplier", normal_font);
                tableIncomeTax.AddCell(cellLeftNoBorder);

                cellLeftNoBorder.Phrase = new Phrase($":   {model.CurrencyCode}", normal_font);
                tableIncomeTax.AddCell(cellLeftNoBorder);

                cellRightNoBorder.Phrase = new Phrase($"{totalWithPph.ToString("n", new CultureInfo("id-ID"))}", normal_font);
                tableIncomeTax.AddCell(cellRightNoBorder);

                tableTax.AddCell(new PdfPCell(tableIncomeTax)
                {
                    Border = Rectangle.NO_BORDER
                });
            }

            tableTax.AddCell(new PdfPCell()
            {
                Border = Rectangle.NO_BORDER
            });

            PdfPTable tableVat = new PdfPTable(2);

            cellJustifyAllNoBorder.Phrase = new Phrase($"Jumlah . . . . . . . . . . . . . . .   {model.CurrencyCode}", normal_font);
            tableVat.AddCell(cellJustifyAllNoBorder);

            cellRightNoBorder.Phrase = new Phrase($"{jumlah.ToString("n", new CultureInfo("id-ID"))}", normal_font);
            tableVat.AddCell(cellRightNoBorder);

            if (model.UseVat)
            {
                cellJustifyAllNoBorder.Phrase = new Phrase($"PPn {model.VatRate} % . . . . . . . . . . . . . .   {model.CurrencyCode}", normal_font);
                tableVat.AddCell(cellJustifyAllNoBorder);
            }
            else
            {
                cellLeftNoBorder.Phrase = new Phrase(string.Concat("PPn %"), normal_font);
                tableVat.AddCell(cellLeftNoBorder);
            }

            cellRightNoBorder.Phrase = new Phrase(model.UseVat ? $"{ppn.ToString("n", new CultureInfo("id-ID"))}" : "-", normal_font);
            tableVat.AddCell(cellRightNoBorder);

            cellJustifyAllNoBorder.Phrase = new Phrase($"T O T A L. . . . . . . . . . . . . .   {model.CurrencyCode}", normal_font);
            tableVat.AddCell(cellJustifyAllNoBorder);

            cellRightNoBorder.Phrase = new Phrase($"{total.ToString("n", new CultureInfo("id-ID"))}", normal_font);
            tableVat.AddCell(cellRightNoBorder);

            tableTax.AddCell(new PdfPCell(tableVat)
            {
                Border = Rectangle.NO_BORDER
            });

            PdfPCell taxCell = new PdfPCell(tableTax);
            tableTax.ExtendLastRow = false;
            tableTax.SpacingAfter  = 15f;
            document.Add(tableTax);

            #endregion

            Paragraph paragraphTerbilang = new Paragraph($"Terbilang : {NumberToTextIDN.terbilang(!withoutIncomeTax ? totalWithPph : total)} {model.CurrencyDescription.ToLower()}", bold_font)
            {
                SpacingAfter = 15f
            };
            document.Add(paragraphTerbilang);

            #region Footer

            PdfPTable tableFooter = new PdfPTable(3);
            tableFooter.SetWidths(new float[] { 1f, 0.3f, 1f });

            PdfPTable tableFooterLeft = new PdfPTable(3);
            tableFooterLeft.SetWidths(new float[] { 5f, 0.4f, 4.6f });

            cellLeftNoBorder.Phrase = new Phrase("Perjanjian Pembayaran", normal_font);
            tableFooterLeft.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Phrase = new Phrase(":", normal_font);
            tableFooterLeft.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Phrase = new Phrase($"{DueDates.Max().ToOffset(new TimeSpan(clientTimeZoneOffset, 0, 0)).ToString("dd MMMM yyyy", new CultureInfo("id-ID"))}", normal_font);
            tableFooterLeft.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Phrase = new Phrase("Invoice", normal_font);
            tableFooterLeft.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Phrase = new Phrase(":", normal_font);
            tableFooterLeft.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Phrase = new Phrase($"{model.InvoiceNo ?? "-"}, {model.InvoiceDate.ToOffset(new TimeSpan(clientTimeZoneOffset, 0, 0)).ToString("dd MMMM yyyy", new CultureInfo("id-ID"))}", normal_font);
            tableFooterLeft.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Phrase = new Phrase("No PIB", normal_font);
            tableFooterLeft.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Phrase = new Phrase(":", normal_font);
            tableFooterLeft.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Phrase = new Phrase($"{model.PibNo ?? "-"}", normal_font);
            tableFooterLeft.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Phrase = new Phrase("Ket.", normal_font);
            tableFooterLeft.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Phrase = new Phrase(":", normal_font);
            tableFooterLeft.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Phrase = new Phrase($"{model.Remark ?? "-"}", normal_font);
            tableFooterLeft.AddCell(cellLeftNoBorder);

            tableFooter.AddCell(new PdfPCell(tableFooterLeft)
            {
                Border = Rectangle.NO_BORDER
            });

            tableFooter.AddCell(new PdfPCell()
            {
                Border = Rectangle.NO_BORDER
            });

            PdfPTable tableFooterRight = new PdfPTable(3);
            tableFooterRight.SetWidths(new float[] { 5f, 0.5f, 6.8f });

            cellLeftNoBorder.Phrase = new Phrase("Barang Datang", normal_font);
            tableFooterRight.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Phrase = new Phrase(":", normal_font);
            tableFooterRight.AddCell(cellLeftNoBorder);

            var maxUnitReceiptNoteDate = UnitReceiptNoteDates.Max();
            cellLeftNoBorder.Phrase = new Phrase($"{maxUnitReceiptNoteDate.ToOffset(new TimeSpan(clientTimeZoneOffset, 0, 0)).ToString("dd MMMM yyyy", new CultureInfo("id-ID"))}", normal_font);
            tableFooterRight.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Phrase = new Phrase("Nomor Faktur Pajak PPN", normal_font);
            tableFooterRight.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Phrase = new Phrase(":", normal_font);
            tableFooterRight.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Phrase = new Phrase($"{model.VatNo ?? "-"}", normal_font);
            tableFooterRight.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Phrase = new Phrase("Pembayaran", normal_font);
            tableFooterRight.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Phrase = new Phrase(":", normal_font);
            tableFooterRight.AddCell(cellLeftNoBorder);

            cellLeftNoBorder.Phrase = new Phrase($"{model.PaymentMethod ?? "-"}", normal_font);
            tableFooterRight.AddCell(cellLeftNoBorder);

            tableFooter.AddCell(new PdfPCell(tableFooterRight)
            {
                Border = Rectangle.NO_BORDER
            });

            PdfPCell taxFooter = new PdfPCell(tableFooter);
            tableFooter.ExtendLastRow = false;
            tableFooter.SpacingAfter  = 30f;
            document.Add(tableFooter);

            #endregion

            #region TableSignature

            PdfPTable tableSignature = new PdfPTable(4);

            cellCenterTopNoBorder.Phrase = new Paragraph("Diperiksa,\nVerifkasi\n\n\n\n\n\n\n\n(                                   )", normal_font);
            tableSignature.AddCell(cellCenterTopNoBorder);
            cellCenterTopNoBorder.Phrase = new Paragraph("Mengetahui,\nPimpinan Bagian\n\n\n\n\n\n\n\n(                                   )", normal_font);
            tableSignature.AddCell(cellCenterTopNoBorder);
            cellCenterTopNoBorder.Phrase = new Paragraph("Tanda Terima,\nBagian Pembelian\n\n\n\n\n\n\n\n(                                   )", normal_font);
            tableSignature.AddCell(cellCenterTopNoBorder);
            cellCenterTopNoBorder.Phrase = new Paragraph($"Dibuat Oleh,\n\n\n\n\n\n\n\n\n( {userName ?? "                                 "} )", normal_font);
            tableSignature.AddCell(cellCenterTopNoBorder);

            PdfPCell cellSignature = new PdfPCell(tableSignature);
            tableSignature.ExtendLastRow = false;
            document.Add(tableSignature);

            #endregion

            document.Close();
            byte[] byteInfo = stream.ToArray();
            stream.Write(byteInfo, 0, byteInfo.Length);
            stream.Position = 0;

            return(stream);
        }
Esempio n. 28
0
 private void btnSupplier_Click(object sender, RoutedEventArgs e)
 {
     DataContext = new SupplierViewModel();
 }
Esempio n. 29
0
        public ActionResult Edit(Guid Id)
        {
            var supplier = _supplierService.GetById(Id);

            return(View(SupplierViewModel.GetSupplierViewModelFromSupplier(supplier)));
        }
Esempio n. 30
0
        public ActionResult AddOrUpdate(SupplierViewModel model)
        {
            if (model.Id == null)
            {
                var account = accountService.GetAccountByUserName(model.Username);
                if (account != null)
                {
                    TempData[Constant.MessageViewBagName] = new GenericMessageViewModel
                    {
                        Message     = "Tài khoản đã tồn tại",
                        MessageType = GenericMessages.error
                    };
                    return(RedirectToAction("SupplierView", "Supplier"));
                }
                else
                {
                    Core.Models.Entities.Supplier supplier = new Core.Models.Entities.Supplier()
                    {
                        Name      = model.Name,
                        Address   = model.Address,
                        CreateAt  = DateTime.Now,
                        UpdateAt  = DateTime.Now,
                        PathImage = model.PathImage
                    };
                    try
                    {
                        var act = new Account()
                        {
                            Username = model.Username, Password = model.Password
                        };
                        context.Accounts.Add(act);

                        supplier.Account = act;
                        context.Suppliers.Add(supplier);
                        context.SaveChanges();

                        TempData[Constant.MessageViewBagName] = new GenericMessageViewModel
                        {
                            Message     = "Thêm người dùng thành công",
                            MessageType = GenericMessages.success
                        };
                        return(RedirectToAction("SupplierView", "Supplier"));
                    }
                    catch (Exception)
                    {
                        TempData[Constant.MessageViewBagName] = new GenericMessageViewModel
                        {
                            Message     = "Thêm người dùng thất bại",
                            MessageType = GenericMessages.error
                        };
                        return(RedirectToAction("SupplierView", "Supplier"));
                    }
                }
            }
            else
            {
                var supplier = supplierService.GetSupplierByID(model.Id);
                if (supplier != null)
                {
                    if (!supplier.Account.Username.Equals(model.Username) && !model.Username.Equals(""))
                    {
                        var listCount = context.Accounts.Where(x => x.Username.Equals(model.Username)).ToList();
                        if (listCount.Count == 0)
                        {
                            supplier.Account.Username = model.Username;
                        }
                        else
                        {
                            TempData[Constant.MessageViewBagName] = new GenericMessageViewModel
                            {
                                Message     = "Tên người dùng đã tồn tại",
                                MessageType = GenericMessages.error
                            };
                            return(RedirectToAction("SupplierView", "Supplier"));
                        }
                    }

                    supplier.Name             = model.Name;
                    supplier.Address          = model.Address;
                    supplier.PathImage        = model.PathImage;
                    supplier.Account.Password = model.Password;
                    supplier.UpdateAt         = DateTime.Now;
                    try
                    {
                        context.SaveChanges();
                        TempData[Constant.MessageViewBagName] = new GenericMessageViewModel
                        {
                            Message     = "Cập nhật người dùng thành công",
                            MessageType = GenericMessages.success
                        };
                        return(RedirectToAction("SupplierView", "Supplier"));
                    }
                    catch (Exception)
                    {
                        TempData[Constant.MessageViewBagName] = new GenericMessageViewModel
                        {
                            Message     = "Cập nhật người dùng thất bại",
                            MessageType = GenericMessages.error
                        };
                        return(RedirectToAction("SupplierView", "Supplier"));
                    }
                }
            }

            TempData[Constant.MessageViewBagName] = new GenericMessageViewModel
            {
                Message     = "Đã xảy ra lỗi",
                MessageType = GenericMessages.error
            };
            return(RedirectToAction("SupplierView", "Supplier"));
        }
Esempio n. 31
0
        public MemoryStream GeneratePdfTemplate(GarmentInvoiceViewModel viewModel, SupplierViewModel supplier, int clientTimeZoneOffset, IGarmentDeliveryOrderFacade DOfacade)
        {
            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, 9);
            Font bold_font   = FontFactory.GetFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 8);
            //Font header_font = FontFactory.GetFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED, 8);

            Document document = new Document(PageSize.A4, 40, 40, 40, 40);

            document.AddHeader("Header", viewModel.npn);
            MemoryStream stream = new MemoryStream();
            PdfWriter    writer = PdfWriter.GetInstance(document, stream);

            writer.PageEvent = new PDFPages();
            document.Open();

            Chunk        chkHeader = new Chunk(" ");
            Phrase       pheader   = new Phrase(chkHeader);
            HeaderFooter header    = new HeaderFooter(pheader, false);

            header.Border    = Rectangle.NO_BORDER;
            header.Alignment = Element.ALIGN_RIGHT;
            document.Header  = header;


            #region Header

            PdfPTable tableHeader = new PdfPTable(1);
            tableHeader.SetWidths(new float[] { 4f });
            PdfPCell cellHeaderContentLeft = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT
            };
            //PdfPCell cellHeaderContentRight = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_RIGHT };

            cellHeaderContentLeft.Phrase = new Phrase("PT DAN LIRIS" + "\n" + "JL. Merapi No.23" + "\n" + "Banaran, Grogol, Kab. Sukoharjo" + "\n" + "Jawa Tengah 57552 - INDONESIA" + "\n" + "PO.BOX 166 Solo 57100" + "\n" + "Telp. (0271) 740888, 714400" + "\n" + "Fax. (0271) 735222, 740777", bold_font);
            tableHeader.AddCell(cellHeaderContentLeft);

            //string noPO = viewModel.Supplier.Import ? "FM-PB-00-06-009/R1" + "\n" + "PO: " + EPONo  : "PO: " + EPONo;


            PdfPCell cellHeader = new PdfPCell(tableHeader);             // dont remove
            tableHeader.ExtendLastRow = false;
            tableHeader.SpacingAfter  = 10f;
            document.Add(tableHeader);

            string    titleString = "NOTA PAJAK PPN\n\n";
            Paragraph title       = new Paragraph(titleString, bold_font)
            {
                Alignment = Element.ALIGN_CENTER
            };
            document.Add(title);
            bold_font.SetStyle(Font.NORMAL);


            PdfPTable tableIncomeTax = new PdfPTable(1);
            tableIncomeTax.SetWidths(new float[] { 4.5f });
            PdfPCell cellTaxLeft = new PdfPCell()
            {
                Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT
            };
            cellTaxLeft.Phrase = new Phrase("No. Nota Pajak" + "    : " + viewModel.npn, normal_font);
            tableIncomeTax.AddCell(cellTaxLeft);
            cellTaxLeft.Phrase = new Phrase("Kode Supplier" + "      : " + viewModel.supplier.Code, normal_font);
            tableIncomeTax.AddCell(cellTaxLeft);
            cellTaxLeft.Phrase = new Phrase("Nama Supplier" + "     : " + viewModel.supplier.Name, normal_font);
            tableIncomeTax.AddCell(cellTaxLeft);
            /* tambahan */
            if (supplier.npwp == "" || supplier.npwp == null)
            {
                supplier.npwp = "00.000.000.0-000.000";
                //cellTaxLeft.Phrase = new Phrase("NPWP                  : 00.000.000.0-000.000", normal_font);
            }
            //else
            //{
            cellTaxLeft.Phrase = new Phrase($"NPWP                  : {supplier.npwp}", normal_font);
            //}
            /* tambahan */
            tableIncomeTax.AddCell(cellTaxLeft);

            cellTaxLeft.Phrase = new Phrase($"Faktur Pajak        : {viewModel.vatNo.ToString()}", normal_font);
            tableIncomeTax.AddCell(cellTaxLeft);


            PdfPCell cellSupplier = new PdfPCell(tableIncomeTax); // dont remove
            tableIncomeTax.ExtendLastRow = false;
            tableIncomeTax.SpacingAfter  = 10f;
            document.Add(tableIncomeTax);
            #endregion
            #region data
            PdfPCell cellCenter = new PdfPCell()
            {
                Border = Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE, Padding = 5
            };
            PdfPCell cellRight = new PdfPCell()
            {
                Border = Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_RIGHT, VerticalAlignment = Element.ALIGN_MIDDLE, Padding = 5
            };
            PdfPCell cellLeft = new PdfPCell()
            {
                Border = Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_MIDDLE, Padding = 5
            };

            PdfPTable tableContent = new PdfPTable(8);
            tableContent.SetWidths(new float[] { 4.5f, 5f, 3.5f, 5f, 4f, 5f, 2.2f, 5f });
            cellCenter.Phrase = new Phrase("No Surat Jalan", bold_font);
            tableContent.AddCell(cellCenter);
            cellCenter.Phrase = new Phrase("Tanggal Surat Jalan", bold_font);
            tableContent.AddCell(cellCenter);
            cellCenter.Phrase = new Phrase("No Invoice", bold_font);
            tableContent.AddCell(cellCenter);
            cellCenter.Phrase = new Phrase("Tanggal Invoice", bold_font);
            tableContent.AddCell(cellCenter);
            cellCenter.Phrase = new Phrase("Nama Barang", bold_font);
            tableContent.AddCell(cellCenter);
            cellCenter.Phrase = new Phrase("DPP", bold_font);
            tableContent.AddCell(cellCenter);
            cellCenter.Phrase = new Phrase("Rate PPn", bold_font);
            tableContent.AddCell(cellCenter);
            cellCenter.Phrase = new Phrase("Sub Total PPn", bold_font);
            tableContent.AddCell(cellCenter);

            double total       = 0;
            double totalPPN    = 0;
            double totalPPNIDR = 0;
            foreach (GarmentInvoiceItemViewModel item in viewModel.items)
            {
                total += item.deliveryOrder.totalAmount;

                foreach (GarmentInvoiceDetailViewModel detail in item.details)
                {
                    cellLeft.Phrase = new Phrase(item.deliveryOrder.doNo, normal_font);
                    tableContent.AddCell(cellLeft);

                    string doDate = item.deliveryOrder.doDate.ToOffset(new TimeSpan(clientTimeZoneOffset, 0, 0)).ToString("dd MMMM yyyy", new CultureInfo("id-ID"));

                    cellLeft.Phrase = new Phrase(doDate, normal_font);
                    tableContent.AddCell(cellLeft);

                    cellLeft.Phrase = new Phrase(viewModel.invoiceNo, normal_font);
                    tableContent.AddCell(cellLeft);

                    string invoiceDate = viewModel.invoiceDate.Value.ToOffset(new TimeSpan(clientTimeZoneOffset, 0, 0)).ToString("dd MMMM yyyy", new CultureInfo("id-ID"));

                    cellLeft.Phrase = new Phrase(invoiceDate, normal_font);
                    tableContent.AddCell(cellLeft);

                    cellLeft.Phrase = new Phrase(detail.product.Name, normal_font);
                    tableContent.AddCell(cellLeft);

                    cellRight.Phrase = new Phrase(Math.Round(detail.pricePerDealUnit * detail.doQuantity, 2).ToString("N2"), normal_font);
                    tableContent.AddCell(cellRight);

                    cellRight.Phrase = new Phrase((viewModel.vatRate).ToString(), normal_font);
                    tableContent.AddCell(cellRight);

                    cellRight.Phrase = new Phrase(Math.Round(viewModel.vatRate * detail.pricePerDealUnit * detail.doQuantity / 100, 2).ToString("N2"), normal_font);
                    tableContent.AddCell(cellRight);

                    totalPPN += ((viewModel.vatRate / 100) * detail.pricePerDealUnit * detail.doQuantity);
                    var    garmentDeliveryOrder = DOfacade.ReadById((int)item.deliveryOrder.Id);
                    double rate = 1;
                    if (garmentDeliveryOrder != null)
                    {
                        rate = (double)garmentDeliveryOrder.DOCurrencyRate;
                    }
                    totalPPNIDR += ((viewModel.vatRate / 100) * detail.pricePerDealUnit * detail.doQuantity * rate);                    /**dikali rate DO*/
                }
            }
            cellRight.Phrase  = new Phrase("Total DPP", normal_font);
            cellRight.Colspan = 7;
            tableContent.AddCell(cellRight);
            cellRight.Phrase  = new Phrase(total.ToString("N2"), normal_font);
            cellRight.Colspan = 7;
            tableContent.AddCell(cellRight);
            cellRight.Phrase  = new Phrase("Total Ppn", normal_font);
            cellRight.Colspan = 7;
            tableContent.AddCell(cellRight);
            cellRight.Phrase  = new Phrase(totalPPN.ToString("N2"), normal_font);
            cellRight.Colspan = 7;
            tableContent.AddCell(cellRight);
            cellRight.Phrase  = new Phrase("Total Ppn IDR", normal_font);
            cellRight.Colspan = 7;
            tableContent.AddCell(cellRight);
            cellRight.Phrase  = new Phrase(totalPPNIDR.ToString("N2"), normal_font);
            cellRight.Colspan = 7;
            tableContent.AddCell(cellRight);

            PdfPCell cellContent = new PdfPCell(tableContent);             // dont remove
            tableContent.ExtendLastRow = false;
            tableContent.SpacingAfter  = 20f;
            document.Add(tableContent);
            #endregion
            #region TableSignature

            PdfPTable tableSignature = new PdfPTable(3);

            PdfPCell cellSignatureContent = new PdfPCell()
            {
                Border = Rectangle.TOP_BORDER | Rectangle.LEFT_BORDER | Rectangle.BOTTOM_BORDER | Rectangle.RIGHT_BORDER, HorizontalAlignment = Element.ALIGN_CENTER
            };

            cellSignatureContent.Phrase = new Phrase("Administrasi\n\n\n\n\n\n\n(  " + "Nama & Tanggal" + "  )", bold_font);
            tableSignature.AddCell(cellSignatureContent);
            cellSignatureContent.Phrase = new Phrase("Staff Pembelian\n\n\n\n\n\n\n(  " + "Nama & Tanggal" + "  )", bold_font);
            tableSignature.AddCell(cellSignatureContent);
            cellSignatureContent.Phrase = new Phrase("Verifikasi\n\n\n\n\n\n\n(  " + "Nama & Tanggal" + "  )", bold_font);
            tableSignature.AddCell(cellSignatureContent);


            PdfPCell cellSignature = new PdfPCell(tableSignature);             // dont remove
            tableSignature.ExtendLastRow = false;
            tableSignature.SpacingBefore = 20f;
            tableSignature.SpacingAfter  = 20f;
            document.Add(tableSignature);

            #endregion
            document.Close();
            byte[] byteInfo = stream.ToArray();
            stream.Write(byteInfo, 0, byteInfo.Length);
            stream.Position = 0;

            return(stream);
        }
Esempio n. 32
0
        public ActionResult UpdateProfile(SupplierViewModel model)
        {
            bool checkUpdate = true;

            if (!model.Id.Equals(""))
            {
                var account = accountService.GetAccountByID(model.AccountID.ToString());
                if (account != null)
                {
                    if (model.Name != null && model.Address != null && model.PathImage != null)
                    {
                        account.Supplier.Name      = model.Name;
                        account.Supplier.Address   = model.Address;
                        account.Supplier.PathImage = model.PathImage;
                    }
                    else
                    {
                        checkUpdate = false;
                    }

                    if (model.Password != null)
                    {
                        account.Password = model.Password;
                    }


                    if (!account.Username.Equals(model.Username) && !model.Username.Equals(""))
                    {
                        var listCount = context.Accounts.Where(x => x.Username.Equals(model.Username)).ToList();
                        if (listCount.Count == 0)
                        {
                            account.Username = model.Username;
                        }
                        else
                        {
                            TempData[Constant.MessageViewBagName] = new GenericMessageViewModel
                            {
                                Message     = "Tên người dùng đã tồn tại",
                                MessageType = GenericMessages.error
                            };
                            return(RedirectToAction("ProfileView", "Supplier", new { Area = "Supplier" }));
                        }
                    }
                }
            }
            try
            {
                context.SaveChanges();
            }
            catch (System.Exception)
            {
                checkUpdate = false;
            }

            if (checkUpdate)
            {
                TempData[Constant.MessageViewBagName] = new GenericMessageViewModel
                {
                    Message     = "Cập nhật thông tin thành công",
                    MessageType = GenericMessages.success
                };
                return(RedirectToAction("ProfileView", "Supplier", new { Area = "Supplier" }));
            }
            TempData[Constant.MessageViewBagName] = new GenericMessageViewModel
            {
                Message     = "Cập nhật thông tin thất bại",
                MessageType = GenericMessages.error
            };
            return(RedirectToAction("ProfileView", "Supplier", new { Area = "Supplier" }));
        }
Esempio n. 33
0
 public async Task <IActionResult> Edit(SupplierViewModel model)
 {
     model.UpdatedDateTime = DateTime.Now;
     return(await SaveSupplierDetails(model, "Edit"));
 }
        public void Add(SupplierViewModel SupplierVM)
        {
            var model = Mapper.Map <SupplierViewModel, Supplier>(SupplierVM);

            _supplierRepository.Add(model);
        }
Esempio n. 35
0
        public ActionResult Create(SupplierViewModel model)
        {
            if (model.V3 != true)
            {
                return this.Json(new { result = Constants.UnSuccess });
            }

            return model.Supplier.bSupplierID != 0 ? EditResultJson(model) : CreateResultJson(model);
        }
        public void Update(SupplierViewModel SupplierVM)
        {
            var page = Mapper.Map <SupplierViewModel, Supplier>(SupplierVM);

            _supplierRepository.Update(page);
        }
Esempio n. 37
0
        public ActionResult Create(int? id)
        {
            var userName = System.Web.HttpContext.Current.User.Identity.Name;
            var user = _systemService.GetUserAndRole(0, userName);
            if (user == null)
            {
                return RedirectToAction("Index", "Login");
            }
            if (user.SupplierR ==0)
            {
                return RedirectToAction("Index", "Home");
            }

            var item = new WAMS_SUPPLIER();

            if (id.HasValue)
            {
                item = _service.GetByKey(id.Value);
            }

            var model = new SupplierViewModel
            {
                Id = item.bSupplierID,
                vSupplierName = item.vSupplierName,
                vAddress = item.vAddress,
                vCity = item.vCity,
                Telephone1 = item.vPhone1,
                Telephone2 = item.vPhone2,
                Mobile = item.vMobile,
                vFax = item.vFax,
                Email = item.vEmail,
                vContactPerson = item.vContactPerson,
                fTotalMoney = item.fTotalMoney,
                bSupplierTypeID = item.bSupplierTypeID,
                iEnable = item.iEnable,
                iService = item.iService,
                dDateCreate = item.dDateCreate,
                CountryId = item.CountryId,
                iMarket = item.iMarket,
                iStore = item.iStore,
                iPayment = item.iPayment,
                dCreated = item.dCreated,
                dModified = item.dModified,
                iCreated = item.iCreated,
                iModified = item.iModified,
                Timestamp = item.Timestamp,
                Stores = new SelectList(_systemService.StoreList(), "Id", "Name"),
                Types = new SelectList(_systemService.SupplierTypeList(), "Id", "Name"),
                Countries = new SelectList(_systemService.CountryList(), "Id", "Name"),
                UserLogin = user
            };

            if (!id.HasValue) return View(model);
            var temp = _service.ListConditionDetail(id.Value, "1");
            model.GetProductDetails = temp;
            model.TotalRecords = temp.Count;

            // FUNCTION
            return View(model);
        }
Esempio n. 38
0
        public static KeyValuePair<Supplier, SupplierViewModel> GetPropertyMaps()
        {
            var id = Guid.NewGuid();
            var samsung = "Samsung";
            var agreementDate = DateTime.Now.AddDays(-2);
            var src = new Supplier
            {
                Id = id,
                Name = samsung,
                AgreementDate = agreementDate,
                Rank = 7
            };

            var dest = new SupplierViewModel
            {
                Id = id,
                Name = samsung,
                AgreementDate = agreementDate,
            };

            var keyValuePair = new KeyValuePair<Supplier, SupplierViewModel>
                (
                src,
                dest
                );
            return keyValuePair;
        }
Esempio n. 39
0
 public ActionResult LoadSupplier(int page, int size, int supplierType, int supplierId, string supplierName, string stockCode, string stockName, int country, int market, string enable)
 {
     var userName = System.Web.HttpContext.Current.User.Identity.Name;
     var totalRecord = _service.ListConditionCount(page, size, supplierType, supplierId, supplierName, stockCode, stockName, country, market, enable);
     var totalTemp = Convert.ToDecimal(totalRecord) / Convert.ToDecimal(size);
     var totalPages = Convert.ToInt32(Math.Ceiling(totalTemp));
     var model = new SupplierViewModel
     {
         UserLogin = _systemService.GetUserAndRole(0, userName),
         SupplierGetListResults = _service.ListCondition(page, size, supplierType, supplierId, supplierName, stockCode, stockName, country, market, enable),
         TotalRecords = Convert.ToInt32(totalRecord),
         TotalPages = totalPages,
         CurrentPage = page,
         PageSize = size
     };
     return PartialView("_SupplierPartial", model);
 }
Esempio n. 40
0
        public static KeyValuePair<FashionProduct, FashionProductViewModel> ComplexMap()
        {
            var sizes = new List<Size>();
            var sizesViewModels = new List<SizeViewModel>();

            var random = new Random();
            var sizeCount = random.Next(3, 10);
            var cityCount = random.Next(4, 10);

            for (var i = 0; i < sizeCount; i++)
            {
                var newGuid = Guid.NewGuid();
                var name = string.Format("Size {0}", i);
                var alias = string.Format("Alias Size {0}", i);
                sizes.Add(
                    new Size
                    {
                        Id = newGuid,
                        Name = name,
                        Alias = alias,
                        SortOrder = i
                    });
                sizesViewModels.Add(new SizeViewModel
                {
                    Id = newGuid,
                    Name = name,
                    Alias = alias,
                    SortOrder = i
                });
            }

            var cities = new List<City>();
            var cityViewModels = new List<CityViewModel>();

            var ftRandom = new Random();
            for (var i = 0; i < cityCount; i++)
            {
                var newGuid = Guid.NewGuid();
                var name = string.Format("City {0}", i);

                var featureCount = ftRandom.Next(7 , 50);
                var features = new Feature[featureCount];
                var featureViewModels = new List<FeatureViewModel>();

                for (var j = 0; j < featureCount; j++)
                {
                    var fId = Guid.NewGuid();
                    var fName = string.Format("Feature - {0}", j);
                    var fDescription = string.Format("Description Feature - {0}", j);
                    features[j] =
                        new Feature
                        {
                            Id = fId,
                            Name = fName,
                            Description = fDescription,
                            Rank = 8
                        };
                    featureViewModels.Add(new FeatureViewModel
                    {
                        Id = fId,
                        Name = fName,
                        Description = fDescription,
                        Rank = 8
                    });
                }

                cities.Add(new City
                {
                    Id = newGuid,
                    Name = name,
                    Features = features
                });
                cityViewModels.Add(new CityViewModel
                {
                    Id = newGuid,
                    Name = name,
                    FeaturesList = featureViewModels
                });
            }

            var brandId = Guid.NewGuid();
            var brandName = "Brand name";
            var brand = new Brand
            {
                Id = brandId,
                Name = brandName
            };
            var brandViewModel = new BrandViewModel
            {
                Id = brandId,
                Name = brandName
            };

            var supId = Guid.NewGuid();
            var supplierName = "Supplier name";
            var agreementDate = DateTime.Now;
            var supplier = new Supplier
            {
                Id = supId,
                Name = supplierName,
                AgreementDate = agreementDate,
                Rank = 6,
                Sizes = sizes,
            };

            var supplierViewModel = new SupplierViewModel
            {
                Id = supId,
                Name = supplierName,
                AgreementDate = agreementDate,
                Sizes = sizesViewModels,
            };

            var sizeId = Guid.NewGuid();
            var lonelySize = "Lonely size";
            var sizeSAlias = "Size's alias";
            var size = new Size
            {
                Id = sizeId,
                Name = lonelySize,
                Alias = sizeSAlias,
                SortOrder = 5
            };
            var sizeViewModel = new SizeViewModel
            {
                Id = sizeId,
                Name = lonelySize,
                Alias = sizeSAlias,
                SortOrder = 5
            };

            var optionsCount = random.Next(10, 50);

            var options = new List<ProductOption>();
            var optionViewModels = new List<ProductOptionViewModel>();

            for (var i = 0; i < optionsCount; i++)
            {
                var optionId = Guid.NewGuid();
                var color = "Random";
                var discount = 54M;
                var price = 34M;
                var stock = 102;
                var weight = 23;
                options.Add(
                    new ProductOption
                    {
                        Id = optionId,
                        Cities = cities,
                        Color = color,
                        Discount = discount,
                        Price = price,
                        Stock = stock,
                        Weight = weight,
                        Size = size
                    });
                optionViewModels.Add(
                    new ProductOptionViewModel
                    {
                        Id = optionId,
                        Cities = cityViewModels,
                        Color = color,
                        Discount = discount,
                        Price = price,
                        Stock = stock,
                        Weight = weight,
                        Size = sizeViewModel,
                        DiscountedPrice = Math.Floor(price * discount / 100)
                    });
            }

            var fpId = Guid.NewGuid();
            var fashionProductDescription = "Fashion product description";
            var ean = "6876876-5345345-345345tgreg-435345df-adskf34";
            var topFashionProductName = "Top Fashion Product";
            var createdOn = DateTime.Now;
            var end = DateTime.Now.AddDays(30);
            var start = DateTime.Now;
            var warehouseOn = DateTime.Now.AddDays(-3);
            var fashionProduct = new FashionProduct
            {
                Id = fpId,
                Brand = brand,
                CreatedOn = createdOn,
                Description = fashionProductDescription,
                Ean = ean,
                End = end,
                Gender = GenderTypes.Unisex,
                Name = topFashionProductName,
                Options = options,
                Start = start,
                Supplier = supplier,
                WarehouseOn = warehouseOn
            };

            var fashionProductViewModel = new FashionProductViewModel
            {
                Id = fpId,
                Brand = brandViewModel,
                CreatedOn = createdOn,
                Description = fashionProductDescription,
                Ean = ean,
                End = end,
                OptionalGender = null,
                Name = topFashionProductName,
                Options = optionViewModels,
                Start = start,
                Supplier = supplierViewModel,
                WarehouseOn = warehouseOn
            };

            var result = new KeyValuePair<FashionProduct, FashionProductViewModel>(fashionProduct, fashionProductViewModel);
            return result;
        }
Esempio n. 41
0
        private JsonResult EditResultJson(SupplierViewModel model)
        {
            if (model.CheckName != model.Supplier.vSupplierName)
            {
                if (_service.ExistedName(model.Supplier.vSupplierName))
                {
                    return Json(new { result = Constants.Duplicate });
                }
            }

            var entity = _service.GetByKey(model.Supplier.bSupplierID);
            if (!Convert.ToBase64String(model.Supplier.Timestamp).Equals(Convert.ToBase64String(entity.Timestamp)))
            {
                return Json(new { result = Constants.DataJustChanged });
            }

            try
            {
                entity.vSupplierName = model.Supplier.vSupplierName;
                entity.vAddress = model.Supplier.vAddress;
                entity.vCity = model.Supplier.vCity;
                entity.vPhone1 = model.Supplier.vPhone1;
                entity.vPhone2 = model.Supplier.vPhone2;
                entity.vMobile = model.Supplier.vMobile;
                entity.vFax = model.Supplier.vFax;
                entity.vEmail = model.Supplier.vEmail;
                entity.vContactPerson = model.Supplier.vContactPerson;
                entity.bSupplierTypeID = model.Supplier.bSupplierTypeID;
                entity.iService = model.Supplier.iService;
                entity.CountryId = model.Supplier.CountryId;
                entity.iMarket = model.Supplier.iMarket;
                entity.iStore = model.Supplier.iStore;
                entity.iPayment = model.Supplier.iPayment;
                entity.iModified = model.LoginId;
                entity.dModified = DateTime.Now;
                _service.Update(entity, model.ListProducts, model.LstDeleteDetailItem);

                return Json(new { result = Constants.Success });
            }
            catch (Exception e)
            {
                Log.Error("Update Supplier!", e);
                return Json(new { result = Constants.UnSuccess });
            }
        }
Esempio n. 42
0
 public ActionResult Edit(SupplierViewModel model)
 {
     if (ModelState.IsValid)
     {
         _contacts.Save(model.Contact.ToModel());
         _contacts.Save(model.Admin.ToModel());
         _suppliers.Save(model.ToModel());
         return RedirectToAction("Index");
     }
     return View(model);
 }