protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (Request.QueryString["page"] == null) { string lastPage = (string)Session["currentPage"]; if (lastPage != null) { lastPage = "RegisterView.aspx" + lastPage; Response.Redirect(lastPage); } } } #region инициализация сессии пользователя и выбранного регистра timeStampsLabel.Text = " 0_" + DateTime.Now.TimeOfDay; int userId = 0; int.TryParse(Session["userID"].ToString(), out userId); if (userId == 0) { Response.Redirect("~/Default.aspx"); } else { ViewState["userID"] = userId; } ///////////////////////////////////////////////////////////////////// int regId; Int32.TryParse(Session["registerID"].ToString(), out regId); //TableActions ta = new TableActions(); var register = (from r in dataContext.Registers where r.RegisterID == regId select r).FirstOrDefault(); #endregion if (register != null) { #region инициализация сессий поисков и get и списков if (!Page.IsPostBack) { ChooseSortFieldIdDropDownList.Items.AddRange(GetListOfColumns(register.RegisterID, userId)); } RegisterNameLabel.Text = register.Name; if (Request.QueryString["page"] != null) { Int32.TryParse(Request.QueryString["page"], out page); } if (Request.QueryString["size"] != null) { Int32.TryParse(Request.QueryString["size"], out size); } if (Request.QueryString["sortFieldId"] != null) { Int32.TryParse(Request.QueryString["sortFieldId"], out sortFieldId); } Session["currentPage"] = "?page=" + page + "&size=" + size + " & sortFieldId = " + sortFieldId; Dictionary <int, string> vSearchList = (Dictionary <int, string>)Session["vSearchList"]; string searchAll = (string)Session["vSearchAll"]; string searchCardId = (string)Session["vSearchById"]; string searchAllExtended = (string)Session["vSearchAllWithParams"]; #endregion CardCommonFunctions cardCommonFunctions = new CardCommonFunctions(); int totalCnt = 0; string sum = cardCommonFunctions.FastSearch(sortFieldId, searchAllExtended, searchCardId, vSearchList, searchAll, register.RegisterID, Convert.ToInt32(userId), dataTable, page * size, (page + 1) * size, out totalCnt); #region инициализация кнопок и инфо timeStampsLabel.Text += cardCommonFunctions.timeStamps; int pagesCnt = totalCnt / size; string pageNumbers = ""; if (totalCnt % size > 0) { pagesCnt++; } int startNumber = page - 5; startNumber = startNumber < 0 ? 0 : startNumber; for (int i = startNumber; i < 10 + startNumber; i++) { if (i > pagesCnt - 1) { continue; } if (i == page) { pageNumbers += "<font color='red'> " + (i + 1).ToString() + " </font>"; } else { pageNumbers += "<a href=\"?page=" + i + "&size=" + size + "&sortFieldId=" + sortFieldId + "\"> " + (i + 1).ToString() + " </a>"; } } GoToFirstTop.OnClientClick = "window.open(location.origin+location.pathname+'?page=0&size=" + size + "&sortFieldId=" + sortFieldId + "','_self'); return false;"; GoToFirstBottom.OnClientClick = "window.open(location.origin+location.pathname+'?page=0&size=" + size + "&sortFieldId=" + sortFieldId + "','_self'); return false;"; if (page == 0) { GoToPreviousTop.Enabled = false; GoToPreviousBottom.Enabled = false; } else { GoToPreviousTop.OnClientClick = "window.open(location.origin+location.pathname+'?page=" + (page - 1) + "&size=" + size + "&sortFieldId=" + sortFieldId + "','_self'); return false;"; GoToPreviousBottom.OnClientClick = "window.open(location.origin+location.pathname+'?page=" + (page - 1) + "&size=" + size + "&sortFieldId=" + sortFieldId + "','_self'); return false;"; } if (page == pagesCnt - 1) { GoToNextTop.Enabled = false; GoToNextBottom.Enabled = false; } else { GoToNextTop.OnClientClick = "window.open(location.origin+location.pathname+'?page=" + (page + 1) + "&size=" + size + "&sortFieldId=" + sortFieldId + "','_self'); return false;"; GoToNextBottom.OnClientClick = "window.open(location.origin+location.pathname+'?page=" + (page + 1) + "&size=" + size + "&sortFieldId=" + sortFieldId + "','_self'); return false;"; } GoToLastTop.OnClientClick = "window.open(location.origin+location.pathname+'?page=" + (pagesCnt - 1) + "&size=" + size + "&sortFieldId=" + sortFieldId + "','_self'); return false;"; GoToLastBottom.OnClientClick = "window.open(location.origin+location.pathname+'?page=" + (pagesCnt - 1) + "&size=" + size + "&sortFieldId=" + sortFieldId + "','_self'); return false;"; string page_info = sum; PagesListTop.Text = pageNumbers; PagesListBottom.Text = pageNumbers; PageInfoTop.Text = page_info; PageInfoBottom.Text = page_info; #endregion } timeStampsLabel.Text += " 7_" + DateTime.Now.TimeOfDay; }
protected void Page_Load(object sender, EventArgs e) { var userID = Session["userID"]; if (userID == null) { Response.Redirect("~/Default.aspx"); } else { ViewState["userID"] = userID; } ///////////////////////////////////////////////////////////////////// var regId = Session["registerID"]; ChancelerryDBDataContext dataContext = new ChancelerryDBDataContext(); TableActions ta = new TableActions(); var register = (from r in dataContext.Registers where r.registerID == Convert.ToInt32(regId) select r).FirstOrDefault(); if (register != null) { RegisterNameLabel.Text = register.name; if (vVersion) { int size = 100; if (Request.QueryString["page"] != null) { Int32.TryParse(Request.QueryString["page"], out page); } Dictionary <int, string> vSearchList = (Dictionary <int, string>)Session["vSearchList"]; CardCommonFunctions cardCommonFunctions = new CardCommonFunctions(); string sum = cardCommonFunctions.FastSearch(vSearchList, register.registerID, Convert.ToInt32(userID), dataTable, page * size, (page + 1) * size); Button5.Visible = true; Button6.Visible = true; Button7.Visible = false; Button8.Visible = false; BottomButton9.Visible = false; BottomButton10.Visible = true; BottomButton11.Visible = true; BottomButton12.Visible = false; string page_info = sum; PageNumberLabel.Text = page_info; BottomPageNumberLabel.Text = page_info; } else { ta.RefreshTable(dataContext, Convert.ToInt32(ViewState["userID"]), register, regId, dataTable, (Dictionary <int, string>)Session["vSearchList"]); TableActions.DTable = dataTable; string page_info = "Cтраница: " + ((int)Session["pageCntrl"] + 1).ToString() + "/" + (int)Session["pageCount"] + ". Всего: " + (int)Session["cardsCount"]; PageNumberLabel.Text = page_info; BottomPageNumberLabel.Text = page_info; } } }