Пример #1
0
 protected void btnFinal_Click(object sender, EventArgs e)
 {
     if (ddlStatus.SelectedValue != "-1")
     {
         Status status   = (Status)Enum.Parse(typeof(Status), ddlStatus.SelectedValue);
         string title    = DateTime.Now.Year.ToString() + " ";
         string fileName = string.Empty;
         if (ddlArea.SelectedValue != "-1")
         {
             Area area = RegionService.GetArea(ddlArea.SelectedValue);
             fileName = Path.Combine(Path.GetTempPath(), area.Name + ".pdf");
             title    = DateTime.Now.Year.ToString() + " " + area.Name + " Area Finalists";
             ReportService.CreateFinalistReport(fileName, status, area, title);
         }
         else
         {
             Region region = RegionService.GetRegion(ddlRegion.SelectedValue);
             title   += region.Name + " Finalists";
             fileName = Path.Combine(Path.GetTempPath(), "report.pdf");
             ReportService.CreateFinalistReport(fileName, status, null, title);
         }
         byte[] buf = FileUtils.LoadFile(fileName);
         Response.Clear();
         Response.ContentType = "application/zip";
         Response.AddHeader("Content-Disposition", "attachment; filename=" + System.IO.Path.GetFileName(fileName));
         Response.AddHeader("Content-Length", buf.Length.ToString());
         Response.BinaryWrite(buf);
         Response.End();
         System.IO.File.Delete(fileName);
     }
 }
Пример #2
0
    private void LoadScores()
    {
        Region region = RegionService.GetRegion(ddlSearchRegion.SelectedValue);

        gvScore.DataSource = ScoreService.GetScoreCategories(region);
        gvScore.DataBind();
    }
Пример #3
0
    private void EditScore(int id)
    {
        Label   lblId       = modalDialog.FindControl("lblId") as Label;
        TextBox txtName     = modalDialog.FindControl("txtName") as TextBox;
        TextBox txtWeight   = modalDialog.FindControl("txtWeight") as TextBox;
        TextBox txtMinRange = modalDialog.FindControl("txtMinRange") as TextBox;
        TextBox txtMaxRange = modalDialog.FindControl("txtMaxRange") as TextBox;

        ScoreCategory sc = null;

        if (id > 0)
        {
            sc = ScoreService.GetScoreCategory(id);
        }
        else
        {
            sc = new ScoreCategory();
            Region region = RegionService.GetRegion(ddlSearchRegion.SelectedValue);
            sc.Region = region;
        }
        lblId.Text       = id.ToString();
        txtName.Text     = sc.Name;
        txtWeight.Text   = sc.Weight.ToString();
        txtMinRange.Text = sc.MinRange.ToString();
        txtMaxRange.Text = sc.MaxRange.ToString();
        modalDialog.ShowModal();
    }
Пример #4
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     this.Validate("ScoreEdit");
     if (IsValid)
     {
         Label         lblId       = modalDialog.FindControl("lblId") as Label;
         TextBox       txtName     = modalDialog.FindControl("txtName") as TextBox;
         TextBox       txtWeight   = modalDialog.FindControl("txtWeight") as TextBox;
         TextBox       txtMinRange = modalDialog.FindControl("txtMinRange") as TextBox;
         TextBox       txtMaxRange = modalDialog.FindControl("txtMaxRange") as TextBox;
         ScoreCategory sc          = null;
         if (Convert.ToInt32(lblId.Text) > 0)
         {
             sc = ScoreService.GetScoreCategory(Convert.ToInt32(lblId.Text));
         }
         else
         {
             sc = new ScoreCategory();
             Region region = RegionService.GetRegion(ddlSearchRegion.SelectedValue);
             sc.Region = region;
         }
         sc.Name     = txtName.Text;
         sc.Weight   = Convert.ToInt32(txtWeight.Text);
         sc.MinRange = Convert.ToInt32(txtMinRange.Text);
         sc.MaxRange = Convert.ToInt32(txtMaxRange.Text);
         ScoreService.Save(sc);
         modalDialog.HideModal();
         LoadScores();
     }
 }
Пример #5
0
 private void LoadAreas()
 {
     if (!"-1".Equals(ddlSearchRegion.SelectedValue))
     {
         Region region = RegionService.GetRegion(ddlSearchRegion.SelectedValue);
         ddlSearchArea.DataSource    = RegionService.GetAreas(region);
         ddlSearchArea.DataMember    = "Id";
         ddlSearchArea.DataTextField = "Name";
         ddlSearchArea.DataBind();
         if (region.Areas.Count > 1)
         {
             ddlSearchArea.Items.Insert(0, new ListItem("All", "-1"));
         }
         ddlCategories.DataSource    = CategoryService.GetCategories(region);
         ddlCategories.DataMember    = "Id";
         ddlCategories.DataTextField = "Name";
         ddlCategories.DataBind();
         ddlCategories.Items.Insert(0, new ListItem("All", "-1"));
     }
     else
     {
         ddlSearchArea.DataSource = null;
         ddlSearchArea.DataBind();
         ddlCategories.DataSource = null;
         ddlCategories.DataBind();
         ddlSearchArea.Items.Insert(0, new ListItem("All", "-1"));
         ddlCategories.Items.Insert(0, new ListItem("All", "-1"));
     }
 }
Пример #6
0
    /// <summary>
    /// Load all users
    /// </summary>
    private void LoadUsers()
    {
        School   school   = null;
        Category category = null;
        RoleType role     = RoleType.All;
        Region   region   = null;
        Area     area     = null;

        if (ddlSearchRegion.SelectedValue != "-1")
        {
            region = RegionService.GetRegion(ddlSearchRegion.SelectedValue);
        }
        if (ddlCategories.SelectedValue != "-1")
        {
            category = CategoryService.GetCategory(region, ddlCategories.SelectedValue);
        }
        if (ddlSearchArea.SelectedValue != "-1")
        {
            area = RegionService.GetArea(region, ddlSearchArea.SelectedValue);
        }
        if (ddlSearchSchool.SelectedValue != "-1")
        {
            school = RegionService.GetSchool(ddlSearchSchool.SelectedValue);
        }
        if (ddlUserType.SelectedValue != "-1")
        {
            role = (RoleType)Convert.ToInt32(ddlUserType.SelectedValue);
        }
        string orderby           = (SortDirection == SortDirection.Ascending) ? " order by " + SortColumn + " ASC " : " order by " + SortColumn + " DESC ";
        IList <DisplayUser> list = UserService.GetAllUsers(region, area, school, category, txtSearchUserName.Text, role, orderby);

        gvUsers.DataSource = list;
        gvUsers.DataBind();
        lblRecCount.Text = string.Format("{0:d} users found", list.Count);
    }
Пример #7
0
    private void LoadRegion()
    {
        Region region = null;

        if (CurrentUser.Role == RoleType.Administrator)
        {
            ddlRegion.DataMember    = "Id";
            ddlRegion.DataTextField = "Name";
            ddlRegion.DataSource    = RegionService.GetRegions();
            ddlRegion.DataBind();
            region = RegionService.GetRegion(ddlRegion.SelectedValue);
        }
        else
        {
            AreaUser au = UserService.GetAreaUser(CurrentUser);
            region = au.Area.Region;
            ddlRegion.Items.Insert(0, new ListItem(au.Area.Region.Name, au.Area.Region.Name));
        }
        ddlCategories.DataSource    = CategoryService.GetCategories(region);
        ddlCategories.DataMember    = "Id";
        ddlCategories.DataTextField = "Name";
        ddlCategories.DataBind();
        ddlCategories.Items.Insert(0, new ListItem("All", "-1"));
        LoadAreas(region);
    }
Пример #8
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        Label        lblId          = modalDialog.FindControl("lblId") as Label;
        TextBox      txtFullName    = modalDialog.FindControl("txtFullName") as TextBox;
        TextBox      txtEmail       = modalDialog.FindControl("txtEmail") as TextBox;
        TextBox      txtComment     = modalDialog.FindControl("txtComment") as TextBox;
        TextBox      txtPhone       = modalDialog.FindControl("txtPhone") as TextBox;
        DropDownList ddlRoleType    = modalDialog.FindControl("ddlRoleType") as DropDownList;
        DropDownList ddlRegion      = modalDialog.FindControl("ddlRegion") as DropDownList;
        DropDownList ddlArea        = modalDialog.FindControl("ddlArea") as DropDownList;
        DropDownList ddlCategory    = modalDialog.FindControl("ddlCategory") as DropDownList;
        DropDownList ddlSchool      = modalDialog.FindControl("ddlSchool") as DropDownList;
        Label        labCustomError = modalDialog.FindControl("labCustomError") as Label;

        UserInput input = new UserInput();

        input.Id       = Convert.ToInt32(lblId.Text);
        input.FullName = txtFullName.Text;
        input.EMail    = txtEmail.Text;
        input.Comment  = txtComment.Text;
        input.Phone    = txtPhone.Text;
        input.Role     = (RoleType)Convert.ToInt32(ddlRoleType.SelectedValue);

        if (input.Role == RoleType.RegionAdministrator)
        {
            Region region = RegionService.GetRegion(ddlRegion.SelectedValue);
            input.Area = RegionService.GetArea(region, ddlArea.SelectedValue);
        }
        if (input.Role == RoleType.AreaJudge | input.Role == RoleType.RegionJudge)
        {
            input.Area     = RegionService.GetArea(ddlArea.SelectedValue);
            input.Category = CategoryService.GetCategory(input.Area.Region, ddlCategory.SelectedValue);
        }
        else if (input.Role == RoleType.Coordinator | input.Role == RoleType.Principal | input.Role == RoleType.Nominee)
        {
            input.School = RegionService.GetSchool(ddlSchool.SelectedValue);
            if (input.Role == RoleType.Nominee)
            {
                input.Category = CategoryService.GetCategory(input.Area.Region, ddlCategory.SelectedValue);
            }
        }

        MembershipCreateStatus status = UserService.AddNewUser(input);

        if (status == MembershipCreateStatus.DuplicateEmail)
        {
            labCustomError.Text    = "The email address is a duplicate, please enter a different email address";
            labCustomError.Visible = true;
        }
        else
        {
            User user = UserService.GetUser(input.EMail);
            if (input.Id <= 0)
            {
                UserService.SendUserEmail(user, "Sterling Scholar Registration Request", System.Web.HttpContext.Current.Server.MapPath("~/") + "/assets/NewUserTemplate.html");
            }
            modalDialog.HideModal();
        }
    }
Пример #9
0
 protected void ddlArea_OnSelectedIndexChanged(object sender, EventArgs e)
 {
     if (!"-1".Equals(ddlArea.SelectedValue))
     {
         Region region = RegionService.GetRegion(ddlRegion.SelectedValue);
         Area   area   = RegionService.GetArea(region, ((DropDownList)sender).SelectedValue);
         LoadSchools(area);
     }
 }
Пример #10
0
        public void GetRegion_WithInvalidId_SholdReturnNull()
        {
            //Arange
            var service = new RegionService(this._dbContext, this._mapper, null);

            //Act
            var region = service.GetRegion(2);

            //Assert
            Assert.IsNull(region);
        }
Пример #11
0
        public new void LoadData()
        {
            if (!string.IsNullOrWhiteSpace(SettingsMain.LogoImageName))
            {
                imgLogo.ImageUrl = "../" + FoldersHelper.GetPath(FolderType.Pictures, SettingsMain.LogoImageName, true);
            }
            else
            {
                imgLogo.Visible = false;
            }

            if (!string.IsNullOrWhiteSpace(SettingsMain.FaviconImageName))
            {
                imgFavicon.ImageUrl = "../" +
                                      FoldersHelper.GetPath(FolderType.Pictures, SettingsMain.FaviconImageName, true);
            }
            else
            {
                imgFavicon.Visible = false;
            }

            if (!(Demo.IsDemoEnabled || TrialService.IsTrialEnabled))
            {
                txtKey.Text = SettingsLic.LicKey;
            }

            txtShopName.Text = SettingsMain.ShopName;
            txtUrl.Text      = SettingsMain.SiteUrl;
            //txtTitle.Text = SettingsSEO.DefaultMetaTitle;
            //txtMetadescription.Text = SettingsSEO.DefaultMetaDescription;
            //txtMetakeywords.Text = SettingsSEO.DefaultMetaKeywords;

            ddlCountry.DataBind();
            ddlCountry.SelectedValue = SettingsMain.SellerCountryId.ToString();
            txtCity.Text             = SettingsMain.City;

            int value = SettingsMain.SellerRegionId;

            if (SettingsMain.SellerRegionId != 0)
            {
                var region = RegionService.GetRegion(SettingsMain.SellerRegionId);
                if (region != null)
                {
                    txtRegion.Text = region.Name;
                }
            }

            txtPhone.Text      = SettingsMain.Phone;
            txtDirector.Text   = SettingsBank.Director;
            txtAccountant.Text = SettingsBank.Accountant;
            txtManager.Text    = SettingsBank.Manager;
        }
Пример #12
0
 protected void ddlRegion_OnSelectedIndexChanged(object sender, EventArgs e)
 {
     if (!"-1".Equals(ddlRegion.SelectedValue))
     {
         Region region = RegionService.GetRegion(ddlRegion.SelectedValue);
         LoadAreas(region);
         ddlCategories.DataSource    = CategoryService.GetCategories(region);
         ddlCategories.DataMember    = "Id";
         ddlCategories.DataTextField = "Name";
         ddlCategories.DataBind();
         ddlCategories.Items.Insert(0, new ListItem("All", "-1"));
     }
 }
Пример #13
0
    protected void ddlRegion_OnSelectedIndexChanged(object sender, EventArgs e)
    {
        DropDownList ddlRegion   = modalDialog.FindControl("ddlRegion") as DropDownList;
        DropDownList ddlArea     = modalDialog.FindControl("ddlArea") as DropDownList;
        DropDownList ddlCategory = modalDialog.FindControl("ddlCategory") as DropDownList;
        Region       region      = RegionService.GetRegion(ddlRegion.SelectedValue);

        ddlArea.DataMember    = "Id";
        ddlArea.DataTextField = "Name";
        ddlArea.DataSource    = region.Areas;
        ddlArea.DataBind();
        ddlCategory.DataMember    = "Id";
        ddlCategory.DataTextField = "Name";
        ddlCategory.DataSource    = CategoryService.GetCategories(region);
        ddlCategory.DataBind();
        LoadSchools(region.Areas[0]);
    }
Пример #14
0
        public void GetRegionById_stringValueReturned()
        {
            var mock = new Mock <IUnitOfWork>();

            mock.Setup(m => m.Regions.Get(1)).Returns(exampleRegions.ElementAt(0));
            var           mapper  = new MapperConfiguration(cfg => cfg.CreateMap <Region, RegionDTO>()).CreateMapper();
            RegionService country = new RegionService(mock.Object);

            // ISerialize<RegionDTO> serialize = new RegionSerialize();
            //RegionDTO example = mapper.Map<Region, RegionDTO>(exampleRegions.ElementAt(0));//serialize.serializeVary()

            RegionDTO data = country.GetRegion(1);

            mock.Verify(lw => lw.Regions.Get(1),
                        Times.Once());
            Assert.IsNotNull(data);
        }
Пример #15
0
    private IList <Portfolio> GetPortfolios()
    {
        School   school   = null;
        Category category = null;
        Region   region   = null;

        string where = " where 1=1 ";

        if (ddlRegion.SelectedValue != "-1")
        {
            region = RegionService.GetRegion(ddlRegion.SelectedValue);
            where += " and p.School.Area.Region.Id = " + region.Id;
        }
        if (ddlCategories.SelectedValue != "-1" && null != region)
        {
            category = CategoryService.GetCategory(region, ddlCategories.SelectedValue);
            where   += " and p.Category.Id = " + category.Id;
        }

        if (ddlArea.SelectedValue != "-1" && null != region)
        {
            Area area = null;
            if (null != region)
            {
                area = RegionService.GetArea(region, ddlArea.SelectedValue);
            }
            where += " and p.School.Area.Id = " + area.Id;
        }
        if (ddlSchools.SelectedValue != "-1")
        {
            school = RegionService.GetSchool(ddlSchools.SelectedValue);
            where += " and p.School.Id = " + school.Id;
        }

        if (ddlStatus.SelectedValue != "-1")
        {
            Status status = (Status)Enum.Parse(typeof(Status), ddlStatus.SelectedValue);
            where += " and p.Status = " + (int)status;
        }
        string            orderby = (SortDirection == SortDirection.Ascending) ? " order by " + SortColumn + " ASC " : " order by " + SortColumn + " DESC ";
        IList <Portfolio> list    = PortfolioService.GetPortfolios(where + orderby);

        return(list);
    }
Пример #16
0
    private void LoadUsers()
    {
        School school = null;
        Region region = null;

        if (ddlSchools.SelectedValue != "-1")
        {
            school = RegionService.GetSchool(ddlSchools.SelectedValue);
        }
        if (!"-1".Equals(ddlRegion.SelectedValue))
        {
            region = RegionService.GetRegion(ddlRegion.SelectedValue);
        }
        IList <DisplayUser> list = UserService.GetAllUsers(region, null, school, null, "", RoleType.Coordinator, "");

        gvCoordinators.DataSource = list;
        gvCoordinators.DataBind();
        lblRecCount.Text = string.Format("{0:d} users found", list.Count);
    }
Пример #17
0
        public void GetRegion_WithValidId_SholdReturnRegion()
        {
            //Arange
            var service = new RegionService(this._dbContext, this._mapper, null);

            this._dbContext.Regions.Add(new Region {
                Id = 2, Area = 125, Name = "Test", Population = 166
            });
            this._dbContext.SaveChanges();

            //Act
            var region = service.GetRegion(2);

            //Assert
            Assert.IsNotNull(region);
            Assert.AreEqual("Test", region.Name);
            Assert.AreEqual(125, region.Area);
            Assert.AreEqual(166, region.Population);
        }
Пример #18
0
 private void LoadSchools()
 {
     if (!"-1".Equals(ddlSearchRegion.SelectedValue))
     {
         Region         region  = RegionService.GetRegion(ddlSearchRegion.SelectedValue);
         Area           area    = RegionService.GetArea(region, ddlSearchArea.SelectedValue);
         IList <School> schools = RegionService.GetSchools(area);
         ddlSearchSchool.DataSource    = schools;
         ddlSearchSchool.DataMember    = "Id";
         ddlSearchSchool.DataTextField = "Name";
         ddlSearchSchool.DataBind();
         ddlSearchSchool.Items.Insert(0, new ListItem("All", "-1"));
     }
     else
     {
         ddlSearchSchool.DataSource = null;
         ddlSearchSchool.DataBind();
         ddlSearchSchool.Items.Insert(0, new ListItem("All", "-1"));
     }
 }
Пример #19
0
    private string GetWhereClause()
    {
        School   school   = null;
        Category category = null;
        Region   region   = null;

        string where = " where 1=1 ";
        if (ddlRegion.SelectedValue != "-1")
        {
            region = RegionService.GetRegion(ddlRegion.SelectedValue);
            where += " and p.School.Area.Region.Id = " + region.Id;
        }
        if (ddlCategories.SelectedValue != "-1")
        {
            category = CategoryService.GetCategory(region, ddlCategories.SelectedValue);
            where   += " and p.Category.Id = " + category.Id;
        }

        if (ddlArea.SelectedValue != "-1")
        {
            Area area = RegionService.GetArea(ddlArea.SelectedValue);
            where += " and p.School.Area.Id = " + area.Id;
        }
        if (ddlSchools.SelectedValue != "-1")
        {
            school = RegionService.GetSchool(ddlSchools.SelectedValue);
            where += " and p.School.Id = " + school.Id;
        }

        if (ddlStatus.SelectedValue != "-1")
        {
            Status status = (Status)Enum.Parse(typeof(Status), ddlStatus.SelectedValue);
            where += " and p.Status = " + (int)status;
        }


        return(where);
    }
Пример #20
0
        public async void GetRegion_CanGetSingleRegion()
        {
            DbContextOptions <RimRockApiDbContext> options = new DbContextOptionsBuilder <RimRockApiDbContext>().UseInMemoryDatabase("CanGetSingleRegion").Options;

            using (RimRockApiDbContext context = new RimRockApiDbContext(options))
            {
                // Arrange
                Region region = new Region();
                region.ID   = 1;
                region.Name = "The Palouse";

                // Act
                RegionService regionService = new RegionService(context);
                await context.Regions.AddAsync(region);

                await context.SaveChangesAsync();

                Region result = await regionService.GetRegion(region.ID);

                // Assert
                Assert.Equal(result, region);
            };
        }
Пример #21
0
 public async Task <RegionDto> GetRegion(string id)
 {
     return(await regionService.GetRegion(id));
 }
Пример #22
0
 public RegionModel GetRegion([FromRoute] int id)
 {
     return(RegionService.GetRegion(id, dbConn));
 }
Пример #23
0
    private void ShowDropDowns(RoleType role)
    {
        DropDownList ddlRegion   = modalDialog.FindControl("ddlRegion") as DropDownList;
        DropDownList ddlArea     = modalDialog.FindControl("ddlArea") as DropDownList;
        DropDownList ddlCategory = modalDialog.FindControl("ddlCategory") as DropDownList;
        DropDownList ddlSchool   = modalDialog.FindControl("ddlSchool") as DropDownList;
        Label        labRole     = modalDialog.FindControl("labRole") as Label;
        Label        labSchool   = modalDialog.FindControl("labSchool") as Label;
        Label        labRegion   = modalDialog.FindControl("labRegion") as Label;
        Label        labArea     = modalDialog.FindControl("labArea") as Label;
        Label        labCategory = modalDialog.FindControl("labCategory") as Label;

        if (role == RoleType.AreaJudge | role == RoleType.RegionJudge)
        {
            ddlRegion.Visible   = true;
            ddlArea.Visible     = (role == RoleType.AreaJudge);
            labArea.Visible     = (role == RoleType.AreaJudge);
            ddlSchool.Visible   = false;
            labSchool.Visible   = false;
            ddlCategory.Visible = true;
            labCategory.Visible = true;
        }
        else if (role == RoleType.Coordinator | role == RoleType.Principal)
        {
            ddlRegion.Visible   = true;
            labRegion.Visible   = true;
            ddlArea.Visible     = true;
            labArea.Visible     = true;
            ddlSchool.Visible   = true;
            labSchool.Visible   = true;
            ddlCategory.Visible = false;
            labCategory.Visible = false;
            Area area = RegionService.GetArea(ddlArea.SelectedValue);
            LoadSchools(area);
        }
        else if (role == RoleType.Administrator)
        {
            ddlRegion.Visible   = false;
            ddlArea.Visible     = false;
            ddlCategory.Visible = false;
            ddlSchool.Visible   = false;
            labSchool.Visible   = false;
            labRegion.Visible   = false;
            labArea.Visible     = false;
            labCategory.Visible = false;
        }
        else if (role == RoleType.RegionAdministrator)
        {
            ddlRegion.Visible   = true;
            ddlArea.Visible     = true;
            ddlCategory.Visible = false;
            ddlSchool.Visible   = false;
            labSchool.Visible   = false;
            labRegion.Visible   = true;
            labArea.Visible     = true;
            labCategory.Visible = false;
        }
        else if (role == RoleType.Nominee)
        {
            ddlRegion.Visible   = true;
            labRegion.Visible   = true;
            ddlArea.Visible     = true;
            labArea.Visible     = true;
            ddlSchool.Visible   = true;
            labSchool.Visible   = true;
            ddlCategory.Visible = true;
            labCategory.Visible = true;
            Region region = RegionService.GetRegion(ddlRegion.SelectedValue);
            Area   area   = RegionService.GetArea(region, ddlArea.SelectedValue);
            LoadSchools(area);
        }
    }
Пример #24
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Page.Title = string.Format("{0} - {1}", AdvantShop.Configuration.SettingsMain.ShopName, Resources.Resource.Admin_MasterPageAdminCatalog_Catalog);
        if (string.IsNullOrEmpty(Request["regionid"]))
        {
            Response.Redirect("Country.aspx");
        }

        Region region = RegionService.GetRegion(Convert.ToInt32(RegionID));

        if (region == null)
        {
            Response.Redirect("Country.aspx");
        }
        else
        {
            lblHead.Text       = region.Name;
            hlBack.NavigateUrl = "Regions.aspx?CountryId=" + region.CountryID;
            hlBack.Text        = Resources.Resource.Admin_Cities_BackToRegions;
        }



        if (!IsPostBack)
        {
            _paging = new SqlPaging {
                TableName = "[Customers].[City]", ItemsPerPage = 20
            };

            var f = new Field {
                Name = "CityID as ID", IsDistinct = true
            };
            _paging.AddField(f);

            f = new Field {
                Name = "CityName", Sorting = SortDirection.Ascending
            };
            _paging.AddField(f);

            f = new Field {
                Name = "CitySort"
            };
            _paging.AddField(f);

            f = new Field {
                Name = "RegionID", Filter = new EqualFieldFilter()
                {
                    ParamName = "@RegionID", Value = RegionID.ToString()
                }
            };
            _paging.AddField(f);

            grid.ChangeHeaderImageUrl("arrowCityName", "images/arrowup.gif");

            pageNumberer.CurrentPageIndex = 1;
            _paging.CurrentPageIndex      = 1;
            ViewState["Paging"]           = _paging;
        }
        else
        {
            _paging = (SqlPaging)(ViewState["Paging"]);
            _paging.ItemsPerPage = Convert.ToInt32(ddRowsPerPage.SelectedValue);

            if (_paging == null)
            {
                throw (new Exception("Paging lost"));
            }

            string strIds = Request.Form["SelectedIds"];

            if (!string.IsNullOrEmpty(strIds))
            {
                strIds = strIds.Trim();
                string[] arrids = strIds.Split(' ');

                var ids = new string[arrids.Length];
                _selectionFilter = new InSetFieldFilter {
                    IncludeValues = true
                };
                for (int idx = 0; idx <= ids.Length - 1; idx++)
                {
                    int t = int.Parse(arrids[idx]);
                    if (t != -1)
                    {
                        ids[idx] = t.ToString();
                    }
                    else
                    {
                        _selectionFilter.IncludeValues = false;
                        _inverseSelection = true;
                    }
                }
                _selectionFilter.Values = ids;
            }
        }
    }
Пример #25
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SetMeta(string.Format("{0} - {1}", AdvantShop.Configuration.SettingsMain.ShopName, Resources.Resource.Admin_MasterPageAdmin_Sities));

            if (RegionId < 0 && CountryId < 0)
            {
                Response.Redirect("Country.aspx");
            }

            if (RegionId != 0)
            {
                var region = RegionService.GetRegion(RegionId);
                if (region != null)
                {
                    lblHead.Text       = region.Name;
                    hlBack.NavigateUrl = "Regions.aspx?CountryId=" + region.CountryID;
                    hlBack.Text        = Resources.Resource.Admin_Cities_BackToRegions;

                    hlBack2.NavigateUrl = "Country.aspx";
                    hlBack2.Text        = Resources.Resource.Admin_Cities_BackToCoutries;
                }
            }

            if (CountryId != 0)
            {
                var country = CountryService.GetCountry(CountryId);
                if (country != null)
                {
                    lblHead.Text       = country.Name;
                    hlBack.NavigateUrl = "Regions.aspx?CountryId=" + country.CountryId;
                    hlBack.Text        = Resources.Resource.Admin_Cities_BackToRegions;

                    hlBack2.NavigateUrl = "Country.aspx";
                    hlBack2.Text        = Resources.Resource.Admin_Cities_BackToCoutries;
                }
                btnAddCity.Visible = false;
            }



            if (!IsPostBack)
            {
                _paging = new SqlPaging
                {
                    TableName    = "[Customers].[City] Left Join Customers.Region On Region.RegionId=City.RegionId",
                    ItemsPerPage = 20
                };

                _paging.AddFieldsRange(
                    new List <Field>
                {
                    new Field {
                        Name = "CityID as ID", IsDistinct = true
                    },
                    new Field {
                        Name = "CityName", Sorting = SortDirection.Ascending
                    },
                    new Field {
                        Name = "CitySort"
                    },
                    new Field {
                        Name = "City.RegionID"
                    },
                    new Field {
                        Name = "City.DisplayInPopup"
                    },
                    new Field {
                        Name = "PhoneNumber"
                    },
                    new Field {
                        Name = "Region.CountryId", NotInQuery = true
                    },
                });

                if (RegionId != 0)
                {
                    _paging.Fields["City.RegionID"].Filter = new EqualFieldFilter
                    {
                        ParamName = "@RegionID",
                        Value     = RegionId.ToString()
                    };
                }

                if (CountryId != 0)
                {
                    _paging.Fields["Region.CountryId"].Filter = new EqualFieldFilter
                    {
                        ParamName = "@CountryId",
                        Value     = CountryId.ToString()
                    };
                }

                grid.ChangeHeaderImageUrl("arrowCityName", "images/arrowup.gif");

                pageNumberer.CurrentPageIndex = 1;
                _paging.CurrentPageIndex      = 1;
                ViewState["Paging"]           = _paging;
            }
            else
            {
                _paging = (SqlPaging)(ViewState["Paging"]);
                _paging.ItemsPerPage = SQLDataHelper.GetInt(ddRowsPerPage.SelectedValue);

                if (_paging == null)
                {
                    throw (new Exception("Paging lost"));
                }

                string strIds = Request.Form["SelectedIds"];

                if (!string.IsNullOrEmpty(strIds))
                {
                    strIds = strIds.Trim();
                    string[] arrids = strIds.Split(' ');

                    var ids = new string[arrids.Length];
                    _selectionFilter = new InSetFieldFilter {
                        IncludeValues = true
                    };
                    for (int idx = 0; idx <= ids.Length - 1; idx++)
                    {
                        int t = int.Parse(arrids[idx]);
                        if (t != -1)
                        {
                            ids[idx] = t.ToString();
                        }
                        else
                        {
                            _selectionFilter.IncludeValues = false;
                            _inverseSelection = true;
                        }
                    }
                    _selectionFilter.Values = ids;
                }
            }
        }