コード例 #1
0
        private void SaveData()
        {
            try
            {
                unit.Name       = txtName.Text.Trim();
                unit.Code       = txtCode.Text.Trim();
                unit.Decription = txtDescription.Text.Trim();

                unit.Enabled = checkBox1.Checked;

                string msg = string.Empty;
                if (string.IsNullOrEmpty(selectId))
                {
                    unit.Id = Guid.NewGuid();
                    PharmacyDatabaseService.AddDictionaryUserDefinedType(out msg, unit);
                }
                else
                {
                    unit.Id = Guid.Parse(selectId);
                    PharmacyDatabaseService.SaveDictionaryUserDefinedType(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);
            }
        }