private void CreateAndStreamFirstAndLast(List<EUSaleWithoutVAT> listOfEUSale, StreamWriter sw, bool firstOrLast, string companyRegNo, int countRec = 0, long sumOfAmount = 0)
 {
     if (firstOrLast)
     {
         sw.Write('0'); sw.Write(';');
         sw.Write(companyRegNo); sw.Write(';');
         sw.Write("LISTE"); sw.Write(';');
         sw.Write(';');
         sw.Write(';');
         sw.Write(';');
         sw.Write(';');
         sw.Write(';');
         sw.WriteLine();
     }
     else
     {
         sw.Write("10"); sw.Write(';');
         NumberConvert.ToStream(sw, countRec); sw.Write(';');
         NumberConvert.ToStream(sw, sumOfAmount); sw.Write(';');
         sw.Write(';');
         sw.Write(';');
         sw.Write(';');
         sw.Write(';');
         sw.Write(';');
         sw.WriteLine();
     }
 }
        private long StreamToFile(List<EUSaleWithoutVAT> listOfImportExport, StreamWriter sw)
        {
            long sumOfAmount = 0;

            foreach (var rec in listOfImportExport)
            {
                string countryStr = null;
                if (rec.Country == CountryCode.Greece)
                    countryStr = "EL";
                else
                    countryStr = Enum.GetName(typeof(CountryISOCode), ((int)rec.Country));

                var itemAmount = NumberConvert.ToLong(rec.ItemAmount);
                var serviceAmount = NumberConvert.ToLong(rec.ServiceAmount);
                var triangularTradeAmount = NumberConvert.ToLong(rec.TriangularTradeAmount);
                sumOfAmount += itemAmount + serviceAmount + triangularTradeAmount;

                rec.SystemInfo = Localization.lookup("Exported");

                sw.Write(rec.RecordType); sw.Write(';');
                sw.Write(rec.ReferenceNumber); sw.Write(';');
                sw.Write(rec.Date.ToString("yyyy-MM-dd")); sw.Write(';');
                sw.Write(rec.CompanyRegNo); sw.Write(';');
                sw.Write(countryStr); sw.Write(';');
                sw.Write(rec._DebtorRegNoFile); sw.Write(';');
                NumberConvert.ToStream(sw, itemAmount); sw.Write(';');
                NumberConvert.ToStream(sw, triangularTradeAmount); sw.Write(';');
                NumberConvert.ToStream(sw, serviceAmount);
                sw.WriteLine();
            }

            return sumOfAmount;
        }
        private void StreamToFileDE(List<EUSaleWithoutVAT> listOfImportExport, StreamWriter sw)
        {
            sw.Write("Laenderkennzeichen"); sw.Write(';');
            sw.Write("USt-IdNr."); sw.Write(';');
            sw.Write("Betrag(EUR)"); sw.Write(';');
            sw.Write("Art der Leistung");
            sw.WriteLine();

            long amount = 0;
            var exp = Localization.lookup("Exported");
            foreach (var rec in listOfImportExport)
            {
                string countryStr;
                if (rec.Country == CountryCode.Greece)
                    countryStr = "EL";
                else
                    countryStr = ((CountryISOCode)rec.Country).ToString();

                sw.Write(countryStr); sw.Write(';');
                sw.Write(rec._DebtorRegNoFile); sw.Write(';');

                string type = null;
                switch (rec.DeType)
                {
                    case 1: type = "L"; amount = NumberConvert.ToLong(rec.ItemAmount);  break;
                    case 2: type = "S"; amount = NumberConvert.ToLong(rec.ServiceAmount); break;
                    case 3: type = "D"; amount = NumberConvert.ToLong(rec.TriangularTradeAmount); break;
                    default: type = ""; break;
                }

                NumberConvert.ToStream(sw, amount); sw.Write(';');
                sw.Write(type);
                sw.WriteLine();

                rec.SystemInfo = exp;
            }
        }