private void BindAllBusinessScopes() { try { string message; BusinessScopes = PharmacyDatabaseService.AllBusinessScopes(out message) .ToList(); if (BusinessScopes != null && string.IsNullOrWhiteSpace(message)) { foreach (BusinessScope businessScope in BusinessScopes) { if (businessScope.BusinessScopeCategory != null) { businessScope.Name = string.Format("{0}>{1}" , businessScope.BusinessScopeCategory.Name , businessScope.Name ); } } } if (BusinessScopes != null) { this.checkedListBoxBusinessScopes.Items.Clear(); this.checkedListBoxBusinessScopes.DisplayMember = "Name"; this.checkedListBoxBusinessScopes.ValueMember = "Id"; this.checkedListBoxBusinessScopes .Items.AddRange(BusinessScopes.Cast <object>().ToArray()); } this.checkedListBoxBusinessScopes.Enabled = true; } catch (Exception ex) { this.checkedListBoxBusinessScopes.Enabled = false; } }
/// <summary> /// 从服务器获取所有经营范围 /// </summary> /// <param name="showMessage"></param> /// <returns></returns> public bool LoadBusinessScopes(bool showMessage = false) { try { string message; BusinessScopes = PharmacyDatabaseService.AllBusinessScopes(out message) .ToList(); if (BusinessScopes != null && string.IsNullOrWhiteSpace(message)) { foreach (BusinessScope businessScope in BusinessScopes) { if (businessScope.BusinessScopeCategory != null) { businessScope.Name = string.Format("{0}>{1}" , businessScope.BusinessScopeCategory.Name , businessScope.Name ); } } return(true); } else { throw new Exception(message); return(false); } } catch (Exception ex) { Log.Error(ex); if (showMessage) { //MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Stop); MessageBox.Show(this.Text + ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Stop); } return(false); } }
private void GetComponentDatas() { try { string msg = string.Empty; _ListDictionaryMeasurementUnit = PharmacyDatabaseService.AllDictionaryMeasurementUnits(out msg).ToList(); _ListDrugCategory = PharmacyDatabaseService.AllDrugCategorys(out msg).ToList(); foreach (DrugCategory category in _ListDrugCategory) { //dicDrugCategory.Add(category.Code, category.Name); } _ListDictionaryUserDefinedType = PharmacyDatabaseService.AllDictionaryUserDefinedTypes(out msg).ToList(); foreach (DictionaryUserDefinedType userDefinedType in _ListDictionaryUserDefinedType) { dicDictionaryUserDefinedType.Add(userDefinedType.Code, userDefinedType.Name); } _ListDictionaryDosage = PharmacyDatabaseService.AllDictionaryDosages(out msg).ToList(); _ListDictionarySpecification = PharmacyDatabaseService.AllDictionarySpecifications(out msg).ToList(); _ListDictionaryPiecemealUnit = PharmacyDatabaseService.AllDictionaryPiecemealUnits(out msg).ToList(); _ListMedicalCategoryDetail = PharmacyDatabaseService.AllMedicalCategoryDetails(out msg).ToList(); foreach (MedicalCategoryDetail unit in _ListMedicalCategoryDetail) { dicMedicalCategoryDetail.Add(unit.Code, unit.Name); //to do } _ListDrugClinicalCategory = PharmacyDatabaseService.AllDrugClinicalCategorys(out msg).ToList(); foreach (DrugClinicalCategory unit in _ListDrugClinicalCategory) { dicDrugClinicalCategory.Add(unit.Code, unit.Name); } _ListDictionaryStorageType = PharmacyDatabaseService.AllDictionaryStorageTypes(out msg).ToList(); foreach (DictionaryStorageType unit in _ListDictionaryStorageType) { dicDrugStorageType.Add(unit.Code, unit.Name); } _ListPurchaseManageCategoryDetail = PharmacyDatabaseService.AllPurchaseManageCategoryDetails(out msg).ToList(); foreach (PurchaseManageCategoryDetail unit in _ListPurchaseManageCategoryDetail) { dicPurchaseManageCategoryDetail.Add(unit.Code, unit.Name); } _ListSpecialDrugCategory = PharmacyDatabaseService.AllSpecialDrugCategorys(out msg).ToList(); foreach (SpecialDrugCategory unit in _ListSpecialDrugCategory) { dicSpecialDrugCategory.Add(unit.Code, unit.Name); } _ListBusinessScope = PharmacyDatabaseService.AllBusinessScopes(out msg).ToList(); foreach (BusinessScope unit in _ListBusinessScope) { dicBusinessScope.Add(unit.Code, unit.Name); } } catch (Exception ex) { MessageBox.Show(ex.Message, "系统错误", MessageBoxButtons.OK); Log.Error(ex); } }