示例#1
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            this.Validate();
            if (!this.ValidateRequiredTextBox())
            {
                return;
            }

            try
            {
                bool result = false;
                if (this.GMPLicense.Id != null && (!this.GMPLicense.Id.Equals(Guid.Empty)))
                {
                    this.GMPLicense.OutDate      = this.dateTimePickerOutDate.Value.Date;
                    this.GMPLicense.IssuanceDate = this.dateTimePickerIssuanceDate.Value.Date;
                    result = PharmacyDatabaseService.SaveGMPLicense(out msg, this.GMPLicense);
                }
                else
                {
                    this.GMPLicense.Id           = Guid.NewGuid();
                    this.GMPLicense.OutDate      = this.dateTimePickerOutDate.Value.Date;
                    this.GMPLicense.IssuanceDate = this.dateTimePickerIssuanceDate.Value.Date;
                    result = PharmacyDatabaseService.AddGMPLicense(out msg, this.GMPLicense);
                }

                if (result && string.IsNullOrWhiteSpace(msg))
                {
                    MessageBox.Show(this.Text + "证书保证成功", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show(this.Text + "证书保存失败" + msg, "错误", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this.Text + "证书保存失败" + ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }