public bool UpdateWorkType(CommContracts.WorkType WorkType) { using (DAL.HisContext ctx = new DAL.HisContext()) { var temp = ctx.WorkTypes.FirstOrDefault(m => m.ID == WorkType.ID); if (temp != null) { temp.Name = WorkType.Name; temp.ModifiedDate = DateTime.Now; } 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 SaveWorkType(CommContracts.WorkType WorkType) { WorkType.ModifiedDate = DateTime.Now; using (DAL.HisContext ctx = new DAL.HisContext()) { var config = new MapperConfiguration(cfg => { cfg.CreateMap <CommContracts.WorkType, DAL.WorkType>(); }); var mapper = config.CreateMapper(); DAL.WorkType temp = new DAL.WorkType(); temp = mapper.Map <DAL.WorkType>(WorkType); ctx.WorkTypes.Add(temp); try { ctx.SaveChanges(); } #pragma warning disable CS0168 // 声明了变量“ex”,但从未使用过 catch (Exception ex) #pragma warning restore CS0168 // 声明了变量“ex”,但从未使用过 { return(false); } } return(true); }
private void SaveBtn_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(this.NameEdit.Text.Trim())) { return; } if (bIsEdit) { m_WorkType.Name = this.NameEdit.Text; CommClient.WorkType WorkTypeClient = new CommClient.WorkType(); if (WorkTypeClient.UpdateWorkType(m_WorkType)) { (this.Parent as Window).DialogResult = true; (this.Parent as Window).Close(); } } else { CommContracts.WorkType WorkType = new CommContracts.WorkType(); WorkType.Name = this.NameEdit.Text; CommClient.WorkType WorkTypeClient = new CommClient.WorkType(); if (WorkTypeClient.SaveWorkType(WorkType)) { (this.Parent as Window).DialogResult = true; (this.Parent as Window).Close(); } } }
public EditWorkTypeView(CommContracts.WorkType WorkType = null) { InitializeComponent(); bIsEdit = false; if (WorkType != null) { this.m_WorkType = WorkType; this.NameEdit.Text = WorkType.Name; bIsEdit = true; } }
public bool SaveWorkType(CommContracts.WorkType WorkType) { return(client.SaveWorkType(WorkType)); }
public bool UpdateWorkType(CommContracts.WorkType WorkType) { return(client.UpdateWorkType(WorkType)); }