public MessageModel UpdateSingleEntity(BreedDrugModel model) { Func <IEntityContext, string> operation = delegate(IEntityContext context) { var data = context.BreedDrug.FirstOrDefault(m => m.DrugID == model.DrugID && m.ModifyTime == model.ModifyTime); if (data == null) { return("当前数据不存在或被更新,请刷新后再次操作!"); } data.DrugID = model.DrugID; data.CultivationID = model.CultivationID; data.CultivationEpc = model.CultivationEpc; data.People = model.People; data.Object = model.Object; data.DrugName = model.DrugName; data.DrugTime = model.DrugTime; data.Problem = model.Problem; data.Method = model.Method; data.DrugCon = model.DrugCon; data.Dilution = model.Dilution; data.Weather = model.Weather; data.Pic = model.Pic; data.Remark = model.Remark; data.IsLocked = model.IsLocked; data.IsShow = model.IsShow; data.ModifyID = UserManagement.CurrentUser.UserID; data.ModifyName = UserManagement.CurrentUser.UserName; data.ModifyTime = DateTime.Now; context.SaveChanges(); return(string.Empty); }; return(base.DbOperation(operation)); }
/// <summary> /// 保存养殖防疫数据 /// </summary> /// <param name="model"></param> public void SaveBredDrugData(BredDrug model) { var productBase = GetProProductByEpc(model.Epc); if (productBase != null) { var cultivationId = GetCultivationId(productBase.ProcessEPC); if (cultivationId != 0) { var drugModel = new BreedDrugModel(); drugModel.CultivationEpc = model.Epc; drugModel.CultivationID = cultivationId; drugModel.Dilution = model.Dilute; drugModel.People = "于硕"; drugModel.Method = model.DrugMethod; drugModel.Problem = model.DrugInsect; drugModel.Object = model.DrugObject; drugModel.DrugCon = int.Parse(model.Dosage); drugModel.DrugTime = DateTime.Now; drugModel.Weather = model.Weather; Context.BreedDrug.Add(drugModel); Context.SaveChanges(); } } }
public void DeleteRow(BreedDrugModel model) { var result = MessageBox.Show("是否删除", "提示", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { var message = iBreedDrugService.DeleteSingleEntity(model.DrugID); if (message.Status == MessageStatus.Success) { LoadData(string.Empty); } } }
public MessageModel InsertSingleEntity(BreedDrugModel model) { Func <IEntityContext, string> operation = delegate(IEntityContext context) { model.ModifyID = UserManagement.CurrentUser.UserID; model.ModifyName = UserManagement.CurrentUser.UserName; model.ModifyTime = DateTime.Now; context.BreedDrug.Add(model); context.SaveChanges(); return(string.Empty); }; return(base.DbOperation(operation)); }
/// <summary> /// 更新单体BreedDrug /// </summary> /// <param name="model"></param> /// <returns></returns> public MessageModel UpdateSingleBreedDrug(BreedDrugModel model) { var data = breedDrugAccess.GetOriEntity(model.DrugID, model.ModifyTime); if (data == null) { return new MessageModel() { Message = "当前数据不存在或被更新,请刷新后再次操作!", Status = MessageStatus.Error } } ; return(breedDrugAccess.UpdateSingleEntity(model)); } }
public void EditRow(BreedDrugModel model) { var vm = IoC.Get <BreedDrugEditViewModel>(); vm.Model = model; vm.Mode = Models.EditMode.UPDATE; var result = IoC.Get <IWindowManager>().ShowDialog(vm, null, new Dictionary <string, object> { { "Title", "编辑" }, { "ResizeMode", System.Windows.ResizeMode.NoResize }, { "Width", 450 }, { "Height", 600 } }); if (result ?? false) { LoadData(string.Empty); } }
/// <summary> /// 插入单条BreedDrug数据 /// </summary> /// <param name="model"></param> /// <returns></returns> public MessageModel InsertSingleBreedDrug(BreedDrugModel model) { return(breedDrugAccess.InsertSingleEntity(model)); }