Ejemplo n.º 1
0
 public object searchInvoice(SearchInvoiceRequest objRequest)
 {
     try
     {
         if (ModelState.IsValid)
         {
             return(invoice.searchInvoice(objRequest));
         }
         else
         {
             searchInvoiceResponse returnObj = new searchInvoiceResponse();
             returnObj.error = UtilitesModel.getErrorList(ModelState);
             return(returnObj);
         }
     }
     catch (Exception ex)
     {
         throw Logs.ErrorException(ex, HttpStatusCode.BadRequest, ex.Message + " - " + ex.StackTrace);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// service export pdf dự thảo hóa đơn
        /// </summary>
        /// <param name="exportObj"></param>
        /// <returns></returns>
        public byte[] exportPDF(ExportInvoiceRequest exportObj)
        {
            try
            {
                SearchInvoiceDA       da         = new SearchInvoiceDA();
                GenerateXMLInvoice    xMLInvoice = new GenerateXMLInvoice();
                searchInvoiceResponse response   = new searchInvoiceResponse();
                //lay hoa don
                PVOILInvoice       invoice      = da.selectItemInvoiceByFKey(exportObj.FKey);
                InvoicesModel      invoiceModel = ModelBase.mapperStatic <PVOILInvoice, InvoicesModel>().Map <PVOILInvoice, InvoicesModel>(invoice);
                searchInvoiceModel tmp          = new searchInvoiceModel();
                //tmp.invoice = invoiceModel;
                ////lay san pham
                //tmp.invoice.products = da.selectProductByInvoice(invoiceModel.id);
                //InvTemplate_GetTemplateInvoice_Result template = da.InvTemplate_GetTemplateInvoice(invoice.Pattern, invoice.ComTaxCode);

                ////Tạo data XML từ invoice và product
                //String xml = xMLInvoice.GetXMLData(tmp.invoice, tmp.invoice.products, template.TemplateName);
                //Tạo data html từ xml
                //String html = xMLInvoice.GetHtml(xMLInvoice.GetData(xml), template);
                //Tạo pdf html từ html
                var htmlToPdf = new NReco.PdfGenerator.HtmlToPdfConverter();
                htmlToPdf.Zoom    = 1.6f;
                htmlToPdf.Size    = NReco.PdfGenerator.PageSize.A4;
                htmlToPdf.Margins = new PageMargins {
                    Left = 20
                };
                //byte[] pdfBytes = htmlToPdf.GeneratePdf(html);
                //return pdfBytes;
                return(null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// service tìm kiếm hóa đơn
 /// </summary>
 /// <param name="searchInvoice"></param>
 /// <returns></returns>
 public object searchInvoice(SearchInvoiceRequest searchInvoice)
 {
     try
     {
         SearchInvoiceDA       da              = new SearchInvoiceDA();
         InvBusinessProcessDA  daInvProcess    = new InvBusinessProcessDA();
         searchInvoiceResponse response        = new searchInvoiceResponse();
         List <PVOILInvoice>   lstInvoice      = da.selectListInvoice(searchInvoice.maDiemxuatHD, searchInvoice.username, searchInvoice.taxCode, searchInvoice.buyerTaxCode, searchInvoice.from, searchInvoice.to, searchInvoice.type);
         List <InvoicesModel>  lstInvoiceModel = ModelBase.mapperStatic <PVOILInvoice, InvoicesModel>().Map <List <PVOILInvoice>, List <InvoicesModel> >(lstInvoice);
         if (searchInvoice.type.ToUpper().Equals("ORTHER"))
         {
             foreach (PVOILInvoice item in lstInvoice)
             {
                 searchInvoiceModel tmp           = new searchInvoiceModel();
                 InvBusinessProcess objInvProcess = daInvProcess.checkExist(item.id);
                 tmp.key       = item.Fkey.ToString();
                 tmp.Pattern   = item.Pattern;
                 tmp.Serial    = item.Serial;
                 tmp.InvoiceNo = Convert.ToInt32(item.No ?? 0).ToString().PadLeft(7, '0');
                 tmp.Soduthao  = item.id;
                 int objStatusApprove = 0;
                 if (objInvProcess?.StatusApprove == null)
                 {
                     objStatusApprove = 0;
                 }
                 else
                 {
                     objStatusApprove = (bool)objInvProcess?.StatusApprove ? 1 : 0;
                 }
                 tmp.Trangthaikiemtra = objStatusApprove;
                 tmp.Ghichu           = objInvProcess?.Comment;
                 //tmp.Ghichu = $"Dữ liệu invoice lấy ra từ DB: {item.No} {item.Status} {DataAccessBase.dbInvoice.db.Database.Connection.ConnectionString}";
                 tmp.Type        = item.Type;
                 tmp.Status      = item.Status;
                 tmp.Draftcancel = item.DraftCancel;
                 response.invoices.Add(tmp);
             }
             return(response);
         }
         else if (searchInvoice.type.ToUpper().Equals("DC"))
         {
             foreach (InvoicesModel item in lstInvoiceModel)
             {
                 InvBusinessProcess objInvProcess = daInvProcess.checkExist(item.id);
                 item.Soduthao = item.id;
                 int objStatusApprove = 0;
                 if (objInvProcess?.StatusApprove == null)
                 {
                     objStatusApprove = 0;
                 }
                 else
                 {
                     objStatusApprove = (bool)objInvProcess?.StatusApprove ? 1 : 0;
                 }
                 item.Trangthaikiemtra = objStatusApprove;
                 item.Ghichu           = objInvProcess?.Comment;
             }
             return(lstInvoiceModel);
         }
         else
         {
             return(null);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }