/// <summary> /// Binds the form. /// </summary> private void BindForm() { CultureInfo ci = GetCurrentCulture(); if (TaxId > 0) { if (_TaxDto.Tax.Count > 0) { this.tbName.Text = _TaxDto.Tax[0].Name; this.tbSortOrder.Text = _TaxDto.Tax[0].SortOrder.ToString(); ManagementHelper.SelectListItem2(TaxTypeList, _TaxDto.Tax[0].TaxType.ToString()); } else { DisplayErrorMessage(String.Format("Tax with id={0} not found.", TaxId)); return; } } else { this.tbSortOrder.Text = "0"; } BindTaxLanguagesList(); }
/// <summary> /// Sets the form fields values. /// </summary> private void SetFormFieldsValues(DateTime affectiveDate, string rate, int jurisdictionGroupId, string taxCategory) { CultureInfo ci = ManagementContext.Current.ConsoleUICulture; this.AffectiveDate.Value = ManagementHelper.GetUserDateTime(affectiveDate); this.tbRate.Text = rate; if (jurisdictionGroupId > 0) { ManagementHelper.SelectListItem2(JurisdictionGroupsList, jurisdictionGroupId.ToString()); } else { ManagementHelper.SelectListItem2(JurisdictionGroupsList, String.Empty); } ManagementHelper.SelectListItem2(TaxCategoriesList, taxCategory); }
/// <summary> /// Binds the batch control. /// </summary> private void BindData() { CatalogEntryDto.VariationRow[] variationRows = null; CatalogEntryDto.CatalogEntryRow item = (CatalogEntryDto.CatalogEntryRow)DataItem; if (IsMetaField) { int MetaClassId = item.MetaClassId; int ObjectId = item.CatalogEntryId; MetaDataContext MDContext = CatalogContext.MetaDataContext; MetaControls.EnableViewState = false; if (MetaControls.Controls.Count > 0) { return; } MetaControls.Controls.Clear(); MetaClass mc = MetaClass.Load(MDContext, MetaClassId); if (mc == null) { return; } MDContext.UseCurrentUICulture = false; MDContext.Language = LanguageCode; MetaObject metaObj = null; if (ObjectId > 0) { metaObj = MetaObject.Load(MDContext, ObjectId, mc); if (metaObj == null) { metaObj = MetaObject.NewObject(MDContext, ObjectId, MetaClassId, FrameworkContext.Current.Profile.UserName); metaObj.AcceptChanges(MDContext); } } MDContext.UseCurrentUICulture = true; MetaField mf = MetaField.Load(MDContext, FieldName); if (mf.IsUser) { string controlName = ResolveMetaControl(mc, mf); Control ctrl = MetaControls.FindControl(mf.Name); if (ctrl == null) { ctrl = Page.LoadControl(controlName); MetaControls.Controls.Add(ctrl); } CoreBaseUserControl coreCtrl = ctrl as CoreBaseUserControl; if (coreCtrl != null) { coreCtrl.MDContext = MDContext; } //ctrl.ID = String.Format("{0}-{1}", mf.Name, index.ToString()); ((IMetaControl)ctrl).MetaField = mf; if (metaObj != null && metaObj[mf.Name] != null) { ((IMetaControl)ctrl).MetaObject = metaObj; } ((IMetaControl)ctrl).LanguageCode = LanguageCode; ((IMetaControl)ctrl).ValidationGroup = String.Empty; ctrl.DataBind(); } } else { switch (FieldName) { case "Name": case "Code": tbItem.Visible = true; tbItem.Text = (string)item[FieldName]; break; case "StartDate": case "EndDate": cdpItem.Visible = true; cdpItem.Value = (DateTime)item[FieldName]; break; case "TemplateName": ddlItem.Visible = true; TemplateDto templates = DictionaryManager.GetTemplateDto(); if (templates.main_Templates.Count > 0) { DataView view = templates.main_Templates.DefaultView; view.RowFilter = "TemplateType = 'entry'"; ddlItem.DataTextField = "FriendlyName"; ddlItem.DataValueField = "Name"; ddlItem.DataSource = view; ddlItem.DataBind(); } ManagementHelper.SelectListItem2(ddlItem, item.TemplateName); break; case "SortOrder": tbItem.Visible = true; CatalogRelationDto relationDto = CatalogContext.Current.GetCatalogRelationDto(item.CatalogId, CatalogNodeId, item.CatalogEntryId, String.Empty, new CatalogRelationResponseGroup(CatalogRelationResponseGroup.ResponseGroup.NodeEntry)); if (relationDto.NodeEntryRelation.Count > 0) { tbItem.Text = relationDto.NodeEntryRelation[0].SortOrder.ToString(); } break; case "IsActive": becItem.Visible = true; becItem.IsSelected = item.IsActive; break; case "ListPrice": tbItem.Visible = true; variationRows = item.GetVariationRows(); if (variationRows.Length > 0) { tbItem.Text = variationRows[0].ListPrice.ToString("#0.00"); } break; case "TaxCategoryId": ddlItem.Visible = true; ddlItem.Items.Add(new ListItem(Resources.CatalogStrings.Entry_Select_Tax_Category, "0")); CatalogTaxDto taxes = CatalogTaxManager.GetTaxCategories(); if (taxes.TaxCategory != null) { foreach (CatalogTaxDto.TaxCategoryRow row in taxes.TaxCategory.Rows) { ddlItem.Items.Add(new ListItem(row.Name, row.TaxCategoryId.ToString())); } } ddlItem.DataBind(); variationRows = item.GetVariationRows(); if (variationRows.Length > 0) { ManagementHelper.SelectListItem2(ddlItem, variationRows[0].TaxCategoryId); } break; case "TrackInventory": becItem.Visible = true; variationRows = item.GetVariationRows(); if (variationRows.Length > 0) { becItem.IsSelected = variationRows[0].TrackInventory; } break; case "MerchantId": ddlItem.Visible = true; ddlItem.Items.Insert(0, new ListItem(Resources.CatalogStrings.Entry_Select_Merchant, "")); CatalogEntryDto merchants = CatalogContext.Current.GetMerchantsDto(); if (merchants.Merchant != null) { foreach (CatalogEntryDto.MerchantRow row in merchants.Merchant.Rows) { ddlItem.Items.Add(new ListItem(row.Name, row.MerchantId.ToString())); } } ddlItem.DataBind(); variationRows = item.GetVariationRows(); if (variationRows.Length > 0 && !variationRows[0].IsMerchantIdNull()) { ManagementHelper.SelectListItem2(ddlItem, variationRows[0].MerchantId); } break; case "WarehouseId": ddlItem.Visible = true; ddlItem.Items.Insert(0, new ListItem(Resources.CatalogStrings.Entry_Select_Warehouse, "0")); WarehouseDto warehouses = WarehouseManager.GetWarehouseDto(); if (warehouses.Warehouse != null) { foreach (WarehouseDto.WarehouseRow row in warehouses.Warehouse.Rows) { ddlItem.Items.Add(new ListItem(row.Name, row.WarehouseId.ToString())); } } ddlItem.DataBind(); variationRows = item.GetVariationRows(); if (variationRows.Length > 0) { ManagementHelper.SelectListItem2(ddlItem, variationRows[0].WarehouseId); } break; case "PackageId": ddlItem.Visible = true; ddlItem.Items.Insert(0, new ListItem(Resources.CatalogStrings.Entry_Select_Package, "0")); ShippingMethodDto shippingDto = ShippingManager.GetShippingPackages(); if (shippingDto.Package != null) { foreach (ShippingMethodDto.PackageRow row in shippingDto.Package.Rows) { ddlItem.Items.Add(new ListItem(row.Name, row.PackageId.ToString())); } } ddlItem.DataBind(); variationRows = item.GetVariationRows(); if (variationRows.Length > 0) { ManagementHelper.SelectListItem2(ddlItem, variationRows[0].PackageId); } break; case "Weight": case "MinQuantity": case "MaxQuantity": tbItem.Visible = true; variationRows = item.GetVariationRows(); if (variationRows.Length > 0 && variationRows[0][FieldName] != DBNull.Value) { tbItem.Text = variationRows[0][FieldName].ToString(); } break; case "InStockQuantity": case "ReservedQuantity": case "ReorderMinQuantity": case "PreorderQuantity": case "BackorderQuantity": tbItem.Visible = true; if (item.InventoryRow != null && item.InventoryRow[FieldName] != DBNull.Value) { tbItem.Text = item.InventoryRow[FieldName].ToString(); } break; case "AllowBackorder": case "AllowPreorder": becItem.Visible = true; if (item.InventoryRow != null) { becItem.IsSelected = (bool)item.InventoryRow[FieldName]; } break; case "InventoryStatus": ddlItem.Visible = true; ddlItem.Items.Insert(0, new ListItem(Resources.SharedStrings.Disabled, "0")); ddlItem.Items.Insert(0, new ListItem(Resources.SharedStrings.Enabled, "1")); ddlItem.Items.Insert(0, new ListItem(Resources.SharedStrings.Ignored, "2")); ddlItem.DataBind(); if (item.InventoryRow != null) { ManagementHelper.SelectListItem2(ddlItem, item.InventoryRow.InventoryStatus); } break; case "PreorderAvailabilityDate": case "BackorderAvailabilityDate": cdpItem.Visible = true; if (item.InventoryRow != null) { cdpItem.Value = (DateTime)item.InventoryRow[FieldName]; } break; } } }
/// <summary> /// Binds the form. /// </summary> /// <param name="reset">if set to <c>true</c> [reset].</param> private void BindForm(bool reset) { if (SaleTypeFilter.Items.Count == 0) { BindSaleTypesList(); } if (CurrencyFilter.Items.Count == 0) { BindCurrenciesList(); // select default currency ManagementHelper.SelectListItemIgnoreCase(CurrencyFilter, _CatalogCurrency); } if (String.IsNullOrEmpty(SelectedSaleTypeField.Value)) { SelectedSaleTypeField.Value = SaleTypeFilter.SelectedValue; } if (String.IsNullOrEmpty(SelectedCurrencyField.Value)) { SelectedCurrencyField.Value = CurrencyFilter.SelectedValue; } CatalogEntryDto.SalePriceRow selectedSalePriceRow = null; if (SalePriceId != 0) { selectedSalePriceRow = _CatalogEntryDto.SalePrice.FindBySalePriceId(SalePriceId); } if (selectedSalePriceRow != null) { if (reset) { SetFormFieldsValues(selectedSalePriceRow.SaleCode, selectedSalePriceRow.UnitPrice, selectedSalePriceRow.MinQuantity, selectedSalePriceRow.StartDate, selectedSalePriceRow.EndDate, selectedSalePriceRow.SaleType, selectedSalePriceRow.Currency); } ManagementHelper.SelectListItem2(SaleTypeFilter, selectedSalePriceRow.SaleType); ManagementHelper.SelectListItem2(CurrencyFilter, selectedSalePriceRow.Currency); } else if (reset) { if (_CatalogEntryDto != null) { SetFormFieldsValues("", 0m, 0m, DateTime.UtcNow, DateTime.UtcNow.AddYears(1), -1, _CatalogCurrency); } else { SetFormFieldsValues("", 0m, 0m, DateTime.UtcNow, DateTime.UtcNow.AddYears(1), -1, _CatalogCurrency); } ManagementHelper.SelectListItem2(CurrencyFilter, _CatalogCurrency); } }