private int GetTaxCategoryId(string taxCategory) { CatalogTaxDto taxes = CatalogTaxManager.GetTaxCategories(); if (taxes.TaxCategory != null) { DataRow[] drws = null; int taxCategoryId = 0; if (Int32.TryParse(taxCategory, out taxCategoryId)) { drws = taxes.TaxCategory.Select(String.Format("TaxCategoryId = '{0}'", taxCategoryId)); if (drws.Length > 0) { return(taxCategoryId); } } else { drws = taxes.TaxCategory.Select(String.Format("Name LIKE '{0}'", taxCategory.Replace("'", "''"))); if (drws.Length > 0) { return(((CatalogTaxDto.TaxCategoryRow)drws[0]).TaxCategoryId); } } } return(0); }
/// <summary> /// Gets the taxes. /// </summary> /// <returns></returns> public static CatalogTaxDto GetTaxCategories() { // Assign new cache key, specific for site guid and response groups requested string cacheKey = CatalogCache.CreateCacheKey("catalog-taxcategory", CatalogConfiguration.Instance.ApplicationId.ToString()); CatalogTaxDto dto = null; // check cache first object cachedObject = CatalogCache.Get(cacheKey); if (cachedObject != null) { dto = (CatalogTaxDto)cachedObject; } // Load the object if (dto == null) { DataCommand cmd = CatalogDataHelper.CreateDataCommand(); cmd.CommandText = "ecf_TaxCategory"; cmd.Parameters = new DataParameters(); cmd.Parameters.Add(new DataParameter("ApplicationId", CatalogConfiguration.Instance.ApplicationId, DataParameterType.UniqueIdentifier)); cmd.DataSet = new CatalogTaxDto(); cmd.TableMapping = DataHelper.MapTables("TaxCategory"); DataResult results = DataService.LoadDataSet(cmd); dto = (CatalogTaxDto)results.DataSet; // Insert to the cache collection CatalogCache.Insert(cacheKey, dto, CatalogConfiguration.Instance.Cache.CatalogSchemaTimeout); } return(dto); }
/// <summary> /// Creates tax category with the specified name. /// </summary> /// <param name="name"></param> /// <param name="updateExisting">If true and tax category with the specified name already exists, it will be updated. Otherwise, a new category will be created.</param> /// <returns></returns> public static CatalogTaxDto CreateTaxCategory(string name, bool updateExisting) { CatalogTaxDto taxCategoryDto = GetTaxCategoryByName(name); CatalogTaxDto.TaxCategoryRow row = null; if (taxCategoryDto != null && taxCategoryDto.TaxCategory.Count > 0 && updateExisting) { // do nothing } else { taxCategoryDto = new CatalogTaxDto(); row = taxCategoryDto.TaxCategory.NewTaxCategoryRow(); row.ApplicationId = CatalogConfiguration.Instance.ApplicationId; row.Name = name; taxCategoryDto.TaxCategory.Rows.Add(row); SaveTaxCategory(taxCategoryDto); } return(taxCategoryDto); }
/// <summary> /// Binds the lists. /// </summary> private void BindLists() { // bind shipment packages if (PackageList.Items.Count <= 1) { ShippingMethodDto shippingDto = ShippingManager.GetShippingPackages(); if (shippingDto.Package != null) { foreach (ShippingMethodDto.PackageRow row in shippingDto.Package.Rows) { PackageList.Items.Add(new ListItem(row.Name, row.PackageId.ToString())); } } PackageList.DataBind(); } // bind warehouses if (WarehouseList.Items.Count <= 1) { WarehouseDto dto = WarehouseManager.GetWarehouseDto(); if (dto.Warehouse != null) { foreach (WarehouseDto.WarehouseRow row in dto.Warehouse.Rows) { WarehouseList.Items.Add(new ListItem(row.Name, row.WarehouseId.ToString())); } } WarehouseList.DataBind(); } // bind merchants if (MerchantList.Items.Count <= 1) { CatalogEntryDto merchants = CatalogContext.Current.GetMerchantsDto(); if (merchants.Merchant != null) { foreach (CatalogEntryDto.MerchantRow row in merchants.Merchant.Rows) { MerchantList.Items.Add(new ListItem(row.Name, row.MerchantId.ToString())); } } MerchantList.DataBind(); } // bind tax categories if (TaxList.Items.Count <= 1) { CatalogTaxDto taxes = CatalogTaxManager.GetTaxCategories(); if (taxes.TaxCategory != null) { foreach (CatalogTaxDto.TaxCategoryRow row in taxes.TaxCategory.Rows) { TaxList.Items.Add(new ListItem(row.Name, row.TaxCategoryId.ToString())); } } TaxList.DataBind(); } }
public override global::System.Data.DataSet Clone() { CatalogTaxDto cln = ((CatalogTaxDto)(base.Clone())); cln.InitVars(); cln.SchemaSerializationMode = this.SchemaSerializationMode; return(cln); }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { CatalogTaxDto ds = new CatalogTaxDto(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }
/// <summary> /// Gets the tax category id by name. /// </summary> /// <returns>TaxCategoryId. If tax category is not found, returns -1.</returns> public static int GetTaxCategoryIdByName(string name) { CatalogTaxDto dto = GetTaxCategoryByName(name); int tcId = -1; if (dto != null && dto.TaxCategory.Count > 0) { tcId = dto.TaxCategory[0].TaxCategoryId; } return(tcId); }
/// <summary> /// Gets the tax category name by id. /// </summary> /// <returns>TaxCategory name. If tax category is not found, returns empty string.</returns> public static string GetTaxCategoryNameById(int id) { CatalogTaxDto dto = GetTaxCategoryByTaxCategoryId(id); string tcName = String.Empty; if (dto != null && dto.TaxCategory.Count > 0) { tcName = dto.TaxCategory[0].Name; } return(tcName); }
/// <summary> /// Loads the data and data bind. /// </summary> /// <param name="sortExpression">The sort expression.</param> private void LoadDataAndDataBind(string sortExpression) { CatalogTaxDto dto = CatalogTaxManager.GetTaxCategories(); if (dto.TaxCategory != null) { DataView view = dto.TaxCategory.DefaultView; view.Sort = sortExpression; MyListView.DataSource = view; } MyListView.CurrentListView.PrimaryKeyId = EcfListView.MakePrimaryKeyIdString("TaxCategoryId"); MyListView.DataBind(); }
/// <summary> /// Checks if entered tax category name is unique. /// </summary> /// <param name="sender">The sender.</param> /// <param name="args">The <see cref="System.Web.UI.WebControls.ServerValidateEventArgs"/> instance containing the event data.</param> public void TaxCategoryNameCheck(object sender, ServerValidateEventArgs args) { // load tax category by name CatalogTaxDto dto = CatalogTaxManager.GetTaxCategoryByName(args.Value); // check if tax category with specified name is loaded if (dto != null && dto.TaxCategory.Count > 0 && dto.TaxCategory[0].TaxCategoryId != TaxCategoryId) { args.IsValid = false; return; } args.IsValid = true; }
/// <summary> /// Saves changes in TaxCategory table. /// </summary> /// <param name="dto">The dto.</param> public static void SaveTaxCategory(CatalogTaxDto dto) { if (dto == null) { throw new ArgumentNullException("dto", String.Format("TaxDto can not be null")); } // TODO: Check if user is allowed to perform this operation DataCommand cmd = CatalogDataHelper.CreateDataCommand(); using (TransactionScope scope = new TransactionScope()) { DataHelper.SaveDataSetSimple(CatalogContext.MetaDataContext, cmd, dto, "TaxCategory"); scope.Complete(); } }
public IEnumerable <ISelectItem> GetSelections(ExtendedMetadata md) { CatalogTaxDto dto = CatalogTaxManager.GetTaxCategories(); List <ISelectItem> listOfSelectItems = new List <ISelectItem>(); foreach (var item in dto.TaxCategory) { SelectItem theItem = new SelectItem() { Text = item.Name, Value = item.TaxCategoryId }; listOfSelectItems.Add(theItem); } return(listOfSelectItems.ToArray()); }
/// <summary> /// Processes the delete command. /// </summary> /// <param name="items">The items.</param> void ProcessDeleteCommand(string[] items) { for (int i = 0; i < items.Length; i++) { string[] keys = EcfListView.GetPrimaryKeyIdStringItems(items[i]); if (keys != null) { int id = Int32.Parse(keys[0]); CatalogTaxDto dto = CatalogTaxManager.GetTaxCategoryByTaxCategoryId(id); if (dto != null && dto.TaxCategory.Count > 0) { dto.TaxCategory[0].Delete(); CatalogTaxManager.SaveTaxCategory(dto); } } } }
/// <summary> /// Gets the tax category by name. /// </summary> /// <returns></returns> public static CatalogTaxDto GetTaxCategoryByName(string taxCategoryName) { CatalogTaxDto dto = null; DataCommand cmd = CatalogDataHelper.CreateDataCommand(); cmd.CommandText = "ecf_TaxCategory_Name"; cmd.Parameters = new DataParameters(); cmd.Parameters.Add(new DataParameter("ApplicationId", CatalogConfiguration.Instance.ApplicationId, DataParameterType.UniqueIdentifier)); cmd.Parameters.Add(new DataParameter("Name", taxCategoryName, DataParameterType.NVarChar, 50)); cmd.DataSet = new CatalogTaxDto(); cmd.TableMapping = DataHelper.MapTables("TaxCategory"); DataResult results = DataService.LoadDataSet(cmd); dto = (CatalogTaxDto)results.DataSet; return(dto); }
/// <summary> /// Binds the tax categories. /// </summary> private void BindTaxCategories() { CatalogTaxDto taxCategoriesDto = CatalogTaxManager.GetTaxCategories(); var query = from taxCategory in taxCategoriesDto.TaxCategory orderby taxCategory.Name select taxCategory; foreach (CatalogTaxDto.TaxCategoryRow taxCategoryRow in query) { ListItem li = new ListItem(taxCategoryRow.Field <string>("Name")); if (!TaxCategoriesList.Items.Contains(li)) { TaxCategoriesList.Items.Add(li); } } TaxCategoriesList.DataBind(); }
/// <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; } } }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) { global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); CatalogTaxDto ds = new CatalogTaxDto(); global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny(); any1.Namespace = "http://www.w3.org/2001/XMLSchema"; any1.MinOccurs = new decimal(0); any1.MaxOccurs = decimal.MaxValue; any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any1); global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny(); any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; any2.MinOccurs = new decimal(1); any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any2); global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute1.Name = "namespace"; attribute1.FixedValue = ds.Namespace; type.Attributes.Add(attribute1); global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute2.Name = "tableTypeName"; attribute2.FixedValue = "TaxCategoryDataTable"; type.Attributes.Add(attribute2); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }
private void BindDataType() { DataRow dr; DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("key", typeof(string))); dt.Columns.Add(new DataColumn("name", typeof(string))); dt.Columns.Add(new DataColumn("Type", typeof(string))); dt.Columns.Add(new DataColumn("IsSystemDictionary", typeof(bool))); dt.Columns.Add(new DataColumn("AllowNulls", typeof(bool))); dt.Columns.Add(new DataColumn("IsConstant", typeof(bool))); MappingMetaClass mmc = null; MetaDataPlus.Import.Rule mapping = null; string MetaClassName = ddlMetaClass.SelectedValue; string language = ddlLanguage.SelectedValue; switch (ddlTypeData.SelectedValue) { case "Category": CatalogContext.MetaDataContext.UseCurrentUICulture = false; CatalogContext.MetaDataContext.Language = language; if (!String.IsNullOrEmpty(MetaClassName)) { mmc = new CategoryMappingMetaClass(CatalogContext.MetaDataContext, MetaClassName, -1); } else { mmc = new CategoryMappingMetaClass(CatalogContext.MetaDataContext, -1); } CatalogContext.MetaDataContext.UseCurrentUICulture = true; mapping = mmc.CreateClassRule(); mapping.Attribute.Add("TypeName", "Category"); if (!String.IsNullOrEmpty(language)) { mapping.Attribute.Add("Language", language); } break; case "Entry": CatalogContext.MetaDataContext.UseCurrentUICulture = false; CatalogContext.MetaDataContext.Language = language; if (!String.IsNullOrEmpty(MetaClassName)) { mmc = new EntryMappingMetaClass(CatalogContext.MetaDataContext, MetaClassName, -1); } else { mmc = new EntryMappingMetaClass(CatalogContext.MetaDataContext, -1); } CatalogContext.MetaDataContext.UseCurrentUICulture = true; mapping = mmc.CreateClassRule(); mapping.Attribute.Add("TypeName", "Entry"); if (!String.IsNullOrEmpty(language)) { mapping.Attribute.Add("Language", language); } break; case "EntryRelation": mmc = new EntryRelationMappingMetaClass(CatalogContext.MetaDataContext, -1); mapping = mmc.CreateClassRule(); mapping.Attribute.Add("TypeName", "EntryRelation"); break; case "EntryAssociation": mmc = new EntryAssociationMappingMetaClass(CatalogContext.MetaDataContext, -1); mapping = mmc.CreateClassRule(); mapping.Attribute.Add("TypeName", "EntryAssociation"); break; case "Variation": mmc = new VariationMappingMetaClass(CatalogContext.MetaDataContext, -1); mapping = mmc.CreateClassRule(); mapping.Attribute.Add("TypeName", "Variation"); break; case "SalePrice": mmc = new PricingMappingMetaClass(CatalogContext.MetaDataContext, -1); mapping = mmc.CreateClassRule(); mapping.Attribute.Add("TypeName", "SalePrice"); break; default: return; } mapping.Attribute.Add("Delimiter", this.ddlDelimiter.SelectedValue); mapping.Attribute.Add("TextQualifier", this.ddlTextQualifier.SelectedValue); foreach (ColumnInfo ci in mmc.ColumnInfos) { dr = dt.NewRow(); if (ci.Field.IsSystem) { dr["key"] = ci.FieldName; dr["name"] = (ci.FieldFriendlyName != null) ? ci.FieldFriendlyName : ci.FieldName; } else { dr["key"] = ci.FieldName; dr["name"] = ci.FieldFriendlyName; } if (ci.Field.MultiLanguageValue && !String.IsNullOrEmpty(language)) { dr["name"] += String.Format(" ({0})", language); } dr["Type"] = ci.Field.DataType.ToString(); dr["IsSystemDictionary"] = ci.IsSystemDictionary; dr["AllowNulls"] = ci.Field.AllowNulls; dr["IsConstant"] = false; dt.Rows.Add(dr); mapping.Add(new RuleItem(ci.Field, MetaDataPlus.Import.FillType.NotUse)); } grdFields.Columns[0].HeaderText = RM.GetString("IMPORT_MAPPING_TITLE_FIELDS"); grdFields.Columns[1].HeaderText = RM.GetString("IMPORT_MAPPING_TITLE_COLUMN_HEADERS"); grdFields.Columns[2].HeaderText = "Custom values"; grdFields.DataSource = dt; grdFields.DataBind(); this.ClassRule = mapping; if (ddlDataFiles.SelectedIndex > 0) { IIncomingDataParser parser = null; DataSet rawData = null; try { char chTextQualifier = (this.ddlTextQualifier.SelectedValue == "") ? '\0' : char.Parse(this.ddlTextQualifier.SelectedValue); parser = new CsvIncomingDataParser(SourcePath, true, char.Parse(this.ddlDelimiter.SelectedValue), chTextQualifier, true, GetEncoding(this.ddlEncoding.SelectedValue)); rawData = parser.Parse(ddlDataFiles.SelectedItem.Text, null); } catch (Exception ex) { DisplayErrorMessage(ex.Message); return; } DataTable dtSource = rawData.Tables[0]; DataTable dtColumns = new DataTable(); dtColumns.Columns.Add(new DataColumn("Text", typeof(string))); dtColumns.Columns.Add(new DataColumn("Value", typeof(string))); foreach (DataColumn dc in dtSource.Columns) { dr = dtColumns.NewRow(); dr["Text"] = "Column " + (dc.Ordinal + 1) + " - " + dc.ColumnName; dr["Value"] = dc.ColumnName; dtColumns.Rows.Add(dr); } foreach (DataGridItem dgi in grdFields.Items) { DropDownList ddl = (DropDownList)dgi.FindControl("ddlFields"); TextBox tbCustomValue = (TextBox)dgi.FindControl("tbCustomValue"); DropDownList ddlValues = (DropDownList)dgi.FindControl("ddlValues"); string sKey = dgi.Cells[3].Text; string sType = dgi.Cells[4].Text; bool sIsSystemDictionary = bool.Parse(dgi.Cells[5].Text); bool allowNulls = bool.Parse(dgi.Cells[6].Text); bool IsConstant = bool.Parse(dgi.Cells[7].Text); bool useDictionaryControl = GetUseDictionaryFlag(dgi); if (!IsConstant) { if (ddl != null) { ddl.DataSource = dtColumns; ddl.DataTextField = "Text"; ddl.DataValueField = "Value"; ddl.DataBind(); if (sIsSystemDictionary) { ddl.Items.Insert(0, new ListItem("<" + RM.GetString("IMPORT_TYPE_VALUES_DICTIONARY_VALUE") + ">", "CustomValue")); } else { ddl.Items.Insert(0, new ListItem("<" + RM.GetString("IMPORT_TYPE_VALUES_CUSTOM_VALUE") + ">", "CustomValue")); } if (allowNulls) { ddl.Items.Insert(0, new ListItem("", "")); } else { ddl.Items.Insert(0, new ListItem("<" + RM.GetString("IMPORT_TYPE_VALUES_NOT_SET") + ">", "NotSet")); } string customControlID = useDictionaryControl ? ddlValues.ClientID : tbCustomValue.ClientID; string jsDllOnChange = String.Format("ddlOnChange(this, 'CustomValue', '{0}')", customControlID); ddl.Attributes.Add("OnChange", jsDllOnChange); } } //fill custom or dictionary controls ddlValues.Visible = useDictionaryControl; tbCustomValue.Visible = !ddlValues.Visible; if (sType.Equals(MetaDataType.Boolean.ToString()) || sType.Equals(MetaDataType.Bit.ToString())) { ddlValues.Items.Clear(); ddlValues.Items.Add("True"); ddlValues.Items.Add("False"); } if (sKey.Equals("sys_RowAction")) { ddlValues.Items.Clear(); ddlValues.Items.Add(RowAction.Default.ToString()); ddlValues.Items.Add(RowAction.Insert.ToString()); ddlValues.Items.Add(RowAction.Update.ToString()); ddlValues.Items.Add(RowAction.Delete.ToString()); } switch (ddlTypeData.SelectedValue) { case "Category": if (sKey == "TemplateName") { TemplateDto templates = DictionaryManager.GetTemplateDto(); if (templates.main_Templates.Count > 0) { DataView view = templates.main_Templates.DefaultView; view.RowFilter = "TemplateType = 'node'"; ddlValues.DataTextField = "FriendlyName"; ddlValues.DataValueField = "Name"; ddlValues.DataSource = view; ddlValues.DataBind(); } } break; case "Entry": if (sKey == "ClassTypeId") { ddlValues.Items.Clear(); ddlValues.Items.Add(new ListItem("Product", EntryType.Product)); ddlValues.Items.Add(new ListItem("Variation/Sku", EntryType.Variation)); ddlValues.Items.Add(new ListItem("Package", EntryType.Package)); ddlValues.Items.Add(new ListItem("Bundle", EntryType.Bundle)); ddlValues.Items.Add(new ListItem("Dynamic Package", EntryType.DynamicPackage)); } if (sKey == "TemplateName") { TemplateDto templates = DictionaryManager.GetTemplateDto(); if (templates.main_Templates.Count > 0) { DataView view = templates.main_Templates.DefaultView; view.RowFilter = "TemplateType = 'entry'"; ddlValues.DataTextField = "FriendlyName"; ddlValues.DataValueField = "Name"; ddlValues.DataSource = view; ddlValues.DataBind(); } } break; case "EntryAssociation": if (sKey == "AssociationType") { ddlValues.Items.Clear(); CatalogAssociationDto dto = CatalogContext.Current.GetCatalogAssociationDto(0); if (dto.AssociationType.Count > 0) { ddlValues.DataTextField = "Description"; ddlValues.DataValueField = "AssociationTypeId"; ddlValues.DataSource = dto.AssociationType; ddlValues.DataBind(); } } break; case "Variation": if (sKey == "TaxCategoryId") { CatalogTaxDto taxes = CatalogTaxManager.GetTaxCategories(); if (taxes.TaxCategory != null) { ddlValues.DataTextField = "Name"; ddlValues.DataValueField = "TaxCategoryId"; ddlValues.DataSource = taxes.TaxCategory.Rows; ddlValues.DataBind(); } } if (sKey == "MerchantId") { CatalogEntryDto merchants = CatalogContext.Current.GetMerchantsDto(); if (merchants.Merchant != null) { ddlValues.DataTextField = "Name"; ddlValues.DataValueField = "MerchantId"; ddlValues.DataSource = merchants.Merchant.Rows; ddlValues.DataBind(); } } if (sKey == "WarehouseId") { WarehouseDto warehouses = WarehouseManager.GetWarehouseDto(); if (warehouses.Warehouse != null) { ddlValues.DataTextField = "Name"; ddlValues.DataValueField = "WarehouseId"; ddlValues.DataSource = warehouses.Warehouse.Rows; ddlValues.DataBind(); } } if (sKey == "PackageId") { ShippingMethodDto shippingDto = ShippingManager.GetShippingPackages(); if (shippingDto.Package != null) { ddlValues.DataTextField = "Name"; ddlValues.DataValueField = "PackageId"; ddlValues.DataSource = shippingDto.Package.Rows; ddlValues.DataBind(); } } break; case "SalePrice": if (sKey == "SaleType") { ddlValues.Items.Clear(); foreach (SalePriceTypeDefinition element in CatalogConfiguration.Instance.SalePriceTypes) { ListItem li = new ListItem(UtilHelper.GetResFileString(element.Description), element.Value.ToString()); ddlValues.Items.Add(li); } } if (sKey == "Currency") { CurrencyDto dto = CatalogContext.Current.GetCurrencyDto(); ddlValues.DataTextField = "Name"; ddlValues.DataValueField = "CurrencyCode"; ddlValues.DataSource = dto.Currency; ddlValues.DataBind(); } break; default: break; } } } }