コード例 #1
0
ファイル: FormGSPLicense.cs プロジェクト: radtek/phamacy2016
 private bool GetGMSPLicenseBusinessScopes()
 {
     try
     {
         string msg = string.Empty;
         GMSPLicenseBusinessScopes = PharmacyDatabaseService.AllGMSPLicenseBusinessScopes(out msg).Where(d => d.GSPLicenseId == GSPLicense.Id && d.Deleted == false).ToList();
         if (GMSPLicenseBusinessScopes.Count != 0)
         {
             foreach (var gms in GMSPLicenseBusinessScopes)
             {
                 PharmacyDatabaseService.DeleteGMSPLicenseBusinessScope(out msg, gms.Id);
             }
         }
         if (GMSPLicenseBusinessScopes.Count == 0)
         {
             GMSPLicenseBusinessScopes = new List <GMSPLicenseBusinessScope>();
         }
         GMSPLicenseBusinessScopes.Clear();
         var items = checkedListBoxGMSPLicenseBusinessScopes.Items;
         for (int i = 0; i < items.Count; i++)
         {
             var businessScope = items[i] as BusinessScope;
             if (businessScope == null)
             {
                 continue;
             }
             if (!checkedListBoxGMSPLicenseBusinessScopes.GetItemChecked(i))
             {
                 continue;
             }
             GMSPLicenseBusinessScopes.Add(new GMSPLicenseBusinessScope
             {
                 Id = Guid.NewGuid()
                 ,
                 BusinessScopeId = businessScope.Id
                 ,
                 GSPLicenseId = GSPLicense.Id
                 ,
                 Deleted = false
             });
         }
         GSPLicense.GMSPLicenseBusinessScopes = GMSPLicenseBusinessScopes.ToArray();
         //foreach (GMSPLicenseBusinessScope gsm in GMSPLicenseBusinessScopes)
         //    return PharmacyDatabaseService.AddGMSPLicenseBusinessScope(out msg,gsm);
         return(true);
     }
     catch (Exception ex)
     {
         Log.Error(ex);
         //MessageBox.Show("从控件收集选择的经营范围失败", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Stop);
         MessageBox.Show(this.Text + "从控件收集选择的经营范围失败", "错误", MessageBoxButtons.OK, MessageBoxIcon.Stop);
         return(false);
     }
 }