Ejemplo n.º 1
0
        private void Control_Init()
        {
            string Variant_PropertyID = Request["Variant_PropertyID"];

            if (!DataEval.IsEmptyQuery(Variant_PropertyID))
            {
                ProductVariantMgr myProductVariantMgr = new ProductVariantMgr();

                Variant_Property myVariant_Property = myProductVariantMgr.Get_Product_Variant_Property(Variant_PropertyID);

                _variant_propertyid             = myVariant_Property.Variant_PropertyID;
                ViewState["Variant_PropertyID"] = _variant_propertyid;

                // Fill the form
                Panel_Input_Options.Visible = false;
                Panel_Updated.Visible       = false;

                tbx_Property_Name.Text    = myVariant_Property.Property_Name;
                lbl_InputOption.Text      = myVariant_Property.Input_Option.ToString();
                tbx_Default_Value.Text    = myVariant_Property.Default_Value;
                tbx_Tooltips.Text         = myVariant_Property.Tooltips;
                tbx_Field_Name.Text       = myVariant_Property.Field_Name;
                chkbox_IsRequired.Checked = myVariant_Property.IsRequired;
                chkbox_IsFilter.Checked   = myVariant_Property.IsFilter;
                chkbox_IsSort.Checked     = myVariant_Property.IsSort;

                switch (myVariant_Property.Input_Option)
                {
                case Input_Option.TextBox:
                    break;

                case Input_Option.NumberBox:
                    break;

                case Input_Option.DropdownList:
                    Display_Input_Options();
                    break;

                case Input_Option.RadioButtonList:
                    Display_Input_Options();
                    break;

                case Input_Option.DatePicker:
                    break;

                case Input_Option.CheckBox:
                    break;

                case Input_Option.CheckBoxList:
                    Display_Input_Options();
                    break;

                case Input_Option.ImageURL:
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        protected void RadGrid_VariantProperties_RowDrop(object sender, GridDragDropEventArgs e)
        {
            if (string.IsNullOrEmpty(e.HtmlElement) && e.DestDataItem != null)
            {
                if (e.DestDataItem.OwnerGridID == RadGrid_VariantSpliter.ClientID)
                {
                    #region Dest drop is on Spliter

                    ProductVariantMgr myProductVariantMgr = new ProductVariantMgr();

                    Variant_Property myVariant_Property = myProductVariantMgr.Get_Product_Variant_Property(e.DraggedItems[0].GetDataKeyValue("Variant_PropertyID").ToString());
                    Variant_Spliter  myVariant_Spliter  = myProductVariantMgr.Get_Product_Variant_Spliter(e.DestDataItem.GetDataKeyValue("Variant_SpliterID").ToString());

                    if (myVariant_Spliter.Variant_SpliterID != myVariant_Property.Variant_SpliterID)
                    {
                        List <Variant_Property> originVariant_Properties = myProductVariantMgr.Get_Product_Variant_Properties_BySpliterID(myVariant_Property.Variant_SpliterID);
                        List <Variant_Property> destVariant_Properties   = myProductVariantMgr.Get_Product_Variant_Properties_BySpliterID(myVariant_Spliter.Variant_SpliterID);

                        Variant_Property draggedVariant_Property = Get_Variant_Property_in_List(originVariant_Properties, myVariant_Property.Variant_PropertyID);


                        originVariant_Properties.Remove(draggedVariant_Property);
                        destVariant_Properties.Add(draggedVariant_Property);

                        // Update Property to new Spliter
                        e2Data[] UpdateData_Property =
                        {
                            new e2Data("Variant_PropertyID", draggedVariant_Property.Variant_PropertyID),
                            new e2Data("Variant_SpliterID",  myVariant_Spliter.Variant_SpliterID)
                        };

                        myProductVariantMgr.Edit_Product_Variant_Property(UpdateData_Property);

                        // Sort Old list
                        foreach (Variant_Property Variant_Property in originVariant_Properties)
                        {
                            // Variant Property
                            e2Data[] UpdateData =
                            {
                                new e2Data("Variant_PropertyID", Variant_Property.Variant_PropertyID),
                                new e2Data("SortOrder",          (originVariant_Properties.IndexOf(Get_Variant_Property_in_List(originVariant_Properties, Variant_Property.Variant_PropertyID)) + 1).ToString())
                            };

                            myProductVariantMgr.Edit_Product_Variant_Property(UpdateData);
                        }

                        // Sort New list
                        foreach (Variant_Property Variant_Property in destVariant_Properties)
                        {
                            // Variant Property
                            e2Data[] UpdateData =
                            {
                                new e2Data("Variant_PropertyID", Variant_Property.Variant_PropertyID),
                                new e2Data("SortOrder",          (destVariant_Properties.IndexOf(Get_Variant_Property_in_List(destVariant_Properties, Variant_Property.Variant_PropertyID)) + 1).ToString())
                            };

                            myProductVariantMgr.Edit_Product_Variant_Property(UpdateData);
                        }
                    }

                    #endregion
                }
                else
                {
                    #region Dest drop is on Property

                    ProductVariantMgr myProductVariantMgr = new ProductVariantMgr();

                    Variant_Property mydraggedVariant_Property = myProductVariantMgr.Get_Product_Variant_Property(e.DraggedItems[0].GetDataKeyValue("Variant_PropertyID").ToString());
                    Variant_Property mydestVariant_Property    = myProductVariantMgr.Get_Product_Variant_Property(e.DestDataItem.GetDataKeyValue("Variant_PropertyID").ToString());

                    if (mydraggedVariant_Property.Variant_SpliterID == mydestVariant_Property.Variant_SpliterID)
                    {
                        // Under same spliter
                        List <Variant_Property> myVariant_Properties = myProductVariantMgr.Get_Product_Variant_Properties_BySpliterID(mydestVariant_Property.Variant_SpliterID);

                        Variant_Property draggedVariant_Property = Get_Variant_Property_in_List(myVariant_Properties, mydraggedVariant_Property.Variant_PropertyID);
                        Variant_Property destVariant_Property    = Get_Variant_Property_in_List(myVariant_Properties, mydestVariant_Property.Variant_PropertyID);

                        int destIndex = myVariant_Properties.IndexOf(destVariant_Property);

                        if (e.DropPosition == GridItemDropPosition.Above && e.DestDataItem.ItemIndex > e.DraggedItems[0].ItemIndex)
                        {
                            destIndex -= 1;
                        }
                        if (e.DropPosition == GridItemDropPosition.Below && e.DestDataItem.ItemIndex < e.DraggedItems[0].ItemIndex)
                        {
                            destIndex += 1;
                        }

                        myVariant_Properties.Remove(draggedVariant_Property);
                        myVariant_Properties.Insert(destIndex, draggedVariant_Property);

                        foreach (Variant_Property myVariant_Property in myVariant_Properties)
                        {
                            // Product Variant
                            e2Data[] UpdateData =
                            {
                                new e2Data("Variant_PropertyID", myVariant_Property.Variant_PropertyID),
                                new e2Data("SortOrder",          (myVariant_Properties.IndexOf(Get_Variant_Property_in_List(myVariant_Properties, myVariant_Property.Variant_PropertyID)) + 1).ToString())
                            };

                            myProductVariantMgr.Edit_Product_Variant_Property(UpdateData);
                        }
                    }
                    else
                    {
                        // Different spliter
                        List <Variant_Property> originVariant_Properties = myProductVariantMgr.Get_Product_Variant_Properties_BySpliterID(mydraggedVariant_Property.Variant_SpliterID);
                        List <Variant_Property> destVariant_Properties   = myProductVariantMgr.Get_Product_Variant_Properties_BySpliterID(mydestVariant_Property.Variant_SpliterID);

                        Variant_Property draggedVariant_Property = Get_Variant_Property_in_List(originVariant_Properties, mydraggedVariant_Property.Variant_PropertyID);
                        Variant_Property destVariant_Property    = Get_Variant_Property_in_List(destVariant_Properties, mydestVariant_Property.Variant_PropertyID);

                        int destIndex = destVariant_Properties.IndexOf(destVariant_Property);

                        if (e.DropPosition == GridItemDropPosition.Below)
                        {
                            destIndex += 1;
                        }

                        originVariant_Properties.Remove(draggedVariant_Property);
                        destVariant_Properties.Insert(destIndex, draggedVariant_Property);

                        // Update Property to new Spliter
                        e2Data[] UpdateData_Property =
                        {
                            new e2Data("Variant_PropertyID", draggedVariant_Property.Variant_PropertyID),
                            new e2Data("Variant_SpliterID",  destVariant_Property.Variant_SpliterID)
                        };

                        myProductVariantMgr.Edit_Product_Variant_Property(UpdateData_Property);

                        // Sort Old list
                        foreach (Variant_Property myVariant_Property in originVariant_Properties)
                        {
                            // Variant Property
                            e2Data[] UpdateData =
                            {
                                new e2Data("Variant_PropertyID", myVariant_Property.Variant_PropertyID),
                                new e2Data("SortOrder",          (originVariant_Properties.IndexOf(Get_Variant_Property_in_List(originVariant_Properties, myVariant_Property.Variant_PropertyID)) + 1).ToString())
                            };

                            myProductVariantMgr.Edit_Product_Variant_Property(UpdateData);
                        }

                        // Sort New list
                        foreach (Variant_Property myVariant_Property in destVariant_Properties)
                        {
                            // Variant Property
                            e2Data[] UpdateData =
                            {
                                new e2Data("Variant_PropertyID", myVariant_Property.Variant_PropertyID),
                                new e2Data("SortOrder",          (destVariant_Properties.IndexOf(Get_Variant_Property_in_List(destVariant_Properties, myVariant_Property.Variant_PropertyID)) + 1).ToString())
                            };

                            myProductVariantMgr.Edit_Product_Variant_Property(UpdateData);
                        }
                    }

                    #endregion
                }

                Control_Init();
            }
        }