public DocumentVM(Context context, Document document) : base(context) { Document = document; DocumentTypes = Context.DocumentTypes.Where(x => x.Sites.Any(s => s.Id == Document.Site.Id)).ToList(); UnitEntriesVM = new UnitEntriesVM(context, Document); }
public OperationController() { _formsController = new FormsController(); var references = new CommandCategory {Name = "СПРАВОЧНИКИ"}; references.RegisterCommand(new UiCommand("Единицы измерения", x => _formsController.ShowReference<ReferenceVM<MeasureUnit>, ViewMeasureUnits>())); references.RegisterCommand(new UiCommand("Контрагенты", x => _formsController.ShowReference<ReferenceVM<Contractor>, ViewNamedEntity>())); references.RegisterCommand(new UiCommand("Организации", x => _formsController.ShowReference<ReferenceVM<Company>, ViewNamedEntity>())); references.RegisterCommand(new UiCommand("Категории ТМЦ", x => _formsController.ShowReference<ReferenceVM<UnitCategory>, ViewNamedEntity>())); references.RegisterCommand(new UiCommand("Товарно-материальные ценности", x => _formsController.ShowReference<ReferenceVM<Unit>, ViewUnits>())); references.RegisterCommand(new UiCommand("Участки учета", x => _formsController.ShowReference<ReferenceVM<AccountingSite>, ViewAccountingSites>())); references.RegisterCommand(new UiCommand("Типы документов", x => _formsController.ShowReference<ReferenceVM<DocumentType>, ViewDocumentTypes>())); references.RegisterCommand(new UiCommand("Рецепты", x => _formsController.ShowReference<ReferenceVM<Recipe>, ViewNamedEntity>())); var accountingSites = new CommandCategory {Name = "УЧЕТ"}; using (var ctx = new Context()) { foreach (var accountingSite in ctx.Sites) { var site = accountingSite; var siteCategory = new CommandCategory {Name = accountingSite.Name}; accountingSites.ChildItems.Add(siteCategory); siteCategory.RegisterCommand(new UiCommand("Приход", x => _formsController.Show<UnitEntryListVM, ViewEntryList>(site.Id, UnitEntryListType.Income))); siteCategory.RegisterCommand(new UiCommand("Наличие", x => _formsController.Show<UnitEntryListVM, ViewEntryList>(site.Id, UnitEntryListType.Balance))); siteCategory.RegisterCommand(new UiCommand("Расход", x => _formsController.Show<UnitEntryListVM, ViewEntryList>(site.Id, UnitEntryListType.Outcome))); siteCategory.RegisterCommand(new UiCommand("Документы", x => _formsController.Show<DocumentsListVM, ViewDocuments>(site.Id))); } } var settings = new CommandCategory {Name = "НАСТРОЙКИ"}; var production = new CommandCategory {Name = "ПРОИЗВОДСТВО"}; production.RegisterCommand(new UiCommand("Заказы", x => { })); production.RegisterCommand(new UiCommand("Наряды", x => { })); _categories = new[] {accountingSites, production, references, settings}; }
public void Accept(Context ctx) { if (Accepted) throw new InvalidOperationException("Документ уже проведен"); var operation = ctx.OperationLog.Add(new Operation {Date = DateTime.Now, Document = this}); if (Type.Operation == OperationType.Income) // income { foreach (var entry in Items) Site.Income(entry, operation); } else // outcome { foreach (var entry in Items) { Site.Outcom(entry, operation); } } Accepted = true; AcceptedDate = DateTime.Now; }
/// <summary> /// Пересчитывает заказ /// </summary> public void Recalculate() { Items.Clear(); foreach (var orderItem in Orders.SelectMany(order => order.Items) .GroupBy(o => o.Unit) .Select(g => new UnitCount {Unit = g.Key, Count = g.Sum(u => u.Count)})) { Items.Add(orderItem); } using (var ctx = new Context()) { RawMaterials.Clear(); foreach (var item in Items.CalculateRaw(ctx.Recipies).Select(u => new UnitCount {Unit = ctx.Units.Single(x=>x.Id == u.UnitId), Count = u.Count})) RawMaterials.Add(item); } }
public Document NewDocument(Context context) { var retval = new Document { Date = DateTime.Now, Number = context.Documents.Max(d => d.Number) + 1, Site = this }; Documents.Add(retval); return retval; }