private void SaveAll(string groupingName, List<GroupsListItem> groups, List<int> productMapIds)
        {
            SmartMap_DomainContext context = new SmartMap_DomainContext();
            if (_grouping == null)
            {
                ProvinceGrouping grouping = new ProvinceGrouping();
                grouping.Name = groupingName;
                context.ProvinceGroupings.Add(grouping);

                foreach (int productMapid in productMapIds)
                    context.ProductProvinceGroupings.Add(new ProductProvinceGrouping { ProductMapID = productMapid, ProvinceGroupingID = grouping.ID });

                groupcounter = 0;
                if (groupcounter < groups.Count)
                {
                    ProvinceGroup group = new ProvinceGroup { Name = groups[groupcounter].GroupName, ProvinceGroupingID = grouping.ID };
                    if (groups[groupcounter].Provinces.Count > 0)
                        group.ParentRegionMapID = groups[groupcounter].Provinces[0].RegionMapID;
                    context.ProvinceGroups.Add(group);
                    foreach (RegionMap rm in groups[groupcounter].Provinces)
                    {
                        ProvinceGroupRegionMap link = new ProvinceGroupRegionMap();
                        link.ProvinceGroupID = group.ID;
                        link.RegionMapID = rm.RegionMapID;
                        context.ProvinceGroupRegionMaps.Add(link);
                    }
                }
                context.SubmitChanges(GroupingSave_Submited, grouping);
            }
            else
            {
                foreach (int productMapid in productMapIds)
                    context.ProductProvinceGroupings.Add(new ProductProvinceGrouping { ProductMapID = productMapid, ProvinceGroupingID = _grouping.ID });
                context.SubmitChanges(ProductProvinceGroupings_Submitted,null);   
            }
        }
 private bool FilterProvinceGroupRegionMaps(ProvinceGroupRegionMap entity)
 {
     return (entity.RegionMapID == this.RegionMapID);
 }
 private void GroupingSave_Submited(SubmitOperation result)
 {
     if (Utils.LoadOperation_Error_Handled(result.Error, "SmartMap"))
     {
         SmartMap_DomainContext context = new SmartMap_DomainContext();
         groupcounter += 1;
         ProvinceGrouping grouping = (ProvinceGrouping)result.UserState;
         if (groupcounter < _groups.Count)
         {
             ProvinceGroup group = new ProvinceGroup { Name = _groups[groupcounter].GroupName, ProvinceGroupingID = grouping.ID };
             if (_groups[groupcounter].Provinces.Count > 0)
                 group.ParentRegionMapID = _groups[groupcounter].Provinces[0].RegionMapID;
             context.ProvinceGroups.Add(group);
             foreach (RegionMap rm in _groups[groupcounter].Provinces)
             {
                 ProvinceGroupRegionMap link = new ProvinceGroupRegionMap();
                 link.ProvinceGroupID = group.ID;
                 link.RegionMapID = rm.RegionMapID;
                 context.ProvinceGroupRegionMaps.Add(link);
             }
             context.SubmitChanges(GroupingSave_Submited, grouping);
         }
         else
         {
             DoneClickedEventArgs args = new DoneClickedEventArgs(grouping);
             this.OnClosed(args);
             this.DialogResult = true;
         }
     }
 }
 private void DetachProvinceGroupRegionMaps(ProvinceGroupRegionMap entity)
 {
     entity.RegionMap = null;
 }
 private void AttachProvinceGroupRegionMaps(ProvinceGroupRegionMap entity)
 {
     entity.RegionMap = this;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the ProvinceGroupRegionMaps EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToProvinceGroupRegionMaps(ProvinceGroupRegionMap provinceGroupRegionMap)
 {
     base.AddObject("ProvinceGroupRegionMaps", provinceGroupRegionMap);
 }
 /// <summary>
 /// Create a new ProvinceGroupRegionMap object.
 /// </summary>
 /// <param name="provinceGroupID">Initial value of the ProvinceGroupID property.</param>
 /// <param name="regionMapID">Initial value of the RegionMapID property.</param>
 public static ProvinceGroupRegionMap CreateProvinceGroupRegionMap(global::System.Int32 provinceGroupID, global::System.Int32 regionMapID)
 {
     ProvinceGroupRegionMap provinceGroupRegionMap = new ProvinceGroupRegionMap();
     provinceGroupRegionMap.ProvinceGroupID = provinceGroupID;
     provinceGroupRegionMap.RegionMapID = regionMapID;
     return provinceGroupRegionMap;
 }
 private void GroupsSaved(SubmitOperation result)
 {
     if (Utils.LoadOperation_Error_Handled(result.Error, "SmartMap"))
     {
         if (groupCounter < GroupsList.Items.Count)
         {
             SmartMap_DomainContext context = new SmartMap_DomainContext();
             GroupsListItem item = (GroupsListItem)GroupsList.Items[groupCounter];
             ProvinceGroup group = new ProvinceGroup { Name = item.GroupName, ProvinceGroupingID = _grouping.ID, ParentRegionMapID = item.Provinces[0].RegionMapID };
             context.ProvinceGroups.Add(group);
             groupCounter += 1;
             foreach (RegionMap rm in item.Provinces)
             {
                 ProvinceGroupRegionMap link = new ProvinceGroupRegionMap();
                 link.ProvinceGroupID = group.ID;
                 link.RegionMapID = rm.RegionMapID;
                 context.ProvinceGroupRegionMaps.Add(link);
             }
             context.SubmitChanges(GroupsSaved, null);
         }
         else
         {
             this.DialogResult = true;
         }
     }
 }