示例#1
0
 protected void add_ServerClick(object sender, EventArgs e)
 {
     if (name.Text.Trim().Null())
     {
         Notify(ap, "请输入要添加的基础数据", "error");
         return;
     }
     var type = (DictionaryType)int.Parse(tree.SelectedValue);
     var content = name.Text.Trim();
     if (db.Value.StoreDictionary.Count(o => o.StoreId == StoreId && o.Type == type && o.Name == content) == 0)
     {
         var dictionary = new StoreDictionary
         {
             StoreId = StoreId,
             Type = type,
             Name = name.Text.Trim(),
             PinYin = db.Value.ToPinYin(name.Text.Trim()).Single()
         };
         db.Value.StoreDictionary.Add(dictionary);
         db.Value.SaveChanges();
         view.Rebind();
     }
     name.Text = string.Empty;
     Notify(ap, "基础数据添加成功", "success");
 }
示例#2
0
 protected void edit_ServerClick(object sender, EventArgs e)
 {
     if (name.Text.Trim().Null())
     {
         Notify(ap, "请输入类别名称", "error");
         return;
     }
     var id = "CatalogId".Query().GlobalId();
     var item = db.Value.StoreCatalog.Single(o => o.Id == id);
     var content = name.Text.Trim();
     var pinYin = db.Value.ToPinYin(content).Single();
     if (CurrentStore.State == StoreState.食品 && item.ParentId == null)
     {
         var dictionary = db.Value.StoreDictionary.Single(o => o.StoreId == StoreId && o.Type == DictionaryType.使用对象 && o.Name == item.Name);
         db.Value.StoreDictionary.Remove(dictionary);
         var dictionary2 = db.Value.StoreDictionary.Single(o => o.StoreId == StoreId && o.Type == DictionaryType.年龄段 && o.Name == item.Name);
         db.Value.StoreDictionary.Remove(dictionary2);
         var _dictionary = new StoreDictionary
         {
             StoreId = StoreId,
             Type = DictionaryType.使用对象,
             Name = content,
             PinYin = pinYin
         };
         db.Value.StoreDictionary.Add(_dictionary);
         var _dictionary2 = new StoreDictionary
         {
             StoreId = StoreId,
             Type = DictionaryType.年龄段,
             Name = content,
             PinYin = pinYin
         };
         db.Value.StoreDictionary.Add(_dictionary2);
     }
     item.Name = content;
     item.PinYin = pinYin;
     item.Ordinal = ordinal.PeekValue(100);
     db.Value.SaveChanges();
     Response.Redirect("~/StoreSetting/Catalog?StoreId={0}&Initial={1}".Formatted(StoreId, item.ParentId));
 }
示例#3
0
 protected Guid Save()
 {
     var test = name.Text.Trim();
     var testx = tree.SelectedValue.GlobalId();
     if (db.Value.StoreObject.Count(x => x.Name == test && x.State < 2 && x.CatalogId == testx) > 0)
     {
         return Guid.Empty;
     }
     var id = db.Value.GlobalId();
     var img = new[] { p0, p1, p2, p3 }.ToList();
     var photo = img.Count(o => !o.Src.Contains("/Content/Images/Transparent.png")) == 0 ? string.Empty : img.Where(o => !o.Src.Contains("/Content/Images/Transparent.png")).Select(o => o.Src).Aggregate("", (a, b) => a += "*" + b, o => o.Substring(1));
     var obj = new StoreObject
     {
         Id = id,
         CatalogId = tree.SelectedValue.GlobalId(),
         SourceCatalogId = null,
         Name = name.Text.Trim(),
         PinYin = db.Value.ToPinYin(name.Text.Trim()).Single(),
         Single = t3.Checked,
         Consumable = t1.Checked,
         Fixed = false,
         Serial = string.Empty,
         Unit = unit.Text.Trim(),
         Specification = specification.Text.Trim(),
         Low = low.PeekValue(0.00M),
         High = high.PeekValue(0.00M),
         Image = photo,
         Note = content.Text.Trim(),
         TimeNode = DateTime.Today.ToTimeNode(),
         Time = DateTime.Today,
         OperationUserId = CurrentUser,
         OperationTime = DateTime.Now,
         Ordinal = ordinal.PeekValue(100),
         State = 1,
         Code = code.Text.Trim(),
         Amount = 0.00M,
         Money = 0.00M
     };
     db.Value.StoreObject.Add(obj);
     if (db.Value.StoreDictionary.Count(o => o.StoreId == StoreId && o.Type == DictionaryType.单位 && o.Name == unit.Text) == 0)
     {
         var dictionary = new StoreDictionary
         {
             StoreId = StoreId,
             Type = DictionaryType.单位,
             Name = unit.Text,
             PinYin = db.Value.ToPinYin(unit.Text).Single()
         };
         db.Value.StoreDictionary.Add(dictionary);
     }
     if (db.Value.StoreDictionary.Count(o => o.StoreId == StoreId && o.Type == DictionaryType.规格 && o.Name == specification.Text) == 0)
     {
         var dictionary = new StoreDictionary
         {
             StoreId = StoreId,
             Type = DictionaryType.规格,
             Name = specification.Text,
             PinYin = db.Value.ToPinYin(specification.Text).Single()
         };
         db.Value.StoreDictionary.Add(dictionary);
     }
     db.Value.SaveChanges();
     return id;
 }
示例#4
0
 public static void ActionInExt(this StoreEntity db, Guid targetId, Guid objectId, string age, string place, string image, Guid? responsibleId, string note, DateTime inTime, Guid operatorId, string code, decimal amount, decimal totalPrice, decimal sourcePerPrice, decimal fee, decimal money)
 {
     var @in = new StoreIn
     {
         Id = db.GlobalId(),
         TargetId = targetId,
         ObjectId = objectId,
         Age = age,
         Place = place,
         Image = image,
         ResponsibleUserId = responsibleId,
         Note = note,
         TimeNode = inTime.ToTimeNode(),
         Time = inTime,
         OperationUserId = operatorId,
         OperationTime = DateTime.Now,
         Code = code,
         Amount = amount,
         SourceAmount = amount,
         OriginalAmount = amount,
         PerPrice = decimal.Divide(totalPrice, amount),
         SourcePerPrice = sourcePerPrice,
         Fee = fee,
         Money = totalPrice + fee,
         SourceMoney = totalPrice + fee,
         OriginalMoney = totalPrice + fee
     };
     db.StoreIn.Add(@in);
     var obj = db.StoreObject.Single(o => o.Id == objectId);
     obj.Amount += amount;
     obj.Money += money;
     var catalog = obj.StoreCatalog;
     var store = catalog.Store;
     if (store.State != StoreState.食品 && db.StoreDictionary.Count(o => o.StoreId == store.Id && o.Type == DictionaryType.年龄段 && o.Name == age) == 0)
     {
         var dictionary = new StoreDictionary
         {
             StoreId = catalog.StoreId,
             Type = DictionaryType.年龄段,
             Name = age,
             PinYin = db.ToPinYin(age).Single()
         };
         db.StoreDictionary.Add(dictionary);
     }
     var flow = new StoreFlow
     {
         Id = db.GlobalId(),
         ObjectId = objectId,
         UserId = operatorId,
         Type = FlowType.入库,
         TypeName = FlowType.入库.ToString(),
         TimeNode = inTime.ToTimeNode(),
         Time = inTime,
         Amount = amount,
         Money = money,
         Note = note
     };
     db.StoreFlow.Add(flow);
     db.ActionRecord(objectId, inTime, amount, money, 0M, 0M, 0M, 0M, 0M, 0M, 0M, 0M);
     if (obj.Single)
     {
         // To Do
     }
     db.SaveChanges();
 }
示例#5
0
 protected Guid Save()
 {
     var oid = "ObjectId".Query().GlobalId();
     var obj = db.Value.StoreObject.Single(o => o.Id == oid);
     var img = new[] { p0, p1, p2, p3 }.ToList();
     var photo = img.Count(o => !o.Src.Contains("/Content/Images/Transparent.png")) == 0 ? string.Empty : img.Where(o => !o.Src.Contains("/Content/Images/Transparent.png")).Select(o => o.Src).Aggregate("", (a, b) => a += "*" + b, o => o.Substring(1));
     obj.CatalogId = tree.SelectedValue.GlobalId();
     obj.Name = name.Text.Trim();
     obj.PinYin = db.Value.ToPinYin(name.Text.Trim()).Single();
     obj.Unit = unit.Text.Trim();
     obj.Specification = specification.Text.Trim();
     obj.Low = low.PeekValue(0.00M);
     obj.High = high.PeekValue(0.00M);
     obj.Image = photo;
     obj.Note = content.Text.Trim();
     obj.Ordinal = ordinal.PeekValue(100);
     obj.Code = code.Text.Trim();
     if (db.Value.StoreDictionary.Count(o => o.StoreId == StoreId && o.Type == DictionaryType.单位 && o.Name == unit.Text) == 0)
     {
         var dictionary = new StoreDictionary
         {
             StoreId = StoreId,
             Type = DictionaryType.单位,
             Name = unit.Text,
             PinYin = db.Value.ToPinYin(unit.Text).Single()
         };
         db.Value.StoreDictionary.Add(dictionary);
     }
     if (db.Value.StoreDictionary.Count(o => o.StoreId == StoreId && o.Type == DictionaryType.规格 && o.Name == specification.Text) == 0)
     {
         var dictionary = new StoreDictionary
         {
             StoreId = StoreId,
             Type = DictionaryType.规格,
             Name = specification.Text,
             PinYin = db.Value.ToPinYin(specification.Text).Single()
         };
         db.Value.StoreDictionary.Add(dictionary);
     }
     db.Value.SaveChanges();
     return obj.Id;
 }
示例#6
0
 protected void add_ServerClick(object sender, EventArgs e)
 {
     var content = name.Text.Trim();
     var value = CurrentNode;
     if (content.Null())
     {
         Notify(ap, "请输入要添加的类别名称", "error");
         return;
     }
     if (CurrentNode.HasValue)
     {
         var parent = CurrentNode.Value;
         if (db.Value.StoreCatalog.Count(o => o.StoreId == StoreId && o.State < 2 && o.Name == content && o.ParentId == parent) == 0)
         {
             var pinYin = db.Value.ToPinYin(content).Single();
             var catalog = new StoreCatalog
             {
                 Id = db.Value.GlobalId(),
                 ParentId = parent,
                 StoreId = StoreId,
                 Name = content,
                 PinYin = pinYin,
                 Ordinal = ordinal.PeekValue(100),
                 State = 1,
                 Code = string.Empty
             };
             db.Value.StoreCatalog.Add(catalog);
             db.Value.SaveChanges();
         }
     }
     else
     {
         if (db.Value.StoreCatalog.Count(o => o.StoreId == StoreId && o.State < 2 && o.Name == content && o.ParentId == null) == 0)
         {
             var pinYin = db.Value.ToPinYin(content).Single();
             var catalog = new StoreCatalog
             {
                 Id = db.Value.GlobalId(),
                 ParentId = null,
                 StoreId = StoreId,
                 Name = content,
                 PinYin = pinYin,
                 Ordinal = ordinal.PeekValue(100),
                 State = 1,
                 Code = string.Empty
             };
             db.Value.StoreCatalog.Add(catalog);
             if (CurrentStore.State == StoreState.食品)
             {
                 var dictionary = new StoreDictionary
                 {
                     StoreId = StoreId,
                     Type = DictionaryType.使用对象,
                     Name = content,
                     PinYin = catalog.PinYin
                 };
                 db.Value.StoreDictionary.Add(dictionary);
                 var dictionary2 = new StoreDictionary
                 {
                     StoreId = StoreId,
                     Type = DictionaryType.年龄段,
                     Name = content,
                     PinYin = catalog.PinYin
                 };
                 db.Value.StoreDictionary.Add(dictionary2);
             }
             db.Value.SaveChanges();
         }
     }
     ordinal.Text = string.Empty;
     ordinal.Value = null;
     name.Text = string.Empty;
     tree.DataSource = db.Value.StoreCatalog.Where(o => o.StoreId == StoreId && o.State < 2).OrderBy(o => o.Ordinal).ToList();
     tree.DataBind();
     if (value.HasValue)
     {
         var node = tree.GetAllNodes().ToList().First(o => o.Value == value.Value.ToString());
         node.Selected = true;
         node.Expanded = true;
         node.ExpandParentNodes();
         node.ExpandChildNodes();
     }
     else
     {
         tree0.Nodes[0].Selected = true;
     }
     view.Rebind();
     Notify(ap, "类别添加成功", "success");
 }
示例#7
0
 protected Guid Save()
 {
     var tid = "TargetId".Query().GlobalId();
     var target = db.Value.StoreTarget.Single(o => o.Id == tid);
     var time = day.SelectedDate.HasValue ? day.SelectedDate.Value : DateTime.Today;
     target.Number = number.Text.Null() ? number.EmptyMessage : number.Text;
     target.ReceiptNumber = receipt.Text;
     target.OrderSource = source.Text;
     target.UsageTarget = usage.Text;
     target.Content = content.Text;
     target.ToPay = toPay.PeekValue(0.00M);
     target.Paid = paid.PeekValue(0.00M);
     target.BrokerageUserId = brokerage.SelectedIndex > 0 ? brokerage.SelectedValue.GlobalId() : (Guid?)null;
     target.KeepUserId = keep.SelectedIndex > 0 ? keep.SelectedValue.GlobalId() : (Guid?)null;
     target.Time = time;
     target.TimeNode = time.ToTimeNode();
     if (db.Value.StoreDictionary.Count(o => o.StoreId == StoreId && o.Type == DictionaryType.采购来源 && o.Name == source.Text) == 0)
     {
         var dictionary = new StoreDictionary
         {
             StoreId = StoreId,
             Type = DictionaryType.采购来源,
             Name = source.Text,
             PinYin = db.Value.ToPinYin(source.Text).Single()
         };
         db.Value.StoreDictionary.Add(dictionary);
     }
     if (CurrentStore.State != StoreState.食品)
     {
         if (db.Value.StoreDictionary.Count(o => o.StoreId == StoreId && o.Type == DictionaryType.使用对象 && o.Name == source.Text) == 0)
         {
             var dictionary = new StoreDictionary
             {
                 StoreId = StoreId,
                 Type = DictionaryType.使用对象,
                 Name = source.Text,
                 PinYin = db.Value.ToPinYin(source.Text).Single()
             };
             db.Value.StoreDictionary.Add(dictionary);
         }
     }
     db.Value.SaveChanges();
     return target.Id;
 }
示例#8
0
 protected Guid Save()
 {
     var id = db.Value.GlobalId();
     var time = day.SelectedDate.HasValue ? day.SelectedDate.Value : DateTime.Today;
     var target = new StoreTarget
     {
         Id = id,
         StoreId = StoreId,
         Number = number.Text.Null() ? number.EmptyMessage : number.Text,
         ReceiptNumber = receipt.Text,
         OrderSource = source.Text,
         UsageTarget = usage.Text,
         Content = content.Text,
         ToPay = toPay.PeekValue(0.00M),
         Paid = paid.PeekValue(0.00M),
         AdjustedMoney = null,
         BrokerageUserId = brokerage.SelectedIndex > 0 ? brokerage.SelectedValue.GlobalId() : (Guid?)null,
         KeepUserId = keep.SelectedIndex > 0 ? keep.SelectedValue.GlobalId() : (Guid?)null,
         In = false,
         Time = time,
         TimeNode = time.ToTimeNode(),
         OperationUserId = CurrentUser,
         OperationTime = DateTime.Now,
         State = 1
     };
     db.Value.StoreTarget.Add(target);
     if (db.Value.StoreDictionary.Count(o => o.StoreId == StoreId && o.Type == DictionaryType.采购来源 && o.Name == source.Text) == 0)
     {
         var dictionary = new StoreDictionary
         {
             StoreId = StoreId,
             Type = DictionaryType.采购来源,
             Name = source.Text,
             PinYin = db.Value.ToPinYin(source.Text).Single()
         };
         db.Value.StoreDictionary.Add(dictionary);
     }
     if (CurrentStore.State != StoreState.食品)
     {
         if (db.Value.StoreDictionary.Count(o => o.StoreId == StoreId && o.Type == DictionaryType.使用对象 && o.Name == source.Text) == 0)
         {
             var dictionary = new StoreDictionary
             {
                 StoreId = StoreId,
                 Type = DictionaryType.使用对象,
                 Name = source.Text,
                 PinYin = db.Value.ToPinYin(source.Text).Single()
             };
             db.Value.StoreDictionary.Add(dictionary);
         }
     }
     db.Value.SaveChanges();
     return id;
 }