public void LoadDefaults(InMemoryUse use) { catalog.DataSource = DataContext.DepotCatalogTreeLoad(Depot.Id).ToList().Where(o => o.Code != "*Homory:Null*").ToList(); ; catalog.DataBind(); amount.Value = (double?)use.Amount; amount.NumberFormat.DecimalDigits = Depot.Featured(DepotType.小数数量库) ? 2 : 0; age.Text = use.Age; place.Text = use.Place; note.Text = use.Note; if (use.CatalogId.HasValue && use.CatalogId.Value != Guid.Empty) { var catalogId = use.CatalogId.Value; var node = catalog.EmbeddedTree.FindNodeByValue(catalogId.ToString()); node.Selected = true; node.ExpandParentNodes(); catalog.SelectedValue = catalogId.ToString(); var source = DataContext.DepotObjectLoad(Depot.Id, use.CatalogId, true).Where(o => o.Amount > 0); obj.DataSource = source.ToList(); obj.DataBind(); if (use.ObjectId.HasValue && use.ObjectId.Value != Guid.Empty) { var oid = use.ObjectId.Value; var so = DataContext.DepotObject.Single(o => o.Id == oid); //if (Depot.Featured(DepotType.幼儿园)) // amount.Value = (double)so.Amount; unit.Text = so.Unit; brand.Text = so.Brand; specification.Text = so.Specification; stored.Text = so.Amount.ToAmount(Depot.Featured(DepotType.小数数量库)); amount.MaxValue = (double)so.Amount; obj.SelectedIndex = obj.FindItemIndexByValue(use.ObjectId.ToString()); if (so.Single) { amount.Visible = false; ordinalList.Visible = true; ordinalList.DataSource = so.DepotInX.ToList().Where(o => o.AvailableAmount == 1).Select(o => o.Ordinal).OrderBy(o => o).ToList(); ordinalList.DataBind(); ordinalList.Items.ToList().ForEach(o => { if (use.Ordinals.Contains(int.Parse(o.Text))) o.Checked = true; }); } else { amount.Visible = true; ordinalList.Visible = false; } if (so.Consumable) { act.DataSource = new[] { "领用" }; act.DataBind(); } else if (so.Single) { act.DataSource = new[] { "借用" }; act.DataBind(); } else { act.DataSource = new[] { "借用", "领用" }; act.DataBind(); } if (!"ObjectId".Query().None()) { act.FindItemByText("UseType".Query().Equals("1") ? "借用" : "领用").Selected = true; } if (use.Type.HasValue) { act.FindItemByText(use.Type.Value.ToString()).Selected = true; } } } else { if (catalog.EmbeddedTree.Nodes.Count > 0) { var node = catalog.EmbeddedTree.Nodes[0]; node.Selected = true; node.ExpandParentNodes(); catalog.SelectedValue = node.Value; var source = DataContext.DepotObjectLoad(Depot.Id, Guid.Parse(node.Value), true).Where(o => o.Amount > 0); obj.DataSource = source.ToList(); obj.DataBind(); } } if (!"ObjectId".Query().None()) { catalog.Enabled = false; obj.Enabled = false; } }
protected void scanAdd_ServerClick(object sender, EventArgs e) { var list = x.Value.None() ? new List<InMemoryUse>() : x.Value.FromJson<List<InMemoryUse>>(); var code = scan.Text.Trim(); if (code.StartsWith("O")) { var inx = DataContext.DepotInX.FirstOrDefault(o => o.Code == code); if (inx == null) { Reset(); return; } var obj = inx.DepotObject; var isVirtual = Depot.Featured(DepotType.固定资产库); var catalogId = DataContext.DepotObjectCatalog.Single(o => o.ObjectId == obj.Id && o.IsVirtual == isVirtual && o.IsLeaf == true).CatalogId; InMemoryUse use = new InMemoryUse { Age = inx.Age, Amount = 1, CatalogId = catalogId, Note = "", ObjectId = obj.Id, Place = inx.Place, Ordinals = new List<int>() }; list.Add(use); } else if (code.StartsWith("S")) { var inx = DataContext.DepotInX.FirstOrDefault(o => o.Code == code); if (inx == null) { Reset(); return; } var obj = inx.DepotObject; var isVirtual = Depot.Featured(DepotType.固定资产库); var catalogId = DataContext.DepotObjectCatalog.Single(o => o.ObjectId == obj.Id && o.IsVirtual == isVirtual && o.IsLeaf == true).CatalogId; InMemoryUse use = new InMemoryUse { Age = inx.Age, Amount = 1, CatalogId = catalogId, Note = "", ObjectId = obj.Id, Place = inx.Place, Ordinals = new List<int>() }; use.Ordinals.Add(inx.Ordinal); list.Add(use); } x.Value = list.ToJson(); counter.Value = list.Count.ToString(); view_obj.Rebind(); Reset(); }
public InMemoryUse PeekValue() { var result = new InMemoryUse(); result.Age = age.Text; result.Place = place.Text; result.CatalogId = catalog.SelectedValue.None() ? (Guid?)null : catalog.SelectedValue.GlobalId(); result.ObjectId = obj.SelectedValue == null || obj.Text.None() ? (Guid?)null : obj.SelectedValue.GlobalId(); result.Amount = amount.Value.HasValue ? (decimal)amount.Value.Value : (decimal?)null; result.Note = note.Text; result.Ordinals = ordinalList.Items.Where(o => o.Checked).Select(o => int.Parse(o.Text)).ToList(); result.Type = act.SelectedIndex == -1 ? (UseType?)null : (UseType)Enum.Parse(typeof(UseType), act.SelectedItem.Text); return result; }
protected void scanAdd_ServerClick(object sender, EventArgs e) { var list = new List<InMemoryUse>(); for (var i = 0; i < view_obj.Items.Count; i++) { var c = view_obj.Items[i].FindControl("ObjectUse") as Control_ObjectUse; var use = c.PeekValue(); if (use.ObjectId.HasValue) { list.Add(use); } } x.Value = list.ToJson(); // var list = x.Value.None() ? new List<InMemoryUse>() : x.Value.FromJson<List<InMemoryUse>>(); var code = scan.Text.Trim(); if (code.StartsWith("O")) { var inx = DataContext.DepotInX.FirstOrDefault(o => o.Code == code); if (inx == null) { Reset(); return; } var obj = inx.DepotObject; var isVirtual = Depot.Featured(DepotType.固定资产库); var catalogId = DataContext.DepotObjectCatalog.Single(o => o.ObjectId == obj.Id && o.IsVirtual == isVirtual && o.IsLeaf == true).CatalogId; if (list.Count(o => o.ObjectId == obj.Id) > 0) { list.First(o => o.ObjectId == obj.Id).Amount++; } else { InMemoryUse use = new InMemoryUse { Age = inx.Age, Amount = 1, CatalogId = catalogId, Note = "", ObjectId = obj.Id, Place = inx.Place, Ordinals = new List<int>() }; list.Add(use); } } else if (code.StartsWith("S")) { var inx = DataContext.DepotInX.FirstOrDefault(o => o.Code == code); if (inx == null) { Reset(); return; } var obj = inx.DepotObject; var isVirtual = Depot.Featured(DepotType.固定资产库); var catalogId = DataContext.DepotObjectCatalog.Single(o => o.ObjectId == obj.Id && o.IsVirtual == isVirtual && o.IsLeaf == true).CatalogId; if (list.Count(o => o.ObjectId == obj.Id) > 0) { var f = list.First(o => o.ObjectId == obj.Id); if (!f.Ordinals.Contains(inx.Ordinal)) { f.Ordinals.Add(inx.Ordinal); } } else { InMemoryUse use = new InMemoryUse { Age = inx.Age, Amount = 1, CatalogId = catalogId, Note = "", ObjectId = obj.Id, Place = inx.Place, Ordinals = new List<int>() }; use.Ordinals.Add(inx.Ordinal); list.Add(use); } } x.Value = list.ToJson(); counter.Value = list.Count.ToString(); view_obj.Rebind(); Reset(); ap.ResponseScripts.Add("window.scrollTo(0, document.body.scrollHeight);"); }