Beispiel #1
0
        public ActionResult AssetEdit(int id, int storeId, FormCollection collection)
        {
            Asset a = db.Assets.Find(id);
            if(a==null)
            {
                a = new Asset { StoreId = storeId };
                db.Assets.Add(a);
            }
            //collection.Remove("");
            TryUpdateModel(a, "", new  string[]{}, new string[] {"Id","StoreId"},collection);
            if (!UserInfo.CurUser.HasRight("门店设置-设备维护", a.StoreId)) return Redirect("~/content/AccessDeny.htm");

            if (ModelState.IsValid)
            {
                if(a.Id==0)
                {
                    a.StoreId = storeId;
                }
                    db.SaveChanges(); BLL.Utilities.AddLogAndSave(a.Id, Asset.LogClass, "修改", "");
                    return Redirect("../AssetView/" + a.Id);

                //}
            }

            return View(a);
        }
Beispiel #2
0
 public ActionResult AssetEdit(int id,int storeId)
 {
     Asset asset = db.Assets.Find(id);
     if(asset==null)
     {
         asset=new Asset();
         asset.StoreId = storeId;
     }
     if (!UserInfo.CurUser.HasRight("门店设置-设备维护", asset.StoreId)) return Redirect("~/content/AccessDeny.htm");
     return View(asset);
 }
Beispiel #3
0
 private void ImportProduct(TransactionScopeOption option, SqlConnection conn)
 {
     using (TransactionScope transcope = new TransactionScope(option, TimeSpan.FromMinutes(5)))
     {
         using (OUContext db = new OUContext())
         {
             db.Configuration.ValidateOnSaveEnabled = false;
             List<megasun> listMegasun = conn.Query<megasun>(megasun.sql).ToList();
             foreach (var mega in listMegasun)
             {
                 Asset asset = new Asset();
                 asset.AssetType = "日晒机";
                 asset.Name = mega.l_mgsname + " " + mega.l_roomnum;
                 asset.Rate = Convert.ToDecimal(mega.l_usage);
                 asset.StoreId = StoreId;
                 asset.Remark = mega.l_mgsid.ToString();
                 db.Assets.Add(asset);
             }
             db.SaveChanges();
             List<product> listProduct = conn.Query<product>(product.sql).ToList();
             foreach (var prod in listProduct)
             {
                 Product p = new Product();
                 p.Name = prod.l_productname;
                 p.UnitPrice = Convert.ToDecimal(prod.l_productprice);
                 p.StoreId = StoreId;
                 p.Remark = prod.l_productid.ToString();
                 switch (prod.l_typename)
                 {
                     case "Minute":
                         p.Catalog = "日晒时长";
                         if (prod.l_productname.Contains("单次"))
                             p.Catalog = "单次日晒";
                         break;
                     case "Health":
                         p.Catalog = "健康产品";
                         break;
                     case "Lotion":
                         p.Catalog = "护肤液";
                         break;
                     case "Cloth":
                         p.Catalog = "服装";
                         break;
                 }
                 db.Products.Add(p);
             }
             db.SaveChanges();
             transcope.Complete();
         }
     }
     Console.WriteLine(DateTime.Now.ToLongTimeString());
 }