示例#1
0
        static public void ImportInvoices(IObjectSpace os, ДокИмпортОснований док, TextReader reader)
        {
            FixedFileEngine engine = new FixedFileEngine(typeof(InvoiceImport));
            String          line;

            os.Delete(док.Основания);
            fmCAVTInvoiceType sf_sfz_type = os.GetObjects <fmCAVTInvoiceType>().First(x => x.Prefix == "Z");

            while ((line = reader.ReadLine()) != null)
            {
                InvoiceImport data = (InvoiceImport)engine.ReadString(line)[0];
                if (data.SF_IO_TYPE.Trim() == String.Empty)
                {
                    continue;
                }
                СтрокаОснов строка = os.CreateObject <СтрокаОснов>();
                док.Основания.Add(строка);
                строка.БуферУст(line);
                СтрокаОснов.ImportLine(os, строка, data);
                СтрокаОснов.ProcessLine(os, строка, data, sf_sfz_type);
            }
            reader.Close();
        }
        private void UpdateAction_Execute(object sender, SimpleActionExecuteEventArgs e)
        {
            ДокИмпортОснований док = View.CurrentObject as ДокИмпортОснований;

            if (док == null)
            {
                return;
            }
            OpenFileDialog dialog = new OpenFileDialog();

            if (dialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            using (IObjectSpace os = ObjectSpace.CreateNestedObjectSpace()) {
                using (StreamReader reader = new StreamReader(dialog.FileName, Encoding.GetEncoding(1251))) {
                    док = os.GetObject <ДокИмпортОснований>(док);
                    ДокИмпортОснований.UpdateInvoices(os, док, reader);
                    reader.Close();
                }
                os.CommitChanges();
            }
        }
示例#3
0
        static public void UpdateInvoices(IObjectSpace os, ДокИмпортОснований док, TextReader reader)
        {
            FileHelperEngine <ImportUpdateInvoice> engine = new FileHelperEngine <ImportUpdateInvoice>();

            engine.Options.IgnoreFirstLines = 1;
            ImportUpdateInvoice[] invoices = engine.ReadStream(reader);
            foreach (ImportUpdateInvoice invoice in invoices)
            {
                foreach (var doc in док.Основания)
                {
                    if (doc.Основание == null)
                    {
                        continue;
                    }
                    if (doc.егНомер == invoice.SF_REGNUM.Trim() &&
                        doc.Дата == invoice.SF_DATE)
                    {
                        doc.СуммаВсего = invoice.SUMM_ALL;
                        doc.СуммаНДС   = invoice.SUMM_VAT;
                        break;
                    }
                }
            }
        }