Exemplo n.º 1
0
        public void Elimina(InvoiceBE pItem)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    InvoiceDL               Invoice               = new InvoiceDL();
                    InvoiceDetailDL         InvoiceDetail         = new InvoiceDetailDL();
                    InspectionCertificateDL InspectionCertificate = new InspectionCertificateDL();

                    //INSPECTION CERTIFICATE DETAIL
                    List <InvoiceDetailBE> lstInvoiceDetail = null;
                    lstInvoiceDetail = new InvoiceDetailDL().ListaTodosActivo(pItem.IdInvoice);

                    foreach (var item in lstInvoiceDetail)
                    {
                        InspectionCertificate.ActualizaSituacion(item.IdInspectionCertificate, 14);

                        InvoiceDetail.Elimina(item);
                    }

                    Invoice.Elimina(pItem);

                    ts.Complete();
                }
            }
            catch (Exception ex)
            { throw ex; }
        }
Exemplo n.º 2
0
        public Int32 Inserta(InvoiceBE pItem, List <InvoiceDetailBE> pListaInvoiceDetail)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    InvoiceDL               Invoice               = new InvoiceDL();
                    InvoiceDetailDL         InvoiceDetail         = new InvoiceDetailDL();
                    InspectionCertificateDL InspectionCertificate = new InspectionCertificateDL();

                    int IdInvoice = 0;
                    IdInvoice = Invoice.Inserta(pItem);

                    foreach (var item in pListaInvoiceDetail)
                    {
                        InspectionCertificate.ActualizaSituacion(item.IdInspectionCertificate, 15);

                        item.IdInvoice = IdInvoice;
                        InvoiceDetail.Inserta(item);
                    }

                    ts.Complete();

                    return(IdInvoice);
                }
            }
            catch (Exception ex)
            { throw ex; }
        }
Exemplo n.º 3
0
        public List <Invoice> GetInvoicesByDate(string today)
        {
            InvoiceDL      invoiceDL = new InvoiceDL();
            List <Invoice> invocies  = invoiceDL.GetInvoicesByDate(today);

            return(invocies);
        }
Exemplo n.º 4
0
        public void Actualiza(InvoiceBE pItem, List <InvoiceDetailBE> pListaInvoiceDetail)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    InvoiceDL       Invoice       = new InvoiceDL();
                    InvoiceDetailDL InvoiceDetail = new InvoiceDetailDL();

                    foreach (var item in pListaInvoiceDetail)
                    {
                        if (item.TipoOper == Convert.ToInt32(Operacion.Nuevo)) //Nuevo
                        {
                            item.IdInvoice = pItem.IdInvoice;
                            InvoiceDetail.Inserta(item);
                        }
                        else
                        {
                            InvoiceDetail.Actualiza(item);
                        }
                    }


                    Invoice.Actualiza(pItem);

                    ts.Complete();
                }
            }
            catch (Exception ex)
            { throw ex; }
        }
Exemplo n.º 5
0
        //private InvoiceDL _invoiceDL = new InvoiceDL();

        /// <summary>
        /// Lấy danh sách hóa đơn
        /// </summary>
        /// <returns></returns>
        public List <Invoice> GetInvoices()
        {
            InvoiceDL      invoiceDL = new InvoiceDL();
            List <Invoice> invocies  = invoiceDL.GetInvoices();

            return(invocies);
        }
Exemplo n.º 6
0
        public List <Invoice> GetInvoiceStatistical(int type, int value)
        {
            InvoiceDL      invoiceDL = new InvoiceDL();
            List <Invoice> invs;

            invs = invoiceDL.GetInvoiceStatistical(type, value);
            return(invs);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Lưu hóa đơn
        /// </summary>
        /// <param name="master"></param>
        /// <param name="detailItem"></param>
        public void SaveInvoice(Invoice master, string detailItem)
        {
            InvoiceDL invoiceDL     = new InvoiceDL();
            InvoiceDL invoiceItemDL = new InvoiceDL();
            Guid      invoiceID     = Guid.NewGuid();

            invoiceDL.SaveInvoice(invoiceID, master);
            invoiceItemDL.SaveInvoiceItem(invoiceID, detailItem);
        }
Exemplo n.º 8
0
 public int SeleccionaBusquedaCount(int IdCompany, int IdClient)
 {
     try
     {
         InvoiceDL Invoice = new InvoiceDL();
         return(Invoice.SeleccionaBusquedaCount(IdCompany, IdClient));
     }
     catch (Exception ex)
     { throw ex; }
 }
Exemplo n.º 9
0
        public object GetInvoicesPaging(int pageNumber, string fromDate, string toDate)
        {
            InvoiceDL      invoiceDL  = new InvoiceDL();
            InvoiceDL      invoiceDL2 = new InvoiceDL();
            List <Invoice> invoices   = invoiceDL.GetInvoicesPaging(pageNumber, fromDate, toDate);
            int            totalRow   = invoiceDL2.GetTotalPage(fromDate, toDate);
            object         obj        = new { data = invoices, totalRow = totalRow };

            return(obj);
        }
Exemplo n.º 10
0
 public List <InvoiceBE> ListaNumberInvoice(int IdCompany, int IdClient, string NumberInvoice)
 {
     try
     {
         InvoiceDL Invoice = new InvoiceDL();
         return(Invoice.ListaNumberInvoice(IdCompany, IdClient, NumberInvoice));
     }
     catch (Exception ex)
     { throw ex; }
 }
Exemplo n.º 11
0
 public List <InvoiceBE> ListaClientDate(int IdCompany, int IdClient, int IdStatus, DateTime DateFrom, DateTime DateTo)
 {
     try
     {
         InvoiceDL Invoice = new InvoiceDL();
         return(Invoice.ListaClientDate(IdCompany, IdClient, IdStatus, DateFrom, DateTo));
     }
     catch (Exception ex)
     { throw ex; }
 }
Exemplo n.º 12
0
 public List <InvoiceBE> ListaClient(int IdCompany, int IdClient, int IdStatus)
 {
     try
     {
         InvoiceDL Invoice = new InvoiceDL();
         return(Invoice.ListaClient(IdCompany, IdClient, IdStatus));
     }
     catch (Exception ex)
     { throw ex; }
 }
Exemplo n.º 13
0
 public List <InvoiceBE> ListaTodosActivo(int IdCompany)
 {
     try
     {
         InvoiceDL Invoice = new InvoiceDL();
         return(Invoice.ListaTodosActivo(IdCompany));
     }
     catch (Exception ex)
     { throw ex; }
 }
Exemplo n.º 14
0
 public InvoiceBE Selecciona(int IdInvoice)
 {
     try
     {
         InvoiceDL Invoice = new InvoiceDL();
         InvoiceBE objEmp  = Invoice.Selecciona(IdInvoice);
         return(objEmp);
     }
     catch (Exception ex)
     { throw ex; }
 }
Exemplo n.º 15
0
 public InvoiceBE SeleccionaNumberInvoice(string NumberInvoice)
 {
     try
     {
         InvoiceDL Invoice = new InvoiceDL();
         InvoiceBE objEmp  = Invoice.SeleccionaNumberInvoice(NumberInvoice);
         return(objEmp);
     }
     catch (Exception ex)
     { throw ex; }
 }
Exemplo n.º 16
0
        public HttpResponseMessage CreateInvoicePDF(string orderkey)
        {
            var viewmodel = new InvoiceViewModel();
            //   string orderKey = "33215b82-91a6-11e9-b6c9-3f0945f4a3b5";
            DeliveryOrderDL orderDl = new DeliveryOrderDL();
            InvoiceDL       dl      = new InvoiceDL();
            var             orderBO = orderDl.GetDeliveryOrder(orderkey);

            viewmodel.Order = orderBO;
            var orderdetailBO = orderDl.GetOrderDetailsByKey(orderkey);

            if (orderdetailBO != null && orderdetailBO.Count > 0)
            {
                var orderdtlList = new List <ThinOrderDetailViewModel>();
                orderdetailBO.ForEach(d =>
                {
                    orderdtlList.Add(new ThinOrderDetailViewModel()
                    {
                        Chassis        = d.Chassis,
                        ContainerNo    = d.ContainerNo,
                        OrderDetailKey = d.OrderDetailKey,
                        InvoiceHeader  = d.OrderDetailKey != null ? dl.GetInvoicebyOrderDetailKey(Convert.ToString(d.OrderDetailKey)) : null,
                        InvoiceDetail  = d.OrderDetailKey != null ? dl.GetInvoiceDetail(Convert.ToString(d.OrderDetailKey)) : null,
                    });
                });
                viewmodel.OrderDtl = orderdtlList;
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, "Order not found", Configuration.Formatters.JsonFormatter));
            }
            var stringified = new InvoiceViewController().RenderRazorViewToString("~/Views/InvoiceView/Index.cshtml", viewmodel);
            var pdf         = IronPdf.HtmlToPdf.StaticRenderHtmlAsPdf(stringified);
            var basepath    = HttpContext.Current.Server.MapPath("~/App_Data/Files/");
            var doccreated  = pdf.SaveAs(Path.Combine(basepath, $"{viewmodel.Order.OrderNo}.pdf"));

            if (doccreated.PageCount > 0)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, "Invoice generated", Configuration.Formatters.JsonFormatter));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, "Error occurred while creating Invoice", Configuration.Formatters.JsonFormatter));
            }
        }
Exemplo n.º 17
0
        public void ActualizaSituacion(int IdInvoice, int IdStatus)
        {
            try
            {
                InvoiceDL Invoice = new InvoiceDL();
                Invoice.ActualizaSituacion(IdInvoice, IdStatus);

                //INSPECTION CERTIFICATE DETAIL
                InspectionCertificateDL InspectionCertificate = new InspectionCertificateDL();
                List <InvoiceDetailBE>  lstInvoiceDetail      = null;
                lstInvoiceDetail = new InvoiceDetailDL().ListaTodosActivo(IdInvoice);

                foreach (var item in lstInvoiceDetail)
                {
                    InspectionCertificate.ActualizaSituacion(item.IdInspectionCertificate, 14);
                }
            }
            catch (Exception ex)
            { throw ex; }
        }
Exemplo n.º 18
0
        public void ActualizaSituacionMasivo(List <InvoiceBE> pListaInvoice)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    InvoiceDL objInvoice = new InvoiceDL();

                    foreach (InvoiceBE item in pListaInvoice)
                    {
                        objInvoice.ActualizaSituacion(item.IdInvoice, item.IdStatus);
                    }

                    ts.Complete();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 19
0
 /// <summary>
 /// Hàm khởi tạo mặc định
 /// </summary>
 /// Người tạo: ntxuan (20/6/2019)
 public InvoiceBL()
 {
     invoiceDL = new InvoiceDL();
 }
Exemplo n.º 20
0
        public int GetTotalPage(string fromDate, string toDate)
        {
            InvoiceDL invoiceDL = new InvoiceDL();

            return(invoiceDL.GetTotalPage(fromDate, toDate));
        }
Exemplo n.º 21
0
        public void DeleteInvoice(Guid id)
        {
            InvoiceDL invoiceDL = new InvoiceDL();

            invoiceDL.DeleteInvoice(id);
        }
Exemplo n.º 22
0
        public Invoice GetInvoice(Guid id)
        {
            InvoiceDL invoiceDL = new InvoiceDL();

            return(invoiceDL.GetInvoice(id));
        }
Exemplo n.º 23
0
        public InvoiceItem GetDetailInvoice(Guid id)
        {
            InvoiceDL invoiceDL = new InvoiceDL();

            return(invoiceDL.GetDetailInvoice(id));
        }
Exemplo n.º 24
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="custname"></param>
        /// <returns></returns>
        //[HttpPost]
        //[Route("DownloadInvoice_1")]
        //[SwaggerOperation("DownloadInvoice_1")]
        private HttpResponseMessage DownloadInvoice_1(string orderkey)
        {
            // var invoicetotals = dl.AutoPullInvoiceCosts(orderkey);
            var             fileuploadPath = HttpContext.Current.Server.MapPath("~/App_Data/Files/");
            PdfDocument     pdfDoc         = new PdfDocument(new PdfWriter(Path.Combine(fileuploadPath, $"invoice_{orderkey}.pdf")));
            DeliveryOrderDL doObj          = new DeliveryOrderDL();
            var             orderHeader    = doObj.GetDeliveryOrder(orderkey);
            var             customer       = new CustomerDL().GetCustomerbykey(orderHeader.CustKey);

            var      orderdetaillist = doObj.GetOrderDetailsByKey(orderkey);
            Document doc             = new Document(pdfDoc);

            /*
             * 1483 Via Plata StreetLong Beach, CA
             */
            var paragraph = new Paragraph("INVOICE").SetTextAlignment(TextAlignment.CENTER).SetFontSize(15);

            doc.Add(paragraph);

            var cell = new Cell().SetTextAlignment(TextAlignment.LEFT);

            cell.Add(new Paragraph(new Text("PLEASE REMIT TO").SetFontSize(14).SetBold()));
            cell.Add(new Paragraph("Junction Collaborative Transports").SetFontSize(12));
            cell.Add(new Paragraph("1483 Via Plata Street").SetFontSize(12));
            cell.Add(new Paragraph("Long Beach, CA").SetFontSize(12));
            cell.Add(new Paragraph("90810").SetFontSize(12));
            cell.Add(new Paragraph("Phone: (310) 537-7730").SetFontSize(12));
            cell.Add(new Paragraph("Fax: (310) 537-7723").SetFontSize(12));

            //p.Add(new Paragraph().Add("PLEASE REMIT TO").Add(customer.CustName).Add(customer.Address.Address1)
            //    .Add(customer.Address.Address2).Add(customer.Address.City).Add(customer.Address.State)
            //    .Add(customer.Address.Zip));
            doc.Add(cell);

            List      header       = new List();
            double    runningtotal = 0.0;
            InvoiceDL dl           = new InvoiceDL();

            foreach (var orderdetail in orderdetaillist)
            {
                var   invoice  = dl.GetInvoicebyOrderDetailKey(orderdetail.OrderDetailKey.ToString());
                Table dtlTable = new Table(UnitValue.CreatePercentArray(7)).UseAllAvailableWidth();
                dtlTable.AddHeaderCell(new Cell().Add(new Paragraph("Container no")));
                dtlTable.AddHeaderCell(new Cell().Add(new Paragraph("Container size")));
                dtlTable.AddHeaderCell(new Cell().Add(new Paragraph("Chassis")));
                dtlTable.AddHeaderCell(new Cell().Add(new Paragraph("Invoice No")));
                dtlTable.AddHeaderCell(new Cell().Add(new Paragraph("Due date")));
                dtlTable.AddHeaderCell(new Cell().Add(new Paragraph("Invoice Date")));
                dtlTable.AddHeaderCell(new Cell().Add(new Paragraph("Amount")));
                dtlTable.AddCell(new Cell().Add(new Paragraph(orderdetail.ContainerNo)));
                dtlTable.AddCell(new Cell().Add(new Paragraph(orderdetail.ContainerSize.ToString())));
                dtlTable.AddCell(new Cell().Add(new Paragraph(orderdetail.Chassis)));
                dtlTable.AddCell(new Cell().Add(new Paragraph(invoice.InvoiceNo.ToString())));
                dtlTable.AddCell(new Cell().Add(new Paragraph(invoice.DueDate.ToString())));
                dtlTable.AddCell(new Cell().Add(new Paragraph(invoice.InvoiceDate.ToString())));
                dtlTable.AddCell(new Cell().Add(new Paragraph(invoice.InvoiceAmt.ToString())));
                runningtotal += (double)invoice.InvoiceAmt;
                ListItem dtl = new ListItem();
                dtl.Add(new Paragraph().Add(dtlTable));

                // doc.Add(dtlTable);

                var      invoicedtl  = dl.GetInvoiceDetail(orderdetail.OrderDetailKey.ToString());
                ListItem invoiceItem = new ListItem();
                Table    table       = new Table(UnitValue.CreatePercentArray(5));
                table.AddHeaderCell(new Cell().Add(new Paragraph("Item")));
                table.AddHeaderCell(new Cell().Add(new Paragraph("Price")));
                table.AddHeaderCell(new Cell().Add(new Paragraph("Quantity")));
                table.AddHeaderCell(new Cell().Add(new Paragraph("UnitPrice")));
                table.AddHeaderCell(new Cell().Add(new Paragraph("Excess Amount")));

                foreach (var invoiceline in invoicedtl)
                {
                    table.AddCell(new Cell().Add(new Paragraph(invoiceline.Description)));
                    table.AddCell(new Cell().Add(new Paragraph(invoiceline.Price.ToString())));
                    table.AddCell(new Cell().Add(new Paragraph(invoiceline.Quantity.ToString())));
                    table.AddCell(new Cell().Add(new Paragraph(invoiceline.UnitPrice.ToString())));
                    table.AddCell(new Cell().Add(new Paragraph(invoiceline.ExcessAmount.ToString())));
                    runningtotal += (double)invoiceline.Price * (double)invoiceline.Quantity;
                }

                invoiceItem.Add(new Paragraph("Detailed Breakup:").SetFirstLineIndent(25).Add(table));
                dtl.Add(invoiceItem);
                header.Add(dtl);
            }
            header.SetSymbolIndent(80).Add($"Total:{runningtotal.ToString()}");
            doc.Add(header);
            //Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);


            // By default column width is calculated automatically for the best fit.
            // useAllAvailableWidth() method set table to use the whole page's width while placing the content.

            //foreach (var record in invoicetotals)
            //{
            //    table.AddCell(new Cell().Add(new Paragraph(record.ContainerNo)));
            //    table.AddCell(new Cell().Add(new Paragraph(record.ItemId)));
            //    table.AddCell(new Cell().Add(new Paragraph(record.UnitPrice.ToString())));
            //}
            //table.AddCell(new Cell().Add(new Paragraph()));
            //table.AddCell(new Cell().Add(new Paragraph("Totals:")));
            //table.AddCell(new Cell().Add(new Paragraph(invoicetotals.Select(x => x.UnitPrice).Sum().ToString())));
            //doc.Add(table);
            //}
            doc.Close();
            if (doc != null)
            {
                byte[] bytes = File.ReadAllBytes(Path.Combine(fileuploadPath, $"invoice_{orderkey}.pdf"));
                HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK);
                //Set the Response Content.
                response.Content = new ByteArrayContent(bytes);

                //Set the Response Content Length.
                response.Content.Headers.ContentLength = bytes.LongLength;

                //Set the Content Disposition Header Value and FileName.
                response.Content.Headers.ContentDisposition          = new ContentDispositionHeaderValue("attachment");
                response.Content.Headers.ContentDisposition.FileName = $"invoice_{orderkey}.pdf";

                //Set the File Content Type.
                response.Content.Headers.ContentType = new MediaTypeHeaderValue(MimeMapping.GetMimeMapping($"invoice_{orderkey}.pdf"));
                return(response);
            }
            return(Request.CreateResponse(HttpStatusCode.InternalServerError, string.Empty, Configuration.Formatters.JsonFormatter));
        }
Exemplo n.º 25
0
        public HttpResponseMessage CreatePDFforInvoice(string invoicekey)
        {
            var             viewmodel = new InvoiceViewModel();
            DeliveryOrderDL orderDl   = new DeliveryOrderDL();
            InvoiceDL       dl        = new InvoiceDL();

            string orderkey = dl.getOrderkeybyInvoicekey(invoicekey);

            if (!string.IsNullOrEmpty(orderkey))
            {
                var orderBO = orderDl.GetDeliveryOrder(orderkey);
                viewmodel.Order         = orderBO;
                viewmodel.InvoiceHeader = dl.GetInvoicebyinvoiceKey(invoicekey);
                viewmodel.InvoiceDetail = dl.GetInvoiceDetail(invoicekey);

                var orderdetailBO = orderDl.GetOrderDetailsByKey(orderkey);

                if (orderdetailBO != null && orderdetailBO.Count > 0)
                {
                    var orderdtlList = new List <ThinOrderDetailViewModel>();
                    orderdetailBO.ForEach(d =>
                    {
                        orderdtlList.Add(new ThinOrderDetailViewModel()
                        {
                            Chassis        = d.Chassis,
                            ContainerNo    = d.ContainerNo,
                            OrderDetailKey = d.OrderDetailKey,
                            //InvoiceHeader = d.OrderDetailKey != null ? dl.GetInvoicebyinvoiceKey(Convert.ToString(invoicekey)) : null,
                            //InvoiceDetail = d.OrderDetailKey != null ? dl.GetInvoiceDetail(invoicekey) : null,
                        });
                    });
                    viewmodel.OrderDtl = orderdtlList;
                }
            }
            //if (orderdetailBO != null && orderdetailBO.Count > 0)
            //{
            //    var orderdtlList = new List<ThinOrderDetailViewModel>();
            //    orderdetailBO.ForEach(d =>
            //    {
            //        orderdtlList.Add(new ThinOrderDetailViewModel()
            //        {
            //            Chassis = d.Chassis,
            //            ContainerNo = d.ContainerNo,
            //            OrderDetailKey = d.OrderDetailKey,
            //            InvoiceHeader = d.OrderDetailKey != null ? dl.GetInvoicebyOrderDetailKey(Convert.ToString(d.OrderDetailKey)) : null,
            //            InvoiceDetail = d.OrderDetailKey != null ? dl.GetInvoiceDetail(Convert.ToString(d.OrderDetailKey)) : null,

            //        });
            //    });
            //    viewmodel.OrderDtl = orderdtlList;
            //}
            //else
            //{
            //    return Request.CreateResponse(HttpStatusCode.InternalServerError, "Order not found", Configuration.Formatters.JsonFormatter);
            //}

            if (viewmodel == null)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, "Order not found", Configuration.Formatters.JsonFormatter));
            }

            var stringified = new InvoiceViewController().RenderRazorViewToString("~/Views/InvoiceView/Invoice.cshtml", viewmodel);
            var pdf         = IronPdf.HtmlToPdf.StaticRenderHtmlAsPdf(stringified);
            var basepath    = HttpContext.Current.Server.MapPath("~/App_Data/Files/");
            var doccreated  = pdf.SaveAs(Path.Combine(basepath, $"{viewmodel.Order.OrderNo}.pdf"));

            if (doccreated.PageCount > 0)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, "Invoice generated", Configuration.Formatters.JsonFormatter));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, "Error occurred while creating Invoice", Configuration.Formatters.JsonFormatter));
            }
        }