public static List <DocFV> Make(string[] files) { List <DocFV> docFvList = new List <DocFV>(); Microsoft.Office.Interop.Word.Application winword = new Microsoft.Office.Interop.Word.Application(); Microsoft.Office.Interop.Word.Document doc; List <string> stringList1 = new List <string>(); List <string> stringList2 = new List <string>(); int num = files.Count(); for (int index = 0; index < num; ++index) { try { doc = winword.Documents.Open(files[index]); List <string> list = ((IEnumerable <string>)doc.Content.Text.Replace('\a', ' ').Split('\r')).ToList <string>(); int count = doc.Tables.Count; string nr = ReaderDocFV.FindFVNumber(ref list).Trim(); string nabywca1 = ReaderDocFV.FindNabywca(ref list); string[] strArray = ReaderDocFV.ReadFirstTable(doc.Tables[1]); List <List <string> > stringListList = ReaderDocFV.ReadSecondTable(doc.Tables[2]); string nabywca2 = nabywca1; string[] dane = strArray; List <List <string> > data = stringListList; DocFV docFv = ReaderDocFV.ReadDocFV(nr, nabywca2, dane, data); docFv.filename = files[index]; docFvList.Add(docFv); doc.Close(); stringList2.Add("Przeczytano plik " + files[index]); } catch { stringList1.Add("Błąd czytania pliku (ReaderDocFV.Make) " + files[index]); } } winword.Quit(); StreamWriter streamWriter1 = new StreamWriter("errors\\WordErrors.txt"); foreach (string str in stringList1) { streamWriter1.WriteLine(str); } streamWriter1.Close(); StreamWriter streamWriter2 = new StreamWriter("errors\\WordRaport.txt"); foreach (string str in stringList2) { streamWriter2.WriteLine(str); } streamWriter2.Close(); return(docFvList); }
public Faktura(Zamowienie zam, int nr_fv) { FV = new DocFV(); FV.data_sprzedaży = zam.data_sprzedazy.Day.ToString("D2") + "." + zam.data_sprzedazy.Month.ToString("D2") + "." + zam.data_sprzedazy.Year.ToString(); company_shortname = zam.nabywca.skrot; FV.data_wystawienia_faktury = FV.data_sprzedaży; FV.nabywca = zam.nabywca.dane_do_fv; int month = zam.data_sprzedazy.Month; string str = month.ToString().ToCharArray().Count() != 1 ? month.ToString() : "0" + month.ToString(); FV.nr = nr_fv.ToString("D2") + "/" + str + "/18"; FV.termin_zaplaty = zam.termin_zaplaty; if (zam.termin_zaplaty != "przedpłata") { FV.termin_zaplaty += " od daty wystawienia faktury"; } FV.sposob_zaplaty = zam.sposob_zaplaty; zamowienie = zam; double num1 = 0.0; int length = zam.towary.Count <Towar>(); FV.lista_brutto = new string[length]; FV.lista_netto = new string[length]; FV.lista_vat = new string[length]; for (int index = 0; index < length; ++index) { double num2 = double.Parse(zam.towary[index].cena_jednostkowa) * double.Parse(zam.towary[index].ilosc); num1 += num2; FV.lista_netto[index] = string.Format("{0:N}", (object)num2); FV.lista_vat[index] = string.Format("{0:N}", (object)(num2 * 0.23)); FV.lista_brutto[index] = string.Format("{0:N}", (object)(num2 * 1.23)); FV.suma_netto = string.Format("{0:N}", (object)num1); FV.suma_vat = string.Format("{0:N}", (object)(num1 * 0.23)); FV.suma_brutto = string.Format("{0:N}", (object)(num1 * 1.23)); } }
private static DocFV ReadDocFV(string nr, string nabywca, string[] dane, List <List <string> > data) { DocFV docFv = new DocFV(); docFv.nr = nr; docFv.nabywca = nabywca; docFv.data_sprzedaży = dane[0].Trim(); docFv.data_wystawienia_faktury = dane[0].Trim(); docFv.termin_zaplaty = dane[2]; docFv.sposob_zaplaty = dane[3]; char[] separator = new char[1] { '\r' }; docFv.lista_produktow = data[1][0].Split(separator, StringSplitOptions.RemoveEmptyEntries); docFv.lista_ilosci = data[1][1].Split(separator, StringSplitOptions.RemoveEmptyEntries); docFv.lista_cen = data[1][2].Split(separator, StringSplitOptions.RemoveEmptyEntries); docFv.lista_netto = data[1][3].Split(separator, StringSplitOptions.RemoveEmptyEntries); docFv.lista_vat = data[1][5].Split(separator, StringSplitOptions.RemoveEmptyEntries); docFv.lista_brutto = data[1][6].Split(separator, StringSplitOptions.RemoveEmptyEntries); docFv.suma_netto = data[2][1].Trim(); docFv.suma_vat = data[2][3].Trim(); docFv.suma_brutto = data[2][4].Trim(); return(docFv); }