public static AccountActorComboBoxStrategyCreator GetCreator(AccountActorTypeEnum type) { AccountActorComboBoxStrategyCreator ret = null; switch (type) { case AccountActorTypeEnum.ORGANIZATION: ret = new AccountActorOrganizationComboBoxStrategyCreator(); break; case AccountActorTypeEnum.DEPARTMENT: ret = new AccountActorDepartmentComboBoxStrategyCreator(); break; case AccountActorTypeEnum.PERSON: ret = new AccountActorPersonComboBoxStrategyCreator(); break; case AccountActorTypeEnum.CUSTOMER: ret = new AccountActorCustomerComboBoxStrategyCreator(); break; case AccountActorTypeEnum.MANUFACTURER: ret = new AccountActorManufacturerComboBoxStrategyCreator(); break; case AccountActorTypeEnum.SUPPLIER: ret = new AccountActorSupplierComboBoxStrategyCreator(); break; case AccountActorTypeEnum.INVENTORY: break; case AccountActorTypeEnum.LOT: ret = new AccountActorLotComboBoxStrategyCreator(); break; case AccountActorTypeEnum.BILL: break; default: break; } return(ret); }
private void UpdateMasterAccountActorComboBox(object sender) { ASPxCallbackPanel panel = sender as ASPxCallbackPanel; GridViewEditItemTemplateContainer itemContainer = (GridViewEditItemTemplateContainer)panel.NamingContainer; ASPxGridView grid = itemContainer.Grid; //Get allocation ASPxComboBox allocationComboBox = (ASPxComboBox)grid.FindEditRowCellTemplateControl(grid.Columns["Allocation!Key"] as GridViewDataColumn, "cboAllocation"); if (allocationComboBox.Value == null) { return; } Guid allocationId = (Guid)allocationComboBox.Value; Allocation allocation = session.GetObjectByKey <Allocation>(allocationId); //Get account actor type AllocationAccountActorType masterAllocationAccountActorType = allocation.AllocationAccountActorTypes.FirstOrDefault(r => r.IsMaster); if (masterAllocationAccountActorType == null) { throw new Exception("Invalid allocation. Make sure that the allocation has a master account actor type."); } AccountActorType accountActorType = masterAllocationAccountActorType.AccountActorTypeId; AccountActorTypeEnum accountActorTypeEnum = (AccountActorTypeEnum)Enum.Parse(typeof(AccountActorTypeEnum), accountActorType.Code); //Get account actor combobox AccountActorComboBox accountActorComboBox = (AccountActorComboBox)panel.FindControl("accountActorComboBox"); //FindEditRowCellTemplateControl(grid.Columns["MasterAccountActor"] as GridViewDataColumn, "accountActorComboBox"); //Validation setting accountActorComboBox.ComboBox.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithTooltip; accountActorComboBox.ComboBox.ValidationSettings.RequiredField.IsRequired = true; accountActorComboBox.ComboBox.ValidationSettings.RequiredField.ErrorText = (string)HttpContext.GetGlobalResourceObject("MessageResource", "Msg_Required_Select"); //Set account actor combobox strategy accountActorComboBox.SetAccountActorComboBoxStrategy( AccountActorComboBoxStrategyCreators.GetCreator(accountActorTypeEnum).Create()); }