Esempio n. 1
0
    public void LoadDefaults(CachedIn @in)
    {
        tid.Value = @in.TargetId.ToString();
        var target = db.Value.StoreTarget.Single(o => o.Id == @in.TargetId);
        var catalogs = db.Value.StoreCatalog.Where(o => o.StoreId == StoreId && o.State < 2).OrderBy(o => o.Ordinal).ToList();
        if (CurrentStore.State == StoreState.食品)
        {
            catalogs.RemoveAll(o => o.ParentId == null && o.Name != target.UsageTarget);
            catalog.DataSource = catalogs;
            catalog.DataBind();
            catalog.EmbeddedTree.Nodes[0].Expanded = true;
            age.ReadOnly = true;
            age.Text = target.UsageTarget;
            place.Text = "{0}食堂".Formatted(target.UsageTarget.Substring(0, 2));
        }
        else
        {
            catalog.DataSource = catalogs;
            catalog.DataBind();
            age.ReadOnly = false;
            age.Text = string.Empty;
        }
        amount.Value = (double?)@in.Amount;
        perPrice.Value = (double?)@in.SourcePerPrice;
        fee.Value = (double?)@in.Fee;
        money.Value = (double?)@in.Money;
        if ([email protected]())
            place.Text = @in.Place;
        note.Text = @in.Note;
        time.SelectedDate = (@in.TimeNode.HasValue ? @in.TimeNode.Value : target.TimeNode).ToTime();
        if (@in.CatalogId.HasValue && @in.CatalogId.Value != Guid.Empty)
        {
            var catalogId = @in.CatalogId.Value;
            var node = catalog.EmbeddedTree.FindNodeByValue(catalogId.ToString());
            node.Selected = true;
            node.ExpandParentNodes();
            catalog.SelectedValue = catalogId.ToString();
            var c = db.Value.StoreCatalog.Single(o => o.Id == catalogId);
            var list = new List<Guid>();
            AddChildren(list, c);
            obj.DataSource = list.Join(db.Value.StoreObject, o => o, o => o.CatalogId, (a, b) => b).OrderBy(o => o.Ordinal).ToList();
            obj.DataBind();
            if (@in.ObjectId.HasValue && @in.ObjectId.Value != Guid.Empty)
            {
                var oid = @in.ObjectId.Value;
                var so = db.Value.StoreObject.Single(o => o.Id == oid);
                unit.Text = so.Unit;
                specification.Text = so.Specification;
                stored.Text = so.Amount.ToAmount();
                obj.SelectedIndex = obj.FindItemIndexByValue(@in.ObjectId.ToString());

                var last = so.StoreIn.OrderByDescending(o => o.AutoId).FirstOrDefault();
                if (last != null)
                {
                    perPrice.Value = (double)last.SourcePerPrice;
                }
            }
            age.Text = @in.Age;
        }
    }
Esempio n. 2
0
 public CachedIn PeekValue()
 {
     var targetId = tid.Value.GlobalId();
     var result = new CachedIn();
     result.TargetId = targetId;
     result.CatalogId = catalog.SelectedValue == null ? (Guid?)null : catalog.SelectedValue.GlobalId();
     result.ObjectId = obj.SelectedValue == null || obj.Text.Null() ? (Guid?)null : obj.SelectedValue.GlobalId();
     result.TimeNode = time.SelectedDate.HasValue ? time.SelectedDate.Value.ToTimeNode() : db.Value.StoreTarget.Single(o => o.Id == targetId).TimeNode;
     result.Amount = amount.Value.HasValue ? (decimal)amount.Value.Value : (decimal?)null;
     result.SourcePerPrice = perPrice.Value.HasValue ? (decimal)perPrice.Value.Value : (decimal?)null;
     result.Fee = fee.Value.HasValue ? (decimal)fee.Value.Value : (decimal?)null;
     result.Money = money.Value.HasValue ? (decimal)money.Value.Value : (decimal?)null;
     result.Age = age.Text;
     result.Place = place.Text;
     result.Note = note.Text;
     return result;
 }