Beispiel #1
0
 /// <summary>
 /// Agrega a la interface el registro de Oracle indicado
 /// </summary>
 /// <param name="record">Registro de Oracle a agregar</param>
 public void AddRecord(OracleRecord record)
 {
     try
     {
         record.Moneda = record.InvoiceCurr;
         if (record.InvoiceCurr.Equals("MXN", StringComparison.OrdinalIgnoreCase))
         {
             record.CurrencyRate = "1";
             record.TipCamb      = "1";
         }
         if (record.Cc.Equals("40.9941.0000.1185.00.000"))
         {
             record.TypeTax = "Y";
         }
         string invoiceDate = "";
         if (record.InvoiceDate != "")
         {
             invoiceDate = ReplaceMonth(record.InvoiceDate);
             try
             {
                 invoiceDate = Convert.ToDateTime(invoiceDate).ToString("MM/dd/yyyy");
             }
             catch (Exception ex)
             {
             }
         }
         var _csvRow = new List <string>()
         {
             record.RecordType,
             record.InvoiceNum,
             record.SupplierNum,
             //string.IsNullOrEmpty(record.InvoiceDate)?Convert.ToDateTime(record.InvoiceDate).ToString("MM/dd/yyyy"):record.InvoiceDate,
             invoiceDate,
             record.InvoiceCurr,
             record.CurrencyRate,
             CerosNull(record.InvoiceAmount, true, false),
             record.RecordType.Equals("2") ? "Y" : record.NoInvDetail,
             //record.NoInvDetail,
             record.Num,
             !record.NoInvDetail2.Equals("Y") ? record.UuidCfdi : "",
             !record.RecordType.Equals("1") ? record.SupplierNum2 : "",
             !record.RecordType.Equals("1") ? CerosNull(record.MontoTotal, true, false) : "",
             !record.RecordType.Equals("1") && !record.RecordType.Equals("3") && !record.RecordType.Equals("2") ? record.Moneda : "",
             !record.RecordType.Equals("1") && !record.RecordType.Equals("3") && !record.RecordType.Equals("2") ? record.TipCamb : "",
             !record.RecordType.Equals("1") ? (record.NoInvDetail2.Equals("Y") ? "Y" : "") : "",
             !record.RecordType.Equals("1") && !record.RecordType.Equals("3") ? record.TypeTax : "",
             !record.RecordType.Equals("1") && !record.RecordType.Equals("3") ? record.Cc : "",
             !record.RecordType.Equals("1") && !record.RecordType.Equals("3") ? CerosNull(record.Amount, true, false) : ""
         };
         _csv.Add(_csvRow);
         _rowNumber++;
     }
     catch (Exception)
     {
         _rowNumber--;
     }
 }
Beispiel #2
0
        private List <OracleRecord> Transform(string pathDelFicheroExcel)
        {
            var list = new List <OracleRecord>();

            using (var package = new ExcelPackage(new FileInfo(pathDelFicheroExcel)))
            {
                var workSheet = package.Workbook.Worksheets.First();
                var start     = workSheet.Dimension.Start;
                var end       = workSheet.Dimension.End;
                for (var row = (start.Row + 2); row <= end.Row; row++)
                {
                    try
                    {
                        var record = new OracleRecord
                        {
                            RowNumber     = row.ToString(),
                            RecordType    = workSheet.Cells[row, 1].Text,
                            InvoiceNum    = workSheet.Cells[row, 2].Text,
                            SupplierNum   = workSheet.Cells[row, 3].Text,
                            InvoiceDate   = workSheet.Cells[row, 4].Text,
                            InvoiceCurr   = workSheet.Cells[row, 5].Text,
                            CurrencyRate  = workSheet.Cells[row, 6].Text,
                            InvoiceAmount = workSheet.Cells[row, 7].Text.Replace(",", ""),
                            NoInvDetail   = workSheet.Cells[row, 8].Text,
                            Num           = workSheet.Cells[row, 9].Text,
                            UuidCfdi      = workSheet.Cells[row, 10].Text,
                            SupplierNum2  = workSheet.Cells[row, 11].Text,
                            MontoTotal    = workSheet.Cells[row, 12].Text.Replace(",", ""),
                            Moneda        = workSheet.Cells[row, 13].Text,
                            TipCamb       = workSheet.Cells[row, 14].Text,
                            NoInvDetail2  = workSheet.Cells[row, 15].Text,
                            TypeTax       = workSheet.Cells[row, 16].Text,
                            Cc            = workSheet.Cells[row, 17].Text,
                            Amount        = workSheet.Cells[row, 18].Text.Replace(",", "")
                        };
                        //if (!string.IsNullOrEmpty(record.RecordType) && !string.IsNullOrEmpty(record.InvoiceNum))
                        //{
                        list.Add(record);
                        //}
                    }
                    catch (Exception)
                    {
                        // ignored
                    }
                }
            }
            return(list);
        }
Beispiel #3
0
        private static bool IsEmpty(OracleRecord record)
        {
            var isEmpty = true;

            isEmpty &= string.IsNullOrEmpty(record.Amount.Trim());
            isEmpty &= string.IsNullOrEmpty(record.Cc.Trim());
            isEmpty &= string.IsNullOrEmpty(record.CurrencyRate.Trim());
            isEmpty &= string.IsNullOrEmpty(record.InvoiceAmount.Trim());
            isEmpty &= string.IsNullOrEmpty(record.InvoiceCurr.Trim());
            isEmpty &= string.IsNullOrEmpty(record.InvoiceDate.Trim());
            isEmpty &= string.IsNullOrEmpty(record.InvoiceNum.Trim());
            isEmpty &= string.IsNullOrEmpty(record.Moneda.Trim());
            isEmpty &= string.IsNullOrEmpty(record.MontoTotal.Trim());
            isEmpty &= string.IsNullOrEmpty(record.NoInvDetail.Trim());
            isEmpty &= string.IsNullOrEmpty(record.NoInvDetail2.Trim());
            isEmpty &= string.IsNullOrEmpty(record.Num.Trim());
            isEmpty &= string.IsNullOrEmpty(record.RecordType.Trim());
            isEmpty &= string.IsNullOrEmpty(record.SupplierNum.Trim());
            isEmpty &= string.IsNullOrEmpty(record.SupplierNum2.Trim());
            isEmpty &= string.IsNullOrEmpty(record.TipCamb.Trim());
            isEmpty &= string.IsNullOrEmpty(record.TypeTax.Trim());
            isEmpty &= string.IsNullOrEmpty(record.UuidCfdi.Trim());
            return(isEmpty);
        }