Esempio n. 1
0
 private void UpdateDataEdit(string selContainerId)
 {
     currentRegion = rootRegion.FindRegion(selContainerId);
     propertiesToolBar.Items.FromKeyButton("Delete").Visible     = true;
     propertiesToolBar.Items.FromKeySeparator("SepDelete").Width = 8;
     setPropertiesVisible(true);
 }
Esempio n. 2
0
        private void loadRegionRow(HyperCatalog.Business.Region region, int offset)
        {
            UltraGridRow newRow = new UltraGridRow(new object[] { region.Code, region.Code + (region.Code2 != null && region.Code2 != string.Empty ? " (" + region.Code2 + ")" : ""), region.Name == null || region.Name.Equals(string.Empty) ? region.Code : region.Name, region.TotalCountryCount });

            regionsGrid.Rows.Add(newRow);
            newRow.DataKey = region.Code;
            newRow.Cells.FromKey("DisplayCode").Style.Padding.Left = Unit.Parse((offset * 5).ToString() + "px");

            //txtParentRegionCodeValue.Items.Add(new ListItem(region.Name == null || region.Name.Equals(string.Empty)?region.Code:region.Name,region.Code));

            foreach (HyperCatalog.Business.Region subRegion in region.SubRegions)
            {
                loadRegionRow(subRegion, offset + 1);
            }
        }
Esempio n. 3
0
        private void mainToolBar_ButtonClicked(object sender, Infragistics.WebUI.UltraWebToolbar.ButtonEvent be)
        {
            switch (be.Button.Key)
            {
            case "Add":
                currentRegion = null;
                propertiesToolBar.Items.FromKeyButton("Delete").Visible     = false;
                propertiesToolBar.Items.FromKeySeparator("SepDelete").Width = 0;
                txtRegionNameValue.Enabled = true;
                setPropertiesVisible(true);
                break;

            case "Export":
                Utils.ExportToExcel(regionsGrid, "Regions", "Regions");
                break;
            }
        }
Esempio n. 4
0
        protected override void OnLoad(EventArgs e)
        {
            UITools.CheckConnection(Page);
            propertiesMsgLbl.Visible = mainMsgLbl.Visible = false;

            if (Request["r"] != null && Request["r"].Length > 0)
            {
                currentRegion = rootRegion.FindRegion(Request["r"]);
            }

            if (!IsPostBack)
            {
                if (Request["r"] == null || Request["r"].Length == 0)
                {
                    loadRegionGrid();
                }
                else
                {
                    UpdateDataEdit(Request["r"]);
                }
            }

            base.OnLoad(e);
        }
Esempio n. 5
0
        private void propertiesToolBar_ButtonClicked(object sender, Infragistics.WebUI.UltraWebToolbar.ButtonEvent be)
        {
            switch (be.Button.Key)
            {
            case "List":
                Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "UpdateCurrentRegion", "UpdateCurrentRegion('')", true);

                setPropertiesVisible(false);
                break;

            case "Save":
                if (!HyperCatalog.Shared.SessionState.User.IsReadOnly && HyperCatalog.Shared.SessionState.User.HasCapability(updateCapability))
                {
                    if (currentRegion != null)
                    {
                        // Update region
                        if (currentRegion.Update(txtRegionCodeValue.Text, txtRegionCode2Value.Text, txtRegionNameValue.Text, txtParentRegionCodeValue.SelectedValue, cbPublishable.Checked, cbFallbackToEnglish.Checked))
                        {
                            Tools.UITools.SetMessage(propertiesMsgLbl, "Region \"" + currentRegion.Name + "\" updated.", Tools.UITools.MessageLevel.Information);
                            loadRegionGrid();
                        }
                        else
                        {
                            Tools.UITools.SetMessage(propertiesMsgLbl, "Region \"" + currentRegion.Name + "\" could not be updated.", Tools.UITools.MessageLevel.Error);
                        }
                    }
                    else if (txtRegionCodeValue.Text != string.Empty)
                    {
                        // Insert new region
                        if (rootRegion == null)
                        {
                            currentRegion = Business.Region.Create(txtRegionCodeValue.Text, txtRegionCode2Value.Text, txtRegionNameValue.Text, null, cbPublishable.Checked, cbFallbackToEnglish.Checked);
                            if (currentRegion != null)
                            {
                                Tools.UITools.SetMessage(mainMsgLbl, "Region \"" + txtRegionCodeValue.Text + "\" insertion succeeded.", Tools.UITools.MessageLevel.Information);
                                loadRegionGrid();
                                setPropertiesVisible(false);
                            }
                            else
                            {
                                Tools.UITools.SetMessage(propertiesMsgLbl, HyperCatalog.Business.Region.LastError, Tools.UITools.MessageLevel.Error);
                            }
                        }
                        else if (rootRegion.FindRegion(txtRegionCodeValue.Text) == null)
                        {
                            currentRegion = rootRegion.FindRegion(txtParentRegionCodeValue.SelectedValue).SubRegions.Add(txtRegionCodeValue.Text, txtRegionCode2Value.Text, txtRegionNameValue.Text, cbPublishable.Checked, cbFallbackToEnglish.Checked);
                            if (currentRegion != null)
                            {
                                Tools.UITools.SetMessage(mainMsgLbl, "Region \"" + txtRegionCodeValue.Text + "\" insertion succeeded.", Tools.UITools.MessageLevel.Information);
                                loadRegionGrid();
                                setPropertiesVisible(false);
                            }
                            else
                            {
                                Tools.UITools.SetMessage(propertiesMsgLbl, HyperCatalog.Business.Region.LastError, Tools.UITools.MessageLevel.Error);
                            }
                        }
                        else
                        {
                            Tools.UITools.SetMessage(propertiesMsgLbl, "This region code is already used for another region.", Tools.UITools.MessageLevel.Warning);
                        }
                    }
                    else
                    {
                        Tools.UITools.SetMessage(propertiesMsgLbl, "You must provide a region code.", Tools.UITools.MessageLevel.Warning);
                    }
                }
                else
                {
                    Tools.UITools.SetMessage(propertiesMsgLbl, "You are not allowed to create or modify regions.", Tools.UITools.MessageLevel.Warning);
                }
                break;

            case "Delete":
                if (currentRegion != null)
                {
                    if (currentRegion.Delete(txtRegionCodeValue.Text))
                    {
                        Tools.UITools.SetMessage(mainMsgLbl, "Region \"" + txtRegionCodeValue.Text + "\" is deleted.", Tools.UITools.MessageLevel.Information);
                        currentRegion = null;
                        rootRegion    = HyperCatalog.Business.Region.GetRootRegion();
                        loadRegionGrid();
                        setPropertiesVisible(false);
                    }
                    else
                    {
                        Tools.UITools.SetMessage(mainMsgLbl, HyperCatalog.Business.Region.LastError, Tools.UITools.MessageLevel.Error);
                        setPropertiesVisible(false);
                    }
                }
                break;
            }
        }