private void SaveData() { try { unit.Name = txtName.Text.Trim(); string msg = string.Empty; if (string.IsNullOrEmpty(selectId)) { unit.Id = Guid.NewGuid(); PharmacyDatabaseService.AddDictionarySpecification(out msg, unit); } else { unit.Id = Guid.Parse(selectId); PharmacyDatabaseService.SaveDictionarySpecification(out msg, unit); } if (string.IsNullOrEmpty(msg)) { this.FormState = FormOperation.Empty; RefreshDataView(); } } catch (Exception ex) { MessageBox.Show("保存数据失败!", "错误"); Log.Error(ex); } }