public ResResultModel GetAssetInStoreModel(object Id) { try { Guid gId = Guid.Empty; if (Id != null) { Guid.TryParse(Id.ToString(), out gId); } if (gId.Equals(Guid.Empty)) { return(ResResult.Response(false, "请求参数值“" + Id + "”不正确", "")); } var bll = new AssetInStore(); var model = bll.GetModel(gId); if (model == null) { return(ResResult.Response(false, "参数值“" + Id + "”对应数据不存在或已被删除", "")); } return(ResResult.Response(true, "调用成功", JsonConvert.SerializeObject(model))); } catch (Exception ex) { return(ResResult.Response(false, ex.Message, "")); } }
private void Bind() { Guid gId = Guid.Empty; if (!string.IsNullOrWhiteSpace(Request.QueryString["Id"])) { Guid.TryParse(Request.QueryString["Id"], out gId); } if (!gId.Equals(Guid.Empty)) { var bll = new AssetInStore(); var model = bll.GetModel(gId); if (model != null) { hId.Value = model.Id.ToString(); hCategoryId.Value = model.CategoryId.ToString(); hUseCompanyId.Value = model.UseCompanyId.ToString(); hUseDepmtId.Value = model.UseDepmtId.ToString(); hOwnedCompanyId.Value = model.OwnedCompanyId.ToString(); hRegionId.Value = model.RegionId.ToString(); hPictureId.Value = model.PictureId.ToString(); txtBarcode.Value = model.Barcode; txtName.Value = model.Named; txtSpecModel.Value = model.SpecModel; txtSNCode.Value = model.SNCode; txtUnit.Value = model.Unit; txtPrice.Value = model.Price.ToString(); txtBuyDate.Value = model.BuyDate.ToString("yyyy-MM-dd"); txtUsePerson.Value = model.UsePerson; txtManager.Value = model.Manager; txtStoreLocation.Value = model.StoreLocation; txtUseExpireMonth.Value = model.UseExpireMonth.ToString(); txtSupplier.Value = model.Supplier; txtRFID.Value = model.RFID; txtRemark.Value = model.Remark; } } }
public ResResultModel SavePandianAsset(PdaPandianAssetFmModel model) { object userId = null; SecurityService.DoCheckLogin(model.AppKey, model.UserName, out userId); if (model == null) { return(ResResult.Response(false, "请求参数集为空字符串", "")); } var pandianId = Guid.Empty; if (model.PandianId == null || !Guid.TryParse(model.PandianId.ToString(), out pandianId)) { return(ResResult.Response(false, "参数PandianId值为“" + model.PandianId + "”无效", "")); } if (model.ItemList == null || model.ItemList.Count == 0) { return(ResResult.Response(false, "请求参数集为空字符串", "")); } var pdaBll = new PandianAsset(); var aisBll = new AssetInStore(); var pdBll = new Pandian(); var effect = 0; foreach (var item in model.ItemList) { PandianAssetInfo pdaModel = null; AssetInStoreInfo assetModel = null; var assetId = Guid.Empty; if (item.AssetId != null) { Guid.TryParse(item.AssetId.ToString(), out assetId); } if (assetId == Guid.Empty) { if (string.IsNullOrWhiteSpace(item.Barcode)) { continue; } if (pdaBll.IsExist(item.Barcode)) { assetModel = aisBll.GetModelByBarcode(item.Barcode); if (assetModel != null) { CreateAssetInStoreInfo(item, ref assetModel, ref pdaModel); pdaModel.AssetId = assetModel.Id; pdaModel.PandianId = pandianId; assetModel.UserId = Guid.Parse(userId.ToString()); pdaModel.UserId = assetModel.UserId; effect += aisBll.Update(assetModel); effect += pdaBll.Update(pdaModel); } } else { CreateAssetInStoreInfo(item, ref assetModel, ref pdaModel); assetModel.Id = Guid.NewGuid(); pdaModel.AssetId = assetModel.Id; pdaModel.PandianId = pandianId; assetModel.UserId = Guid.Parse(userId.ToString()); pdaModel.UserId = assetModel.UserId; effect += aisBll.InsertByOutput(assetModel); effect += pdaBll.Insert(pdaModel); } } else { assetModel = aisBll.GetModel(assetId); pdaModel = pdaBll.GetModel(pandianId, assetId); CreateAssetInStoreInfo(item, ref assetModel, ref pdaModel); pdaModel.UserId = Guid.Parse(userId.ToString()); effect += pdaBll.Update(pdaModel); } } if (effect < 1) { return(ResResult.Response(false, "操作失败", "")); } return(ResResult.Response(true, "调用成功", "")); }