Example #1
0
 private void SaveTemplateFaceItem()
 {
     //template.CustomItems.Clear();
     temp.DeleteCustomItem(TemplateTypeHelp.GetTemplateString(template.Template_Type));
     foreach (object o in TemplateFaceListBox.Items)
     {
         ItemTypeField field = o as ItemTypeField;
         if (field.Basic == false)
         {
             temp.SaveCustomItems(TemplateTypeHelp.GetTemplateString(template.Template_Type), field.Name);
         }
     }
 }
Example #2
0
        private void EditCustomBtn_Click(object sender, EventArgs e)
        {
            TemplateItemName itemNameForm = new TemplateItemName();

            if (TemplateFaceListBox.SelectedIndex != -1)
            {
                itemNameForm.Name1 = TemplateFaceListBox.SelectedItem.ToString();
                itemNameForm.InitFormName();
                if (itemNameForm.ShowDialog() == DialogResult.OK)
                {
                    ItemTypeField field = TemplateFaceListBox.SelectedItem as ItemTypeField;
                    field.Name = itemNameForm.Name1;
                    TemplateFaceListBox.Items[TemplateFaceListBox.SelectedIndex] = field;
                    //TemplateFaceListBox.Items.Add(new ItemTypeField(false, itemNameForm.Name1));
                }
            }
        }
Example #3
0
 private void TemplateFaceListBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (TemplateFaceListBox.SelectedIndex != -1)
     {
         ItemTypeField field = TemplateFaceListBox.SelectedItem as ItemTypeField;
         if (field.Basic)
         {
             EditCustomBtn.Enabled   = false;
             DeleteCustomBtn.Enabled = false;
         }
         else
         {
             EditCustomBtn.Enabled   = true;
             DeleteCustomBtn.Enabled = true;
         }
     }
 }
Example #4
0
        private void TemplateFaceListBox_MouseDown(object sender, MouseEventArgs e)
        {
            if (TemplateFaceListBox.Items.Count == 0)
            {
                return;
            }

            int index = TemplateFaceListBox.IndexFromPoint(e.X, e.Y);

            //lastIndex = index;
            if (index == -1)
            {
                return;
            }
            string          s    = TemplateFaceListBox.Items[index].ToString();
            DragDropEffects dde1 = DoDragDrop(s,
                                              DragDropEffects.All);

            if (dde1 == DragDropEffects.All)
            {
                //TemplateFaceListBox.Items.RemoveAt(TemplateFaceListBox.IndexFromPoint(e.X, e.Y));
            }

            if (TemplateFaceListBox.Items[index] != null)
            {
                ItemTypeField field = TemplateFaceListBox.Items[index] as ItemTypeField;
                if (field.Basic)
                {
                    EditCustomBtn.Enabled   = false;
                    DeleteCustomBtn.Enabled = false;
                }
                else
                {
                    EditCustomBtn.Enabled   = true;
                    DeleteCustomBtn.Enabled = true;
                }
            }
        }
 public ItemTypeFieldTransformer(ItemTypeField field) : base("itemType", field.Negate)
 {
     Key = field.ItemType;
 }
Example #6
0
 private SearchNode(ItemTypeField itemType)
 {
     ItemType = itemType;
     Type     = SearchNodeType.ItemType;
 }
Example #7
0
 public static SearchNode ItemTypeSearchNode(ItemTypeField itemTypeField)
 {
     return(new SearchNode(itemTypeField));
 }
        public static void SaveItemFieldPreferences(List <ItemTypeFieldsValues> objectList)
        {
            using (StageBitzDB dataContext = new StageBitzDB())
            {
                List <ItemTypeField> allItemTypeFields = dataContext.ItemTypeFields.ToList();

                List <FieldData> allFields = (from f in dataContext.Fields
                                              where f.IsActive == true && f.FieldGroup.IsActive == true
                                              orderby f.FieldGroup.SortOrder
                                              select new FieldData
                {
                    Field = f,
                    FieldId = f.FieldId,
                    FieldHtml = f.FieldType.FieldTypeHtml,
                    FieldHtmlControl = f.FieldType.HtmlControl,
                    FieldInnerHtml = f.FieldType.InnerHtmlTemplate,
                    Group = f.FieldGroup,
                    GroupId = f.GroupId,
                    FieldOptions = f.FieldOptions.OrderBy(fo => fo.SortOrder).Select(fo => new FieldOptionValue {
                        OptionId = fo.FieldOptionId, OptionValue = fo.OptionText
                    }),
                    FieldAttributes = f.FieldAttributes.Select(fa => new FieldAttributeValue {
                        TagName = fa.Attribute.TagName, AttributeValue = fa.FieldAttributeValue
                    }),                                                                                                                                                                                //(from fa in dataContext.FieldAttributes  where fa.FieldId==f.FieldId select new FieldAttributeValue { AttributeId = fa.AttributeId, AttributeValue = fa.FieldAttributeValue }).ToList(),
                }).ToList();

                List <Data.FieldGroup> fieldGroups = allFields.Select(fg => fg.Group).OrderBy(fg => fg.SortOrder).Distinct().ToList();
                var itemTypeHtmls = (from it in dataContext.ItemTypes
                                     from ith in dataContext.ItemTypeHtmls.Where(ith => ith.ItemTypeId == it.ItemTypeId).DefaultIfEmpty()
                                     select new { it.ItemTypeId, ith }).ToList();
                List <int> itemTypeIds = itemTypeHtmls.Select(ith => ith.ItemTypeId).ToList();

                //these are hard coded countries for the Sizing field.
                List <String> countries = new List <string>();
                countries.Add("Australia");
                countries.Add("United States");
                countries.Add("United Kingdom");
                List <Country> countryList = dataContext.Countries.Where(c => countries.Contains(c.CountryName)).ToList();

                List <FieldData> groupFields;
                StringBuilder    groupHtml, leftColumnHtml, rightColumnHtml, fieldHtml, fieldOptions, masterHtml;
                int[]            itemTypeFields;
                const string     FIELD_VISIBLE    = "Visible";
                const string     NAME             = "Name";
                const string     COLUMN1          = "@Column1";
                const string     COLUMN2          = "@Column2";
                const string     FIELD            = "Field";
                const string     CLASSINVISIBLE   = "remove_dynamic_field";
                const string     FIELDOPTIONS     = "@Options";
                const string     FIELDOPTIONValue = "@Option";
                const string     FIELDOPTIONID    = "@optionvalue";
                const string     TAGWATERMARK     = "@watermark";
                const string     TAGCLASS         = "@class";
                const string     TAGHEIGHT        = "@height";
                const string     TAGWIDTH         = "@width";
                const string     TAGMAXLENGTH     = "@maxlength";
                const string     TAGFieldId       = "@fieldId";
                const string     TAGCountryId     = "@countryId";
                bool             groupHasFields   = false;
                int i = 0;
                foreach (int itemTypeId in itemTypeIds)
                {
                    masterHtml      = new StringBuilder(Utils.GetSystemValue("ItemFieldsMasterHtml"));
                    leftColumnHtml  = new StringBuilder();
                    rightColumnHtml = new StringBuilder();
                    itemTypeFields  = objectList.Where(itfv => itfv.ItemTypeId == itemTypeId).Select(itfv => itfv.Fields).FirstOrDefault();
                    if (itemTypeFields != null)
                    {
                        foreach (Data.FieldGroup fieldGroup in fieldGroups)
                        {
                            groupFields = allFields.Where(f => f.GroupId == fieldGroup.FieldGroupId).ToList();

                            groupHtml = new StringBuilder(fieldGroup.FieldGroupHtml);
                            groupHtml.Replace(fieldGroup.TagName + ":" + NAME, fieldGroup.DisplayName);
                            foreach (FieldData fieldData in groupFields)
                            {
                                if (itemTypeFields != null && Array.IndexOf(itemTypeFields, fieldData.FieldId) > -1)
                                {
                                    groupHasFields = true;
                                    groupHtml.Replace(fieldData.Field.TagName + ":" + FIELD_VISIBLE, string.Empty);
                                    groupHtml.Replace(fieldData.Field.TagName + ":" + NAME, fieldData.Field.DisplayName);
                                    fieldHtml = new StringBuilder(fieldData.FieldHtml);
                                    fieldHtml.Replace(TAGFieldId, fieldData.FieldId.ToString());
                                    foreach (FieldAttributeValue attribute in fieldData.FieldAttributes)
                                    {
                                        fieldHtml.Replace(attribute.TagName, attribute.AttributeValue);
                                    }
                                    fieldHtml.Replace(TAGWATERMARK, string.Empty);
                                    fieldHtml.Replace(TAGCLASS, string.Empty);
                                    fieldHtml.Replace(TAGHEIGHT, string.Empty);
                                    fieldHtml.Replace(TAGWIDTH, string.Empty);
                                    fieldHtml.Replace(TAGMAXLENGTH, string.Empty);

                                    if (fieldData.FieldOptions.Count() > 0)
                                    {
                                        fieldOptions = new StringBuilder();
                                        foreach (FieldOptionValue option in fieldData.FieldOptions)
                                        {
                                            StringBuilder fieldOption = new StringBuilder(fieldData.FieldInnerHtml);
                                            fieldOption.Replace(FIELDOPTIONID, option.OptionId.ToString());
                                            fieldOption.Replace(FIELDOPTIONValue, option.OptionValue);
                                            if (fieldData.FieldHtmlControl.Equals("CountryDropDown"))
                                            {
                                                fieldOption.Replace(TAGCountryId, GetSizingCountryValue(countryList, option.OptionValue));
                                            }
                                            fieldOptions.Append(fieldOption);
                                        }
                                        fieldHtml.Replace(FIELDOPTIONS, fieldOptions.ToString());
                                    }

                                    //we need to insert record if and only if the record doesn't exist.
                                    if (allItemTypeFields.Where(itf => itf.FieldId == fieldData.FieldId && itf.ItemTypeId == itemTypeId).FirstOrDefault() == null)
                                    {
                                        Data.ItemTypeField itemTypeField = new ItemTypeField();
                                        itemTypeField.FieldId    = fieldData.FieldId;
                                        itemTypeField.ItemTypeId = itemTypeId;
                                        dataContext.ItemTypeFields.AddObject(itemTypeField);
                                    }
                                    groupHtml.Replace(fieldData.Field.TagName + ":" + FIELD, fieldHtml.ToString());
                                }
                                else
                                {
                                    //we need to delete the record if only it already exists in the table.
                                    Data.ItemTypeField itemTypeField = allItemTypeFields.Where(itf => itf.FieldId == fieldData.FieldId && itf.ItemTypeId == itemTypeId).FirstOrDefault();
                                    if (itemTypeField != null)
                                    {
                                        dataContext.ItemTypeFields.DeleteObject(itemTypeField);
                                    }
                                    //hide the field from the group
                                    groupHtml.Replace(fieldData.Field.TagName + ":" + FIELD_VISIBLE, CLASSINVISIBLE);
                                }
                            }
                            //if the group has at least one field that group attached to the group.
                            if (groupHasFields)
                            {
                                if (i++ % 2 == 0)
                                {
                                    leftColumnHtml.Append(groupHtml);
                                }
                                else
                                {
                                    rightColumnHtml.Append(groupHtml);
                                }
                            }
                            groupHasFields = false;
                        }
                    }
                    masterHtml.Replace(COLUMN1, leftColumnHtml.ToString());
                    masterHtml.Replace(COLUMN2, rightColumnHtml.ToString());
                    Data.ItemTypeHtml itemTypeHtml = itemTypeHtmls.Where(ith => ith.ItemTypeId == itemTypeId).Select(ith => ith.ith).FirstOrDefault();
                    if (itemTypeHtml != null)
                    {
                        itemTypeHtml.Html = masterHtml.ToString();
                    }
                    else
                    {
                        itemTypeHtml            = new ItemTypeHtml();
                        itemTypeHtml.ItemTypeId = itemTypeId;
                        itemTypeHtml.Html       = masterHtml.ToString();
                        dataContext.ItemTypeHtmls.AddObject(itemTypeHtml);
                    }
                    itemTypeFields = null;
                    i = 0;
                }
                dataContext.SaveChanges();
            }
        }