Пример #1
0
        /// <summary>Конвертація списку елементів в таблицю</summary>
        private void convertListsToTables()
        {
            Dictionary<Product, Parties> partyDic = getPartyForTable();
            Document.NomenclatureInfo.Rows.Clear();
            foreach (NomenclatureData data in waresList)
                {
                if (data.Description != null && data.Description.Id != 0)
                    {
                    DataRow newRow = Document.NomenclatureInfo.GetNewRow(Document);
                    newRow.SetRefValueToRowCell(Document, Document.Nomenclature, data.Description.Id, typeof(Nomenclature));
                    newRow[Document.NomenclatureCount] = data.Quantity;
                    newRow.SetRefValueToRowCell(Document, Document.NomenclatureParty, partyDic[new Product(data.Description.Id, data.Date.Date)]);
                    newRow.AddRowToTable(Document);

                    var nomenclature = new Nomenclature() { ReadingId = data.Description.Id };
                    if (nomenclature.ShelfLife != data.ShelfLifeDays)
                        {
                        nomenclature.ShelfLife = data.ShelfLifeDays;
                        nomenclature.Write();
                        }
                    }
                }
            Document.SetSubtableModified(Document.NomenclatureInfo.TableName);

            Document.TareInfo.Rows.Clear();
            tareList = tareList ?? new List<NomenclatureData>();
            foreach (NomenclatureData data in tareList)
                {
                if (data.Description != null && data.Description.Id != 0)
                    {
                    DataRow newRow = Document.TareInfo.GetNewRow(Document);
                    newRow.SetRefValueToRowCell(Document, Document.Tare, data.Description.Id, typeof(Nomenclature));
                    newRow[Document.TareCount] = data.Quantity;
                    newRow.AddRowToTable(Document);
                    }
                }
            Document.SetSubtableModified(Document.TareInfo.TableName);
        }