Exemplo n.º 1
0
        private void SaveData()
        {
            try
            {
                DrugType unit = new DrugType();

                unit.Name       = txtName.Text.Trim();
                unit.Code       = txtCode.Text.Trim();
                unit.Decription = txtDescription.Text.Trim();
                unit.Enabled    = checkBox1.Checked;
                if (this.cbxCategory.DataSource != null)
                {
                    unit.DrugCategoryId = Guid.Parse(this.cbxCategory.SelectedValue.ToString());
                }


                string msg = string.Empty;
                if (string.IsNullOrEmpty(selectId))
                {
                    unit.Id = Guid.NewGuid();
                    PharmacyDatabaseService.AddDrugType(out msg, unit);
                }
                else
                {
                    unit.Id = Guid.Parse(selectId);
                    PharmacyDatabaseService.SaveDrugType(out msg, unit);
                }
                if (string.IsNullOrEmpty(msg))
                {
                    this.FormState = FormOperation.Empty;

                    RefreshDataView();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("保存数据失败!", "错误");
                Log.Error(ex);
            }
        }