Пример #1
0
        protected void btnYes_Click(object sender, EventArgs e)
        {
            var dbContext = new DBClassesDataContext();

            var userOrders = (from ord in dbContext.Orders
                              where ord.UserId == int.Parse(Request.QueryString["UserId"])
                              select ord).ToList();

            var user = (from u in dbContext.Users
                        where u.UserId == int.Parse(Request.QueryString["UserId"])
                        select u).SingleOrDefault();

            try
            {
                dbContext.Orders.DeleteAllOnSubmit(userOrders);
                dbContext.Users.DeleteOnSubmit(user);
                dbContext.SubmitChanges();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            Response.Redirect("Default.aspx");
        }
Пример #2
0
        protected void btnYes_Click(object sender, EventArgs e)
        {
            var dbContext = new DBClassesDataContext();

            var user = (from u in dbContext.Users
                        where u.UserId == int.Parse(Request.QueryString["UserId"])
                        select u).SingleOrDefault();

            try
            {
                if (user != null)
                {
                    user.UserName  = Session["name"].ToString();
                    user.UserEmail = Session["address"].ToString();
                }

                dbContext.SubmitChanges();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            Response.Redirect("Default.aspx");
        }
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var dbContext = new DBClassesDataContext();

            if (Request.QueryString["id"] == null)
            {
                return;
            }
            var q = (from o in dbContext.Orders
                     where o.UserId == int.Parse(Request.QueryString["id"])
                     select new
            {
                o.OrderDate,
                o.Amount
            }).ToList();

            DetailInfo.DataSource = q;
            DetailInfo.DataBind();
        }