public bool EditGSPLiscence(GSPLicense m) { try { var c = this.Get(m.Id); foreach (var i in c.GMSPLicenseBusinessScopes) { this.BusinessHandlerFactory.GMSPLicenseBusinessScopeBusinessHandler.Delete(i.Id); } foreach (var i in m.GMSPLicenseBusinessScopes.ToList()) { GMSPLicenseBusinessScope bs = new GMSPLicenseBusinessScope { GSPLicenseId = i.GSPLicenseId, Id = Guid.NewGuid(), BusinessScopeCodeMemo = i.BusinessScopeCodeMemo, BusinessScopeCode = i.BusinessScopeCode }; this.RepositoryProvider.Db.GMSPLicenseBusinessScopes.Add(bs); } m.GMSPLicenseBusinessScopes = null; this.Save(m); this.Save(); return(true); } catch (Exception ex) { return(false); } }
private void buttonSave_Click(object sender, EventArgs e) { try { if (this._instCategory.ListCategory.Count(r => r.IsChecked) <= 0) { MessageBox.Show("您没有选择任何器械分类代码,请设置!"); return; } this._gspLiscence.GMSPLicenseBusinessScopes = null; IList <GMSPLicenseBusinessScope> newlist = new List <GMSPLicenseBusinessScope>(); foreach (var row in this._instCategory.ListCategory) { if (!row.IsChecked) { continue; } GMSPLicenseBusinessScope gmsp = new GMSPLicenseBusinessScope { BusinessScopeCode = row.StandardCode, BusinessScopeCodeMemo = row.Description, GSPLicenseId = this._gspLiscence.Id, Id = Guid.NewGuid(), }; newlist.Add(gmsp); } this._gspLiscence.GMSPLicenseBusinessScopes = newlist; bool result = false; if (this._fs.FStatus == FormStatusEnum.New) { result = PharmacyDatabaseService.AddGSPLicense(out msg, this._gspLiscence); } else { result = PharmacyDatabaseService.EditGSPLiscence(this._gspLiscence, out msg); } if (result && string.IsNullOrWhiteSpace(msg)) { MessageBox.Show(this.Text + "证书保证成功", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information); this.DialogResult = System.Windows.Forms.DialogResult.OK; this._gspLiscenceId = this._gspLiscence.Id; } else { MessageBox.Show(this.Text + "证书保存失败" + msg, "错误", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } catch (Exception ex) { MessageBox.Show(this.Text + "证书保存失败" + ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Stop); } }