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