Esempio n. 1
0
 public static string CreateUrl(Section section)
 {
     return RouteTable.Routes.GetVirtualPath(null, null,
     new RouteValueDictionary()
         {
         {"section", section.NameSection},
         {"page", "1"}
         }).VirtualPath;
 }
Esempio n. 2
0
        public string CreateUrl(Section section)
        {
            string path = RouteTable.Routes.GetVirtualPath(null, "editsection",
                    new RouteValueDictionary()
                {
                    {"editsection", section.Id}
                }).VirtualPath;

                return string.Format("<a href='{0}'>Изменить</a>",
                    path);
        }
Esempio n. 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack &&
             !HttpContext.Current.User.Identity.IsAuthenticated)
            {
                Response.RedirectToRoute("login");
                return;
            }
            if (!Page.IsPostBack &&
              HttpContext.Current.User.Identity.IsAuthenticated)
            {

                if (Security.Authorizate(HttpContext.Current.User.Identity.Name) == Security.SystemRoles.User)
                {
                    Response.RedirectToRoute("login");
                    return;
                }
                MultiView.ActiveViewIndex = 0;
                int sectionId;
                int.TryParse((string)Page.RouteData.Values["editsection"]
                                ?? Request.QueryString["editsection"], out sectionId);

                if (sectionId == 1)
                {
                    Response.RedirectToRoute("sectionmng");
                    return;
                }
                else
                {
                    if (sectionId != 0)
                    {
                        using (AuctionEntities au = new AuctionEntities())
                        {
                            section = au.Sections.First(s => s.Id == sectionId);
                            nameBox.Text = section.NameSection;
                        }
                    }
                }
            }
        }
Esempio n. 4
0
        protected void saveBtn_Click(object sender, EventArgs e)
        {
            Page.Validate();

            if (Page.IsValid)
            {
                int sectionId;
                int.TryParse((string)Page.RouteData.Values["editsection"]
                                ?? Request.QueryString["editsection"], out sectionId);
                if (sectionId != 0)
                {
                    using (AuctionEntities au = new AuctionEntities())
                    {
                        section = au.Sections.First(s => s.Id == sectionId);
                        section.NameSection = nameBox.Text;
                        Methods.AddSection(section);
                        MultiView.ActiveViewIndex = 1;
                    }
                }
                else
                {
                    using (AuctionEntities au = new AuctionEntities())
                    {
                        Section newSection = new Section();
                        newSection.NameSection = nameBox.Text;
                        Methods.AddSection(newSection);
                        MultiView.ActiveViewIndex = 1;
                    }
                }
            }
        }