public bool UpdateRegistrationDitch(CommContracts.RegistrationDitch RegistrationDitch) { using (DAL.HisContext ctx = new DAL.HisContext()) { var temp = ctx.RegistrationDitchs.FirstOrDefault(m => m.ID == RegistrationDitch.ID); if (temp != null) { temp.Name = RegistrationDitch.Name; temp.Priority = (DAL.PriorityEnum)RegistrationDitch.Priority; temp.Proportion = RegistrationDitch.Proportion; temp.Status = (DAL.RegistrationDitchStatusEnum)RegistrationDitch.Status; temp.StartTime = RegistrationDitch.StartTime; } else { return(false); } try { ctx.SaveChanges(); } #pragma warning disable CS0168 // 声明了变量“ex”,但从未使用过 catch (Exception ex) #pragma warning restore CS0168 // 声明了变量“ex”,但从未使用过 { return(false); } } return(true); }
public bool SaveRegistrationDitch(CommContracts.RegistrationDitch RegistrationDitch) { using (DAL.HisContext ctx = new DAL.HisContext()) { var config = new MapperConfiguration(cfg => { cfg.CreateMap <CommContracts.RegistrationDitch, DAL.RegistrationDitch>(); }); var mapper = config.CreateMapper(); DAL.RegistrationDitch temp = new DAL.RegistrationDitch(); temp = mapper.Map <DAL.RegistrationDitch>(RegistrationDitch); ctx.RegistrationDitchs.Add(temp); try { ctx.SaveChanges(); } #pragma warning disable CS0168 // 声明了变量“ex”,但从未使用过 catch (Exception ex) #pragma warning restore CS0168 // 声明了变量“ex”,但从未使用过 { return(false); } } return(true); }
private void updateDateToView(CommContracts.RegistrationDitch RegistrationDitch) { var vm = this.DataContext as HISGUISetVM; vm.CurrentRegistrationDitch = RegistrationDitch; this.StartTime.SetMyValue(vm.CurrentRegistrationDitch.StartTime); bIsEdit = true; }
private void newRegistrationDitch() { bIsEdit = false; CommContracts.RegistrationDitch vistTime = new CommContracts.RegistrationDitch(); updateDateToView(vistTime); EditGrid.IsEnabled = true; this.NameBox.Focus(); if (this.AllRegistrationDitchViewList.SelectedItem != null) { this.AllRegistrationDitchViewList.SelectedItem = null; } }